Guest User

extend ke_search KeSearchExtenedPagesIndexer.php

a guest
Jun 18th, 2014
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.93 KB | None | 0 0
  1. <?php
  2.  
  3. /***************************************************************
  4. * Copyright notice
  5. *
  6. * (c) 2012 Christian Bülter (kennziffer.com) <[email protected]>
  7. * All rights reserved
  8. *
  9. * This script is part of the TYPO3 project. The TYPO3 project is
  10. * free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * The GNU General Public License can be found at
  16. * http://www.gnu.org/copyleft/gpl.html.
  17. *
  18. * This script is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * This copyright notice MUST APPEAR in all copies of the script!
  24. ***************************************************************/
  25.  
  26. class KeSearchExtenedPagesIndexer {
  27.  
  28. /**
  29. * Adds the custom indexer to the TCA of indexer configurations, so that
  30. * it's selectable in the backend as an indexer type when you create a
  31. * new indexer configuration.
  32. *
  33. * @param array $params
  34. * @param type $pObj
  35. */
  36. function registerIndexerConfiguration(&$params, $pObj) {
  37.  
  38. // add item to "type" field
  39. $newArray = array(
  40. 'Extend pages',
  41. 'extended_pages',
  42. \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('example') . 'Resources/Public/Icons/kesearch-indexer-extend_pages.gif'
  43. );
  44. $params['items'][] = $newArray;
  45.  
  46. // enable fields in indexer config
  47. $GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['fileext']['displayCond'] .= ',extended_pages';
  48. $GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['index_content_with_restrictions']['displayCond'] .= ',extended_pages';
  49. $GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['index_use_page_tags_for_files']['displayCond'] .= ',extended_pages';
  50. $GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['single_pages']['displayCond'] .= ',extended_pages';
  51. $GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['startingpoints_recursive']['displayCond'] .= ',extended_pages';
  52. $GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['targetpid']['displayCond'] .= ',extended_pages';
  53. $GLOBALS['TCA']['tx_kesearch_indexerconfig']['columns']['targetpid']['displayCond'] .= ',extended_pages';
  54. }
  55.  
  56. /**
  57. * Custom indexer for ke_search
  58. *
  59. * @param array $indexerConfig Configuration from TYPO3 Backend
  60. * @param array $indexerObject Reference to indexer class.
  61. * @return string Output.
  62. */
  63. public function customIndexer(&$indexerConfig, &$indexerObject) {
  64. if($indexerConfig['type'] == 'extended_pages') {
  65. $content = '';
  66.  
  67. // Create new instance from tx_kesearch_indexer_types_page
  68. $keseachIndexerTypesPage = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_kesearch_indexer_types_page');
  69. $keseachIndexerTypesPage->pObj = $indexerObject;
  70. $keseachIndexerTypesPage->indexerConfig = $indexerConfig;
  71.  
  72. // Add own CTypes
  73. $ownCTypes = array(
  74. 'example_1',
  75. 'example_2',
  76. 'example_3',
  77. );
  78. $keseachIndexerTypesPage->indexCTypes = array_merge($keseachIndexerTypesPage->indexCTypes, $ownCTypes);
  79. foreach ($keseachIndexerTypesPage->indexCTypes as $value) {
  80. $cTypes[] = 'CType="' . $value . '"';
  81. }
  82. $keseachIndexerTypesPage->whereClauseForCType = implode(' OR ', $cTypes);
  83.  
  84. // Start indexing
  85. $content = $keseachIndexerTypesPage->startIndexing();
  86.  
  87. return $content;
  88. }
  89. }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment