[FEATURE] Integrate File Abstraction Layer Indexer Task
[Packages/TYPO3.CMS.git] / typo3 / sysext / scheduler / tasks / class.tx_scheduler_fileindexing.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2011 Lorenz Ulrich <lorenz.ulrich@visol.ch>
6 * All rights reserved
7 *
8 * This script is part of the TYPO3 project. The TYPO3 project is
9 * free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * The GNU General Public License can be found at
15 * http://www.gnu.org/copyleft/gpl.html.
16 *
17 * This script is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * This copyright notice MUST APPEAR in all copies of the script!
23 ***************************************************************/
24
25 /**
26 * This class provides Scheduler plugin implementation
27 *
28 * @author Lorenz Ulrich <lorenz.ulrich@visol.ch>
29 * @package TYPO3
30 * @subpackage media
31 */
32 class tx_scheduler_FileIndexing extends tx_scheduler_Task {
33 /**
34 * @var string
35 */
36 protected $indexingConfiguration;
37
38 /**
39 * @var string
40 */
41 protected $paths;
42
43 /**
44 * Get the value of the protected property indexingConfiguration
45 *
46 * @return string UID of indexing configuration used for the job
47 */
48 public function getIndexingConfiguration() {
49 return $this->indexingConfiguration;
50 }
51
52 /**
53 * Set the value of the private property indexingConfiguration
54 *
55 * @param string $indexingConfiguration UID of indexing configuration used for the job
56 * @return void
57 */
58 public function setIndexingConfiguration($indexingConfiguration) {
59 $this->indexingConfiguration = $indexingConfiguration;
60 }
61
62 /**
63 * Get the value of the protected property paths
64 *
65 * @return string path information for scheduler job (JSON encoded array)
66 */
67 public function getPaths() {
68 return $this->paths;
69 }
70
71 /**
72 * Set the value of the private property paths
73 *
74 * @param array $paths path information for scheduler job (JSON encoded array)
75 * @return void
76 */
77 public function setPaths($paths) {
78 $this->paths = $paths;
79 }
80
81 /**
82 * Function execute from the Scheduler
83 *
84 * @return boolean TRUE on successful execution, FALSE on error
85 */
86 public function execute() {
87 $successfullyExecuted = TRUE;
88 /** @var $fileFactory t3lib_file_Factory */
89 $fileFactory = t3lib_div::makeInstance('t3lib_file_Factory');
90 /** @var $indexerService t3lib_file_Service_IndexerService */
91 $indexerService = t3lib_div::makeInstance('t3lib_file_Service_IndexerService');
92 $indexerService->setFactory($fileFactory);
93
94 // run indexing of every storage
95 $storageRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
96 '*',
97 'sys_file_storage',
98 'deleted = 0'
99 );
100 foreach ($storageRecords as $storageRecord) {
101 $storageObject = $fileFactory->getStorageObject($storageRecord['uid'], $storageRecord);
102 $folder = $storageObject->getRootLevelFolder();
103 $indexerService->indexFilesInFolder($folder);
104 }
105
106 return $successfullyExecuted;
107 }
108 }
109
110 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/tasks/class.tx_scheduler_fileindexing.php'])) {
111 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['ext/scheduler/tasks/class.tx_scheduler_fileindexing.php']);
112 }
113
114 ?>