| @@ -132,6 +132,7 @@ | ||
| 132 | 132 | /** | 
| 133 | 133 | * Internal method to count items by a given where clause | 
| 134 | 134 | * | 
| 135 | + * @param string $where | |
| 135 | 136 | */ | 
| 136 | 137 |  	protected function countItemsByWhereClause($where) { | 
| 137 | 138 | $db = $this->getDB(); | 
| @@ -25,270 +25,270 @@ | ||
| 25 | 25 |  class tx_crawler_domain_queue_repository extends tx_crawler_domain_lib_abstract_repository { | 
| 26 | 26 | |
| 27 | 27 | |
| 28 | - protected $objectClassname = 'tx_crawler_domain_queue_entry'; | |
| 28 | + protected $objectClassname = 'tx_crawler_domain_queue_entry'; | |
| 29 | 29 | |
| 30 | - protected $tableName = 'tx_crawler_queue'; | |
| 30 | + protected $tableName = 'tx_crawler_queue'; | |
| 31 | 31 | |
| 32 | - /** | |
| 33 | - * This mehtod is used to find the youngest entry for a given process. | |
| 34 | - * | |
| 35 | - * @author Timo Schmidt <[email protected]> | |
| 36 | - * @param tx_crawler_domain_process $process | |
| 37 | - * @return tx_crawler_domain_queue_entry $entry | |
| 38 | - */ | |
| 39 | -	public function findYoungestEntryForProcess(tx_crawler_domain_process $process) { | |
| 40 | - return $this->getFirstOrLastObjectByProcess($process,'exec_time ASC'); | |
| 41 | - } | |
| 32 | + /** | |
| 33 | + * This mehtod is used to find the youngest entry for a given process. | |
| 34 | + * | |
| 35 | + * @author Timo Schmidt <[email protected]> | |
| 36 | + * @param tx_crawler_domain_process $process | |
| 37 | + * @return tx_crawler_domain_queue_entry $entry | |
| 38 | + */ | |
| 39 | +    public function findYoungestEntryForProcess(tx_crawler_domain_process $process) { | |
| 40 | + return $this->getFirstOrLastObjectByProcess($process,'exec_time ASC'); | |
| 41 | + } | |
| 42 | 42 | |
| 43 | - /** | |
| 44 | - * This method is used to find the oldest entry for a given process. | |
| 45 | - * | |
| 46 | - * @param tx_crawler_domain_process $process | |
| 47 | - * @return tx_crawler_domain_queue_entry | |
| 48 | - */ | |
| 49 | -	public function findOldestEntryForProcess(tx_crawler_domain_process $process) { | |
| 50 | - return $this->getFirstOrLastObjectByProcess($process,'exec_time DESC'); | |
| 51 | - } | |
| 43 | + /** | |
| 44 | + * This method is used to find the oldest entry for a given process. | |
| 45 | + * | |
| 46 | + * @param tx_crawler_domain_process $process | |
| 47 | + * @return tx_crawler_domain_queue_entry | |
| 48 | + */ | |
| 49 | +    public function findOldestEntryForProcess(tx_crawler_domain_process $process) { | |
| 50 | + return $this->getFirstOrLastObjectByProcess($process,'exec_time DESC'); | |
| 51 | + } | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | - /** | |
| 55 | - * This internal helper method is used to create an instance of an entry object | |
| 56 | - * | |
| 57 | - * @param tx_crawler_domain_process $process | |
| 58 | - * @param string $orderby first matching item will be returned as object | |
| 59 | - * @return tx_crawler_domain_queue_entry | |
| 60 | - */ | |
| 61 | -	protected function getFirstOrLastObjectByProcess($process, $orderby) { | |
| 62 | - $db = $this->getDB(); | |
| 63 | - $where = 'process_id_completed='.$db->fullQuoteStr($process->getProcess_id(),$this->tableName). | |
| 64 | - ' AND exec_time > 0 '; | |
| 65 | - $limit = 1; | |
| 66 | - $groupby = ''; | |
| 54 | + /** | |
| 55 | + * This internal helper method is used to create an instance of an entry object | |
| 56 | + * | |
| 57 | + * @param tx_crawler_domain_process $process | |
| 58 | + * @param string $orderby first matching item will be returned as object | |
| 59 | + * @return tx_crawler_domain_queue_entry | |
| 60 | + */ | |
| 61 | +    protected function getFirstOrLastObjectByProcess($process, $orderby) { | |
| 62 | + $db = $this->getDB(); | |
| 63 | + $where = 'process_id_completed='.$db->fullQuoteStr($process->getProcess_id(),$this->tableName). | |
| 64 | + ' AND exec_time > 0 '; | |
| 65 | + $limit = 1; | |
| 66 | + $groupby = ''; | |
| 67 | 67 | |
| 68 | -		$res 	= $db->exec_SELECTgetRows('*','tx_crawler_queue',$where,$groupby,$orderby,$limit); | |
| 69 | -		if($res) { | |
| 70 | - $first = $res[0]; | |
| 71 | -		}else{ | |
| 72 | - $first = array(); | |
| 73 | - } | |
| 74 | - $resultObject = new tx_crawler_domain_queue_entry($first); | |
| 75 | - return $resultObject; | |
| 76 | - } | |
| 68 | +        $res 	= $db->exec_SELECTgetRows('*','tx_crawler_queue',$where,$groupby,$orderby,$limit); | |
| 69 | +        if($res) { | |
| 70 | + $first = $res[0]; | |
| 71 | +        }else{ | |
| 72 | + $first = array(); | |
| 73 | + } | |
| 74 | + $resultObject = new tx_crawler_domain_queue_entry($first); | |
| 75 | + return $resultObject; | |
| 76 | + } | |
| 77 | 77 | |
| 78 | - /** | |
| 79 | - * Counts all executed items of a process. | |
| 80 | - * | |
| 81 | - * @param tx_crawler_domain_process $process | |
| 82 | - * @return int | |
| 83 | - */ | |
| 84 | -	public function countExtecutedItemsByProcess($process) { | |
| 78 | + /** | |
| 79 | + * Counts all executed items of a process. | |
| 80 | + * | |
| 81 | + * @param tx_crawler_domain_process $process | |
| 82 | + * @return int | |
| 83 | + */ | |
| 84 | +    public function countExtecutedItemsByProcess($process) { | |
| 85 | 85 | |
| 86 | -		return $this->countItemsByWhereClause('exec_time > 0 AND process_id_completed = '.$this->getDB()->fullQuoteStr($process->getProcess_id(),$this->tableName)); | |
| 87 | - } | |
| 86 | +        return $this->countItemsByWhereClause('exec_time > 0 AND process_id_completed = '.$this->getDB()->fullQuoteStr($process->getProcess_id(),$this->tableName)); | |
| 87 | + } | |
| 88 | 88 | |
| 89 | - /** | |
| 90 | - * Counts items of a process which yet have not been processed/executed | |
| 91 | - * | |
| 92 | - * @param tx_crawler_domain_process $process | |
| 93 | - * @return int | |
| 94 | - */ | |
| 95 | -	public function countNonExecutedItemsByProcess($process) { | |
| 96 | -		return $this->countItemsByWhereClause('exec_time = 0 AND process_id = '.$this->getDB()->fullQuoteStr($process->getProcess_id(),$this->tableName)); | |
| 97 | - } | |
| 89 | + /** | |
| 90 | + * Counts items of a process which yet have not been processed/executed | |
| 91 | + * | |
| 92 | + * @param tx_crawler_domain_process $process | |
| 93 | + * @return int | |
| 94 | + */ | |
| 95 | +    public function countNonExecutedItemsByProcess($process) { | |
| 96 | +        return $this->countItemsByWhereClause('exec_time = 0 AND process_id = '.$this->getDB()->fullQuoteStr($process->getProcess_id(),$this->tableName)); | |
| 97 | + } | |
| 98 | 98 | |
| 99 | - /** | |
| 100 | - * This method can be used to count all queue entrys which are | |
| 101 | - * scheduled for now or a earler date. | |
| 102 | - * | |
| 103 | - * @param void | |
| 104 | - * @return int | |
| 105 | - */ | |
| 106 | -	public function countAllPendingItems() { | |
| 107 | -		return $this->countItemsByWhereClause('exec_time = 0 AND scheduled < '.time()); | |
| 108 | - } | |
| 99 | + /** | |
| 100 | + * This method can be used to count all queue entrys which are | |
| 101 | + * scheduled for now or a earler date. | |
| 102 | + * | |
| 103 | + * @param void | |
| 104 | + * @return int | |
| 105 | + */ | |
| 106 | +    public function countAllPendingItems() { | |
| 107 | +        return $this->countItemsByWhereClause('exec_time = 0 AND scheduled < '.time()); | |
| 108 | + } | |
| 109 | 109 | |
| 110 | - /** | |
| 111 | - * This method can be used to count all queue entrys which are | |
| 112 | - * scheduled for now or a earler date and are assigned to a process. | |
| 113 | - * | |
| 114 | - * @param void | |
| 115 | - * @return int | |
| 116 | - */ | |
| 117 | -	public function countAllAssignedPendingItems() { | |
| 118 | -		return $this->countItemsByWhereClause("exec_time = 0 AND scheduled < ".time()." AND process_id != ''"); | |
| 119 | - } | |
| 110 | + /** | |
| 111 | + * This method can be used to count all queue entrys which are | |
| 112 | + * scheduled for now or a earler date and are assigned to a process. | |
| 113 | + * | |
| 114 | + * @param void | |
| 115 | + * @return int | |
| 116 | + */ | |
| 117 | +    public function countAllAssignedPendingItems() { | |
| 118 | +        return $this->countItemsByWhereClause("exec_time = 0 AND scheduled < ".time()." AND process_id != ''"); | |
| 119 | + } | |
| 120 | 120 | |
| 121 | - /** | |
| 122 | - * This method can be used to count all queue entrys which are | |
| 123 | - * scheduled for now or a earler date and are not assigned to a process. | |
| 124 | - * | |
| 125 | - * @param void | |
| 126 | - * @return int | |
| 127 | - */ | |
| 128 | -	public function countAllUnassignedPendingItems() { | |
| 129 | -		return $this->countItemsByWhereClause("exec_time = 0 AND scheduled < ".time()." AND process_id = ''"); | |
| 130 | - } | |
| 121 | + /** | |
| 122 | + * This method can be used to count all queue entrys which are | |
| 123 | + * scheduled for now or a earler date and are not assigned to a process. | |
| 124 | + * | |
| 125 | + * @param void | |
| 126 | + * @return int | |
| 127 | + */ | |
| 128 | +    public function countAllUnassignedPendingItems() { | |
| 129 | +        return $this->countItemsByWhereClause("exec_time = 0 AND scheduled < ".time()." AND process_id = ''"); | |
| 130 | + } | |
| 131 | 131 | |
| 132 | - /** | |
| 133 | - * Internal method to count items by a given where clause | |
| 134 | - * | |
| 135 | - */ | |
| 136 | -	protected function countItemsByWhereClause($where) { | |
| 137 | - $db = $this->getDB(); | |
| 138 | -		$rs 	= $db->exec_SELECTquery('count(*) as anz',$this->tableName,$where); | |
| 139 | - $res = $db->sql_fetch_assoc($rs); | |
| 132 | + /** | |
| 133 | + * Internal method to count items by a given where clause | |
| 134 | + * | |
| 135 | + */ | |
| 136 | +    protected function countItemsByWhereClause($where) { | |
| 137 | + $db = $this->getDB(); | |
| 138 | +        $rs 	= $db->exec_SELECTquery('count(*) as anz',$this->tableName,$where); | |
| 139 | + $res = $db->sql_fetch_assoc($rs); | |
| 140 | 140 | |
| 141 | - return $res['anz']; | |
| 142 | - } | |
| 141 | + return $res['anz']; | |
| 142 | + } | |
| 143 | 143 | |
| 144 | - /** | |
| 145 | - * Count pending queue entries grouped by configuration key | |
| 146 | - * | |
| 147 | - * @param void | |
| 148 | - * @return array | |
| 149 | - * @author Fabrizio Branca <[email protected]> | |
| 150 | - * @since 2099-09-03 | |
| 151 | - */ | |
| 152 | -	public function countPendingItemsGroupedByConfigurationKey() { | |
| 153 | - $db = $this->getDB(); | |
| 154 | - $res = $db->exec_SELECTquery( | |
| 155 | - "configuration, count(*) as unprocessed, sum(process_id != '') as assignedButUnprocessed", | |
| 156 | - $this->tableName, | |
| 157 | - 'exec_time = 0 AND scheduled < '.time(), | |
| 158 | - 'configuration' | |
| 159 | - ); | |
| 160 | - $rows = array(); | |
| 161 | -		while ($row = $db->sql_fetch_assoc($res)) { | |
| 162 | - $rows[] = $row; | |
| 163 | - } | |
| 164 | - return $rows; | |
| 165 | - } | |
| 144 | + /** | |
| 145 | + * Count pending queue entries grouped by configuration key | |
| 146 | + * | |
| 147 | + * @param void | |
| 148 | + * @return array | |
| 149 | + * @author Fabrizio Branca <[email protected]> | |
| 150 | + * @since 2099-09-03 | |
| 151 | + */ | |
| 152 | +    public function countPendingItemsGroupedByConfigurationKey() { | |
| 153 | + $db = $this->getDB(); | |
| 154 | + $res = $db->exec_SELECTquery( | |
| 155 | + "configuration, count(*) as unprocessed, sum(process_id != '') as assignedButUnprocessed", | |
| 156 | + $this->tableName, | |
| 157 | + 'exec_time = 0 AND scheduled < '.time(), | |
| 158 | + 'configuration' | |
| 159 | + ); | |
| 160 | + $rows = array(); | |
| 161 | +        while ($row = $db->sql_fetch_assoc($res)) { | |
| 162 | + $rows[] = $row; | |
| 163 | + } | |
| 164 | + return $rows; | |
| 165 | + } | |
| 166 | 166 | |
| 167 | - /** | |
| 168 | - * Get set id with unprocessed entries | |
| 169 | - * | |
| 170 | - * @param void | |
| 171 | - * @return array array of set ids | |
| 172 | - * @author Fabrizio Branca <[email protected]> | |
| 173 | - * @since 2009-09-03 | |
| 174 | - */ | |
| 175 | -	public function getSetIdWithUnprocessedEntries() { | |
| 176 | - $db = $this->getDB(); | |
| 177 | - $res = $db->exec_SELECTquery( | |
| 178 | - 'set_id', | |
| 179 | - $this->tableName, | |
| 180 | - 'exec_time = 0 AND scheduled < '.time(), | |
| 181 | - 'set_id' | |
| 182 | - ); | |
| 183 | - $setIds = array(); | |
| 184 | -		while ($row = $db->sql_fetch_assoc($res)) { | |
| 185 | - $setIds[] = intval($row['set_id']); | |
| 186 | - } | |
| 187 | - return $setIds; | |
| 188 | - } | |
| 167 | + /** | |
| 168 | + * Get set id with unprocessed entries | |
| 169 | + * | |
| 170 | + * @param void | |
| 171 | + * @return array array of set ids | |
| 172 | + * @author Fabrizio Branca <[email protected]> | |
| 173 | + * @since 2009-09-03 | |
| 174 | + */ | |
| 175 | +    public function getSetIdWithUnprocessedEntries() { | |
| 176 | + $db = $this->getDB(); | |
| 177 | + $res = $db->exec_SELECTquery( | |
| 178 | + 'set_id', | |
| 179 | + $this->tableName, | |
| 180 | + 'exec_time = 0 AND scheduled < '.time(), | |
| 181 | + 'set_id' | |
| 182 | + ); | |
| 183 | + $setIds = array(); | |
| 184 | +        while ($row = $db->sql_fetch_assoc($res)) { | |
| 185 | + $setIds[] = intval($row['set_id']); | |
| 186 | + } | |
| 187 | + return $setIds; | |
| 188 | + } | |
| 189 | 189 | |
| 190 | - /** | |
| 191 | - * Get total queue entries by configuration | |
| 192 | - * | |
| 193 | - * @param array set ids | |
| 194 | - * @return array totals by configuration (keys) | |
| 195 | - * @author Fabrizio Branca <[email protected]> | |
| 196 | - * @since 2009-09-03 | |
| 197 | - */ | |
| 198 | -	public function getTotalQueueEntriesByConfiguration(array $setIds) { | |
| 199 | - $totals = array(); | |
| 200 | -		if (count($setIds) > 0) { | |
| 201 | - $db = $this->getDB(); | |
| 202 | - $res = $db->exec_SELECTquery( | |
| 203 | - 'configuration, count(*) as c', | |
| 204 | - $this->tableName, | |
| 205 | -				'set_id in ('. implode(',',$setIds).') AND scheduled < '.time(), | |
| 206 | - 'configuration' | |
| 207 | - ); | |
| 208 | -			while ($row = $db->sql_fetch_assoc($res)) { | |
| 209 | - $totals[$row['configuration']] = $row['c']; | |
| 210 | - } | |
| 211 | - } | |
| 212 | - return $totals; | |
| 213 | - } | |
| 190 | + /** | |
| 191 | + * Get total queue entries by configuration | |
| 192 | + * | |
| 193 | + * @param array set ids | |
| 194 | + * @return array totals by configuration (keys) | |
| 195 | + * @author Fabrizio Branca <[email protected]> | |
| 196 | + * @since 2009-09-03 | |
| 197 | + */ | |
| 198 | +    public function getTotalQueueEntriesByConfiguration(array $setIds) { | |
| 199 | + $totals = array(); | |
| 200 | +        if (count($setIds) > 0) { | |
| 201 | + $db = $this->getDB(); | |
| 202 | + $res = $db->exec_SELECTquery( | |
| 203 | + 'configuration, count(*) as c', | |
| 204 | + $this->tableName, | |
| 205 | +                'set_id in ('. implode(',',$setIds).') AND scheduled < '.time(), | |
| 206 | + 'configuration' | |
| 207 | + ); | |
| 208 | +            while ($row = $db->sql_fetch_assoc($res)) { | |
| 209 | + $totals[$row['configuration']] = $row['c']; | |
| 210 | + } | |
| 211 | + } | |
| 212 | + return $totals; | |
| 213 | + } | |
| 214 | 214 | |
| 215 | - /** | |
| 216 | - * Get the timestamps of the last processed entries | |
| 217 | - * | |
| 218 | - * @param void | |
| 219 | - * @return array | |
| 220 | - * @author Fabrizio Branca <[email protected]> | |
| 221 | - * @since 2009-09-03 | |
| 222 | - */ | |
| 223 | -	public function getLastProcessedEntriesTimestamps($limit = 100) { | |
| 224 | - $db = $this->getDB(); | |
| 225 | - $res = $db->exec_SELECTquery( | |
| 226 | - 'exec_time', | |
| 227 | - $this->tableName, | |
| 228 | - '', | |
| 229 | - '', | |
| 230 | - 'exec_time desc', | |
| 231 | - $limit | |
| 232 | - ); | |
| 215 | + /** | |
| 216 | + * Get the timestamps of the last processed entries | |
| 217 | + * | |
| 218 | + * @param void | |
| 219 | + * @return array | |
| 220 | + * @author Fabrizio Branca <[email protected]> | |
| 221 | + * @since 2009-09-03 | |
| 222 | + */ | |
| 223 | +    public function getLastProcessedEntriesTimestamps($limit = 100) { | |
| 224 | + $db = $this->getDB(); | |
| 225 | + $res = $db->exec_SELECTquery( | |
| 226 | + 'exec_time', | |
| 227 | + $this->tableName, | |
| 228 | + '', | |
| 229 | + '', | |
| 230 | + 'exec_time desc', | |
| 231 | + $limit | |
| 232 | + ); | |
| 233 | 233 | |
| 234 | - $rows = array(); | |
| 235 | -		while (($row = $db->sql_fetch_assoc($res)) !== false) { | |
| 236 | - $rows[] = $row['exec_time']; | |
| 237 | - } | |
| 238 | - return $rows; | |
| 239 | - } | |
| 234 | + $rows = array(); | |
| 235 | +        while (($row = $db->sql_fetch_assoc($res)) !== false) { | |
| 236 | + $rows[] = $row['exec_time']; | |
| 237 | + } | |
| 238 | + return $rows; | |
| 239 | + } | |
| 240 | 240 | |
| 241 | - /** | |
| 242 | - * Get the last processed entries | |
| 243 | - * | |
| 244 | - * @param string $selectFields | |
| 245 | - * @param int $limit | |
| 246 | - * @return array | |
| 247 | - * @author Fabrizio Branca <[email protected]> | |
| 248 | - * @since 2010-11-16 | |
| 249 | - */ | |
| 250 | -	public function getLastProcessedEntries($selectFields='*', $limit='100') { | |
| 251 | - $db = $this->getDB(); | |
| 252 | - $res = $db->exec_SELECTquery( | |
| 253 | - $selectFields, | |
| 254 | - $this->tableName, | |
| 255 | - '', | |
| 256 | - '', | |
| 257 | - 'exec_time desc', | |
| 258 | - $limit | |
| 259 | - ); | |
| 241 | + /** | |
| 242 | + * Get the last processed entries | |
| 243 | + * | |
| 244 | + * @param string $selectFields | |
| 245 | + * @param int $limit | |
| 246 | + * @return array | |
| 247 | + * @author Fabrizio Branca <[email protected]> | |
| 248 | + * @since 2010-11-16 | |
| 249 | + */ | |
| 250 | +    public function getLastProcessedEntries($selectFields='*', $limit='100') { | |
| 251 | + $db = $this->getDB(); | |
| 252 | + $res = $db->exec_SELECTquery( | |
| 253 | + $selectFields, | |
| 254 | + $this->tableName, | |
| 255 | + '', | |
| 256 | + '', | |
| 257 | + 'exec_time desc', | |
| 258 | + $limit | |
| 259 | + ); | |
| 260 | 260 | |
| 261 | - $rows = array(); | |
| 262 | -		while (($row = $db->sql_fetch_assoc($res)) !== false) { | |
| 263 | - $rows[] = $row; | |
| 264 | - } | |
| 265 | - return $rows; | |
| 266 | - } | |
| 261 | + $rows = array(); | |
| 262 | +        while (($row = $db->sql_fetch_assoc($res)) !== false) { | |
| 263 | + $rows[] = $row; | |
| 264 | + } | |
| 265 | + return $rows; | |
| 266 | + } | |
| 267 | 267 | |
| 268 | - /** | |
| 269 | - * Get performance statistics data | |
| 270 | - * | |
| 271 | - * @param int start timestamp | |
| 272 | - * @param int end timestamp | |
| 273 | - * @return array performance data | |
| 274 | - * @author Fabrizio Branca <[email protected]> | |
| 275 | - * @since 2009-09-03 | |
| 276 | - */ | |
| 277 | -	public function getPerformanceData($start, $end) { | |
| 278 | - $db = $this->getDB(); | |
| 279 | - $res = $db->exec_SELECTquery( | |
| 280 | - 'process_id_completed, min(exec_time) as start, max(exec_time) as end, count(*) as urlcount', | |
| 281 | - $this->tableName, | |
| 282 | - 'exec_time != 0 and exec_time >= '.intval($start). ' and exec_time <= ' . intval($end), | |
| 283 | - 'process_id_completed' | |
| 284 | - ); | |
| 268 | + /** | |
| 269 | + * Get performance statistics data | |
| 270 | + * | |
| 271 | + * @param int start timestamp | |
| 272 | + * @param int end timestamp | |
| 273 | + * @return array performance data | |
| 274 | + * @author Fabrizio Branca <[email protected]> | |
| 275 | + * @since 2009-09-03 | |
| 276 | + */ | |
| 277 | +    public function getPerformanceData($start, $end) { | |
| 278 | + $db = $this->getDB(); | |
| 279 | + $res = $db->exec_SELECTquery( | |
| 280 | + 'process_id_completed, min(exec_time) as start, max(exec_time) as end, count(*) as urlcount', | |
| 281 | + $this->tableName, | |
| 282 | + 'exec_time != 0 and exec_time >= '.intval($start). ' and exec_time <= ' . intval($end), | |
| 283 | + 'process_id_completed' | |
| 284 | + ); | |
| 285 | 285 | |
| 286 | - $rows = array(); | |
| 287 | -		while (($row = $db->sql_fetch_assoc($res)) !== false) { | |
| 288 | - $rows[$row['process_id_completed']] = $row; | |
| 289 | - } | |
| 290 | - return $rows; | |
| 291 | - } | |
| 286 | + $rows = array(); | |
| 287 | +        while (($row = $db->sql_fetch_assoc($res)) !== false) { | |
| 288 | + $rows[$row['process_id_completed']] = $row; | |
| 289 | + } | |
| 290 | + return $rows; | |
| 291 | + } | |
| 292 | 292 | |
| 293 | 293 | /** | 
| 294 | 294 | * This method is used to count all processes in the process table. | 
| @@ -103,7 +103,7 @@ | ||
| 103 | 103 | * This method is used to set the uid of the queue entry | 
| 104 | 104 | * where the reason is relevant for. | 
| 105 | 105 | * | 
| 106 | - * @param int $entry_id | |
| 106 | + * @param int $entry_uid | |
| 107 | 107 | */ | 
| 108 | 108 |  	public function setQueueEntryUid($entry_uid) { | 
| 109 | 109 | $this->row['queue_entry_uid'] = $entry_uid; | 
| @@ -24,90 +24,90 @@ | ||
| 24 | 24 | |
| 25 | 25 |  class tx_crawler_domain_reason extends tx_crawler_domain_lib_abstract_dbobject { | 
| 26 | 26 | |
| 27 | - protected static $tableName = 'tx_crawler_reason'; | |
| 27 | + protected static $tableName = 'tx_crawler_reason'; | |
| 28 | 28 | |
| 29 | - /** | |
| 30 | - * THE CONSTANTS REPRESENT THE KIND OF THE REASON | |
| 31 | - * | |
| 32 | - * Convention for own states: <extensionkey>_<reason> | |
| 33 | - */ | |
| 34 | - const REASON_DEFAULT = 'crawler_default_reason'; | |
| 35 | - const REASON_GUI_SUBMIT = 'crawler_gui_submit_reason'; | |
| 36 | - const REASON_CLI_SUBMIT = 'crawler_cli_submit_reason'; | |
| 29 | + /** | |
| 30 | + * THE CONSTANTS REPRESENT THE KIND OF THE REASON | |
| 31 | + * | |
| 32 | + * Convention for own states: <extensionkey>_<reason> | |
| 33 | + */ | |
| 34 | + const REASON_DEFAULT = 'crawler_default_reason'; | |
| 35 | + const REASON_GUI_SUBMIT = 'crawler_gui_submit_reason'; | |
| 36 | + const REASON_CLI_SUBMIT = 'crawler_cli_submit_reason'; | |
| 37 | 37 | |
| 38 | - /** | |
| 39 | - * Set uid | |
| 40 | - * | |
| 41 | - * @param int uid | |
| 42 | - * @return void | |
| 43 | - */ | |
| 44 | -	public function setUid($uid) { | |
| 45 | - $this->row['uid'] = $uid; | |
| 46 | - } | |
| 38 | + /** | |
| 39 | + * Set uid | |
| 40 | + * | |
| 41 | + * @param int uid | |
| 42 | + * @return void | |
| 43 | + */ | |
| 44 | +    public function setUid($uid) { | |
| 45 | + $this->row['uid'] = $uid; | |
| 46 | + } | |
| 47 | 47 | |
| 48 | - /** | |
| 49 | - * Method to set a timestamp for the creation time of this record | |
| 50 | - * | |
| 51 | - * @param int $time | |
| 52 | - */ | |
| 53 | -	public function setCreationDate($time) { | |
| 54 | - $this->row['crdate'] = $time; | |
| 55 | - } | |
| 48 | + /** | |
| 49 | + * Method to set a timestamp for the creation time of this record | |
| 50 | + * | |
| 51 | + * @param int $time | |
| 52 | + */ | |
| 53 | +    public function setCreationDate($time) { | |
| 54 | + $this->row['crdate'] = $time; | |
| 55 | + } | |
| 56 | 56 | |
| 57 | - /** | |
| 58 | - * This method can be used to set a user id of the user who has created this reason entry | |
| 59 | - * | |
| 60 | - * @param int $user_id | |
| 61 | - */ | |
| 62 | -	public function setBackendUserId($user_id) { | |
| 63 | - $this->row['cruser_id'] = $user_id; | |
| 64 | - } | |
| 57 | + /** | |
| 58 | + * This method can be used to set a user id of the user who has created this reason entry | |
| 59 | + * | |
| 60 | + * @param int $user_id | |
| 61 | + */ | |
| 62 | +    public function setBackendUserId($user_id) { | |
| 63 | + $this->row['cruser_id'] = $user_id; | |
| 64 | + } | |
| 65 | 65 | |
| 66 | - /** | |
| 67 | - * Method to set the type of the reason for this reason instance (see constances) | |
| 68 | - * | |
| 69 | - * @param string $string | |
| 70 | - */ | |
| 71 | -	public function setReason($string) { | |
| 72 | - $this->row['reason'] = $string; | |
| 73 | - } | |
| 66 | + /** | |
| 67 | + * Method to set the type of the reason for this reason instance (see constances) | |
| 68 | + * | |
| 69 | + * @param string $string | |
| 70 | + */ | |
| 71 | +    public function setReason($string) { | |
| 72 | + $this->row['reason'] = $string; | |
| 73 | + } | |
| 74 | 74 | |
| 75 | - /** | |
| 76 | - * This method returns the attached reason text. | |
| 77 | - * @return string | |
| 78 | - */ | |
| 79 | -	public function getReason() { | |
| 80 | - return $this->row['reason']; | |
| 81 | - } | |
| 75 | + /** | |
| 76 | + * This method returns the attached reason text. | |
| 77 | + * @return string | |
| 78 | + */ | |
| 79 | +    public function getReason() { | |
| 80 | + return $this->row['reason']; | |
| 81 | + } | |
| 82 | 82 | |
| 83 | - /** | |
| 84 | - * This method can be used to assign a detail text to the crawler reason | |
| 85 | - * | |
| 86 | - * @param string $detail_text | |
| 87 | - */ | |
| 88 | -	public function setDetailText($detail_text) { | |
| 89 | - $this->row['detail_text'] = $detail_text; | |
| 90 | - } | |
| 83 | + /** | |
| 84 | + * This method can be used to assign a detail text to the crawler reason | |
| 85 | + * | |
| 86 | + * @param string $detail_text | |
| 87 | + */ | |
| 88 | +    public function setDetailText($detail_text) { | |
| 89 | + $this->row['detail_text'] = $detail_text; | |
| 90 | + } | |
| 91 | 91 | |
| 92 | - /** | |
| 93 | - * Returns the attachet detail text. | |
| 94 | - * | |
| 95 | - * @param void | |
| 96 | - * @return string | |
| 97 | - */ | |
| 98 | -	public function getDetailText() { | |
| 99 | - return $this->row['detail_text']; | |
| 100 | - } | |
| 92 | + /** | |
| 93 | + * Returns the attachet detail text. | |
| 94 | + * | |
| 95 | + * @param void | |
| 96 | + * @return string | |
| 97 | + */ | |
| 98 | +    public function getDetailText() { | |
| 99 | + return $this->row['detail_text']; | |
| 100 | + } | |
| 101 | 101 | |
| 102 | - /** | |
| 103 | - * This method is used to set the uid of the queue entry | |
| 104 | - * where the reason is relevant for. | |
| 105 | - * | |
| 106 | - * @param int $entry_id | |
| 107 | - */ | |
| 108 | -	public function setQueueEntryUid($entry_uid) { | |
| 109 | - $this->row['queue_entry_uid'] = $entry_uid; | |
| 110 | - } | |
| 102 | + /** | |
| 103 | + * This method is used to set the uid of the queue entry | |
| 104 | + * where the reason is relevant for. | |
| 105 | + * | |
| 106 | + * @param int $entry_id | |
| 107 | + */ | |
| 108 | +    public function setQueueEntryUid($entry_uid) { | |
| 109 | + $this->row['queue_entry_uid'] = $entry_uid; | |
| 110 | + } | |
| 111 | 111 | |
| 112 | 112 | } | 
| 113 | 113 | |
| @@ -709,6 +709,7 @@ discard block | ||
| 709 | 709 | * @param array Page row or set-id | 
| 710 | 710 | * @param string Title string | 
| 711 | 711 | * @param int Items per Page setting | 
| 712 | + * @param string $titleString | |
| 712 | 713 | * @return string HTML <tr> content (one or more) | 
| 713 | 714 | */ | 
| 714 | 715 |  	function drawLog_addRows($pageRow_setId, $titleString, $itemsPerPage=10) { | 
| @@ -1214,6 +1215,8 @@ discard block | ||
| 1214 | 1215 | * @param string Selector box name | 
| 1215 | 1216 | * @param string Selector box value (array for multiple...) | 
| 1216 | 1217 | * @param boolean If set, will draw multiple box. | 
| 1218 | + * @param string $name | |
| 1219 | + * @param integer $multiple | |
| 1217 | 1220 | * @return string HTML select element | 
| 1218 | 1221 | */ | 
| 1219 | 1222 |  	function selectorBox($optArray, $name, $value, $multiple)	{ | 
| @@ -35,126 +35,126 @@ discard block | ||
| 35 | 35 | * @subpackage tx_crawler | 
| 36 | 36 | */ | 
| 37 | 37 |  class tx_crawler_modfunc1 extends \TYPO3\CMS\Backend\Module\AbstractFunctionModule { | 
| 38 | - // Internal, dynamic: | |
| 39 | - var $duplicateTrack = array(); | |
| 40 | - var $submitCrawlUrls = FALSE; | |
| 41 | - var $downloadCrawlUrls = FALSE; | |
| 42 | - | |
| 43 | - var $scheduledTime = 0; | |
| 44 | - var $reqMinute = 0; | |
| 45 | - | |
| 46 | - /** | |
| 47 | - * @var array holds the selection of configuration from the configuration selector box | |
| 48 | - */ | |
| 49 | - var $incomingConfigurationSelection = array(); | |
| 50 | - | |
| 51 | - /** | |
| 52 | - * @var tx_crawler_lib | |
| 53 | - */ | |
| 54 | - var $crawlerObj; | |
| 55 | - | |
| 56 | - var $CSVaccu = array(); | |
| 57 | - | |
| 58 | - /** | |
| 59 | - * If true the user requested a CSV export of the queue | |
| 60 | - * | |
| 61 | - * @var boolean | |
| 62 | - */ | |
| 63 | - var $CSVExport = FALSE; | |
| 64 | - | |
| 65 | - var $downloadUrls = array(); | |
| 66 | - | |
| 67 | - /** | |
| 68 | - * Holds the configuration from ext_conf_template loaded by loadExtensionSettings() | |
| 69 | - * | |
| 70 | - * @var array | |
| 71 | - */ | |
| 72 | - protected $extensionSettings = array(); | |
| 73 | - | |
| 74 | - /** | |
| 75 | - * Indicate that an flash message with an error is present. | |
| 76 | - * | |
| 77 | - * @var boolean | |
| 78 | - */ | |
| 79 | - protected $isErrorDetected = false; | |
| 80 | - | |
| 81 | - /** | |
| 82 | - * the constructor | |
| 83 | - */ | |
| 84 | -	public function __construct() { | |
| 85 | - $this->processManager = new tx_crawler_domain_process_manager(); | |
| 86 | - } | |
| 87 | - | |
| 88 | - /** | |
| 89 | - * Additions to the function menu array | |
| 90 | - * | |
| 91 | - * @return array Menu array | |
| 92 | - */ | |
| 93 | -	function modMenu()	{ | |
| 94 | - global $LANG; | |
| 95 | - | |
| 96 | - return array ( | |
| 97 | - 'depth' => array( | |
| 98 | -				0 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_0'), | |
| 99 | -				1 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_1'), | |
| 100 | -				2 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_2'), | |
| 101 | -				3 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_3'), | |
| 102 | -				4 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_4'), | |
| 103 | -				99 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_infi'), | |
| 104 | - ), | |
| 105 | - 'crawlaction' => array( | |
| 106 | -				'start' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.start'), | |
| 107 | -				'log' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.log'), | |
| 108 | -				'multiprocess' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.multiprocess') | |
| 109 | - ), | |
| 110 | - 'log_resultLog' => '', | |
| 111 | - 'log_feVars' => '', | |
| 112 | - 'processListMode' => '', | |
| 113 | - 'log_display' => array( | |
| 114 | -				'all' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.all'), | |
| 115 | -				'pending' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.pending'), | |
| 116 | -				'finished' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.finished') | |
| 117 | - ), | |
| 118 | - 'itemsPerPage' => array( | |
| 119 | -				'5' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.5'), | |
| 120 | -				'10' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.10'), | |
| 121 | -				'50' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.50'), | |
| 122 | -				'0' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.0') | |
| 123 | - ) | |
| 124 | - ); | |
| 125 | - } | |
| 126 | - | |
| 127 | - /** | |
| 128 | - * Load extension settings | |
| 129 | - * | |
| 130 | - * @param void | |
| 131 | - * @return void | |
| 132 | - */ | |
| 133 | -	protected function loadExtensionSettings() { | |
| 134 | - $this->extensionSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['crawler']); | |
| 135 | - } | |
| 136 | - | |
| 137 | - /** | |
| 138 | - * Main function | |
| 139 | - * | |
| 140 | - * @return string HTML output | |
| 141 | - */ | |
| 142 | -	function main() { | |
| 143 | - global $LANG, $BACK_PATH; | |
| 144 | - | |
| 145 | - $this->incLocalLang(); | |
| 146 | - | |
| 147 | - $this->loadExtensionSettings(); | |
| 148 | -		if (empty($this->pObj->MOD_SETTINGS['processListMode'])) { | |
| 149 | - $this->pObj->MOD_SETTINGS['processListMode'] = 'simple'; | |
| 150 | - } | |
| 38 | + // Internal, dynamic: | |
| 39 | + var $duplicateTrack = array(); | |
| 40 | + var $submitCrawlUrls = FALSE; | |
| 41 | + var $downloadCrawlUrls = FALSE; | |
| 42 | + | |
| 43 | + var $scheduledTime = 0; | |
| 44 | + var $reqMinute = 0; | |
| 45 | + | |
| 46 | + /** | |
| 47 | + * @var array holds the selection of configuration from the configuration selector box | |
| 48 | + */ | |
| 49 | + var $incomingConfigurationSelection = array(); | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * @var tx_crawler_lib | |
| 53 | + */ | |
| 54 | + var $crawlerObj; | |
| 55 | + | |
| 56 | + var $CSVaccu = array(); | |
| 57 | + | |
| 58 | + /** | |
| 59 | + * If true the user requested a CSV export of the queue | |
| 60 | + * | |
| 61 | + * @var boolean | |
| 62 | + */ | |
| 63 | + var $CSVExport = FALSE; | |
| 64 | + | |
| 65 | + var $downloadUrls = array(); | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * Holds the configuration from ext_conf_template loaded by loadExtensionSettings() | |
| 69 | + * | |
| 70 | + * @var array | |
| 71 | + */ | |
| 72 | + protected $extensionSettings = array(); | |
| 73 | + | |
| 74 | + /** | |
| 75 | + * Indicate that an flash message with an error is present. | |
| 76 | + * | |
| 77 | + * @var boolean | |
| 78 | + */ | |
| 79 | + protected $isErrorDetected = false; | |
| 80 | + | |
| 81 | + /** | |
| 82 | + * the constructor | |
| 83 | + */ | |
| 84 | +    public function __construct() { | |
| 85 | + $this->processManager = new tx_crawler_domain_process_manager(); | |
| 86 | + } | |
| 87 | + | |
| 88 | + /** | |
| 89 | + * Additions to the function menu array | |
| 90 | + * | |
| 91 | + * @return array Menu array | |
| 92 | + */ | |
| 93 | +    function modMenu()	{ | |
| 94 | + global $LANG; | |
| 95 | + | |
| 96 | + return array ( | |
| 97 | + 'depth' => array( | |
| 98 | +                0 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_0'), | |
| 99 | +                1 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_1'), | |
| 100 | +                2 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_2'), | |
| 101 | +                3 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_3'), | |
| 102 | +                4 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_4'), | |
| 103 | +                99 => $LANG->sL('LLL:EXT:lang/locallang_core.php:labels.depth_infi'), | |
| 104 | + ), | |
| 105 | + 'crawlaction' => array( | |
| 106 | +                'start' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.start'), | |
| 107 | +                'log' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.log'), | |
| 108 | +                'multiprocess' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.multiprocess') | |
| 109 | + ), | |
| 110 | + 'log_resultLog' => '', | |
| 111 | + 'log_feVars' => '', | |
| 112 | + 'processListMode' => '', | |
| 113 | + 'log_display' => array( | |
| 114 | +                'all' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.all'), | |
| 115 | +                'pending' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.pending'), | |
| 116 | +                'finished' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.finished') | |
| 117 | + ), | |
| 118 | + 'itemsPerPage' => array( | |
| 119 | +                '5' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.5'), | |
| 120 | +                '10' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.10'), | |
| 121 | +                '50' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.50'), | |
| 122 | +                '0' => $LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage.0') | |
| 123 | + ) | |
| 124 | + ); | |
| 125 | + } | |
| 126 | + | |
| 127 | + /** | |
| 128 | + * Load extension settings | |
| 129 | + * | |
| 130 | + * @param void | |
| 131 | + * @return void | |
| 132 | + */ | |
| 133 | +    protected function loadExtensionSettings() { | |
| 134 | + $this->extensionSettings = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['crawler']); | |
| 135 | + } | |
| 136 | + | |
| 137 | + /** | |
| 138 | + * Main function | |
| 139 | + * | |
| 140 | + * @return string HTML output | |
| 141 | + */ | |
| 142 | +    function main() { | |
| 143 | + global $LANG, $BACK_PATH; | |
| 144 | + | |
| 145 | + $this->incLocalLang(); | |
| 146 | + | |
| 147 | + $this->loadExtensionSettings(); | |
| 148 | +        if (empty($this->pObj->MOD_SETTINGS['processListMode'])) { | |
| 149 | + $this->pObj->MOD_SETTINGS['processListMode'] = 'simple'; | |
| 150 | + } | |
| 151 | 151 | |
| 152 | - // Set CSS styles specific for this document: | |
| 153 | -		$this->pObj->content = str_replace('/*###POSTCSSMARKER###*/',' | |
| 152 | + // Set CSS styles specific for this document: | |
| 153 | +        $this->pObj->content = str_replace('/*###POSTCSSMARKER###*/',' | |
| 154 | 154 |  			TABLE.c-list TR TD { white-space: nowrap; vertical-align: top; } | 
| 155 | 155 | ',$this->pObj->content); | 
| 156 | 156 | |
| 157 | - $this->pObj->content .= '<style type="text/css"><!-- | |
| 157 | + $this->pObj->content .= '<style type="text/css"><!-- | |
| 158 | 158 | table.url-table, | 
| 159 | 159 | table.param-expanded, | 
| 160 | 160 |  			table.crawlerlog { | 
| @@ -172,16 +172,16 @@ discard block | ||
| 172 | 172 | <link rel="stylesheet" type="text/css" href="'.$BACK_PATH.'../typo3conf/ext/crawler/template/res.css" /> | 
| 173 | 173 | '; | 
| 174 | 174 | |
| 175 | - // Type function menu: | |
| 176 | - $h_func = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( | |
| 177 | - $this->pObj->id, | |
| 178 | - 'SET[crawlaction]', | |
| 179 | - $this->pObj->MOD_SETTINGS['crawlaction'], | |
| 180 | - $this->pObj->MOD_MENU['crawlaction'], | |
| 181 | - 'index.php' | |
| 182 | - ); | |
| 175 | + // Type function menu: | |
| 176 | + $h_func = \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( | |
| 177 | + $this->pObj->id, | |
| 178 | + 'SET[crawlaction]', | |
| 179 | + $this->pObj->MOD_SETTINGS['crawlaction'], | |
| 180 | + $this->pObj->MOD_MENU['crawlaction'], | |
| 181 | + 'index.php' | |
| 182 | + ); | |
| 183 | 183 | |
| 184 | - /* | |
| 184 | + /* | |
| 185 | 185 | // Showing depth-menu in certain cases: | 
| 186 | 186 |  		if ($this->pObj->MOD_SETTINGS['crawlaction']!=='cli' && $this->pObj->MOD_SETTINGS['crawlaction']!== 'multiprocess' && ($this->pObj->MOD_SETTINGS['crawlaction']!=='log' || $this->pObj->id))	{ | 
| 187 | 187 | $h_func .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( | 
| @@ -194,63 +194,63 @@ discard block | ||
| 194 | 194 | } | 
| 195 | 195 | */ | 
| 196 | 196 | |
| 197 | - // Additional menus for the log type: | |
| 198 | -		if ($this->pObj->MOD_SETTINGS['crawlaction']==='log')	{ | |
| 199 | - $h_func .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( | |
| 200 | - $this->pObj->id, | |
| 201 | - 'SET[depth]', | |
| 202 | - $this->pObj->MOD_SETTINGS['depth'], | |
| 203 | - $this->pObj->MOD_MENU['depth'], | |
| 204 | - 'index.php' | |
| 205 | - ); | |
| 197 | + // Additional menus for the log type: | |
| 198 | +        if ($this->pObj->MOD_SETTINGS['crawlaction']==='log')	{ | |
| 199 | + $h_func .= \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( | |
| 200 | + $this->pObj->id, | |
| 201 | + 'SET[depth]', | |
| 202 | + $this->pObj->MOD_SETTINGS['depth'], | |
| 203 | + $this->pObj->MOD_MENU['depth'], | |
| 204 | + 'index.php' | |
| 205 | + ); | |
| 206 | + | |
| 207 | +            $quiPart = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details') ? '&qid_details=' . intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details')) : ''; | |
| 208 | + | |
| 209 | +            $setId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); | |
| 210 | + | |
| 211 | + $h_func.= '<hr/>'. | |
| 212 | +                    $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.display').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id,'SET[log_display]',$this->pObj->MOD_SETTINGS['log_display'],$this->pObj->MOD_MENU['log_display'],'index.php','&setID='.$setId) . ' - ' . | |
| 213 | +                    $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showresultlog').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,'SET[log_resultLog]',$this->pObj->MOD_SETTINGS['log_resultLog'],'index.php','&setID='.$setId . $quiPart) . ' - ' . | |
| 214 | +                    $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showfevars').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,'SET[log_feVars]',$this->pObj->MOD_SETTINGS['log_feVars'],'index.php','&setID='.$setId . $quiPart) . ' - ' . | |
| 215 | +                    $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage').': ' . | |
| 216 | + \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( | |
| 217 | + $this->pObj->id, | |
| 218 | + 'SET[itemsPerPage]', | |
| 219 | + $this->pObj->MOD_SETTINGS['itemsPerPage'], | |
| 220 | + $this->pObj->MOD_MENU['itemsPerPage'], | |
| 221 | + 'index.php' | |
| 222 | + ); | |
| 223 | + } | |
| 206 | 224 | |
| 207 | -			$quiPart = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details') ? '&qid_details=' . intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details')) : ''; | |
| 208 | - | |
| 209 | -			$setId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); | |
| 210 | - | |
| 211 | - $h_func.= '<hr/>'. | |
| 212 | -					$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.display').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id,'SET[log_display]',$this->pObj->MOD_SETTINGS['log_display'],$this->pObj->MOD_MENU['log_display'],'index.php','&setID='.$setId) . ' - ' . | |
| 213 | -					$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showresultlog').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,'SET[log_resultLog]',$this->pObj->MOD_SETTINGS['log_resultLog'],'index.php','&setID='.$setId . $quiPart) . ' - ' . | |
| 214 | -					$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showfevars').': '.\TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,'SET[log_feVars]',$this->pObj->MOD_SETTINGS['log_feVars'],'index.php','&setID='.$setId . $quiPart) . ' - ' . | |
| 215 | -					$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage').': ' . | |
| 216 | - \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu( | |
| 217 | - $this->pObj->id, | |
| 218 | - 'SET[itemsPerPage]', | |
| 219 | - $this->pObj->MOD_SETTINGS['itemsPerPage'], | |
| 220 | - $this->pObj->MOD_MENU['itemsPerPage'], | |
| 221 | - 'index.php' | |
| 222 | - ); | |
| 223 | - } | |
| 225 | + $theOutput= $this->pObj->doc->spacer(5); | |
| 226 | +        $theOutput.= $this->pObj->doc->section($LANG->getLL('title'), $h_func, 0, 1); | |
| 224 | 227 | |
| 225 | - $theOutput= $this->pObj->doc->spacer(5); | |
| 226 | -		$theOutput.= $this->pObj->doc->section($LANG->getLL('title'), $h_func, 0, 1); | |
| 227 | - | |
| 228 | - // Branch based on type: | |
| 229 | -		switch ((string)$this->pObj->MOD_SETTINGS['crawlaction']) { | |
| 230 | - case 'start': | |
| 231 | -				if (empty($this->pObj->id)) { | |
| 232 | -					$this->addErrorMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noPageSelected')); | |
| 233 | -				} else { | |
| 234 | -					$theOutput .= $this->pObj->doc->section('', $this->drawURLs(), 0, 1); | |
| 235 | - } | |
| 236 | - break; | |
| 237 | - case 'log': | |
| 238 | -				if (empty($this->pObj->id)) { | |
| 239 | -					$this->addErrorMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noPageSelected')); | |
| 240 | -				} else { | |
| 241 | -					$theOutput .= $this->pObj->doc->section('', $this->drawLog(), 0, 1); | |
| 242 | - } | |
| 243 | - break; | |
| 244 | - case 'cli': | |
| 245 | -				$theOutput .= $this->pObj->doc->section('', $this->drawCLIstatus(), 0, 1); | |
| 246 | - break; | |
| 247 | - case 'multiprocess': | |
| 248 | -				$theOutput .= $this->pObj->doc->section('', $this->drawProcessOverviewAction(), 0, 1); | |
| 249 | - break; | |
| 250 | - } | |
| 228 | + // Branch based on type: | |
| 229 | +        switch ((string)$this->pObj->MOD_SETTINGS['crawlaction']) { | |
| 230 | + case 'start': | |
| 231 | +                if (empty($this->pObj->id)) { | |
| 232 | +                    $this->addErrorMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noPageSelected')); | |
| 233 | +                } else { | |
| 234 | +                    $theOutput .= $this->pObj->doc->section('', $this->drawURLs(), 0, 1); | |
| 235 | + } | |
| 236 | + break; | |
| 237 | + case 'log': | |
| 238 | +                if (empty($this->pObj->id)) { | |
| 239 | +                    $this->addErrorMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noPageSelected')); | |
| 240 | +                } else { | |
| 241 | +                    $theOutput .= $this->pObj->doc->section('', $this->drawLog(), 0, 1); | |
| 242 | + } | |
| 243 | + break; | |
| 244 | + case 'cli': | |
| 245 | +                $theOutput .= $this->pObj->doc->section('', $this->drawCLIstatus(), 0, 1); | |
| 246 | + break; | |
| 247 | + case 'multiprocess': | |
| 248 | +                $theOutput .= $this->pObj->doc->section('', $this->drawProcessOverviewAction(), 0, 1); | |
| 249 | + break; | |
| 250 | + } | |
| 251 | 251 | |
| 252 | - return $theOutput; | |
| 253 | - } | |
| 252 | + return $theOutput; | |
| 253 | + } | |
| 254 | 254 | |
| 255 | 255 | |
| 256 | 256 | |
| @@ -263,176 +263,176 @@ discard block | ||
| 263 | 263 | |
| 264 | 264 | |
| 265 | 265 | |
| 266 | - /******************************* | |
| 266 | + /******************************* | |
| 267 | 267 | * | 
| 268 | 268 | * Generate URLs for crawling: | 
| 269 | 269 | * | 
| 270 | 270 | ******************************/ | 
| 271 | 271 | |
| 272 | - /** | |
| 273 | - * Produces a table with overview of the URLs to be crawled for each page | |
| 274 | - * | |
| 275 | - * @return string HTML output | |
| 276 | - */ | |
| 277 | -	function drawURLs()	{ | |
| 278 | - global $BACK_PATH, $BE_USER; | |
| 279 | - | |
| 280 | - // Init: | |
| 281 | - $this->duplicateTrack = array(); | |
| 282 | -		$this->submitCrawlUrls = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_crawl'); | |
| 283 | -		$this->downloadCrawlUrls = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_download'); | |
| 284 | - $this->makeCrawlerProcessableChecks(); | |
| 285 | - | |
| 286 | -		switch((string)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('tstamp'))	{ | |
| 287 | - case 'midnight': | |
| 288 | - $this->scheduledTime = mktime(0,0,0); | |
| 289 | - break; | |
| 290 | - case '04:00': | |
| 291 | - $this->scheduledTime = mktime(0,0,0)+4*3600; | |
| 292 | - break; | |
| 293 | - case 'now': | |
| 294 | - default: | |
| 295 | - $this->scheduledTime = time(); | |
| 296 | - break; | |
| 297 | - } | |
| 298 | -		// $this->reqMinute = \TYPO3\CMS\Core\Utility\GeneralUtility::intInRange(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('perminute'),1,10000); | |
| 299 | - // TODO: check relevance | |
| 300 | - $this->reqMinute = 1000; | |
| 272 | + /** | |
| 273 | + * Produces a table with overview of the URLs to be crawled for each page | |
| 274 | + * | |
| 275 | + * @return string HTML output | |
| 276 | + */ | |
| 277 | +    function drawURLs()	{ | |
| 278 | + global $BACK_PATH, $BE_USER; | |
| 279 | + | |
| 280 | + // Init: | |
| 281 | + $this->duplicateTrack = array(); | |
| 282 | +        $this->submitCrawlUrls = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_crawl'); | |
| 283 | +        $this->downloadCrawlUrls = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('_download'); | |
| 284 | + $this->makeCrawlerProcessableChecks(); | |
| 285 | + | |
| 286 | +        switch((string)\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('tstamp'))	{ | |
| 287 | + case 'midnight': | |
| 288 | + $this->scheduledTime = mktime(0,0,0); | |
| 289 | + break; | |
| 290 | + case '04:00': | |
| 291 | + $this->scheduledTime = mktime(0,0,0)+4*3600; | |
| 292 | + break; | |
| 293 | + case 'now': | |
| 294 | + default: | |
| 295 | + $this->scheduledTime = time(); | |
| 296 | + break; | |
| 297 | + } | |
| 298 | +        // $this->reqMinute = \TYPO3\CMS\Core\Utility\GeneralUtility::intInRange(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('perminute'),1,10000); | |
| 299 | + // TODO: check relevance | |
| 300 | + $this->reqMinute = 1000; | |
| 301 | 301 | |
| 302 | 302 | |
| 303 | -		$this->incomingConfigurationSelection = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('configurationSelection'); | |
| 304 | -		$this->incomingConfigurationSelection = is_array($this->incomingConfigurationSelection) ? $this->incomingConfigurationSelection : array(''); | |
| 303 | +        $this->incomingConfigurationSelection = \TYPO3\CMS\Core\Utility\GeneralUtility::_GP('configurationSelection'); | |
| 304 | +        $this->incomingConfigurationSelection = is_array($this->incomingConfigurationSelection) ? $this->incomingConfigurationSelection : array(''); | |
| 305 | 305 | |
| 306 | -		$this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); | |
| 307 | -		$this->crawlerObj->setAccessMode('gui'); | |
| 308 | - $this->crawlerObj->setID = \TYPO3\CMS\Core\Utility\GeneralUtility::md5int(microtime()); | |
| 306 | +        $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); | |
| 307 | +        $this->crawlerObj->setAccessMode('gui'); | |
| 308 | + $this->crawlerObj->setID = \TYPO3\CMS\Core\Utility\GeneralUtility::md5int(microtime()); | |
| 309 | 309 | |
| 310 | - if (empty($this->incomingConfigurationSelection) | |
| 311 | - || (count($this->incomingConfigurationSelection)==1 && empty($this->incomingConfigurationSelection[0])) | |
| 312 | -			) { | |
| 313 | - $code= ' | |
| 310 | + if (empty($this->incomingConfigurationSelection) | |
| 311 | + || (count($this->incomingConfigurationSelection)==1 && empty($this->incomingConfigurationSelection[0])) | |
| 312 | +            ) { | |
| 313 | + $code= ' | |
| 314 | 314 | <tr> | 
| 315 | 315 |  				<td colspan="7"><b>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noConfigSelected').'</b></td> | 
| 316 | 316 | </tr>'; | 
| 317 | -		} else { | |
| 318 | -			if($this->submitCrawlUrls){ | |
| 319 | - $reason = new tx_crawler_domain_reason(); | |
| 320 | - $reason->setReason(tx_crawler_domain_reason::REASON_GUI_SUBMIT); | |
| 321 | - | |
| 322 | -				if($BE_USER instanceof \TYPO3\CMS\Core\Authentication\BackendUserAuthentication){ $username = $BE_USER->user['username']; } | |
| 323 | -				$reason->setDetailText('The user '.$username.' added pages to the crawler queue manually '); | |
| 324 | - | |
| 325 | - tx_crawler_domain_events_dispatcher::getInstance()->post( 'invokeQueueChange', | |
| 326 | - $this->findCrawler()->setID, | |
| 327 | - array( 'reason' => $reason )); | |
| 328 | - } | |
| 329 | - | |
| 330 | - $code = $this->crawlerObj->getPageTreeAndUrls( | |
| 331 | - $this->pObj->id, | |
| 332 | - $this->pObj->MOD_SETTINGS['depth'], | |
| 333 | - $this->scheduledTime, | |
| 334 | - $this->reqMinute, | |
| 335 | - $this->submitCrawlUrls, | |
| 336 | - $this->downloadCrawlUrls, | |
| 337 | - array(), // Do not filter any processing instructions | |
| 338 | - $this->incomingConfigurationSelection | |
| 339 | - ); | |
| 317 | +        } else { | |
| 318 | +            if($this->submitCrawlUrls){ | |
| 319 | + $reason = new tx_crawler_domain_reason(); | |
| 320 | + $reason->setReason(tx_crawler_domain_reason::REASON_GUI_SUBMIT); | |
| 321 | + | |
| 322 | +                if($BE_USER instanceof \TYPO3\CMS\Core\Authentication\BackendUserAuthentication){ $username = $BE_USER->user['username']; } | |
| 323 | +                $reason->setDetailText('The user '.$username.' added pages to the crawler queue manually '); | |
| 324 | + | |
| 325 | + tx_crawler_domain_events_dispatcher::getInstance()->post( 'invokeQueueChange', | |
| 326 | + $this->findCrawler()->setID, | |
| 327 | + array( 'reason' => $reason )); | |
| 328 | + } | |
| 329 | + | |
| 330 | + $code = $this->crawlerObj->getPageTreeAndUrls( | |
| 331 | + $this->pObj->id, | |
| 332 | + $this->pObj->MOD_SETTINGS['depth'], | |
| 333 | + $this->scheduledTime, | |
| 334 | + $this->reqMinute, | |
| 335 | + $this->submitCrawlUrls, | |
| 336 | + $this->downloadCrawlUrls, | |
| 337 | + array(), // Do not filter any processing instructions | |
| 338 | + $this->incomingConfigurationSelection | |
| 339 | + ); | |
| 340 | 340 | |
| 341 | 341 | |
| 342 | - } | |
| 342 | + } | |
| 343 | 343 | |
| 344 | - $this->downloadUrls = $this->crawlerObj->downloadUrls; | |
| 345 | - $this->duplicateTrack = $this->crawlerObj->duplicateTrack; | |
| 344 | + $this->downloadUrls = $this->crawlerObj->downloadUrls; | |
| 345 | + $this->duplicateTrack = $this->crawlerObj->duplicateTrack; | |
| 346 | 346 | |
| 347 | - $output = ''; | |
| 348 | -		if ($code)	{ | |
| 347 | + $output = ''; | |
| 348 | +        if ($code)	{ | |
| 349 | 349 | |
| 350 | -			$output .= '<h3>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.configuration').':</h3>'; | |
| 351 | - $output .= '<input type="hidden" name="id" value="'.intval($this->pObj->id).'" />'; | |
| 350 | +            $output .= '<h3>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.configuration').':</h3>'; | |
| 351 | + $output .= '<input type="hidden" name="id" value="'.intval($this->pObj->id).'" />'; | |
| 352 | 352 | |
| 353 | -			if (!$this->submitCrawlUrls)	{ | |
| 354 | - $output .= $this->drawURLs_cfgSelectors().'<br />'; | |
| 355 | -				$output .= '<input type="submit" name="_update" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerUpdate').'" /> '; | |
| 356 | -				$output .= '<input type="submit" name="_crawl" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerCrawl').'" /> '; | |
| 357 | -				$output .= '<input type="submit" name="_download" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerDownload').'" /><br /><br />'; | |
| 358 | -				$output .= $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.count').': '.count(array_keys($this->duplicateTrack)).'<br />'; | |
| 359 | -				$output .= $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.curtime').': '.date('H:i:s',time()).'<br />'; | |
| 360 | - $output .= '<br /> | |
| 353 | +            if (!$this->submitCrawlUrls)	{ | |
| 354 | + $output .= $this->drawURLs_cfgSelectors().'<br />'; | |
| 355 | +                $output .= '<input type="submit" name="_update" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerUpdate').'" /> '; | |
| 356 | +                $output .= '<input type="submit" name="_crawl" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerCrawl').'" /> '; | |
| 357 | +                $output .= '<input type="submit" name="_download" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.triggerDownload').'" /><br /><br />'; | |
| 358 | +                $output .= $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.count').': '.count(array_keys($this->duplicateTrack)).'<br />'; | |
| 359 | +                $output .= $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.curtime').': '.date('H:i:s',time()).'<br />'; | |
| 360 | + $output .= '<br /> | |
| 361 | 361 | <table class="lrPadding c-list url-table">'. | 
| 362 | - $this->drawURLs_printTableHeader(). | |
| 363 | - $code. | |
| 364 | - '</table>'; | |
| 365 | -			} else { | |
| 366 | -				$output .= count(array_keys($this->duplicateTrack)).' '.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.submitted').'. <br /><br />'; | |
| 367 | -				$output .= '<input type="submit" name="_" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.continue').'" />'; | |
| 368 | -				$output .= '<input type="submit" onclick="this.form.elements[\'SET[crawlaction]\'].value=\'log\';" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.continueinlog').'" />'; | |
| 369 | - } | |
| 370 | - } | |
| 371 | - | |
| 372 | - // Download Urls to crawl: | |
| 373 | -		if ($this->downloadCrawlUrls)	{ | |
| 374 | - | |
| 375 | - // Creating output header: | |
| 376 | - $mimeType = 'application/octet-stream'; | |
| 377 | -			Header('Content-Type: '.$mimeType); | |
| 378 | -			Header('Content-Disposition: attachment; filename=CrawlerUrls.txt'); | |
| 379 | - | |
| 380 | - // Printing the content of the CSV lines: | |
| 381 | - echo implode(chr(13).chr(10),$this->downloadUrls); | |
| 382 | - | |
| 383 | - // Exits: | |
| 384 | - exit; | |
| 385 | - } | |
| 386 | - | |
| 387 | - // Return output: | |
| 388 | - return $output; | |
| 389 | - } | |
| 362 | + $this->drawURLs_printTableHeader(). | |
| 363 | + $code. | |
| 364 | + '</table>'; | |
| 365 | +            } else { | |
| 366 | +                $output .= count(array_keys($this->duplicateTrack)).' '.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.submitted').'. <br /><br />'; | |
| 367 | +                $output .= '<input type="submit" name="_" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.continue').'" />'; | |
| 368 | +                $output .= '<input type="submit" onclick="this.form.elements[\'SET[crawlaction]\'].value=\'log\';" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.continueinlog').'" />'; | |
| 369 | + } | |
| 370 | + } | |
| 390 | 371 | |
| 391 | - /** | |
| 392 | - * Draws the configuration selectors for compiling URLs: | |
| 393 | - * | |
| 394 | - * @return string HTML table | |
| 395 | - */ | |
| 396 | -	function drawURLs_cfgSelectors()	{ | |
| 372 | + // Download Urls to crawl: | |
| 373 | +        if ($this->downloadCrawlUrls)	{ | |
| 397 | 374 | |
| 398 | - // depth | |
| 399 | - $cell[] = $this->selectorBox( | |
| 400 | - array( | |
| 401 | -				0 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_0'), | |
| 402 | -				1 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_1'), | |
| 403 | -				2 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_2'), | |
| 404 | -				3 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_3'), | |
| 405 | -				4 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_4'), | |
| 406 | -				99 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_infi'), | |
| 407 | - ), | |
| 408 | - 'SET[depth]', | |
| 409 | - $this->pObj->MOD_SETTINGS['depth'], | |
| 410 | - 0 | |
| 411 | - ); | |
| 412 | - $availableConfigurations = $this->crawlerObj->getConfigurationsForBranch($this->pObj->id, $this->pObj->MOD_SETTINGS['depth']?$this->pObj->MOD_SETTINGS['depth']:0 ); | |
| 375 | + // Creating output header: | |
| 376 | + $mimeType = 'application/octet-stream'; | |
| 377 | +            Header('Content-Type: '.$mimeType); | |
| 378 | +            Header('Content-Disposition: attachment; filename=CrawlerUrls.txt'); | |
| 413 | 379 | |
| 414 | - // Configurations | |
| 415 | - $cell[] = $this->selectorBox( | |
| 416 | - empty($availableConfigurations)?array():array_combine($availableConfigurations, $availableConfigurations), | |
| 417 | - 'configurationSelection', | |
| 418 | - $this->incomingConfigurationSelection, | |
| 419 | - 1 | |
| 420 | - ); | |
| 380 | + // Printing the content of the CSV lines: | |
| 381 | + echo implode(chr(13).chr(10),$this->downloadUrls); | |
| 421 | 382 | |
| 422 | - // Scheduled time: | |
| 423 | - $cell[] = $this->selectorBox( | |
| 424 | - array( | |
| 425 | -				'now' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.now'), | |
| 426 | -				'midnight' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.midnight'), | |
| 427 | -				'04:00' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.4am'), | |
| 428 | - ), | |
| 429 | - 'tstamp', | |
| 430 | -			\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('tstamp'), | |
| 431 | - 0 | |
| 432 | - ); | |
| 383 | + // Exits: | |
| 384 | + exit; | |
| 385 | + } | |
| 433 | 386 | |
| 434 | - // TODO: check relevance | |
| 435 | - /* | |
| 387 | + // Return output: | |
| 388 | + return $output; | |
| 389 | + } | |
| 390 | + | |
| 391 | + /** | |
| 392 | + * Draws the configuration selectors for compiling URLs: | |
| 393 | + * | |
| 394 | + * @return string HTML table | |
| 395 | + */ | |
| 396 | +    function drawURLs_cfgSelectors()	{ | |
| 397 | + | |
| 398 | + // depth | |
| 399 | + $cell[] = $this->selectorBox( | |
| 400 | + array( | |
| 401 | +                0 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_0'), | |
| 402 | +                1 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_1'), | |
| 403 | +                2 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_2'), | |
| 404 | +                3 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_3'), | |
| 405 | +                4 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_4'), | |
| 406 | +                99 => $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.php:labels.depth_infi'), | |
| 407 | + ), | |
| 408 | + 'SET[depth]', | |
| 409 | + $this->pObj->MOD_SETTINGS['depth'], | |
| 410 | + 0 | |
| 411 | + ); | |
| 412 | + $availableConfigurations = $this->crawlerObj->getConfigurationsForBranch($this->pObj->id, $this->pObj->MOD_SETTINGS['depth']?$this->pObj->MOD_SETTINGS['depth']:0 ); | |
| 413 | + | |
| 414 | + // Configurations | |
| 415 | + $cell[] = $this->selectorBox( | |
| 416 | + empty($availableConfigurations)?array():array_combine($availableConfigurations, $availableConfigurations), | |
| 417 | + 'configurationSelection', | |
| 418 | + $this->incomingConfigurationSelection, | |
| 419 | + 1 | |
| 420 | + ); | |
| 421 | + | |
| 422 | + // Scheduled time: | |
| 423 | + $cell[] = $this->selectorBox( | |
| 424 | + array( | |
| 425 | +                'now' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.now'), | |
| 426 | +                'midnight' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.midnight'), | |
| 427 | +                '04:00' => $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.time.4am'), | |
| 428 | + ), | |
| 429 | + 'tstamp', | |
| 430 | +            \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('tstamp'), | |
| 431 | + 0 | |
| 432 | + ); | |
| 433 | + | |
| 434 | + // TODO: check relevance | |
| 435 | + /* | |
| 436 | 436 | // Requests per minute: | 
| 437 | 437 | $cell[] = $this->selectorBox( | 
| 438 | 438 | array( | 
| @@ -453,7 +453,7 @@ discard block | ||
| 453 | 453 | ); | 
| 454 | 454 | */ | 
| 455 | 455 | |
| 456 | - $output = ' | |
| 456 | + $output = ' | |
| 457 | 457 | <table class="lrPadding c-list"> | 
| 458 | 458 | <tr class="bgColor5 tableheader"> | 
| 459 | 459 |  					<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.depth').':</td> | 
| @@ -466,17 +466,17 @@ discard block | ||
| 466 | 466 | </tr> | 
| 467 | 467 | </table>'; | 
| 468 | 468 | |
| 469 | - return $output; | |
| 470 | - } | |
| 469 | + return $output; | |
| 470 | + } | |
| 471 | 471 | |
| 472 | - /** | |
| 473 | - * Create Table header row for URL display | |
| 474 | - * | |
| 475 | - * @return string Table header | |
| 476 | - */ | |
| 477 | -	function drawURLs_printTableHeader()	{ | |
| 472 | + /** | |
| 473 | + * Create Table header row for URL display | |
| 474 | + * | |
| 475 | + * @return string Table header | |
| 476 | + */ | |
| 477 | +    function drawURLs_printTableHeader()	{ | |
| 478 | 478 | |
| 479 | - $content = ' | |
| 479 | + $content = ' | |
| 480 | 480 | <tr class="bgColor5 tableheader"> | 
| 481 | 481 |  				<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.pagetitle').':</td> | 
| 482 | 482 |  				<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.key').':</td> | 
| @@ -487,8 +487,8 @@ discard block | ||
| 487 | 487 |  				<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.parameters').':</td> | 
| 488 | 488 | </tr>'; | 
| 489 | 489 | |
| 490 | - return $content; | |
| 491 | - } | |
| 490 | + return $content; | |
| 491 | + } | |
| 492 | 492 | |
| 493 | 493 | |
| 494 | 494 | |
| @@ -501,110 +501,110 @@ discard block | ||
| 501 | 501 | |
| 502 | 502 | |
| 503 | 503 | |
| 504 | - /******************************* | |
| 504 | + /******************************* | |
| 505 | 505 | * | 
| 506 | 506 | * Shows log of indexed URLs | 
| 507 | 507 | * | 
| 508 | 508 | ******************************/ | 
| 509 | 509 | |
| 510 | - /** | |
| 511 | - * Shows the log of indexed URLs | |
| 512 | - * | |
| 513 | - * @return string HTML output | |
| 514 | - */ | |
| 515 | -	function drawLog()	{ | |
| 516 | - global $BACK_PATH; | |
| 517 | - $output = ''; | |
| 518 | - | |
| 519 | - // Init: | |
| 520 | -		$this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); | |
| 521 | -		$this->crawlerObj->setAccessMode('gui'); | |
| 522 | - $this->crawlerObj->setID = \TYPO3\CMS\Core\Utility\GeneralUtility::md5int(microtime()); | |
| 523 | - | |
| 524 | -		$this->CSVExport = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_csv'); | |
| 525 | - | |
| 526 | - // Read URL: | |
| 527 | -		if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_read'))	{ | |
| 528 | -			$this->crawlerObj->readUrl(intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_read')),TRUE); | |
| 529 | - } | |
| 510 | + /** | |
| 511 | + * Shows the log of indexed URLs | |
| 512 | + * | |
| 513 | + * @return string HTML output | |
| 514 | + */ | |
| 515 | +    function drawLog()	{ | |
| 516 | + global $BACK_PATH; | |
| 517 | + $output = ''; | |
| 518 | + | |
| 519 | + // Init: | |
| 520 | +        $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); | |
| 521 | +        $this->crawlerObj->setAccessMode('gui'); | |
| 522 | + $this->crawlerObj->setID = \TYPO3\CMS\Core\Utility\GeneralUtility::md5int(microtime()); | |
| 523 | + | |
| 524 | +        $this->CSVExport = \TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_csv'); | |
| 525 | + | |
| 526 | + // Read URL: | |
| 527 | +        if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_read'))	{ | |
| 528 | +            $this->crawlerObj->readUrl(intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_read')),TRUE); | |
| 529 | + } | |
| 530 | 530 | |
| 531 | - // Look for set ID sent - if it is, we will display contents of that set: | |
| 532 | -		$showSetId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); | |
| 531 | + // Look for set ID sent - if it is, we will display contents of that set: | |
| 532 | +        $showSetId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); | |
| 533 | 533 | |
| 534 | - // Show details: | |
| 535 | -		if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details'))	{ | |
| 534 | + // Show details: | |
| 535 | +        if (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details'))	{ | |
| 536 | 536 | |
| 537 | - // Get entry record: | |
| 538 | -			list($q_entry) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','tx_crawler_queue','qid='.intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details'))); | |
| 537 | + // Get entry record: | |
| 538 | +            list($q_entry) = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*','tx_crawler_queue','qid='.intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('qid_details'))); | |
| 539 | 539 | |
| 540 | - // Explode values: | |
| 541 | - $resStatus = $this->getResStatus($q_entry); | |
| 542 | - $q_entry['parameters'] = unserialize($q_entry['parameters']); | |
| 543 | - $q_entry['result_data'] = unserialize($q_entry['result_data']); | |
| 544 | -			if (is_array($q_entry['result_data']))	{ | |
| 545 | - $q_entry['result_data']['content'] = unserialize($q_entry['result_data']['content']); | |
| 546 | - } | |
| 540 | + // Explode values: | |
| 541 | + $resStatus = $this->getResStatus($q_entry); | |
| 542 | + $q_entry['parameters'] = unserialize($q_entry['parameters']); | |
| 543 | + $q_entry['result_data'] = unserialize($q_entry['result_data']); | |
| 544 | +            if (is_array($q_entry['result_data']))	{ | |
| 545 | + $q_entry['result_data']['content'] = unserialize($q_entry['result_data']['content']); | |
| 546 | + } | |
| 547 | 547 | |
| 548 | -			if(!$this->pObj->MOD_SETTINGS['log_resultLog']) { | |
| 549 | - unset($q_entry['result_data']['content']['log']); | |
| 550 | - } | |
| 548 | +            if(!$this->pObj->MOD_SETTINGS['log_resultLog']) { | |
| 549 | + unset($q_entry['result_data']['content']['log']); | |
| 550 | + } | |
| 551 | 551 | |
| 552 | - // Print rudimentary details: | |
| 553 | - $output .= ' | |
| 552 | + // Print rudimentary details: | |
| 553 | + $output .= ' | |
| 554 | 554 | <br /><br /> | 
| 555 | 555 |  				<input type="submit" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.back') . '" name="_back" /> | 
| 556 | 556 | <input type="hidden" value="' . $this->pObj->id . '" name="id" /> | 
| 557 | 557 | <input type="hidden" value="' . $showSetId . '" name="setID" /> | 
| 558 | 558 | <br /> | 
| 559 | 559 |  				Current server time: ' . date('H:i:s', time()) . '<br />' . | 
| 560 | - 'Status: ' . $resStatus . '<br />' . | |
| 561 | - \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($q_entry); | |
| 562 | -		} else {	// Show list: | |
| 563 | - | |
| 564 | - // If either id or set id, show list: | |
| 565 | -			if ($this->pObj->id || $showSetId)	{ | |
| 566 | -				if ($this->pObj->id)	{ | |
| 567 | - // Drawing tree: | |
| 568 | -					$tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Backend\Tree\View\PageTreeView'); | |
| 569 | - $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); | |
| 570 | -					$tree->init('AND '.$perms_clause); | |
| 571 | - | |
| 572 | - // Set root row: | |
| 573 | -					$HTML = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $this->pObj->pageinfo); | |
| 574 | -					$HTML = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $this->pObj->pageinfo); | |
| 575 | - $tree->tree[] = Array( | |
| 576 | - 'row' => $this->pObj->pageinfo, | |
| 577 | - 'HTML' => $HTML | |
| 578 | - ); | |
| 579 | - | |
| 580 | - // Get branch beneath: | |
| 581 | -					if ($this->pObj->MOD_SETTINGS['depth'])	{ | |
| 582 | - $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS['depth'], ''); | |
| 583 | - } | |
| 584 | - | |
| 585 | - // Traverse page tree: | |
| 586 | - $code = ''; $count = 0; | |
| 587 | -					foreach($tree->tree as $data)	{ | |
| 588 | - $code .= $this->drawLog_addRows( | |
| 589 | - $data['row'], | |
| 590 | -									$data['HTML'] . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages',$data['row'],TRUE), | |
| 591 | - intval($this->pObj->MOD_SETTINGS['itemsPerPage']) | |
| 592 | - ); | |
| 593 | -						if (++$count == 1000) { | |
| 594 | - break; | |
| 595 | - } | |
| 596 | - } | |
| 597 | -				} else { | |
| 598 | - $code = ''; | |
| 599 | - $code.= $this->drawLog_addRows( | |
| 600 | - $showSetId, | |
| 601 | - 'Set ID: '.$showSetId | |
| 602 | - ); | |
| 603 | - } | |
| 604 | - | |
| 605 | -				if ($code)	{ | |
| 606 | - | |
| 607 | - $output .= ' | |
| 560 | + 'Status: ' . $resStatus . '<br />' . | |
| 561 | + \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($q_entry); | |
| 562 | +        } else {	// Show list: | |
| 563 | + | |
| 564 | + // If either id or set id, show list: | |
| 565 | +            if ($this->pObj->id || $showSetId)	{ | |
| 566 | +                if ($this->pObj->id)	{ | |
| 567 | + // Drawing tree: | |
| 568 | +                    $tree = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Backend\Tree\View\PageTreeView'); | |
| 569 | + $perms_clause = $GLOBALS['BE_USER']->getPagePermsClause(1); | |
| 570 | +                    $tree->init('AND '.$perms_clause); | |
| 571 | + | |
| 572 | + // Set root row: | |
| 573 | +                    $HTML = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $this->pObj->pageinfo); | |
| 574 | +                    $HTML = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', $this->pObj->pageinfo); | |
| 575 | + $tree->tree[] = Array( | |
| 576 | + 'row' => $this->pObj->pageinfo, | |
| 577 | + 'HTML' => $HTML | |
| 578 | + ); | |
| 579 | + | |
| 580 | + // Get branch beneath: | |
| 581 | +                    if ($this->pObj->MOD_SETTINGS['depth'])	{ | |
| 582 | + $tree->getTree($this->pObj->id, $this->pObj->MOD_SETTINGS['depth'], ''); | |
| 583 | + } | |
| 584 | + | |
| 585 | + // Traverse page tree: | |
| 586 | + $code = ''; $count = 0; | |
| 587 | +                    foreach($tree->tree as $data)	{ | |
| 588 | + $code .= $this->drawLog_addRows( | |
| 589 | + $data['row'], | |
| 590 | +                                    $data['HTML'] . \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle('pages',$data['row'],TRUE), | |
| 591 | + intval($this->pObj->MOD_SETTINGS['itemsPerPage']) | |
| 592 | + ); | |
| 593 | +                        if (++$count == 1000) { | |
| 594 | + break; | |
| 595 | + } | |
| 596 | + } | |
| 597 | +                } else { | |
| 598 | + $code = ''; | |
| 599 | + $code.= $this->drawLog_addRows( | |
| 600 | + $showSetId, | |
| 601 | + 'Set ID: '.$showSetId | |
| 602 | + ); | |
| 603 | + } | |
| 604 | + | |
| 605 | +                if ($code)	{ | |
| 606 | + | |
| 607 | + $output .= ' | |
| 608 | 608 | <br /><br /> | 
| 609 | 609 |  						<input type="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.reloadlist').'" name="_reload" /> | 
| 610 | 610 |  						<input type="submit" value="'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.downloadcsv').'" name="_csv" /> | 
| @@ -618,20 +618,20 @@ discard block | ||
| 618 | 618 | |
| 619 | 619 | |
| 620 | 620 | <table class="lrPadding c-list crawlerlog">'. | 
| 621 | - $this->drawLog_printTableHeader(). | |
| 622 | - $code. | |
| 623 | - '</table>'; | |
| 624 | - } | |
| 625 | -			} else {	// Otherwise show available sets: | |
| 626 | - $setList = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( | |
| 627 | - 'set_id, count(*) as count_value, scheduled', | |
| 628 | - 'tx_crawler_queue', | |
| 629 | - '', | |
| 630 | - 'set_id, scheduled', | |
| 631 | - 'scheduled DESC' | |
| 632 | - ); | |
| 633 | - | |
| 634 | - $code = ' | |
| 621 | + $this->drawLog_printTableHeader(). | |
| 622 | + $code. | |
| 623 | + '</table>'; | |
| 624 | + } | |
| 625 | +            } else {	// Otherwise show available sets: | |
| 626 | + $setList = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows( | |
| 627 | + 'set_id, count(*) as count_value, scheduled', | |
| 628 | + 'tx_crawler_queue', | |
| 629 | + '', | |
| 630 | + 'set_id, scheduled', | |
| 631 | + 'scheduled DESC' | |
| 632 | + ); | |
| 633 | + | |
| 634 | + $code = ' | |
| 635 | 635 | <tr class="bgColor5 tableheader"> | 
| 636 | 636 |  						<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.setid').':</td> | 
| 637 | 637 |  						<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.count').'t:</td> | 
| @@ -639,9 +639,9 @@ discard block | ||
| 639 | 639 | </tr> | 
| 640 | 640 | '; | 
| 641 | 641 | |
| 642 | - $cc=0; | |
| 643 | -				foreach($setList as $set)	{ | |
| 644 | - $code.= ' | |
| 642 | + $cc=0; | |
| 643 | +                foreach($setList as $set)	{ | |
| 644 | + $code.= ' | |
| 645 | 645 | <tr class="bgColor'.($cc%2 ? '-20':'-10').'"> | 
| 646 | 646 |  							<td><a href="'.htmlspecialchars('index.php?setID='.$set['set_id']).'">'.$set['set_id'].'</a></td> | 
| 647 | 647 | <td>'.$set['count_value'].'</td> | 
| @@ -649,217 +649,217 @@ discard block | ||
| 649 | 649 | </tr> | 
| 650 | 650 | '; | 
| 651 | 651 | |
| 652 | - $cc++; | |
| 653 | - } | |
| 652 | + $cc++; | |
| 653 | + } | |
| 654 | 654 | |
| 655 | - $output .= ' | |
| 655 | + $output .= ' | |
| 656 | 656 | <br /><br /> | 
| 657 | 657 | <table class="lrPadding c-list">'. | 
| 658 | - $code. | |
| 659 | - '</table>'; | |
| 660 | - } | |
| 661 | - } | |
| 658 | + $code. | |
| 659 | + '</table>'; | |
| 660 | + } | |
| 661 | + } | |
| 662 | 662 | |
| 663 | -		if($this->CSVExport) { | |
| 664 | - $this->outputCsvFile(); | |
| 665 | - } | |
| 663 | +        if($this->CSVExport) { | |
| 664 | + $this->outputCsvFile(); | |
| 665 | + } | |
| 666 | 666 | |
| 667 | - // Return output | |
| 668 | - return $output; | |
| 669 | - } | |
| 667 | + // Return output | |
| 668 | + return $output; | |
| 669 | + } | |
| 670 | 670 | |
| 671 | - /** | |
| 672 | - * Outputs the CSV file and sets the correct headers | |
| 673 | - */ | |
| 674 | -	protected function outputCsvFile() { | |
| 671 | + /** | |
| 672 | + * Outputs the CSV file and sets the correct headers | |
| 673 | + */ | |
| 674 | +    protected function outputCsvFile() { | |
| 675 | 675 | |
| 676 | -		if (!count($this->CSVaccu)) { | |
| 677 | -			$this->addWarningMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.canNotExportEmptyQueueToCsvText')); | |
| 678 | - return; | |
| 679 | - } | |
| 676 | +        if (!count($this->CSVaccu)) { | |
| 677 | +            $this->addWarningMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.canNotExportEmptyQueueToCsvText')); | |
| 678 | + return; | |
| 679 | + } | |
| 680 | 680 | |
| 681 | - $csvLines = array(); | |
| 681 | + $csvLines = array(); | |
| 682 | 682 | |
| 683 | - // Field names: | |
| 684 | - reset($this->CSVaccu); | |
| 685 | - $fieldNames = array_keys(current($this->CSVaccu)); | |
| 686 | - $csvLines[] = \TYPO3\CMS\Core\Utility\GeneralUtility::csvValues($fieldNames); | |
| 683 | + // Field names: | |
| 684 | + reset($this->CSVaccu); | |
| 685 | + $fieldNames = array_keys(current($this->CSVaccu)); | |
| 686 | + $csvLines[] = \TYPO3\CMS\Core\Utility\GeneralUtility::csvValues($fieldNames); | |
| 687 | 687 | |
| 688 | - // Data: | |
| 689 | -		foreach($this->CSVaccu as $row)	{ | |
| 690 | - $csvLines[] = \TYPO3\CMS\Core\Utility\GeneralUtility::csvValues($row); | |
| 691 | - } | |
| 688 | + // Data: | |
| 689 | +        foreach($this->CSVaccu as $row)	{ | |
| 690 | + $csvLines[] = \TYPO3\CMS\Core\Utility\GeneralUtility::csvValues($row); | |
| 691 | + } | |
| 692 | 692 | |
| 693 | - // Creating output header: | |
| 694 | - $mimeType = 'application/octet-stream'; | |
| 695 | -		Header('Content-Type: '.$mimeType); | |
| 696 | -		Header('Content-Disposition: attachment; filename=CrawlerLog.csv'); | |
| 693 | + // Creating output header: | |
| 694 | + $mimeType = 'application/octet-stream'; | |
| 695 | +        Header('Content-Type: '.$mimeType); | |
| 696 | +        Header('Content-Disposition: attachment; filename=CrawlerLog.csv'); | |
| 697 | + | |
| 698 | + // Printing the content of the CSV lines: | |
| 699 | + echo implode(chr(13).chr(10),$csvLines); | |
| 700 | + | |
| 701 | + // Exits: | |
| 702 | + exit; | |
| 703 | + } | |
| 704 | + | |
| 705 | + /** | |
| 706 | + * Create the rows for display of the page tree | |
| 707 | + * For each page a number of rows are shown displaying GET variable configuration | |
| 708 | + * | |
| 709 | + * @param array Page row or set-id | |
| 710 | + * @param string Title string | |
| 711 | + * @param int Items per Page setting | |
| 712 | + * @return string HTML <tr> content (one or more) | |
| 713 | + */ | |
| 714 | +    function drawLog_addRows($pageRow_setId, $titleString, $itemsPerPage=10) { | |
| 715 | + | |
| 716 | + // If Flush button is pressed, flush tables instead of selecting entries: | |
| 717 | + | |
| 718 | +        if(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_flush')) { | |
| 719 | + $doFlush = true; | |
| 720 | + $doFullFlush = false; | |
| 721 | +        } elseif(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_flush_all')) { | |
| 722 | + $doFlush = true; | |
| 723 | + $doFullFlush = true; | |
| 724 | +        } else { | |
| 725 | + $doFlush = false; | |
| 726 | + $doFullFlush = false; | |
| 727 | + } | |
| 697 | 728 | |
| 698 | - // Printing the content of the CSV lines: | |
| 699 | - echo implode(chr(13).chr(10),$csvLines); | |
| 729 | + // Get result: | |
| 730 | +        if (is_array($pageRow_setId))	{ | |
| 731 | + $res = $this->crawlerObj->getLogEntriesForPageId($pageRow_setId['uid'], $this->pObj->MOD_SETTINGS['log_display'], $doFlush, $doFullFlush, intval($itemsPerPage)); | |
| 732 | +        } else { | |
| 733 | + $res = $this->crawlerObj->getLogEntriesForSetId($pageRow_setId, $this->pObj->MOD_SETTINGS['log_display'], $doFlush, $doFullFlush, intval($itemsPerPage)); | |
| 734 | + } | |
| 700 | 735 | |
| 701 | - // Exits: | |
| 702 | - exit; | |
| 703 | - } | |
| 736 | + // Init var: | |
| 737 | + $colSpan = 9 | |
| 738 | + + ($this->pObj->MOD_SETTINGS['log_resultLog'] ? -1 : 0) | |
| 739 | + + ($this->pObj->MOD_SETTINGS['log_feVars'] ? 3 : 0); | |
| 740 | + | |
| 741 | +        if (count($res))	{ | |
| 742 | + // Traverse parameter combinations: | |
| 743 | + $c = 0; | |
| 744 | + $content=''; | |
| 745 | +            foreach($res as $kk => $vv)	{ | |
| 746 | + | |
| 747 | + // Title column: | |
| 748 | +                if (!$c)	{ | |
| 749 | + $titleClm = '<td rowspan="'.count($res).'">'.$titleString.'</td>'; | |
| 750 | +                } else { | |
| 751 | + $titleClm = ''; | |
| 752 | + } | |
| 704 | 753 | |
| 705 | - /** | |
| 706 | - * Create the rows for display of the page tree | |
| 707 | - * For each page a number of rows are shown displaying GET variable configuration | |
| 708 | - * | |
| 709 | - * @param array Page row or set-id | |
| 710 | - * @param string Title string | |
| 711 | - * @param int Items per Page setting | |
| 712 | - * @return string HTML <tr> content (one or more) | |
| 713 | - */ | |
| 714 | -	function drawLog_addRows($pageRow_setId, $titleString, $itemsPerPage=10) { | |
| 715 | - | |
| 716 | - // If Flush button is pressed, flush tables instead of selecting entries: | |
| 717 | - | |
| 718 | -		if(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_flush')) { | |
| 719 | - $doFlush = true; | |
| 720 | - $doFullFlush = false; | |
| 721 | -		} elseif(\TYPO3\CMS\Core\Utility\GeneralUtility::_POST('_flush_all')) { | |
| 722 | - $doFlush = true; | |
| 723 | - $doFullFlush = true; | |
| 724 | -		} else { | |
| 725 | - $doFlush = false; | |
| 726 | - $doFullFlush = false; | |
| 727 | - } | |
| 754 | + // Result: | |
| 755 | + $resLog = $this->getResultLog($vv); | |
| 728 | 756 | |
| 729 | - // Get result: | |
| 730 | -		if (is_array($pageRow_setId))	{ | |
| 731 | - $res = $this->crawlerObj->getLogEntriesForPageId($pageRow_setId['uid'], $this->pObj->MOD_SETTINGS['log_display'], $doFlush, $doFullFlush, intval($itemsPerPage)); | |
| 732 | -		} else { | |
| 733 | - $res = $this->crawlerObj->getLogEntriesForSetId($pageRow_setId, $this->pObj->MOD_SETTINGS['log_display'], $doFlush, $doFullFlush, intval($itemsPerPage)); | |
| 734 | - } | |
| 757 | + $resStatus = $this->getResStatus($vv); | |
| 758 | + $resFeVars = $this->getResFeVars($vv); | |
| 759 | + | |
| 760 | + // Compile row: | |
| 761 | + $parameters = unserialize($vv['parameters']); | |
| 762 | + | |
| 763 | + // Put data into array: | |
| 764 | + $rowData = array(); | |
| 765 | +                if ($this->pObj->MOD_SETTINGS['log_resultLog'])	{ | |
| 766 | + $rowData['result_log'] = $resLog; | |
| 767 | +                } else { | |
| 768 | +                    $rowData['scheduled'] = ($vv['scheduled']> 0) ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['scheduled']) : ' '.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.immediate'); | |
| 769 | + $rowData['exec_time'] = $vv['exec_time'] ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['exec_time']) : '-'; | |
| 770 | + } | |
| 771 | + $rowData['result_status'] = \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($resStatus,50); | |
| 772 | + $rowData['url'] = '<a href="'.htmlspecialchars($parameters['url']).'" target="_newWIndow">'.htmlspecialchars($parameters['url']).'</a>'; | |
| 773 | + $rowData['feUserGroupList'] = $parameters['feUserGroupList']; | |
| 774 | +                $rowData['procInstructions'] = is_array($parameters['procInstructions']) ? implode('; ',$parameters['procInstructions']) : ''; | |
| 775 | + $rowData['set_id'] = $vv['set_id']; | |
| 776 | + | |
| 777 | +                if ($this->pObj->MOD_SETTINGS['log_feVars']) { | |
| 778 | + $rowData['tsfe_id'] = $resFeVars['id']; | |
| 779 | + $rowData['tsfe_gr_list'] = $resFeVars['gr_list']; | |
| 780 | + $rowData['tsfe_no_cache'] = $resFeVars['no_cache']; | |
| 781 | + } | |
| 782 | + | |
| 783 | +                $setId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); | |
| 784 | + | |
| 785 | + $refreshIcon = $GLOBALS['BACK_PATH'] . 'gfx/refresh_n.gif'; | |
| 786 | +                if (version_compare(TYPO3_version,'7.0','>=')) { | |
| 787 | + $refreshIcon = $GLOBALS['BACK_PATH'] . 'sysext/t3skin/extjs/images/grid/refresh.gif'; | |
| 788 | + } | |
| 735 | 789 | |
| 736 | - // Init var: | |
| 737 | - $colSpan = 9 | |
| 738 | - + ($this->pObj->MOD_SETTINGS['log_resultLog'] ? -1 : 0) | |
| 739 | - + ($this->pObj->MOD_SETTINGS['log_feVars'] ? 3 : 0); | |
| 740 | - | |
| 741 | -		if (count($res))	{ | |
| 742 | - // Traverse parameter combinations: | |
| 743 | - $c = 0; | |
| 744 | - $content=''; | |
| 745 | -			foreach($res as $kk => $vv)	{ | |
| 746 | - | |
| 747 | - // Title column: | |
| 748 | -				if (!$c)	{ | |
| 749 | - $titleClm = '<td rowspan="'.count($res).'">'.$titleString.'</td>'; | |
| 750 | -				} else { | |
| 751 | - $titleClm = ''; | |
| 752 | - } | |
| 753 | - | |
| 754 | - // Result: | |
| 755 | - $resLog = $this->getResultLog($vv); | |
| 756 | - | |
| 757 | - $resStatus = $this->getResStatus($vv); | |
| 758 | - $resFeVars = $this->getResFeVars($vv); | |
| 759 | - | |
| 760 | - // Compile row: | |
| 761 | - $parameters = unserialize($vv['parameters']); | |
| 762 | - | |
| 763 | - // Put data into array: | |
| 764 | - $rowData = array(); | |
| 765 | -				if ($this->pObj->MOD_SETTINGS['log_resultLog'])	{ | |
| 766 | - $rowData['result_log'] = $resLog; | |
| 767 | -				} else { | |
| 768 | -					$rowData['scheduled'] = ($vv['scheduled']> 0) ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['scheduled']) : ' '.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.immediate'); | |
| 769 | - $rowData['exec_time'] = $vv['exec_time'] ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['exec_time']) : '-'; | |
| 770 | - } | |
| 771 | - $rowData['result_status'] = \TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs($resStatus,50); | |
| 772 | - $rowData['url'] = '<a href="'.htmlspecialchars($parameters['url']).'" target="_newWIndow">'.htmlspecialchars($parameters['url']).'</a>'; | |
| 773 | - $rowData['feUserGroupList'] = $parameters['feUserGroupList']; | |
| 774 | -				$rowData['procInstructions'] = is_array($parameters['procInstructions']) ? implode('; ',$parameters['procInstructions']) : ''; | |
| 775 | - $rowData['set_id'] = $vv['set_id']; | |
| 776 | - | |
| 777 | -				if ($this->pObj->MOD_SETTINGS['log_feVars']) { | |
| 778 | - $rowData['tsfe_id'] = $resFeVars['id']; | |
| 779 | - $rowData['tsfe_gr_list'] = $resFeVars['gr_list']; | |
| 780 | - $rowData['tsfe_no_cache'] = $resFeVars['no_cache']; | |
| 781 | - } | |
| 782 | - | |
| 783 | -				$setId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID')); | |
| 784 | - | |
| 785 | - $refreshIcon = $GLOBALS['BACK_PATH'] . 'gfx/refresh_n.gif'; | |
| 786 | -				if (version_compare(TYPO3_version,'7.0','>=')) { | |
| 787 | - $refreshIcon = $GLOBALS['BACK_PATH'] . 'sysext/t3skin/extjs/images/grid/refresh.gif'; | |
| 788 | - } | |
| 789 | - | |
| 790 | - // Put rows together: | |
| 791 | - $content.= ' | |
| 790 | + // Put rows together: | |
| 791 | + $content.= ' | |
| 792 | 792 | <tr class="bgColor'.($c%2 ? '-20':'-10').'"> | 
| 793 | 793 | '.$titleClm.' | 
| 794 | 794 |  						<td><a href="' . $this->getModuleUrl(array('qid_details' => $vv['qid'], 'setID' => $setId)) . '">'.htmlspecialchars($vv['qid']).'</a></td> | 
| 795 | 795 |  						<td><a href="' . $this->getModuleUrl(array('qid_read' => $vv['qid'], 'setID' => $setId)) . '"><img src="' . $refreshIcon . '" width="14" hspace="1" vspace="2" height="14" border="0" title="'.htmlspecialchars('Read').'" alt="" /></a></td>'; | 
| 796 | -				foreach($rowData as $fKey => $value) { | |
| 796 | +                foreach($rowData as $fKey => $value) { | |
| 797 | 797 | |
| 798 | -					if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('url',$fKey))	{ | |
| 799 | - $content.= ' | |
| 798 | +                    if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList('url',$fKey))	{ | |
| 799 | + $content.= ' | |
| 800 | 800 | <td>'.$value.'</td>'; | 
| 801 | -					} else { | |
| 802 | - $content.= ' | |
| 801 | +                    } else { | |
| 802 | + $content.= ' | |
| 803 | 803 | <td>'.nl2br(htmlspecialchars($value)).'</td>'; | 
| 804 | - } | |
| 805 | - } | |
| 806 | - $content.= ' | |
| 804 | + } | |
| 805 | + } | |
| 806 | + $content.= ' | |
| 807 | 807 | </tr>'; | 
| 808 | - $c++; | |
| 809 | - | |
| 810 | -				if ($this->CSVExport)	{ | |
| 811 | - // Only for CSV (adding qid and scheduled/exec_time if needed): | |
| 812 | -					$rowData['result_log'] = implode('// ',explode(chr(10),$resLog)); | |
| 813 | - $rowData['qid'] = $vv['qid']; | |
| 814 | - $rowData['scheduled'] = \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['scheduled']); | |
| 815 | - $rowData['exec_time'] = $vv['exec_time'] ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['exec_time']) : '-'; | |
| 816 | - $this->CSVaccu[] = $rowData; | |
| 817 | - } | |
| 818 | - } | |
| 819 | -		} else { | |
| 808 | + $c++; | |
| 809 | + | |
| 810 | +                if ($this->CSVExport)	{ | |
| 811 | + // Only for CSV (adding qid and scheduled/exec_time if needed): | |
| 812 | +                    $rowData['result_log'] = implode('// ',explode(chr(10),$resLog)); | |
| 813 | + $rowData['qid'] = $vv['qid']; | |
| 814 | + $rowData['scheduled'] = \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['scheduled']); | |
| 815 | + $rowData['exec_time'] = $vv['exec_time'] ? \TYPO3\CMS\Backend\Utility\BackendUtility::datetime($vv['exec_time']) : '-'; | |
| 816 | + $this->CSVaccu[] = $rowData; | |
| 817 | + } | |
| 818 | + } | |
| 819 | +        } else { | |
| 820 | 820 | |
| 821 | - // Compile row: | |
| 822 | - $content = ' | |
| 821 | + // Compile row: | |
| 822 | + $content = ' | |
| 823 | 823 | <tr class="bgColor-20"> | 
| 824 | 824 | <td>'.$titleString.'</td> | 
| 825 | 825 |  					<td colspan="'.$colSpan.'"><em>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.noentries').'</em></td> | 
| 826 | 826 | </tr>'; | 
| 827 | - } | |
| 828 | - | |
| 829 | - return $content; | |
| 830 | - } | |
| 827 | + } | |
| 831 | 828 | |
| 832 | - /** | |
| 833 | - * Find Fe vars | |
| 834 | - * | |
| 835 | - * @param array $row | |
| 836 | - * @return array | |
| 837 | - */ | |
| 838 | -	function getResFeVars($row) { | |
| 839 | - $feVars = array(); | |
| 840 | - | |
| 841 | -		if ($row['result_data']) { | |
| 842 | - $resultData = unserialize($row['result_data']); | |
| 843 | - $requestResult = unserialize($resultData['content']); | |
| 844 | - $feVars = $requestResult['vars']; | |
| 845 | - } | |
| 829 | + return $content; | |
| 830 | + } | |
| 831 | + | |
| 832 | + /** | |
| 833 | + * Find Fe vars | |
| 834 | + * | |
| 835 | + * @param array $row | |
| 836 | + * @return array | |
| 837 | + */ | |
| 838 | +    function getResFeVars($row) { | |
| 839 | + $feVars = array(); | |
| 840 | + | |
| 841 | +        if ($row['result_data']) { | |
| 842 | + $resultData = unserialize($row['result_data']); | |
| 843 | + $requestResult = unserialize($resultData['content']); | |
| 844 | + $feVars = $requestResult['vars']; | |
| 845 | + } | |
| 846 | 846 | |
| 847 | - return $feVars; | |
| 848 | - } | |
| 847 | + return $feVars; | |
| 848 | + } | |
| 849 | 849 | |
| 850 | - /** | |
| 851 | - * Create Table header row (log) | |
| 852 | - * | |
| 853 | - * @return string Table header | |
| 854 | - */ | |
| 855 | -	function drawLog_printTableHeader()	{ | |
| 850 | + /** | |
| 851 | + * Create Table header row (log) | |
| 852 | + * | |
| 853 | + * @return string Table header | |
| 854 | + */ | |
| 855 | +    function drawLog_printTableHeader()	{ | |
| 856 | 856 | |
| 857 | - $content = ' | |
| 857 | + $content = ' | |
| 858 | 858 | <tr class="bgColor5 tableheader"> | 
| 859 | 859 |  				<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.pagetitle').':</td> | 
| 860 | 860 |  				<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.qid').':</td> | 
| 861 | 861 | <td> </td>'. | 
| 862 | - ($this->pObj->MOD_SETTINGS['log_resultLog'] ? ' | |
| 862 | + ($this->pObj->MOD_SETTINGS['log_resultLog'] ? ' | |
| 863 | 863 |  				<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.resultlog').':</td>' : ' | 
| 864 | 864 |  				<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.scheduledtime').':</td> | 
| 865 | 865 |  				<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.runtime').':</td>').' | 
| @@ -868,14 +868,14 @@ discard block | ||
| 868 | 868 |  				<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.groups').':</td> | 
| 869 | 869 |  				<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.procinstr').':</td> | 
| 870 | 870 |  				<td>'.$GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.setid').':</td>'. | 
| 871 | - ($this->pObj->MOD_SETTINGS['log_feVars'] ? ' | |
| 871 | + ($this->pObj->MOD_SETTINGS['log_feVars'] ? ' | |
| 872 | 872 |  				<td>'.htmlspecialchars('TSFE->id').'</td> | 
| 873 | 873 |  				<td>'.htmlspecialchars('TSFE->gr_list').'</td> | 
| 874 | 874 |  				<td>'.htmlspecialchars('TSFE->no_cache').'</td>' : '').' | 
| 875 | 875 | </tr>'; | 
| 876 | 876 | |
| 877 | - return $content; | |
| 878 | - } | |
| 877 | + return $content; | |
| 878 | + } | |
| 879 | 879 | |
| 880 | 880 | /** | 
| 881 | 881 | * Extract the log information from the current row and retrive it as formatted string. | 
| @@ -902,25 +902,25 @@ discard block | ||
| 902 | 902 | return $content; | 
| 903 | 903 | } | 
| 904 | 904 | |
| 905 | -	function getResStatus($vv) { | |
| 906 | -		if ($vv['result_data'])	{ | |
| 907 | - $requestContent = unserialize($vv['result_data']); | |
| 908 | - $requestResult = unserialize($requestContent['content']); | |
| 909 | -			if (is_array($requestResult)) { | |
| 910 | -				if (empty($requestResult['errorlog'])) { | |
| 911 | - $resStatus = 'OK'; | |
| 912 | -				} else { | |
| 913 | -					$resStatus = implode("\n", $requestResult['errorlog']); | |
| 914 | - } | |
| 915 | - $resLog = is_array($requestResult['log']) ? implode(chr(10),$requestResult['log']) : ''; | |
| 916 | -			} else { | |
| 917 | -				$resStatus = 'Error: '.substr(preg_replace('/\s+/',' ',strip_tags($requestContent['content'])),0,10000).'...'; | |
| 918 | - } | |
| 919 | -		} else { | |
| 920 | - $resStatus = '-'; | |
| 921 | - } | |
| 922 | - return $resStatus; | |
| 923 | - } | |
| 905 | +    function getResStatus($vv) { | |
| 906 | +        if ($vv['result_data'])	{ | |
| 907 | + $requestContent = unserialize($vv['result_data']); | |
| 908 | + $requestResult = unserialize($requestContent['content']); | |
| 909 | +            if (is_array($requestResult)) { | |
| 910 | +                if (empty($requestResult['errorlog'])) { | |
| 911 | + $resStatus = 'OK'; | |
| 912 | +                } else { | |
| 913 | +                    $resStatus = implode("\n", $requestResult['errorlog']); | |
| 914 | + } | |
| 915 | + $resLog = is_array($requestResult['log']) ? implode(chr(10),$requestResult['log']) : ''; | |
| 916 | +            } else { | |
| 917 | +                $resStatus = 'Error: '.substr(preg_replace('/\s+/',' ',strip_tags($requestContent['content'])),0,10000).'...'; | |
| 918 | + } | |
| 919 | +        } else { | |
| 920 | + $resStatus = '-'; | |
| 921 | + } | |
| 922 | + return $resStatus; | |
| 923 | + } | |
| 924 | 924 | |
| 925 | 925 | |
| 926 | 926 | |
| @@ -929,343 +929,343 @@ discard block | ||
| 929 | 929 | |
| 930 | 930 | |
| 931 | 931 | |
| 932 | - /***************************** | |
| 932 | + /***************************** | |
| 933 | 933 | * | 
| 934 | 934 | * CLI status display | 
| 935 | 935 | * | 
| 936 | 936 | *****************************/ | 
| 937 | 937 | |
| 938 | - /** | |
| 939 | - * This method is used to show an overview about the active an the finished crawling processes | |
| 940 | - * | |
| 941 | - * @author Timo Schmidt | |
| 942 | - * @param void | |
| 943 | - * @return string | |
| 944 | - */ | |
| 945 | -	protected function drawProcessOverviewAction(){ | |
| 946 | - | |
| 947 | - $this->runRefreshHooks(); | |
| 948 | - | |
| 949 | - global $BACK_PATH; | |
| 950 | - $this->makeCrawlerProcessableChecks(); | |
| 951 | - | |
| 952 | - $crawler = $this->findCrawler(); | |
| 953 | -		try { | |
| 954 | - $this->handleProcessOverviewActions(); | |
| 955 | -		} catch (Exception $e) { | |
| 956 | - $this->addErrorMessage($e->getMessage()); | |
| 957 | - } | |
| 958 | - | |
| 959 | -		$offset 	= intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('offset')); | |
| 960 | - $perpage = 20; | |
| 961 | - | |
| 962 | - $processRepository = new tx_crawler_domain_process_repository(); | |
| 963 | - $queueRepository = new tx_crawler_domain_queue_repository(); | |
| 964 | - | |
| 965 | - $mode = $this->pObj->MOD_SETTINGS['processListMode']; | |
| 966 | -		if ($mode == 'detail') { | |
| 967 | - $where = ''; | |
| 968 | -		} elseif($mode == 'simple') { | |
| 969 | - $where = 'active = 1'; | |
| 970 | - } | |
| 971 | - | |
| 972 | -		$allProcesses 		= $processRepository->findAll('ttl','DESC', $perpage, $offset,$where); | |
| 973 | - $allCount = $processRepository->countAll($where); | |
| 974 | - | |
| 975 | - $listView = new tx_crawler_view_process_list(); | |
| 976 | - $listView->setPageId($this->pObj->id); | |
| 977 | - $listView->setIconPath($BACK_PATH.'../typo3conf/ext/crawler/template/process/res/img/'); | |
| 978 | - $listView->setProcessCollection($allProcesses); | |
| 979 | - $listView->setCliPath($this->processManager->getCrawlerCliPath()); | |
| 980 | - $listView->setIsCrawlerEnabled(!$crawler->getDisabled() && !$this->isErrorDetected); | |
| 981 | - $listView->setTotalUnprocessedItemCount($queueRepository->countAllPendingItems()); | |
| 982 | - $listView->setAssignedUnprocessedItemCount($queueRepository->countAllAssignedPendingItems()); | |
| 983 | - $listView->setActiveProcessCount($processRepository->countActive()); | |
| 984 | - $listView->setMaxActiveProcessCount(tx_crawler_api::forceIntegerInRange($this->extensionSettings['processLimit'],1,99,1)); | |
| 985 | - $listView->setMode($mode); | |
| 986 | - | |
| 987 | - $paginationView = new tx_crawler_view_pagination(); | |
| 988 | - $paginationView->setCurrentOffset($offset); | |
| 989 | - $paginationView->setPerPage($perpage); | |
| 990 | - $paginationView->setTotalItemCount($allCount); | |
| 991 | - | |
| 992 | - $output = $listView->render(); | |
| 993 | - | |
| 994 | -		if ($paginationView->getTotalPagesCount() > 1) { | |
| 995 | - $output .= ' <br />'.$paginationView->render(); | |
| 996 | - } | |
| 997 | - | |
| 998 | - return $output; | |
| 999 | - } | |
| 1000 | - | |
| 1001 | - /** | |
| 1002 | - * Verify that the crawler is exectuable. | |
| 1003 | - * | |
| 1004 | - * @access protected | |
| 1005 | - * @return void | |
| 1006 | - * | |
| 1007 | - * @author Michael Klapper <[email protected]> | |
| 1008 | - */ | |
| 1009 | -	protected function makeCrawlerProcessableChecks() { | |
| 1010 | - global $LANG; | |
| 1011 | - | |
| 1012 | -		if ($this->isCrawlerUserAvailable() === false) { | |
| 1013 | -			$this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.noBeUserAvailable')); | |
| 1014 | -		} elseif ($this->isCrawlerUserNotAdmin() === false) { | |
| 1015 | -			$this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.beUserIsAdmin')); | |
| 1016 | - } | |
| 938 | + /** | |
| 939 | + * This method is used to show an overview about the active an the finished crawling processes | |
| 940 | + * | |
| 941 | + * @author Timo Schmidt | |
| 942 | + * @param void | |
| 943 | + * @return string | |
| 944 | + */ | |
| 945 | +    protected function drawProcessOverviewAction(){ | |
| 946 | + | |
| 947 | + $this->runRefreshHooks(); | |
| 948 | + | |
| 949 | + global $BACK_PATH; | |
| 950 | + $this->makeCrawlerProcessableChecks(); | |
| 951 | + | |
| 952 | + $crawler = $this->findCrawler(); | |
| 953 | +        try { | |
| 954 | + $this->handleProcessOverviewActions(); | |
| 955 | +        } catch (Exception $e) { | |
| 956 | + $this->addErrorMessage($e->getMessage()); | |
| 957 | + } | |
| 1017 | 958 | |
| 1018 | -		if ($this->isPhpForkAvailable() === false) { | |
| 1019 | -			$this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.noPhpForkAvailable')); | |
| 1020 | - } | |
| 959 | +        $offset 	= intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('offset')); | |
| 960 | + $perpage = 20; | |
| 1021 | 961 | |
| 1022 | - $exitCode = 0; | |
| 1023 | - $out = array(); | |
| 1024 | - exec(escapeshellcmd($this->extensionSettings['phpPath'] . ' -v'), $out, $exitCode); | |
| 1025 | -		if ($exitCode > 0) { | |
| 1026 | -			$this->addErrorMessage(sprintf($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.phpBinaryNotFound'), htmlspecialchars($this->extensionSettings['phpPath']))); | |
| 1027 | - } | |
| 1028 | - } | |
| 1029 | - | |
| 1030 | - /** | |
| 1031 | - * Indicate that the required PHP method "popen" is | |
| 1032 | - * available in the system. | |
| 1033 | - * | |
| 1034 | - * @access protected | |
| 1035 | - * @return boolean | |
| 1036 | - * | |
| 1037 | - * @author Michael Klapper <[email protected]> | |
| 1038 | - */ | |
| 1039 | -	protected function isPhpForkAvailable() { | |
| 1040 | -		return function_exists('popen'); | |
| 1041 | - } | |
| 1042 | - | |
| 1043 | - /** | |
| 1044 | - * Indicate that the required be_user "_cli_crawler" is | |
| 1045 | - * global available in the system. | |
| 1046 | - * | |
| 1047 | - * @access protected | |
| 1048 | - * @return boolean | |
| 1049 | - * | |
| 1050 | - * @author Michael Klapper <[email protected]> | |
| 1051 | - */ | |
| 1052 | -	protected function isCrawlerUserAvailable() { | |
| 1053 | - $isAvailable = false; | |
| 1054 | -		$userArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('be_users', 'username', '_cli_crawler'); | |
| 962 | + $processRepository = new tx_crawler_domain_process_repository(); | |
| 963 | + $queueRepository = new tx_crawler_domain_queue_repository(); | |
| 1055 | 964 | |
| 1056 | - if (is_array($userArray)) | |
| 1057 | - $isAvailable = true; | |
| 1058 | - | |
| 1059 | - return $isAvailable; | |
| 1060 | - } | |
| 965 | + $mode = $this->pObj->MOD_SETTINGS['processListMode']; | |
| 966 | +        if ($mode == 'detail') { | |
| 967 | + $where = ''; | |
| 968 | +        } elseif($mode == 'simple') { | |
| 969 | + $where = 'active = 1'; | |
| 970 | + } | |
| 1061 | 971 | |
| 1062 | - /** | |
| 1063 | - * Indicate that the required be_user "_cli_crawler" is | |
| 1064 | - * has no admin rights. | |
| 1065 | - * | |
| 1066 | - * @access protected | |
| 1067 | - * @return boolean | |
| 1068 | - * | |
| 1069 | - * @author Michael Klapper <[email protected]> | |
| 1070 | - */ | |
| 1071 | -	protected function isCrawlerUserNotAdmin() { | |
| 1072 | - $isAvailable = false; | |
| 1073 | -		$userArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('be_users', 'username', '_cli_crawler'); | |
| 972 | +        $allProcesses 		= $processRepository->findAll('ttl','DESC', $perpage, $offset,$where); | |
| 973 | + $allCount = $processRepository->countAll($where); | |
| 974 | + | |
| 975 | + $listView = new tx_crawler_view_process_list(); | |
| 976 | + $listView->setPageId($this->pObj->id); | |
| 977 | + $listView->setIconPath($BACK_PATH.'../typo3conf/ext/crawler/template/process/res/img/'); | |
| 978 | + $listView->setProcessCollection($allProcesses); | |
| 979 | + $listView->setCliPath($this->processManager->getCrawlerCliPath()); | |
| 980 | + $listView->setIsCrawlerEnabled(!$crawler->getDisabled() && !$this->isErrorDetected); | |
| 981 | + $listView->setTotalUnprocessedItemCount($queueRepository->countAllPendingItems()); | |
| 982 | + $listView->setAssignedUnprocessedItemCount($queueRepository->countAllAssignedPendingItems()); | |
| 983 | + $listView->setActiveProcessCount($processRepository->countActive()); | |
| 984 | + $listView->setMaxActiveProcessCount(tx_crawler_api::forceIntegerInRange($this->extensionSettings['processLimit'],1,99,1)); | |
| 985 | + $listView->setMode($mode); | |
| 986 | + | |
| 987 | + $paginationView = new tx_crawler_view_pagination(); | |
| 988 | + $paginationView->setCurrentOffset($offset); | |
| 989 | + $paginationView->setPerPage($perpage); | |
| 990 | + $paginationView->setTotalItemCount($allCount); | |
| 991 | + | |
| 992 | + $output = $listView->render(); | |
| 993 | + | |
| 994 | +        if ($paginationView->getTotalPagesCount() > 1) { | |
| 995 | + $output .= ' <br />'.$paginationView->render(); | |
| 996 | + } | |
| 1074 | 997 | |
| 1075 | - if (is_array($userArray) && $userArray[0]['admin'] == 0) | |
| 1076 | - $isAvailable = true; | |
| 998 | + return $output; | |
| 999 | + } | |
| 1000 | + | |
| 1001 | + /** | |
| 1002 | + * Verify that the crawler is exectuable. | |
| 1003 | + * | |
| 1004 | + * @access protected | |
| 1005 | + * @return void | |
| 1006 | + * | |
| 1007 | + * @author Michael Klapper <[email protected]> | |
| 1008 | + */ | |
| 1009 | +    protected function makeCrawlerProcessableChecks() { | |
| 1010 | + global $LANG; | |
| 1011 | + | |
| 1012 | +        if ($this->isCrawlerUserAvailable() === false) { | |
| 1013 | +            $this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.noBeUserAvailable')); | |
| 1014 | +        } elseif ($this->isCrawlerUserNotAdmin() === false) { | |
| 1015 | +            $this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.beUserIsAdmin')); | |
| 1016 | + } | |
| 1077 | 1017 | |
| 1078 | - return $isAvailable; | |
| 1079 | - } | |
| 1018 | +        if ($this->isPhpForkAvailable() === false) { | |
| 1019 | +            $this->addErrorMessage($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.noPhpForkAvailable')); | |
| 1020 | + } | |
| 1080 | 1021 | |
| 1081 | - /** | |
| 1082 | - * Method to handle incomming actions of the process overview | |
| 1083 | - * | |
| 1084 | - * @param void | |
| 1085 | - * @return void | |
| 1086 | - */ | |
| 1087 | -	protected function handleProcessOverviewActions(){ | |
| 1088 | - | |
| 1089 | - $crawler = $this->findCrawler(); | |
| 1090 | - | |
| 1091 | -		switch (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('action')) { | |
| 1092 | - case 'stopCrawling' : | |
| 1093 | - //set the cli status to disable (all processes will be terminated) | |
| 1094 | - $crawler->setDisabled(true); | |
| 1095 | - break; | |
| 1096 | - case 'resumeCrawling' : | |
| 1097 | - //set the cli status to end (all processes will be terminated) | |
| 1098 | - $crawler->setDisabled(false); | |
| 1099 | - break; | |
| 1100 | - case 'addProcess' : | |
| 1101 | - $handle = $this->processManager->startProcess(); | |
| 1102 | -				if ($handle === false) { | |
| 1103 | -					throw new Exception($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.newprocesserror')); | |
| 1104 | - } | |
| 1105 | -				$this->addNoticeMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.newprocess')); | |
| 1106 | - break; | |
| 1107 | - } | |
| 1108 | - } | |
| 1022 | + $exitCode = 0; | |
| 1023 | + $out = array(); | |
| 1024 | + exec(escapeshellcmd($this->extensionSettings['phpPath'] . ' -v'), $out, $exitCode); | |
| 1025 | +        if ($exitCode > 0) { | |
| 1026 | +            $this->addErrorMessage(sprintf($LANG->sL('LLL:EXT:crawler/modfunc1/locallang.xml:message.phpBinaryNotFound'), htmlspecialchars($this->extensionSettings['phpPath']))); | |
| 1027 | + } | |
| 1028 | + } | |
| 1029 | + | |
| 1030 | + /** | |
| 1031 | + * Indicate that the required PHP method "popen" is | |
| 1032 | + * available in the system. | |
| 1033 | + * | |
| 1034 | + * @access protected | |
| 1035 | + * @return boolean | |
| 1036 | + * | |
| 1037 | + * @author Michael Klapper <[email protected]> | |
| 1038 | + */ | |
| 1039 | +    protected function isPhpForkAvailable() { | |
| 1040 | +        return function_exists('popen'); | |
| 1041 | + } | |
| 1042 | + | |
| 1043 | + /** | |
| 1044 | + * Indicate that the required be_user "_cli_crawler" is | |
| 1045 | + * global available in the system. | |
| 1046 | + * | |
| 1047 | + * @access protected | |
| 1048 | + * @return boolean | |
| 1049 | + * | |
| 1050 | + * @author Michael Klapper <[email protected]> | |
| 1051 | + */ | |
| 1052 | +    protected function isCrawlerUserAvailable() { | |
| 1053 | + $isAvailable = false; | |
| 1054 | +        $userArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('be_users', 'username', '_cli_crawler'); | |
| 1055 | + | |
| 1056 | + if (is_array($userArray)) | |
| 1057 | + $isAvailable = true; | |
| 1058 | + | |
| 1059 | + return $isAvailable; | |
| 1060 | + } | |
| 1061 | + | |
| 1062 | + /** | |
| 1063 | + * Indicate that the required be_user "_cli_crawler" is | |
| 1064 | + * has no admin rights. | |
| 1065 | + * | |
| 1066 | + * @access protected | |
| 1067 | + * @return boolean | |
| 1068 | + * | |
| 1069 | + * @author Michael Klapper <[email protected]> | |
| 1070 | + */ | |
| 1071 | +    protected function isCrawlerUserNotAdmin() { | |
| 1072 | + $isAvailable = false; | |
| 1073 | +        $userArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordsByField('be_users', 'username', '_cli_crawler'); | |
| 1074 | + | |
| 1075 | + if (is_array($userArray) && $userArray[0]['admin'] == 0) | |
| 1076 | + $isAvailable = true; | |
| 1077 | + | |
| 1078 | + return $isAvailable; | |
| 1079 | + } | |
| 1080 | + | |
| 1081 | + /** | |
| 1082 | + * Method to handle incomming actions of the process overview | |
| 1083 | + * | |
| 1084 | + * @param void | |
| 1085 | + * @return void | |
| 1086 | + */ | |
| 1087 | +    protected function handleProcessOverviewActions(){ | |
| 1088 | + | |
| 1089 | + $crawler = $this->findCrawler(); | |
| 1090 | + | |
| 1091 | +        switch (\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('action')) { | |
| 1092 | + case 'stopCrawling' : | |
| 1093 | + //set the cli status to disable (all processes will be terminated) | |
| 1094 | + $crawler->setDisabled(true); | |
| 1095 | + break; | |
| 1096 | + case 'resumeCrawling' : | |
| 1097 | + //set the cli status to end (all processes will be terminated) | |
| 1098 | + $crawler->setDisabled(false); | |
| 1099 | + break; | |
| 1100 | + case 'addProcess' : | |
| 1101 | + $handle = $this->processManager->startProcess(); | |
| 1102 | +                if ($handle === false) { | |
| 1103 | +                    throw new Exception($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.newprocesserror')); | |
| 1104 | + } | |
| 1105 | +                $this->addNoticeMessage($GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.newprocess')); | |
| 1106 | + break; | |
| 1107 | + } | |
| 1108 | + } | |
| 1109 | 1109 | |
| 1110 | 1110 | |
| 1111 | 1111 | |
| 1112 | 1112 | |
| 1113 | - /** | |
| 1114 | - * Returns the singleton instance of the crawler. | |
| 1115 | - * | |
| 1116 | - * @param void | |
| 1117 | - * @return tx_crawler_lib crawler object | |
| 1118 | - * @author Timo Schmidt <[email protected]> | |
| 1119 | - */ | |
| 1120 | -	protected function findCrawler(){ | |
| 1121 | -		if(!$this->crawlerObj instanceof tx_crawler_lib){ | |
| 1122 | -			$this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); | |
| 1123 | - } | |
| 1124 | - return $this->crawlerObj; | |
| 1125 | - } | |
| 1113 | + /** | |
| 1114 | + * Returns the singleton instance of the crawler. | |
| 1115 | + * | |
| 1116 | + * @param void | |
| 1117 | + * @return tx_crawler_lib crawler object | |
| 1118 | + * @author Timo Schmidt <[email protected]> | |
| 1119 | + */ | |
| 1120 | +    protected function findCrawler(){ | |
| 1121 | +        if(!$this->crawlerObj instanceof tx_crawler_lib){ | |
| 1122 | +            $this->crawlerObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); | |
| 1123 | + } | |
| 1124 | + return $this->crawlerObj; | |
| 1125 | + } | |
| 1126 | 1126 | |
| 1127 | 1127 | |
| 1128 | 1128 | |
| 1129 | - /***************************** | |
| 1129 | + /***************************** | |
| 1130 | 1130 | * | 
| 1131 | 1131 | * General Helper Functions | 
| 1132 | 1132 | * | 
| 1133 | 1133 | *****************************/ | 
| 1134 | 1134 | |
| 1135 | - /** | |
| 1136 | - * This method is used to add a message to the internal queue | |
| 1137 | - * | |
| 1138 | - * NOTE: | |
| 1139 | - * This method is basesd on TYPO3 4.3 or higher! | |
| 1140 | - * | |
| 1141 | - * @param string the message itself | |
| 1142 | - * @param integer message level (-1 = success (default), 0 = info, 1 = notice, 2 = warning, 3 = error) | |
| 1143 | - * | |
| 1144 | - * @access private | |
| 1145 | - * @return void | |
| 1146 | - */ | |
| 1147 | -	private function addMessage($message, $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK) { | |
| 1148 | - $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( | |
| 1149 | - 'TYPO3\CMS\Core\Messaging\FlashMessage', | |
| 1150 | - $message, | |
| 1151 | - '', | |
| 1152 | - $severity | |
| 1153 | - ); | |
| 1154 | - | |
| 1155 | - // TODO: | |
| 1156 | - /** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */ | |
| 1157 | -		$flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); | |
| 1158 | - $flashMessageService->getMessageQueueByIdentifier()->addMessage($message); | |
| 1159 | - } | |
| 1160 | - | |
| 1161 | - /** | |
| 1162 | - * Add notice message to the user interface. | |
| 1163 | - * | |
| 1164 | - * NOTE: | |
| 1165 | - * This method is basesd on TYPO3 4.3 or higher! | |
| 1166 | - * | |
| 1167 | - * @param string The message | |
| 1168 | - * | |
| 1169 | - * @access protected | |
| 1170 | - * @return void | |
| 1171 | - * | |
| 1172 | - * @author Michael Klapper <[email protected]> | |
| 1173 | - */ | |
| 1174 | -	protected function addNoticeMessage($message) { | |
| 1175 | - $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE); | |
| 1176 | - } | |
| 1177 | - | |
| 1178 | - /** | |
| 1179 | - * Add error message to the user interface. | |
| 1180 | - * | |
| 1181 | - * NOTE: | |
| 1182 | - * This method is basesd on TYPO3 4.3 or higher! | |
| 1183 | - * | |
| 1184 | - * @param string The message | |
| 1185 | - * | |
| 1186 | - * @access protected | |
| 1187 | - * @return void | |
| 1188 | - * | |
| 1189 | - * @author Michael Klapper <[email protected]> | |
| 1190 | - */ | |
| 1191 | -	protected function addErrorMessage($message) { | |
| 1192 | - $this->isErrorDetected = TRUE; | |
| 1193 | - $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); | |
| 1194 | - } | |
| 1195 | - | |
| 1196 | - /** | |
| 1197 | - * Add error message to the user interface. | |
| 1198 | - * | |
| 1199 | - * NOTE: | |
| 1200 | - * This method is basesd on TYPO3 4.3 or higher! | |
| 1201 | - * | |
| 1202 | - * @param string The message | |
| 1203 | - * | |
| 1204 | - * @access protected | |
| 1205 | - * @return void | |
| 1206 | - * | |
| 1207 | - * @author Michael Klapper <[email protected]> | |
| 1208 | - */ | |
| 1209 | -	protected function addWarningMessage($message) { | |
| 1210 | - $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING); | |
| 1211 | - } | |
| 1212 | - | |
| 1213 | - /** | |
| 1214 | - * Create selector box | |
| 1215 | - * | |
| 1216 | - * @param array Options key(value) => label pairs | |
| 1217 | - * @param string Selector box name | |
| 1218 | - * @param string Selector box value (array for multiple...) | |
| 1219 | - * @param boolean If set, will draw multiple box. | |
| 1220 | - * @return string HTML select element | |
| 1221 | - */ | |
| 1222 | -	function selectorBox($optArray, $name, $value, $multiple)	{ | |
| 1223 | - | |
| 1224 | - $options = array(); | |
| 1225 | -		foreach($optArray as $key => $val)	{ | |
| 1226 | - $options[] = ' | |
| 1135 | + /** | |
| 1136 | + * This method is used to add a message to the internal queue | |
| 1137 | + * | |
| 1138 | + * NOTE: | |
| 1139 | + * This method is basesd on TYPO3 4.3 or higher! | |
| 1140 | + * | |
| 1141 | + * @param string the message itself | |
| 1142 | + * @param integer message level (-1 = success (default), 0 = info, 1 = notice, 2 = warning, 3 = error) | |
| 1143 | + * | |
| 1144 | + * @access private | |
| 1145 | + * @return void | |
| 1146 | + */ | |
| 1147 | +    private function addMessage($message, $severity = \TYPO3\CMS\Core\Messaging\FlashMessage::OK) { | |
| 1148 | + $message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance( | |
| 1149 | + 'TYPO3\CMS\Core\Messaging\FlashMessage', | |
| 1150 | + $message, | |
| 1151 | + '', | |
| 1152 | + $severity | |
| 1153 | + ); | |
| 1154 | + | |
| 1155 | + // TODO: | |
| 1156 | + /** @var \TYPO3\CMS\Core\Messaging\FlashMessageService $flashMessageService */ | |
| 1157 | +        $flashMessageService = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessageService'); | |
| 1158 | + $flashMessageService->getMessageQueueByIdentifier()->addMessage($message); | |
| 1159 | + } | |
| 1160 | + | |
| 1161 | + /** | |
| 1162 | + * Add notice message to the user interface. | |
| 1163 | + * | |
| 1164 | + * NOTE: | |
| 1165 | + * This method is basesd on TYPO3 4.3 or higher! | |
| 1166 | + * | |
| 1167 | + * @param string The message | |
| 1168 | + * | |
| 1169 | + * @access protected | |
| 1170 | + * @return void | |
| 1171 | + * | |
| 1172 | + * @author Michael Klapper <[email protected]> | |
| 1173 | + */ | |
| 1174 | +    protected function addNoticeMessage($message) { | |
| 1175 | + $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::NOTICE); | |
| 1176 | + } | |
| 1177 | + | |
| 1178 | + /** | |
| 1179 | + * Add error message to the user interface. | |
| 1180 | + * | |
| 1181 | + * NOTE: | |
| 1182 | + * This method is basesd on TYPO3 4.3 or higher! | |
| 1183 | + * | |
| 1184 | + * @param string The message | |
| 1185 | + * | |
| 1186 | + * @access protected | |
| 1187 | + * @return void | |
| 1188 | + * | |
| 1189 | + * @author Michael Klapper <[email protected]> | |
| 1190 | + */ | |
| 1191 | +    protected function addErrorMessage($message) { | |
| 1192 | + $this->isErrorDetected = TRUE; | |
| 1193 | + $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::ERROR); | |
| 1194 | + } | |
| 1195 | + | |
| 1196 | + /** | |
| 1197 | + * Add error message to the user interface. | |
| 1198 | + * | |
| 1199 | + * NOTE: | |
| 1200 | + * This method is basesd on TYPO3 4.3 or higher! | |
| 1201 | + * | |
| 1202 | + * @param string The message | |
| 1203 | + * | |
| 1204 | + * @access protected | |
| 1205 | + * @return void | |
| 1206 | + * | |
| 1207 | + * @author Michael Klapper <[email protected]> | |
| 1208 | + */ | |
| 1209 | +    protected function addWarningMessage($message) { | |
| 1210 | + $this->addMessage($message, \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING); | |
| 1211 | + } | |
| 1212 | + | |
| 1213 | + /** | |
| 1214 | + * Create selector box | |
| 1215 | + * | |
| 1216 | + * @param array Options key(value) => label pairs | |
| 1217 | + * @param string Selector box name | |
| 1218 | + * @param string Selector box value (array for multiple...) | |
| 1219 | + * @param boolean If set, will draw multiple box. | |
| 1220 | + * @return string HTML select element | |
| 1221 | + */ | |
| 1222 | +    function selectorBox($optArray, $name, $value, $multiple)	{ | |
| 1223 | + | |
| 1224 | + $options = array(); | |
| 1225 | +        foreach($optArray as $key => $val)	{ | |
| 1226 | + $options[] = ' | |
| 1227 | 1227 | <option value="'.htmlspecialchars($key).'"'.((!$multiple && !strcmp($value,$key)) || ($multiple && in_array($key,(array)$value))?' selected="selected"':'').'>'.htmlspecialchars($val).'</option>'; | 
| 1228 | - } | |
| 1229 | - | |
| 1230 | -		$output = '<select name="'.htmlspecialchars($name.($multiple?'[]':'')).'"'.($multiple ? ' multiple="multiple" size="'.count($options).'"' : '').'>'.implode('',$options).'</select>'; | |
| 1231 | - | |
| 1232 | - return $output; | |
| 1233 | - } | |
| 1234 | - | |
| 1235 | - /** | |
| 1236 | - * Activate hooks | |
| 1237 | - * | |
| 1238 | - * @return void | |
| 1239 | - */ | |
| 1240 | -	function runRefreshHooks() { | |
| 1241 | -		$crawlerLib = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); | |
| 1242 | -		if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['refresh_hooks'])) { | |
| 1243 | -			foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['refresh_hooks'] as $objRef) { | |
| 1244 | - $hookObj = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($objRef); | |
| 1245 | -				if (is_object($hookObj)) { | |
| 1246 | - $hookObj->crawler_init($crawlerLib); | |
| 1247 | - } | |
| 1248 | - } | |
| 1249 | - } | |
| 1228 | + } | |
| 1250 | 1229 | |
| 1251 | - } | |
| 1230 | +        $output = '<select name="'.htmlspecialchars($name.($multiple?'[]':'')).'"'.($multiple ? ' multiple="multiple" size="'.count($options).'"' : '').'>'.implode('',$options).'</select>'; | |
| 1231 | + | |
| 1232 | + return $output; | |
| 1233 | + } | |
| 1234 | + | |
| 1235 | + /** | |
| 1236 | + * Activate hooks | |
| 1237 | + * | |
| 1238 | + * @return void | |
| 1239 | + */ | |
| 1240 | +    function runRefreshHooks() { | |
| 1241 | +        $crawlerLib = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_lib'); | |
| 1242 | +        if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['refresh_hooks'])) { | |
| 1243 | +            foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['crawler']['refresh_hooks'] as $objRef) { | |
| 1244 | + $hookObj = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($objRef); | |
| 1245 | +                if (is_object($hookObj)) { | |
| 1246 | + $hookObj->crawler_init($crawlerLib); | |
| 1247 | + } | |
| 1248 | + } | |
| 1249 | + } | |
| 1252 | 1250 | |
| 1253 | - /** | |
| 1254 | - * Returns the URL to the current module, including $_GET['id']. | |
| 1255 | - * | |
| 1256 | - * @param array $urlParameters optional parameters to add to the URL | |
| 1257 | - * @return string | |
| 1258 | - */ | |
| 1259 | -	protected function getModuleUrl(array $urlParameters = array()) { | |
| 1260 | -	    if ($this->pObj->id) { | |
| 1261 | - $urlParameters = array_merge($urlParameters, array( | |
| 1251 | + } | |
| 1252 | + | |
| 1253 | + /** | |
| 1254 | + * Returns the URL to the current module, including $_GET['id']. | |
| 1255 | + * | |
| 1256 | + * @param array $urlParameters optional parameters to add to the URL | |
| 1257 | + * @return string | |
| 1258 | + */ | |
| 1259 | +    protected function getModuleUrl(array $urlParameters = array()) { | |
| 1260 | +        if ($this->pObj->id) { | |
| 1261 | + $urlParameters = array_merge($urlParameters, array( | |
| 1262 | 1262 | 'id' => $this->pObj->id | 
| 1263 | 1263 | )); | 
| 1264 | - } | |
| 1264 | + } | |
| 1265 | 1265 |          return \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('M'), $urlParameters); | 
| 1266 | - } | |
| 1266 | + } | |
| 1267 | 1267 | } | 
| 1268 | 1268 | |
| 1269 | 1269 |  if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/modfunc1/class.tx_crawler_modfunc1.php'])	{ | 
| 1270 | - include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/modfunc1/class.tx_crawler_modfunc1.php']); | |
| 1270 | + include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/modfunc1/class.tx_crawler_modfunc1.php']); | |
| 1271 | 1271 | } | 
| 1272 | 1272 | \ No newline at end of file | 
| @@ -123,7 +123,7 @@ | ||
| 123 | 123 | * Returns the total number of pages needed to display all content which | 
| 124 | 124 | * is paginatable | 
| 125 | 125 | * | 
| 126 | - * @return int | |
| 126 | + * @return double | |
| 127 | 127 | */ | 
| 128 | 128 |  	public function getTotalPagesCount() { | 
| 129 | 129 | return ceil($this->getTotalItemCount() / $this->getPerPage()); | 
| @@ -24,121 +24,121 @@ | ||
| 24 | 24 | |
| 25 | 25 |  class tx_crawler_view_pagination { | 
| 26 | 26 | |
| 27 | - /** | |
| 28 | - * @var string template path | |
| 29 | - */ | |
| 30 | - protected $template = 'EXT:crawler/template/pagination.php'; | |
| 31 | - | |
| 32 | - /** | |
| 33 | - * @var int $perpage number of items perPage | |
| 34 | - */ | |
| 35 | - protected $perPage; | |
| 36 | - | |
| 37 | - /** | |
| 38 | - * @var int $currentOffset current offset | |
| 39 | - */ | |
| 40 | - protected $currentOffset; | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * @var int $totalItemCount number of total item | |
| 44 | - */ | |
| 45 | - protected $totalItemCount; | |
| 46 | - | |
| 47 | - /** | |
| 48 | - * @var string $baseUrl | |
| 49 | - */ | |
| 50 | - protected $baseUrl; | |
| 51 | - | |
| 52 | - | |
| 53 | - | |
| 54 | - | |
| 55 | - /** | |
| 56 | - * Method to render the view. | |
| 57 | - * | |
| 58 | - * @return string html content | |
| 59 | - */ | |
| 60 | -	public function render() { | |
| 61 | - ob_start(); | |
| 62 | - $this->template = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->template); | |
| 63 | - include($this->template); | |
| 64 | - $content = ob_get_contents(); | |
| 65 | - ob_end_clean(); | |
| 66 | - | |
| 67 | - return $content; | |
| 68 | - } | |
| 69 | - | |
| 70 | - /** | |
| 71 | - * Returns the currently configured offset- | |
| 72 | - * @return int | |
| 73 | - */ | |
| 74 | -	public function getCurrentOffset() { | |
| 75 | - return $this->currentOffset; | |
| 76 | - } | |
| 77 | - | |
| 78 | - /** | |
| 79 | - * Method to read the number of items per page | |
| 80 | - * | |
| 81 | - * @return int | |
| 82 | - */ | |
| 83 | -	public function getPerPage() { | |
| 84 | - return $this->perPage; | |
| 85 | - } | |
| 86 | - | |
| 87 | - /** | |
| 88 | - * Method to set the current offset from start | |
| 89 | - * | |
| 90 | - * @param int $currentOffset | |
| 91 | - */ | |
| 92 | -	public function setCurrentOffset($currentOffset) { | |
| 93 | - $this->currentOffset = $currentOffset; | |
| 94 | - } | |
| 95 | - | |
| 96 | - /** | |
| 97 | - * Number of items per page. | |
| 98 | - * | |
| 99 | - * @param int $perPage | |
| 100 | - */ | |
| 101 | -	public function setPerPage($perPage) { | |
| 102 | - $this->perPage = $perPage; | |
| 103 | - } | |
| 104 | - | |
| 105 | - /** | |
| 106 | - * returns the total number of items | |
| 107 | - * @return int | |
| 108 | - */ | |
| 109 | -	public function getTotalItemCount() { | |
| 110 | - return $this->totalItemCount; | |
| 111 | - } | |
| 112 | - | |
| 113 | - /** | |
| 114 | - * Method to set the total number of items in the pagination | |
| 115 | - * | |
| 116 | - * @param int $totalItemCount | |
| 117 | - */ | |
| 118 | -	public function setTotalItemCount($totalItemCount) { | |
| 119 | - $this->totalItemCount = $totalItemCount; | |
| 120 | - } | |
| 121 | - | |
| 122 | - /** | |
| 123 | - * Returns the total number of pages needed to display all content which | |
| 124 | - * is paginatable | |
| 125 | - * | |
| 126 | - * @return int | |
| 127 | - */ | |
| 128 | -	public function getTotalPagesCount() { | |
| 129 | - return ceil($this->getTotalItemCount() / $this->getPerPage()); | |
| 130 | - } | |
| 131 | - | |
| 132 | - /** | |
| 133 | - * This method is used to caluclate the label for a pageoffset, | |
| 134 | - * in normal cases its the internal offset + 1 | |
| 135 | - * | |
| 136 | - * @param int $pageoffset | |
| 137 | - * @return int | |
| 138 | - */ | |
| 139 | -	protected function getLabelForPageOffset($pageoffset) { | |
| 140 | - return $pageoffset + 1; | |
| 141 | - } | |
| 27 | + /** | |
| 28 | + * @var string template path | |
| 29 | + */ | |
| 30 | + protected $template = 'EXT:crawler/template/pagination.php'; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * @var int $perpage number of items perPage | |
| 34 | + */ | |
| 35 | + protected $perPage; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * @var int $currentOffset current offset | |
| 39 | + */ | |
| 40 | + protected $currentOffset; | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * @var int $totalItemCount number of total item | |
| 44 | + */ | |
| 45 | + protected $totalItemCount; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * @var string $baseUrl | |
| 49 | + */ | |
| 50 | + protected $baseUrl; | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * Method to render the view. | |
| 57 | + * | |
| 58 | + * @return string html content | |
| 59 | + */ | |
| 60 | +    public function render() { | |
| 61 | + ob_start(); | |
| 62 | + $this->template = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->template); | |
| 63 | + include($this->template); | |
| 64 | + $content = ob_get_contents(); | |
| 65 | + ob_end_clean(); | |
| 66 | + | |
| 67 | + return $content; | |
| 68 | + } | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * Returns the currently configured offset- | |
| 72 | + * @return int | |
| 73 | + */ | |
| 74 | +    public function getCurrentOffset() { | |
| 75 | + return $this->currentOffset; | |
| 76 | + } | |
| 77 | + | |
| 78 | + /** | |
| 79 | + * Method to read the number of items per page | |
| 80 | + * | |
| 81 | + * @return int | |
| 82 | + */ | |
| 83 | +    public function getPerPage() { | |
| 84 | + return $this->perPage; | |
| 85 | + } | |
| 86 | + | |
| 87 | + /** | |
| 88 | + * Method to set the current offset from start | |
| 89 | + * | |
| 90 | + * @param int $currentOffset | |
| 91 | + */ | |
| 92 | +    public function setCurrentOffset($currentOffset) { | |
| 93 | + $this->currentOffset = $currentOffset; | |
| 94 | + } | |
| 95 | + | |
| 96 | + /** | |
| 97 | + * Number of items per page. | |
| 98 | + * | |
| 99 | + * @param int $perPage | |
| 100 | + */ | |
| 101 | +    public function setPerPage($perPage) { | |
| 102 | + $this->perPage = $perPage; | |
| 103 | + } | |
| 104 | + | |
| 105 | + /** | |
| 106 | + * returns the total number of items | |
| 107 | + * @return int | |
| 108 | + */ | |
| 109 | +    public function getTotalItemCount() { | |
| 110 | + return $this->totalItemCount; | |
| 111 | + } | |
| 112 | + | |
| 113 | + /** | |
| 114 | + * Method to set the total number of items in the pagination | |
| 115 | + * | |
| 116 | + * @param int $totalItemCount | |
| 117 | + */ | |
| 118 | +    public function setTotalItemCount($totalItemCount) { | |
| 119 | + $this->totalItemCount = $totalItemCount; | |
| 120 | + } | |
| 121 | + | |
| 122 | + /** | |
| 123 | + * Returns the total number of pages needed to display all content which | |
| 124 | + * is paginatable | |
| 125 | + * | |
| 126 | + * @return int | |
| 127 | + */ | |
| 128 | +    public function getTotalPagesCount() { | |
| 129 | + return ceil($this->getTotalItemCount() / $this->getPerPage()); | |
| 130 | + } | |
| 131 | + | |
| 132 | + /** | |
| 133 | + * This method is used to caluclate the label for a pageoffset, | |
| 134 | + * in normal cases its the internal offset + 1 | |
| 135 | + * | |
| 136 | + * @param int $pageoffset | |
| 137 | + * @return int | |
| 138 | + */ | |
| 139 | +    protected function getLabelForPageOffset($pageoffset) { | |
| 140 | + return $pageoffset + 1; | |
| 141 | + } | |
| 142 | 142 | |
| 143 | 143 | } | 
| 144 | 144 | |
| @@ -111,6 +111,7 @@ discard block | ||
| 111 | 111 | * Set the page id | 
| 112 | 112 | * | 
| 113 | 113 | * @param int page id | 
| 114 | + * @param integer $pageId | |
| 114 | 115 | */ | 
| 115 | 116 |  	public function setPageId($pageId) { | 
| 116 | 117 | $this->pageId = $pageId; | 
| @@ -269,7 +270,7 @@ discard block | ||
| 269 | 270 | * Converts seconds into minutes | 
| 270 | 271 | * | 
| 271 | 272 | * @param int $seconds | 
| 272 | - * @return int | |
| 273 | + * @return double | |
| 273 | 274 | */ | 
| 274 | 275 |  	protected function asMinutes($seconds) { | 
| 275 | 276 | return round($seconds / 60); | 
| @@ -409,7 +410,7 @@ discard block | ||
| 409 | 410 | * just a wrapper should be done in a cleaner way | 
| 410 | 411 | * later on | 
| 411 | 412 | * | 
| 412 | - * @param $label | |
| 413 | + * @param string $label | |
| 413 | 414 | * @return string | 
| 414 | 415 | */ | 
| 415 | 416 |  	protected function getLLLabel($label) { | 
| @@ -24,397 +24,397 @@ | ||
| 24 | 24 | |
| 25 | 25 |  class tx_crawler_view_process_list { | 
| 26 | 26 | |
| 27 | - /** | |
| 28 | - * @var string template path | |
| 29 | - */ | |
| 30 | - protected $template = 'EXT:crawler/template/process/list.php'; | |
| 31 | - | |
| 32 | - /** | |
| 33 | - * @var string icon path | |
| 34 | - */ | |
| 35 | - protected $iconPath; | |
| 36 | - | |
| 37 | - /** | |
| 38 | - * @var string Holds the path to start a cli process via command line | |
| 39 | - */ | |
| 40 | - protected $cliPath; | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * @var int Holds the total number of items pending in the queue to be processed | |
| 44 | - */ | |
| 45 | - protected $totalItemCount; | |
| 46 | - | |
| 47 | - /** | |
| 48 | - * @var boolean Holds the enable state of the crawler | |
| 49 | - */ | |
| 50 | - protected $isCrawlerEnabled; | |
| 51 | - | |
| 52 | - /** | |
| 53 | - * @var int Holds the number of active processes | |
| 54 | - */ | |
| 55 | - protected $activeProcessCount; | |
| 56 | - | |
| 57 | - /** | |
| 58 | - * @var int Holds the number of maximum active processes | |
| 59 | - */ | |
| 60 | - protected $maxActiveProcessCount; | |
| 61 | - | |
| 62 | - /** | |
| 63 | - * @var string Holds the mode state, can be simple or detail | |
| 64 | - */ | |
| 65 | - protected $mode; | |
| 66 | - | |
| 67 | - /** | |
| 68 | - * @var int Holds the current page id | |
| 69 | - */ | |
| 70 | - protected $pageId; | |
| 71 | - | |
| 72 | - /** | |
| 73 | - * @var int $totalItemCount number of total item | |
| 74 | - */ | |
| 75 | - protected $totalUnprocessedItemCount; | |
| 76 | - | |
| 77 | - /** | |
| 78 | - * @var int Holds the number of assigned unprocessed items | |
| 79 | - */ | |
| 80 | - protected $assignedUnprocessedItemCount; | |
| 81 | - | |
| 82 | - /** | |
| 83 | - * @return int | |
| 84 | - */ | |
| 85 | -	public function getAssignedUnprocessedItemCount() { | |
| 86 | - return $this->assignedUnprocessedItemCount; | |
| 87 | - } | |
| 88 | - | |
| 89 | - /** | |
| 90 | - * @return int | |
| 91 | - */ | |
| 92 | -	public function getTotalUnprocessedItemCount() { | |
| 93 | - return $this->totalUnprocessedItemCount; | |
| 94 | - } | |
| 95 | - | |
| 96 | - /** | |
| 97 | - * @param int $assignedUnprocessedItemCount | |
| 98 | - */ | |
| 99 | -	public function setAssignedUnprocessedItemCount($assignedUnprocessedItemCount) { | |
| 100 | - $this->assignedUnprocessedItemCount = $assignedUnprocessedItemCount; | |
| 101 | - } | |
| 102 | - | |
| 103 | - /** | |
| 104 | - * @param int $totalUnprocessedItemCount | |
| 105 | - */ | |
| 106 | -	public function setTotalUnprocessedItemCount($totalUnprocessedItemCount) { | |
| 107 | - $this->totalUnprocessedItemCount = $totalUnprocessedItemCount; | |
| 108 | - } | |
| 109 | - | |
| 110 | - /** | |
| 111 | - * Set the page id | |
| 112 | - * | |
| 113 | - * @param int page id | |
| 114 | - */ | |
| 115 | -	public function setPageId($pageId) { | |
| 116 | - $this->pageId = $pageId; | |
| 117 | - } | |
| 118 | - | |
| 119 | - /** | |
| 120 | - * Get the page id | |
| 121 | - * | |
| 122 | - * @return int page id | |
| 123 | - */ | |
| 124 | -	public function getPageId() { | |
| 125 | - return $this->pageId; | |
| 126 | - } | |
| 127 | - | |
| 128 | - /** | |
| 129 | - * @return string | |
| 130 | - */ | |
| 131 | -	public function getMode() { | |
| 132 | - return $this->mode; | |
| 133 | - } | |
| 134 | - | |
| 135 | - /** | |
| 136 | - * @param string $mode | |
| 137 | - */ | |
| 138 | -	public function setMode($mode) { | |
| 139 | - $this->mode = $mode; | |
| 140 | - } | |
| 141 | - | |
| 142 | - | |
| 143 | - /** | |
| 144 | - * @return int | |
| 145 | - */ | |
| 146 | -	public function getMaxActiveProcessCount() { | |
| 147 | - return $this->maxActiveProcessCount; | |
| 148 | - } | |
| 149 | - | |
| 150 | - /** | |
| 151 | - * @param int $maxActiveProcessCount | |
| 152 | - */ | |
| 153 | -	public function setMaxActiveProcessCount($maxActiveProcessCount) { | |
| 154 | - $this->maxActiveProcessCount = $maxActiveProcessCount; | |
| 155 | - } | |
| 156 | - | |
| 157 | - | |
| 158 | - /** | |
| 159 | - * @return int | |
| 160 | - */ | |
| 161 | -	public function getActiveProcessCount() { | |
| 162 | - return $this->activeProcessCount; | |
| 163 | - } | |
| 164 | - | |
| 165 | - /** | |
| 166 | - * @param int $activeProcessCount | |
| 167 | - */ | |
| 168 | -	public function setActiveProcessCount($activeProcessCount) { | |
| 169 | - $this->activeProcessCount = $activeProcessCount; | |
| 170 | - } | |
| 171 | - | |
| 172 | - /** | |
| 173 | - * @return boolean | |
| 174 | - */ | |
| 175 | -	public function getIsCrawlerEnabled() { | |
| 176 | - return $this->isCrawlerEnabled; | |
| 177 | - } | |
| 178 | - | |
| 179 | - /** | |
| 180 | - * @param boolean $isCrawlerEnabled | |
| 181 | - */ | |
| 182 | -	public function setIsCrawlerEnabled($isCrawlerEnabled) { | |
| 183 | - $this->isCrawlerEnabled = $isCrawlerEnabled; | |
| 184 | - } | |
| 185 | - | |
| 186 | - | |
| 187 | - /** | |
| 188 | - * Returns the path to start a cli process from the shell | |
| 189 | - * @return string | |
| 190 | - */ | |
| 191 | -	public function getCliPath() { | |
| 192 | - return $this->cliPath; | |
| 193 | - } | |
| 194 | - | |
| 195 | - /** | |
| 196 | - * @param string $cliPath | |
| 197 | - */ | |
| 198 | -	public function setCliPath($cliPath) { | |
| 199 | - $this->cliPath = $cliPath; | |
| 200 | - } | |
| 201 | - | |
| 202 | - | |
| 203 | - /** | |
| 204 | - * @return int | |
| 205 | - */ | |
| 206 | -	public function getTotalItemCount() { | |
| 207 | - return $this->totalItemCount; | |
| 208 | - } | |
| 209 | - | |
| 210 | - /** | |
| 211 | - * @param int $totalItemCount | |
| 212 | - */ | |
| 213 | -	public function setTotalItemCount($totalItemCount) { | |
| 214 | - $this->totalItemCount = $totalItemCount; | |
| 215 | - } | |
| 216 | - | |
| 217 | - /** | |
| 218 | - * Method to set the path to the icon from outside | |
| 219 | - * | |
| 220 | - * @param string $iconPath | |
| 221 | - */ | |
| 222 | -	public function setIconPath($iconPath) { | |
| 223 | - $this->iconPath = $iconPath; | |
| 224 | - } | |
| 225 | - | |
| 226 | - /** | |
| 227 | - * Method to read the configured icon path | |
| 228 | - * | |
| 229 | - * @return string | |
| 230 | - */ | |
| 231 | -	protected function getIconPath() { | |
| 232 | - return $this->iconPath; | |
| 233 | - } | |
| 234 | - | |
| 235 | - /** | |
| 236 | - * Method to set a collection of process objects to be displayed in | |
| 237 | - * the list view. | |
| 238 | - * | |
| 239 | - * @param tx_crawler_domain_process_collection $processCollection | |
| 240 | - */ | |
| 241 | -	public function setProcessCollection($processCollection) { | |
| 242 | - $this->processCollection = $processCollection; | |
| 243 | - } | |
| 244 | - | |
| 245 | - /** | |
| 246 | - * Returns a collection of processObjects. | |
| 247 | - * | |
| 248 | - * @return tx_crawler_domain_process_collection | |
| 249 | - */ | |
| 250 | -	protected function getProcessCollection() { | |
| 251 | - return $this->processCollection; | |
| 252 | - } | |
| 253 | - | |
| 254 | - /** | |
| 255 | - * Formats a timestamp as date | |
| 256 | - * | |
| 257 | - * @param int $timestamp | |
| 258 | - * @return string | |
| 259 | - */ | |
| 260 | -	protected function asDate($timestamp) { | |
| 261 | -		if ($timestamp > 0) { | |
| 262 | -			return date($this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:time.detailed'), $timestamp); | |
| 263 | -		} else { | |
| 264 | - return ''; | |
| 265 | - } | |
| 266 | - } | |
| 267 | - | |
| 268 | - /** | |
| 269 | - * Converts seconds into minutes | |
| 270 | - * | |
| 271 | - * @param int $seconds | |
| 272 | - * @return int | |
| 273 | - */ | |
| 274 | -	protected function asMinutes($seconds) { | |
| 275 | - return round($seconds / 60); | |
| 276 | - } | |
| 277 | - | |
| 278 | - /** | |
| 279 | - * Returns the state icon for the current job | |
| 280 | - * | |
| 281 | - * @param string $state | |
| 282 | - * @return string icon | |
| 283 | - */ | |
| 284 | -	protected function getIconForState($state) { | |
| 285 | -		switch($state) { | |
| 286 | - case 'running': | |
| 287 | - $icon = 'bullet_orange'; | |
| 288 | -				$title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.running'); | |
| 289 | - break; | |
| 290 | - case 'completed': | |
| 291 | - $icon = 'bullet_green'; | |
| 292 | -				$title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.success'); | |
| 293 | - break; | |
| 294 | - case 'cancelled': | |
| 295 | - $icon = 'bullet_red'; | |
| 296 | -				$title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.cancelled'); | |
| 297 | - break; | |
| 298 | - } | |
| 299 | - | |
| 300 | - return $this->getIcon($icon, $title); | |
| 301 | - } | |
| 302 | - | |
| 303 | - /** | |
| 304 | - * Returns a tag for the refresh icon | |
| 305 | - * | |
| 306 | - * @return string | |
| 307 | - */ | |
| 308 | -	protected function getRefreshIcon() { | |
| 309 | -		return $this->getIcon('arrow_refresh'); | |
| 310 | - } | |
| 311 | - | |
| 312 | - /** | |
| 313 | - * Returns a tag for the refresh icon | |
| 314 | - * | |
| 315 | - * @return string | |
| 316 | - */ | |
| 317 | -	protected function getRefreshLink() { | |
| 318 | -		return '<input onclick="window.location=\'' . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_info') . '&SET[crawlaction]=multiprocess' . '\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_refresh.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.refresh') . '" />'; | |
| 319 | - } | |
| 320 | - | |
| 321 | - /** | |
| 322 | - * Returns an icon to stop all processes | |
| 323 | - * | |
| 324 | - * @return string html tag for stop icon | |
| 325 | - */ | |
| 326 | -	protected function getStopIcon() { | |
| 327 | -		return $this->getIcon('stop'); | |
| 328 | - } | |
| 329 | - | |
| 330 | - /** | |
| 331 | - * Returns a link for the panel to enable or disable the crawler | |
| 332 | - * | |
| 333 | - * @return string | |
| 334 | - */ | |
| 335 | -	protected function getEnableDisableLink() { | |
| 336 | -		if ($this->getIsCrawlerEnabled()) { | |
| 337 | -			return '<input onclick="window.location+=\'&action=stopCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'control_stop_blue.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.disablecrawling') . '" />'; | |
| 338 | -		} else { | |
| 339 | -			return '<input onclick="window.location+=\'&action=resumeCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'control_play.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.enablecrawling') . '" />'; | |
| 340 | - } | |
| 341 | - } | |
| 342 | - | |
| 343 | - /** | |
| 344 | - * Get mode link | |
| 345 | - * | |
| 346 | - * @param void | |
| 347 | - * @return string a-tag | |
| 348 | - */ | |
| 349 | -	protected function getModeLink() { | |
| 350 | -		if ($this->getMode() == 'detail') { | |
| 351 | -			return '<input onclick="window.location+=\'&SET[processListMode]=simple\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_in.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.running') . '" />'; | |
| 352 | -		} elseif ($this->getMode() == 'simple') { | |
| 353 | -			return '<input onclick="window.location+=\'&SET[processListMode]=detail\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_out.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.all') . '" />'; | |
| 354 | - } | |
| 355 | - } | |
| 356 | - | |
| 357 | - /** | |
| 358 | - * Get add link | |
| 359 | - * | |
| 360 | - * @param void | |
| 361 | - * @return string a-tag | |
| 362 | - */ | |
| 363 | -	protected function getAddLink() { | |
| 364 | -		if ($this->getActiveProcessCount() < $this->getMaxActiveProcessCount() && $this->getIsCrawlerEnabled()) { | |
| 365 | -			return '<input onclick="window.location+=\'&action=addProcess\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'add.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.add') . '" />'; | |
| 366 | -		} else { | |
| 367 | - return ''; | |
| 368 | - } | |
| 369 | - } | |
| 370 | - | |
| 371 | - /** | |
| 372 | - * Returns the icon to add new crawler processes | |
| 373 | - * | |
| 374 | - * @return string html tag for image to add new processes | |
| 375 | - */ | |
| 376 | -	protected function getAddIcon() { | |
| 377 | -		return $this->getIcon('add'); | |
| 378 | - } | |
| 379 | - | |
| 380 | - /** | |
| 381 | - * Returns an imagetag for an icon | |
| 382 | - * | |
| 383 | - * @param string $icon | |
| 384 | - * @return string html tag for icon | |
| 385 | - */ | |
| 386 | -	protected function getIcon($icon, $title='') { | |
| 387 | -		if (!empty($title)) { | |
| 388 | - $title = ' title="'.$title.'"'; | |
| 389 | - } | |
| 390 | - return '<img src="'.$this->getIconPath().$icon.'.png" ' . $title . ' />'; | |
| 391 | - } | |
| 392 | - | |
| 393 | - /** | |
| 394 | - * Method to render the view. | |
| 395 | - * | |
| 396 | - * @return string html content | |
| 397 | - */ | |
| 398 | -	public function render() { | |
| 399 | - ob_start(); | |
| 400 | - $this->template = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->template); | |
| 401 | - include($this->template); | |
| 402 | - $content = ob_get_contents(); | |
| 403 | - ob_end_clean(); | |
| 404 | - return $content; | |
| 405 | - } | |
| 406 | - | |
| 407 | - /** | |
| 408 | - * retrieve locallanglabel from environment | |
| 409 | - * just a wrapper should be done in a cleaner way | |
| 410 | - * later on | |
| 411 | - * | |
| 412 | - * @param $label | |
| 413 | - * @return string | |
| 414 | - */ | |
| 415 | -	protected function getLLLabel($label) { | |
| 416 | - return $GLOBALS['LANG']->sL($label); | |
| 417 | - } | |
| 27 | + /** | |
| 28 | + * @var string template path | |
| 29 | + */ | |
| 30 | + protected $template = 'EXT:crawler/template/process/list.php'; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * @var string icon path | |
| 34 | + */ | |
| 35 | + protected $iconPath; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * @var string Holds the path to start a cli process via command line | |
| 39 | + */ | |
| 40 | + protected $cliPath; | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * @var int Holds the total number of items pending in the queue to be processed | |
| 44 | + */ | |
| 45 | + protected $totalItemCount; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * @var boolean Holds the enable state of the crawler | |
| 49 | + */ | |
| 50 | + protected $isCrawlerEnabled; | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * @var int Holds the number of active processes | |
| 54 | + */ | |
| 55 | + protected $activeProcessCount; | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * @var int Holds the number of maximum active processes | |
| 59 | + */ | |
| 60 | + protected $maxActiveProcessCount; | |
| 61 | + | |
| 62 | + /** | |
| 63 | + * @var string Holds the mode state, can be simple or detail | |
| 64 | + */ | |
| 65 | + protected $mode; | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * @var int Holds the current page id | |
| 69 | + */ | |
| 70 | + protected $pageId; | |
| 71 | + | |
| 72 | + /** | |
| 73 | + * @var int $totalItemCount number of total item | |
| 74 | + */ | |
| 75 | + protected $totalUnprocessedItemCount; | |
| 76 | + | |
| 77 | + /** | |
| 78 | + * @var int Holds the number of assigned unprocessed items | |
| 79 | + */ | |
| 80 | + protected $assignedUnprocessedItemCount; | |
| 81 | + | |
| 82 | + /** | |
| 83 | + * @return int | |
| 84 | + */ | |
| 85 | +    public function getAssignedUnprocessedItemCount() { | |
| 86 | + return $this->assignedUnprocessedItemCount; | |
| 87 | + } | |
| 88 | + | |
| 89 | + /** | |
| 90 | + * @return int | |
| 91 | + */ | |
| 92 | +    public function getTotalUnprocessedItemCount() { | |
| 93 | + return $this->totalUnprocessedItemCount; | |
| 94 | + } | |
| 95 | + | |
| 96 | + /** | |
| 97 | + * @param int $assignedUnprocessedItemCount | |
| 98 | + */ | |
| 99 | +    public function setAssignedUnprocessedItemCount($assignedUnprocessedItemCount) { | |
| 100 | + $this->assignedUnprocessedItemCount = $assignedUnprocessedItemCount; | |
| 101 | + } | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * @param int $totalUnprocessedItemCount | |
| 105 | + */ | |
| 106 | +    public function setTotalUnprocessedItemCount($totalUnprocessedItemCount) { | |
| 107 | + $this->totalUnprocessedItemCount = $totalUnprocessedItemCount; | |
| 108 | + } | |
| 109 | + | |
| 110 | + /** | |
| 111 | + * Set the page id | |
| 112 | + * | |
| 113 | + * @param int page id | |
| 114 | + */ | |
| 115 | +    public function setPageId($pageId) { | |
| 116 | + $this->pageId = $pageId; | |
| 117 | + } | |
| 118 | + | |
| 119 | + /** | |
| 120 | + * Get the page id | |
| 121 | + * | |
| 122 | + * @return int page id | |
| 123 | + */ | |
| 124 | +    public function getPageId() { | |
| 125 | + return $this->pageId; | |
| 126 | + } | |
| 127 | + | |
| 128 | + /** | |
| 129 | + * @return string | |
| 130 | + */ | |
| 131 | +    public function getMode() { | |
| 132 | + return $this->mode; | |
| 133 | + } | |
| 134 | + | |
| 135 | + /** | |
| 136 | + * @param string $mode | |
| 137 | + */ | |
| 138 | +    public function setMode($mode) { | |
| 139 | + $this->mode = $mode; | |
| 140 | + } | |
| 141 | + | |
| 142 | + | |
| 143 | + /** | |
| 144 | + * @return int | |
| 145 | + */ | |
| 146 | +    public function getMaxActiveProcessCount() { | |
| 147 | + return $this->maxActiveProcessCount; | |
| 148 | + } | |
| 149 | + | |
| 150 | + /** | |
| 151 | + * @param int $maxActiveProcessCount | |
| 152 | + */ | |
| 153 | +    public function setMaxActiveProcessCount($maxActiveProcessCount) { | |
| 154 | + $this->maxActiveProcessCount = $maxActiveProcessCount; | |
| 155 | + } | |
| 156 | + | |
| 157 | + | |
| 158 | + /** | |
| 159 | + * @return int | |
| 160 | + */ | |
| 161 | +    public function getActiveProcessCount() { | |
| 162 | + return $this->activeProcessCount; | |
| 163 | + } | |
| 164 | + | |
| 165 | + /** | |
| 166 | + * @param int $activeProcessCount | |
| 167 | + */ | |
| 168 | +    public function setActiveProcessCount($activeProcessCount) { | |
| 169 | + $this->activeProcessCount = $activeProcessCount; | |
| 170 | + } | |
| 171 | + | |
| 172 | + /** | |
| 173 | + * @return boolean | |
| 174 | + */ | |
| 175 | +    public function getIsCrawlerEnabled() { | |
| 176 | + return $this->isCrawlerEnabled; | |
| 177 | + } | |
| 178 | + | |
| 179 | + /** | |
| 180 | + * @param boolean $isCrawlerEnabled | |
| 181 | + */ | |
| 182 | +    public function setIsCrawlerEnabled($isCrawlerEnabled) { | |
| 183 | + $this->isCrawlerEnabled = $isCrawlerEnabled; | |
| 184 | + } | |
| 185 | + | |
| 186 | + | |
| 187 | + /** | |
| 188 | + * Returns the path to start a cli process from the shell | |
| 189 | + * @return string | |
| 190 | + */ | |
| 191 | +    public function getCliPath() { | |
| 192 | + return $this->cliPath; | |
| 193 | + } | |
| 194 | + | |
| 195 | + /** | |
| 196 | + * @param string $cliPath | |
| 197 | + */ | |
| 198 | +    public function setCliPath($cliPath) { | |
| 199 | + $this->cliPath = $cliPath; | |
| 200 | + } | |
| 201 | + | |
| 202 | + | |
| 203 | + /** | |
| 204 | + * @return int | |
| 205 | + */ | |
| 206 | +    public function getTotalItemCount() { | |
| 207 | + return $this->totalItemCount; | |
| 208 | + } | |
| 209 | + | |
| 210 | + /** | |
| 211 | + * @param int $totalItemCount | |
| 212 | + */ | |
| 213 | +    public function setTotalItemCount($totalItemCount) { | |
| 214 | + $this->totalItemCount = $totalItemCount; | |
| 215 | + } | |
| 216 | + | |
| 217 | + /** | |
| 218 | + * Method to set the path to the icon from outside | |
| 219 | + * | |
| 220 | + * @param string $iconPath | |
| 221 | + */ | |
| 222 | +    public function setIconPath($iconPath) { | |
| 223 | + $this->iconPath = $iconPath; | |
| 224 | + } | |
| 225 | + | |
| 226 | + /** | |
| 227 | + * Method to read the configured icon path | |
| 228 | + * | |
| 229 | + * @return string | |
| 230 | + */ | |
| 231 | +    protected function getIconPath() { | |
| 232 | + return $this->iconPath; | |
| 233 | + } | |
| 234 | + | |
| 235 | + /** | |
| 236 | + * Method to set a collection of process objects to be displayed in | |
| 237 | + * the list view. | |
| 238 | + * | |
| 239 | + * @param tx_crawler_domain_process_collection $processCollection | |
| 240 | + */ | |
| 241 | +    public function setProcessCollection($processCollection) { | |
| 242 | + $this->processCollection = $processCollection; | |
| 243 | + } | |
| 244 | + | |
| 245 | + /** | |
| 246 | + * Returns a collection of processObjects. | |
| 247 | + * | |
| 248 | + * @return tx_crawler_domain_process_collection | |
| 249 | + */ | |
| 250 | +    protected function getProcessCollection() { | |
| 251 | + return $this->processCollection; | |
| 252 | + } | |
| 253 | + | |
| 254 | + /** | |
| 255 | + * Formats a timestamp as date | |
| 256 | + * | |
| 257 | + * @param int $timestamp | |
| 258 | + * @return string | |
| 259 | + */ | |
| 260 | +    protected function asDate($timestamp) { | |
| 261 | +        if ($timestamp > 0) { | |
| 262 | +            return date($this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:time.detailed'), $timestamp); | |
| 263 | +        } else { | |
| 264 | + return ''; | |
| 265 | + } | |
| 266 | + } | |
| 267 | + | |
| 268 | + /** | |
| 269 | + * Converts seconds into minutes | |
| 270 | + * | |
| 271 | + * @param int $seconds | |
| 272 | + * @return int | |
| 273 | + */ | |
| 274 | +    protected function asMinutes($seconds) { | |
| 275 | + return round($seconds / 60); | |
| 276 | + } | |
| 277 | + | |
| 278 | + /** | |
| 279 | + * Returns the state icon for the current job | |
| 280 | + * | |
| 281 | + * @param string $state | |
| 282 | + * @return string icon | |
| 283 | + */ | |
| 284 | +    protected function getIconForState($state) { | |
| 285 | +        switch($state) { | |
| 286 | + case 'running': | |
| 287 | + $icon = 'bullet_orange'; | |
| 288 | +                $title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.running'); | |
| 289 | + break; | |
| 290 | + case 'completed': | |
| 291 | + $icon = 'bullet_green'; | |
| 292 | +                $title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.success'); | |
| 293 | + break; | |
| 294 | + case 'cancelled': | |
| 295 | + $icon = 'bullet_red'; | |
| 296 | +                $title = $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.cancelled'); | |
| 297 | + break; | |
| 298 | + } | |
| 299 | + | |
| 300 | + return $this->getIcon($icon, $title); | |
| 301 | + } | |
| 302 | + | |
| 303 | + /** | |
| 304 | + * Returns a tag for the refresh icon | |
| 305 | + * | |
| 306 | + * @return string | |
| 307 | + */ | |
| 308 | +    protected function getRefreshIcon() { | |
| 309 | +        return $this->getIcon('arrow_refresh'); | |
| 310 | + } | |
| 311 | + | |
| 312 | + /** | |
| 313 | + * Returns a tag for the refresh icon | |
| 314 | + * | |
| 315 | + * @return string | |
| 316 | + */ | |
| 317 | +    protected function getRefreshLink() { | |
| 318 | +        return '<input onclick="window.location=\'' . \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('web_info') . '&SET[crawlaction]=multiprocess' . '\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_refresh.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.refresh') . '" />'; | |
| 319 | + } | |
| 320 | + | |
| 321 | + /** | |
| 322 | + * Returns an icon to stop all processes | |
| 323 | + * | |
| 324 | + * @return string html tag for stop icon | |
| 325 | + */ | |
| 326 | +    protected function getStopIcon() { | |
| 327 | +        return $this->getIcon('stop'); | |
| 328 | + } | |
| 329 | + | |
| 330 | + /** | |
| 331 | + * Returns a link for the panel to enable or disable the crawler | |
| 332 | + * | |
| 333 | + * @return string | |
| 334 | + */ | |
| 335 | +    protected function getEnableDisableLink() { | |
| 336 | +        if ($this->getIsCrawlerEnabled()) { | |
| 337 | +            return '<input onclick="window.location+=\'&action=stopCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'control_stop_blue.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.disablecrawling') . '" />'; | |
| 338 | +        } else { | |
| 339 | +            return '<input onclick="window.location+=\'&action=resumeCrawling\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'control_play.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.enablecrawling') . '" />'; | |
| 340 | + } | |
| 341 | + } | |
| 342 | + | |
| 343 | + /** | |
| 344 | + * Get mode link | |
| 345 | + * | |
| 346 | + * @param void | |
| 347 | + * @return string a-tag | |
| 348 | + */ | |
| 349 | +    protected function getModeLink() { | |
| 350 | +        if ($this->getMode() == 'detail') { | |
| 351 | +            return '<input onclick="window.location+=\'&SET[processListMode]=simple\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_in.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.running') . '" />'; | |
| 352 | +        } elseif ($this->getMode() == 'simple') { | |
| 353 | +            return '<input onclick="window.location+=\'&SET[processListMode]=detail\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'arrow_out.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.show.all') . '" />'; | |
| 354 | + } | |
| 355 | + } | |
| 356 | + | |
| 357 | + /** | |
| 358 | + * Get add link | |
| 359 | + * | |
| 360 | + * @param void | |
| 361 | + * @return string a-tag | |
| 362 | + */ | |
| 363 | +    protected function getAddLink() { | |
| 364 | +        if ($this->getActiveProcessCount() < $this->getMaxActiveProcessCount() && $this->getIsCrawlerEnabled()) { | |
| 365 | +            return '<input onclick="window.location+=\'&action=addProcess\';" type="button" style="padding:4px 4px 4px 20px; background-position: 3px 3px; background-image: url(\'' . $this->getIconPath() . 'add.png' . '\'); background-repeat: no-repeat;" value="' . $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.process.add') . '" />'; | |
| 366 | +        } else { | |
| 367 | + return ''; | |
| 368 | + } | |
| 369 | + } | |
| 370 | + | |
| 371 | + /** | |
| 372 | + * Returns the icon to add new crawler processes | |
| 373 | + * | |
| 374 | + * @return string html tag for image to add new processes | |
| 375 | + */ | |
| 376 | +    protected function getAddIcon() { | |
| 377 | +        return $this->getIcon('add'); | |
| 378 | + } | |
| 379 | + | |
| 380 | + /** | |
| 381 | + * Returns an imagetag for an icon | |
| 382 | + * | |
| 383 | + * @param string $icon | |
| 384 | + * @return string html tag for icon | |
| 385 | + */ | |
| 386 | +    protected function getIcon($icon, $title='') { | |
| 387 | +        if (!empty($title)) { | |
| 388 | + $title = ' title="'.$title.'"'; | |
| 389 | + } | |
| 390 | + return '<img src="'.$this->getIconPath().$icon.'.png" ' . $title . ' />'; | |
| 391 | + } | |
| 392 | + | |
| 393 | + /** | |
| 394 | + * Method to render the view. | |
| 395 | + * | |
| 396 | + * @return string html content | |
| 397 | + */ | |
| 398 | +    public function render() { | |
| 399 | + ob_start(); | |
| 400 | + $this->template = \TYPO3\CMS\Core\Utility\GeneralUtility::getFileAbsFileName($this->template); | |
| 401 | + include($this->template); | |
| 402 | + $content = ob_get_contents(); | |
| 403 | + ob_end_clean(); | |
| 404 | + return $content; | |
| 405 | + } | |
| 406 | + | |
| 407 | + /** | |
| 408 | + * retrieve locallanglabel from environment | |
| 409 | + * just a wrapper should be done in a cleaner way | |
| 410 | + * later on | |
| 411 | + * | |
| 412 | + * @param $label | |
| 413 | + * @return string | |
| 414 | + */ | |
| 415 | +    protected function getLLLabel($label) { | |
| 416 | + return $GLOBALS['LANG']->sL($label); | |
| 417 | + } | |
| 418 | 418 | } | 
| 419 | 419 | |
| 420 | 420 | ?> | 
| @@ -53,7 +53,7 @@ | ||
| 53 | 53 | * @param string $uri | 
| 54 | 54 | * @param TypoScriptFrontendController $frontend | 
| 55 | 55 | * | 
| 56 | - * @return array | |
| 56 | + * @return string[] | |
| 57 | 57 | * | 
| 58 | 58 | * @throws \Exception | 
| 59 | 59 | * | 
| @@ -5,11 +5,11 @@ | ||
| 5 | 5 | <?php echo $this->getRefreshLink(); ?> | 
| 6 | 6 | <?php echo $this->getEnableDisableLink(); ?> | 
| 7 | 7 | <?php | 
| 8 | - // Check if ActiveProcess is reached | |
| 9 | -		if (\TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($this->getActiveProcessCount()) < \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($this->getMaxActiveProcessCount())) { | |
| 10 | - echo $this->getAddLink(); | |
| 11 | - } | |
| 12 | - ?> | |
| 8 | + // Check if ActiveProcess is reached | |
| 9 | +        if (\TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($this->getActiveProcessCount()) < \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($this->getMaxActiveProcessCount())) { | |
| 10 | + echo $this->getAddLink(); | |
| 11 | + } | |
| 12 | + ?> | |
| 13 | 13 | <?php echo $this->getModeLink(); ?> | 
| 14 | 14 | </div> | 
| 15 | 15 | |
| @@ -37,29 +37,29 @@ | ||
| 37 | 37 | */ | 
| 38 | 38 |  class tx_crawler_cli extends \TYPO3\CMS\Core\Controller\CommandLineController {
 | 
| 39 | 39 | |
| 40 | - /** | |
| 41 | - * Constructor | |
| 42 | - * | |
| 43 | - * @return void | |
| 44 | - */ | |
| 45 | -	function __construct() {
 | |
| 46 | - parent::__construct(); | |
| 40 | + /** | |
| 41 | + * Constructor | |
| 42 | + * | |
| 43 | + * @return void | |
| 44 | + */ | |
| 45 | +    function __construct() {
 | |
| 46 | + parent::__construct(); | |
| 47 | 47 | |
| 48 | -		$this->cli_options[] = array('-h', 'Show the help', '');
 | |
| 49 | -		$this->cli_options[] = array('--help', 'Same as -h', '');
 | |
| 50 | -		$this->cli_options[] = array('--countInARun count', 'Amount of pages', 'How many pages should be crawled during that run.');
 | |
| 51 | -		$this->cli_options[] = array('--sleepTime milliseconds', 'Millisecounds to relax system during crawls', 'Amount of millisecounds which the system should use to relax between crawls.');
 | |
| 52 | -		$this->cli_options[] = array('--sleepAfterFinish seconds', 'Secounds to relax system after all crawls.', 'Amount of secounds which the system should use to relax after all crawls are done.');
 | |
| 48 | +        $this->cli_options[] = array('-h', 'Show the help', '');
 | |
| 49 | +        $this->cli_options[] = array('--help', 'Same as -h', '');
 | |
| 50 | +        $this->cli_options[] = array('--countInARun count', 'Amount of pages', 'How many pages should be crawled during that run.');
 | |
| 51 | +        $this->cli_options[] = array('--sleepTime milliseconds', 'Millisecounds to relax system during crawls', 'Amount of millisecounds which the system should use to relax between crawls.');
 | |
| 52 | +        $this->cli_options[] = array('--sleepAfterFinish seconds', 'Secounds to relax system after all crawls.', 'Amount of secounds which the system should use to relax after all crawls are done.');
 | |
| 53 | 53 | |
| 54 | - // Setting help texts: | |
| 55 | - $this->cli_help['name'] = 'crawler CLI interface -- Crawling the URLs from the queue'; | |
| 56 | - $this->cli_help['synopsis'] = '###OPTIONS###'; | |
| 57 | - $this->cli_help['description'] = ""; | |
| 58 | - $this->cli_help['examples'] = "/.../cli_dispatch.phpsh crawler\nWill trigger the crawler which starts to process the queue entires\n"; | |
| 59 | - $this->cli_help['author'] = 'Kasper Skaarhoj, Daniel Poetzinger, Fabrizio Branca, Tolleiv Nietsch, Timo Schmidt - AOE media 2010'; | |
| 60 | - } | |
| 54 | + // Setting help texts: | |
| 55 | + $this->cli_help['name'] = 'crawler CLI interface -- Crawling the URLs from the queue'; | |
| 56 | + $this->cli_help['synopsis'] = '###OPTIONS###'; | |
| 57 | + $this->cli_help['description'] = ""; | |
| 58 | + $this->cli_help['examples'] = "/.../cli_dispatch.phpsh crawler\nWill trigger the crawler which starts to process the queue entires\n"; | |
| 59 | + $this->cli_help['author'] = 'Kasper Skaarhoj, Daniel Poetzinger, Fabrizio Branca, Tolleiv Nietsch, Timo Schmidt - AOE media 2010'; | |
| 60 | + } | |
| 61 | 61 | } | 
| 62 | 62 | |
| 63 | 63 |  if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/cli/class.tx_crawler_cli.php']) {
 | 
| 64 | - include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/cli/class.tx_crawler_cli.php']); | |
| 64 | + include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/cli/class.tx_crawler_cli.php']); | |
| 65 | 65 | } | 
| @@ -37,41 +37,41 @@ | ||
| 37 | 37 | */ | 
| 38 | 38 |  class tx_crawler_cli_im extends \TYPO3\CMS\Core\Controller\CommandLineController {
 | 
| 39 | 39 | |
| 40 | - /** | |
| 41 | - * Constructor | |
| 42 | - * | |
| 43 | - * @return void | |
| 44 | - */ | |
| 45 | -	function __construct() {
 | |
| 46 | - parent::__construct(); | |
| 40 | + /** | |
| 41 | + * Constructor | |
| 42 | + * | |
| 43 | + * @return void | |
| 44 | + */ | |
| 45 | +    function __construct() {
 | |
| 46 | + parent::__construct(); | |
| 47 | 47 | |
| 48 | - // Adding options to help archive: | |
| 49 | - /** | |
| 50 | - * We removed the "proc" option as it seemd not to be working any more. But as the complete handling of the crawler has changed regarding the configuration | |
| 51 | - * this is completely ok. Since configuration records were introduced to configure "what should be done" additionally to page ts the way to setup jobs | |
| 52 | - * has drifted from selecting filtering processing instructions to selecting/filtering configuration keys (you can configure the processing instructions there). | |
| 53 | - * This is also reflected in the backend modules and allows you a much clearer and powerful way to work with the crawler extension. | |
| 54 | - */ | |
| 55 | -		// $this->cli_options[] = array('-proc listOfProcInstr', 'Comma list of processing instructions. These are the "actions" carried out when crawling and you must specify at least one. Depends on third-party extensions. Examples are "tx_cachemgm_recache" from "cachemgm" extension (will recache pages), "tx_staticpub_publish" from "staticpub" (publishing pages to static files) or "tx_indexedsearch_reindex" from "indexed_search" (indexes pages).');
 | |
| 56 | - // TODO: cleanup here! | |
| 57 | -		$this->cli_options[] = array('-d depth', 'Tree depth, 0-99', "How many levels under the 'page_id' to include.");
 | |
| 58 | -		$this->cli_options[] = array('-o mode', 'Output mode: "url", "exec", "queue"', "Specifies output modes\nurl : Will list URLs which wget could use as input.\nqueue: Will put entries in queue table.\nexec: Will execute all entries right away!");
 | |
| 59 | -		$this->cli_options[] = array('-n number', 'Number of items per minute.', 'Specifies how many items are put in the queue per minute. Only valid for output mode "queue"');
 | |
| 60 | -		$this->cli_options[] = array('-conf configurationkeys','List of Configuration Keys','A commaseperated list of crawler configurations');
 | |
| 61 | -		#		$this->cli_options[] = array('-v level', 'Verbosity level 0-3', "The value of level can be:\n  0 = all output\n  1 = info and greater (default)\n  2 = warnings and greater\n  3 = errors");
 | |
| 48 | + // Adding options to help archive: | |
| 49 | + /** | |
| 50 | + * We removed the "proc" option as it seemd not to be working any more. But as the complete handling of the crawler has changed regarding the configuration | |
| 51 | + * this is completely ok. Since configuration records were introduced to configure "what should be done" additionally to page ts the way to setup jobs | |
| 52 | + * has drifted from selecting filtering processing instructions to selecting/filtering configuration keys (you can configure the processing instructions there). | |
| 53 | + * This is also reflected in the backend modules and allows you a much clearer and powerful way to work with the crawler extension. | |
| 54 | + */ | |
| 55 | +        // $this->cli_options[] = array('-proc listOfProcInstr', 'Comma list of processing instructions. These are the "actions" carried out when crawling and you must specify at least one. Depends on third-party extensions. Examples are "tx_cachemgm_recache" from "cachemgm" extension (will recache pages), "tx_staticpub_publish" from "staticpub" (publishing pages to static files) or "tx_indexedsearch_reindex" from "indexed_search" (indexes pages).');
 | |
| 56 | + // TODO: cleanup here! | |
| 57 | +        $this->cli_options[] = array('-d depth', 'Tree depth, 0-99', "How many levels under the 'page_id' to include.");
 | |
| 58 | +        $this->cli_options[] = array('-o mode', 'Output mode: "url", "exec", "queue"', "Specifies output modes\nurl : Will list URLs which wget could use as input.\nqueue: Will put entries in queue table.\nexec: Will execute all entries right away!");
 | |
| 59 | +        $this->cli_options[] = array('-n number', 'Number of items per minute.', 'Specifies how many items are put in the queue per minute. Only valid for output mode "queue"');
 | |
| 60 | +        $this->cli_options[] = array('-conf configurationkeys','List of Configuration Keys','A commaseperated list of crawler configurations');
 | |
| 61 | +        #		$this->cli_options[] = array('-v level', 'Verbosity level 0-3', "The value of level can be:\n  0 = all output\n  1 = info and greater (default)\n  2 = warnings and greater\n  3 = errors");
 | |
| 62 | 62 | |
| 63 | - // Setting help texts: | |
| 64 | - $this->cli_help['name'] = 'crawler CLI interface -- Submitting URLs to be crawled via CLI interface.'; | |
| 65 | - $this->cli_help['synopsis'] = 'page_id ###OPTIONS###'; | |
| 66 | - $this->cli_help['description'] = "Works as a CLI interface to some functionality from the Web > Info > Site Crawler module; It can put entries in the queue from command line options, return the list of URLs and even execute all entries right away without having to queue them up - this can be useful for immediate re-cache, re-indexing or static publishing from command line."; | |
| 67 | - $this->cli_help['examples'] = "/.../cli_dispatch.phpsh crawler_im 7 -d=2 -conf=<configurationKey> -o=exec\nWill re-cache pages from page 7 and two levels down, executed immediately.\n"; | |
| 68 | - $this->cli_help['examples'].= "/.../cli_dispatch.phpsh crawler_im 7 -d=0 -conf=<configurationKey> -n=4 -o=queue\nWill put entries for re-caching pages from page 7 into queue, 4 every minute.\n"; | |
| 69 | - $this->cli_help['author'] = 'Kasper Skaarhoj, Daniel Poetzinger, Fabrizio Branca, Tolleiv Nietsch, Timo Schmidt - AOE media 2009'; | |
| 70 | - } | |
| 63 | + // Setting help texts: | |
| 64 | + $this->cli_help['name'] = 'crawler CLI interface -- Submitting URLs to be crawled via CLI interface.'; | |
| 65 | + $this->cli_help['synopsis'] = 'page_id ###OPTIONS###'; | |
| 66 | + $this->cli_help['description'] = "Works as a CLI interface to some functionality from the Web > Info > Site Crawler module; It can put entries in the queue from command line options, return the list of URLs and even execute all entries right away without having to queue them up - this can be useful for immediate re-cache, re-indexing or static publishing from command line."; | |
| 67 | + $this->cli_help['examples'] = "/.../cli_dispatch.phpsh crawler_im 7 -d=2 -conf=<configurationKey> -o=exec\nWill re-cache pages from page 7 and two levels down, executed immediately.\n"; | |
| 68 | + $this->cli_help['examples'].= "/.../cli_dispatch.phpsh crawler_im 7 -d=0 -conf=<configurationKey> -n=4 -o=queue\nWill put entries for re-caching pages from page 7 into queue, 4 every minute.\n"; | |
| 69 | + $this->cli_help['author'] = 'Kasper Skaarhoj, Daniel Poetzinger, Fabrizio Branca, Tolleiv Nietsch, Timo Schmidt - AOE media 2009'; | |
| 70 | + } | |
| 71 | 71 | } | 
| 72 | 72 | |
| 73 | 73 |  if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/cli/class.tx_crawler_cli_im.php']) {
 | 
| 74 | - include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/cli/class.tx_crawler_cli_im.php']); | |
| 74 | + include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/cli/class.tx_crawler_cli_im.php']); | |
| 75 | 75 | } | 
| 76 | 76 | |
| 77 | 77 | ?> |