@@ -37,30 +37,30 @@ |
||
37 | 37 | */ |
38 | 38 | class tx_crawler_cli_flush 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 | - $this->cli_options[] = array('-o mode', 'Output mode: "finished", "all", "pending"', "Specifies the type queue entries which is flushed in the process."); |
|
50 | - # $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 | + $this->cli_options[] = array('-o mode', 'Output mode: "finished", "all", "pending"', "Specifies the type queue entries which is flushed in the process."); |
|
50 | + # $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"); |
|
51 | 51 | |
52 | - // Setting help texts: |
|
53 | - $this->cli_help['name'] = 'crawler CLI interface -- Cleaning up the queue.'; |
|
54 | - $this->cli_help['synopsis'] = 'page_id ###OPTIONS###'; |
|
55 | - $this->cli_help['description'] = "Works as a CLI interface to some functionality from the Web > Info > Site Crawler module; It will remove queue entires and perform a cleanup."; |
|
56 | - $this->cli_help['examples'] = "/.../cli_dispatch.phpsh crawler_flush 5 -o=finished\nWill remove all finished queue-entries in the sub-branch of page 5\n"; |
|
57 | - $this->cli_help['examples'] = "/.../cli_dispatch.phpsh crawler_flush 0 -o=all\nWill remove all queue-entries for every page\n"; |
|
58 | - $this->cli_help['author'] = 'Kasper Skaarhoj, Daniel Poetzinger, Fabrizio Branca, Tolleiv Nietsch, Timo Schmidt - AOE media 2009'; |
|
59 | - } |
|
52 | + // Setting help texts: |
|
53 | + $this->cli_help['name'] = 'crawler CLI interface -- Cleaning up the queue.'; |
|
54 | + $this->cli_help['synopsis'] = 'page_id ###OPTIONS###'; |
|
55 | + $this->cli_help['description'] = "Works as a CLI interface to some functionality from the Web > Info > Site Crawler module; It will remove queue entires and perform a cleanup."; |
|
56 | + $this->cli_help['examples'] = "/.../cli_dispatch.phpsh crawler_flush 5 -o=finished\nWill remove all finished queue-entries in the sub-branch of page 5\n"; |
|
57 | + $this->cli_help['examples'] = "/.../cli_dispatch.phpsh crawler_flush 0 -o=all\nWill remove all queue-entries for every page\n"; |
|
58 | + $this->cli_help['author'] = 'Kasper Skaarhoj, Daniel Poetzinger, Fabrizio Branca, Tolleiv Nietsch, Timo Schmidt - AOE media 2009'; |
|
59 | + } |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/cli/class.tx_crawler_cli_flush.php']) { |
63 | - include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/cli/class.tx_crawler_cli_flush.php']); |
|
63 | + include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/cli/class.tx_crawler_cli_flush.php']); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | ?> |
@@ -24,43 +24,43 @@ |
||
24 | 24 | |
25 | 25 | abstract class tx_crawler_domain_lib_abstract_dbobject { |
26 | 26 | |
27 | - /** |
|
28 | - * @var array |
|
29 | - */ |
|
30 | - protected $row; |
|
27 | + /** |
|
28 | + * @var array |
|
29 | + */ |
|
30 | + protected $row; |
|
31 | 31 | |
32 | - /** |
|
33 | - * @var string table name |
|
34 | - */ |
|
35 | - protected static $tableName; |
|
32 | + /** |
|
33 | + * @var string table name |
|
34 | + */ |
|
35 | + protected static $tableName; |
|
36 | 36 | |
37 | - /** |
|
38 | - * Constructor |
|
39 | - * |
|
40 | - * @param array $row optional array with propertys |
|
41 | - */ |
|
42 | - public function __construct($row = array()) { |
|
43 | - $this->row = $row; |
|
44 | - } |
|
37 | + /** |
|
38 | + * Constructor |
|
39 | + * |
|
40 | + * @param array $row optional array with propertys |
|
41 | + */ |
|
42 | + public function __construct($row = array()) { |
|
43 | + $this->row = $row; |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Get table name |
|
48 | - * |
|
49 | - * @param void |
|
50 | - * @return string table name |
|
51 | - */ |
|
52 | - public static function getTableName(){ |
|
53 | - return self::$tableName; |
|
54 | - } |
|
46 | + /** |
|
47 | + * Get table name |
|
48 | + * |
|
49 | + * @param void |
|
50 | + * @return string table name |
|
51 | + */ |
|
52 | + public static function getTableName(){ |
|
53 | + return self::$tableName; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * Returns the propertys of the object as array |
|
58 | - * |
|
59 | - * @return array |
|
60 | - */ |
|
61 | - public function getRow() { |
|
62 | - return $this->row; |
|
63 | - } |
|
56 | + /** |
|
57 | + * Returns the propertys of the object as array |
|
58 | + * |
|
59 | + * @return array |
|
60 | + */ |
|
61 | + public function getRow() { |
|
62 | + return $this->row; |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | * @param void |
50 | 50 | * @return string table name |
51 | 51 | */ |
52 | - public static function getTableName(){ |
|
52 | + public static function getTableName() { |
|
53 | 53 | return self::$tableName; |
54 | 54 | } |
55 | 55 |
@@ -24,19 +24,19 @@ |
||
24 | 24 | |
25 | 25 | class tx_crawler_domain_queue_entry extends tx_crawler_domain_lib_abstract_dbobject { |
26 | 26 | |
27 | - /** |
|
28 | - * @var string table name |
|
29 | - */ |
|
30 | - protected static $tableName = 'tx_crawler_queue'; |
|
27 | + /** |
|
28 | + * @var string table name |
|
29 | + */ |
|
30 | + protected static $tableName = 'tx_crawler_queue'; |
|
31 | 31 | |
32 | - /** |
|
33 | - * Returns the execution time of the record as int value |
|
34 | - * |
|
35 | - * @return int |
|
36 | - */ |
|
37 | - public function getExecutionTime(){ |
|
38 | - return $this->row['exec_time']; |
|
39 | - } |
|
32 | + /** |
|
33 | + * Returns the execution time of the record as int value |
|
34 | + * |
|
35 | + * @return int |
|
36 | + */ |
|
37 | + public function getExecutionTime(){ |
|
38 | + return $this->row['exec_time']; |
|
39 | + } |
|
40 | 40 | |
41 | 41 | } |
42 | 42 |
@@ -34,7 +34,7 @@ |
||
34 | 34 | * |
35 | 35 | * @return int |
36 | 36 | */ |
37 | - public function getExecutionTime(){ |
|
37 | + public function getExecutionTime() { |
|
38 | 38 | return $this->row['exec_time']; |
39 | 39 | } |
40 | 40 |
@@ -69,7 +69,7 @@ |
||
69 | 69 | { |
70 | 70 | $db = $this->getDB(); |
71 | 71 | $where = 'process_id_completed=' . $db->fullQuoteStr($process->getProcess_id(), $this->tableName) . |
72 | - ' AND exec_time > 0 '; |
|
72 | + ' AND exec_time > 0 '; |
|
73 | 73 | $limit = 1; |
74 | 74 | $groupby = ''; |
75 | 75 |
@@ -68,7 +68,7 @@ discard block |
||
68 | 68 | protected function getFirstOrLastObjectByProcess($process, $orderby) |
69 | 69 | { |
70 | 70 | $db = $this->getDB(); |
71 | - $where = 'process_id_completed=' . $db->fullQuoteStr($process->getProcess_id(), $this->tableName) . |
|
71 | + $where = 'process_id_completed='.$db->fullQuoteStr($process->getProcess_id(), $this->tableName). |
|
72 | 72 | ' AND exec_time > 0 '; |
73 | 73 | $limit = 1; |
74 | 74 | $groupby = ''; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | */ |
94 | 94 | public function countExecutedItemsByProcess($process) |
95 | 95 | { |
96 | - return $this->countItemsByWhereClause('exec_time > 0 AND process_id_completed = ' . $this->getDB()->fullQuoteStr($process->getProcess_id(), |
|
96 | + return $this->countItemsByWhereClause('exec_time > 0 AND process_id_completed = '.$this->getDB()->fullQuoteStr($process->getProcess_id(), |
|
97 | 97 | $this->tableName)); |
98 | 98 | } |
99 | 99 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | */ |
107 | 107 | public function countNonExecutedItemsByProcess($process) |
108 | 108 | { |
109 | - return $this->countItemsByWhereClause('exec_time = 0 AND process_id = ' . $this->getDB()->fullQuoteStr($process->getProcess_id(), |
|
109 | + return $this->countItemsByWhereClause('exec_time = 0 AND process_id = '.$this->getDB()->fullQuoteStr($process->getProcess_id(), |
|
110 | 110 | $this->tableName)); |
111 | 111 | } |
112 | 112 | |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function countAllPendingItems() |
122 | 122 | { |
123 | - return $this->countItemsByWhereClause('exec_time = 0 AND scheduled < ' . time()); |
|
123 | + return $this->countItemsByWhereClause('exec_time = 0 AND scheduled < '.time()); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | public function countAllAssignedPendingItems() |
135 | 135 | { |
136 | - return $this->countItemsByWhereClause("exec_time = 0 AND scheduled < " . time() . " AND process_id != ''"); |
|
136 | + return $this->countItemsByWhereClause("exec_time = 0 AND scheduled < ".time()." AND process_id != ''"); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -146,7 +146,7 @@ discard block |
||
146 | 146 | */ |
147 | 147 | public function countAllUnassignedPendingItems() |
148 | 148 | { |
149 | - return $this->countItemsByWhereClause("exec_time = 0 AND scheduled < " . time() . " AND process_id = ''"); |
|
149 | + return $this->countItemsByWhereClause("exec_time = 0 AND scheduled < ".time()." AND process_id = ''"); |
|
150 | 150 | } |
151 | 151 | |
152 | 152 | /** |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | $res = $db->exec_SELECTquery( |
177 | 177 | "configuration, count(*) as unprocessed, sum(process_id != '') as assignedButUnprocessed", |
178 | 178 | $this->tableName, |
179 | - 'exec_time = 0 AND scheduled < ' . time(), |
|
179 | + 'exec_time = 0 AND scheduled < '.time(), |
|
180 | 180 | 'configuration' |
181 | 181 | ); |
182 | 182 | $rows = array(); |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $res = $db->exec_SELECTquery( |
201 | 201 | 'set_id', |
202 | 202 | $this->tableName, |
203 | - 'exec_time = 0 AND scheduled < ' . time(), |
|
203 | + 'exec_time = 0 AND scheduled < '.time(), |
|
204 | 204 | 'set_id' |
205 | 205 | ); |
206 | 206 | $setIds = array(); |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $res = $db->exec_SELECTquery( |
227 | 227 | 'configuration, count(*) as c', |
228 | 228 | $this->tableName, |
229 | - 'set_id in (' . implode(',', $setIds) . ') AND scheduled < ' . time(), |
|
229 | + 'set_id in ('.implode(',', $setIds).') AND scheduled < '.time(), |
|
230 | 230 | 'configuration' |
231 | 231 | ); |
232 | 232 | while ($row = $db->sql_fetch_assoc($res)) { |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | $res = $db->exec_SELECTquery( |
307 | 307 | 'process_id_completed, min(exec_time) as start, max(exec_time) as end, count(*) as urlcount', |
308 | 308 | $this->tableName, |
309 | - 'exec_time != 0 and exec_time >= ' . intval($start) . ' and exec_time <= ' . intval($end), |
|
309 | + 'exec_time != 0 and exec_time >= '.intval($start).' and exec_time <= '.intval($end), |
|
310 | 310 | 'process_id_completed' |
311 | 311 | ); |
312 | 312 |
@@ -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_uid |
|
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_uid |
|
107 | + */ |
|
108 | + public function setQueueEntryUid($entry_uid) { |
|
109 | + $this->row['queue_entry_uid'] = $entry_uid; |
|
110 | + } |
|
111 | 111 | |
112 | 112 | } |
113 | 113 |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $this->tableName, |
67 | 67 | $where, |
68 | 68 | '', |
69 | - htmlspecialchars($orderField) . ' ' . htmlspecialchars($orderDirection), |
|
69 | + htmlspecialchars($orderField).' '.htmlspecialchars($orderDirection), |
|
70 | 70 | self::getLimitFromItemCountAndOffset($itemCount, $offset) |
71 | 71 | ); |
72 | 72 | |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | */ |
112 | 112 | public function countNotTimeouted($ttl) |
113 | 113 | { |
114 | - return $this->countByWhere('deleted = 0 AND ttl > ' . intval($ttl)); |
|
114 | + return $this->countByWhere('deleted = 0 AND ttl > '.intval($ttl)); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | { |
128 | 128 | $itemCount = filter_var($itemCount, FILTER_VALIDATE_INT, ['options' => ['min_range' => 1, 'default' => 20]]); |
129 | 129 | $offset = filter_var($offset, FILTER_VALIDATE_INT, ['options' => ['min_range' => 0, 'default' => 0]]); |
130 | - $limit = $offset . ', ' . $itemCount; |
|
130 | + $limit = $offset.', '.$itemCount; |
|
131 | 131 | |
132 | 132 | return $limit; |
133 | 133 | } |
@@ -24,145 +24,145 @@ |
||
24 | 24 | |
25 | 25 | class tx_crawler_domain_process extends tx_crawler_domain_lib_abstract_dbobject { |
26 | 26 | |
27 | - CONST STATE_RUNNING = 'running'; |
|
28 | - CONST STATE_CANCELLED = 'cancelled'; |
|
29 | - CONST STATE_COMPLETED = 'completed'; |
|
30 | - |
|
31 | - /** |
|
32 | - * @var string table name |
|
33 | - */ |
|
34 | - protected static $tableName = 'tx_crawler_process'; |
|
35 | - |
|
36 | - /** |
|
37 | - * Returns the activity state for this process |
|
38 | - * |
|
39 | - * @param void |
|
40 | - * @return boolean |
|
41 | - */ |
|
42 | - public function getActive() { |
|
43 | - return $this->row['active']; |
|
44 | - } |
|
45 | - |
|
46 | - /** |
|
47 | - * Returns the identifier for the process |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function getProcess_id() { |
|
52 | - return $this->row['process_id']; |
|
53 | - } |
|
54 | - |
|
55 | - /** |
|
56 | - * Returns the timestamp of the exectime for the first relevant queue item. |
|
57 | - * This can be used to determine the runtime |
|
58 | - * |
|
59 | - * @return int |
|
60 | - */ |
|
61 | - public function getTimeForFirstItem() { |
|
62 | - $queueRepository = new tx_crawler_domain_queue_repository(); |
|
63 | - $entry = $queueRepository->findYoungestEntryForProcess($this); |
|
64 | - |
|
65 | - return $entry->getExecutionTime(); |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * Returns the timestamp of the exectime for the last relevant queue item. |
|
70 | - * This can be used to determine the runtime |
|
71 | - * |
|
72 | - * @return int |
|
73 | - */ |
|
74 | - public function getTimeForLastItem() { |
|
75 | - $queueRepository = new tx_crawler_domain_queue_repository(); |
|
76 | - $entry = $queueRepository->findOldestEntryForProcess($this); |
|
77 | - |
|
78 | - return $entry->getExecutionTime(); |
|
79 | - } |
|
80 | - |
|
81 | - /** |
|
82 | - * Returns the difference between first and last processed item |
|
83 | - * |
|
84 | - * @return int |
|
85 | - */ |
|
86 | - public function getRuntime() { |
|
87 | - return $this->getTimeForLastItem() - $this->getTimeForFirstItem(); |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Returns the ttl of the process |
|
92 | - * |
|
93 | - * @return int |
|
94 | - */ |
|
95 | - public function getTTL() { |
|
96 | - return $this->row['ttl']; |
|
97 | - } |
|
98 | - |
|
99 | - /** |
|
100 | - * Counts the number of items which need to be processed |
|
101 | - * |
|
102 | - * @author Timo Schmidt <[email protected]> |
|
103 | - * @param void |
|
104 | - * @return int |
|
105 | - */ |
|
106 | - public function countItemsProcessed() { |
|
107 | - $queueRepository = new tx_crawler_domain_queue_repository(); |
|
108 | - return $queueRepository->countExecutedItemsByProcess($this); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * Counts the number of items which still need to be processed |
|
113 | - * |
|
114 | - * @author Timo Schmidt <[email protected]> |
|
115 | - * @param void |
|
116 | - * @return int |
|
117 | - */ |
|
118 | - public function countItemsToProcess() { |
|
119 | - $queueRepository = new tx_crawler_domain_queue_repository(); |
|
120 | - return $queueRepository->countNonExecutedItemsByProcess($this); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Returns the Progress of a crawling process as a percentage value |
|
125 | - * |
|
126 | - * @param void |
|
127 | - * @return float |
|
128 | - */ |
|
129 | - public function getProgress() { |
|
130 | - $all = $this->countItemsAssigned(); |
|
131 | - if ($all<=0) { |
|
132 | - return 0; |
|
133 | - } |
|
134 | - |
|
135 | - $res = round((100 / $all) * $this->countItemsProcessed()); |
|
136 | - |
|
137 | - if ($res > 100.0) { |
|
138 | - return 100.0; |
|
139 | - } |
|
140 | - return $res; |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Returns the number of assigned Entrys |
|
145 | - * |
|
146 | - * @return int |
|
147 | - */ |
|
148 | - public function countItemsAssigned() { |
|
149 | - return $this->row['assigned_items_count']; |
|
150 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * Return the processes current state |
|
154 | - * |
|
155 | - * @param void |
|
156 | - * @return string 'running'|'cancelled'|'completed' |
|
157 | - */ |
|
158 | - public function getState() { |
|
159 | - if ($this->getActive() && $this->getProgress() < 100) { |
|
160 | - $stage = tx_crawler_domain_process::STATE_RUNNING; |
|
161 | - } elseif (!$this->getActive() && $this->getProgress() < 100) { |
|
162 | - $stage = tx_crawler_domain_process::STATE_CANCELLED; |
|
163 | - } else { |
|
164 | - $stage = tx_crawler_domain_process::STATE_COMPLETED; |
|
165 | - } |
|
166 | - return $stage; |
|
167 | - } |
|
27 | + CONST STATE_RUNNING = 'running'; |
|
28 | + CONST STATE_CANCELLED = 'cancelled'; |
|
29 | + CONST STATE_COMPLETED = 'completed'; |
|
30 | + |
|
31 | + /** |
|
32 | + * @var string table name |
|
33 | + */ |
|
34 | + protected static $tableName = 'tx_crawler_process'; |
|
35 | + |
|
36 | + /** |
|
37 | + * Returns the activity state for this process |
|
38 | + * |
|
39 | + * @param void |
|
40 | + * @return boolean |
|
41 | + */ |
|
42 | + public function getActive() { |
|
43 | + return $this->row['active']; |
|
44 | + } |
|
45 | + |
|
46 | + /** |
|
47 | + * Returns the identifier for the process |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function getProcess_id() { |
|
52 | + return $this->row['process_id']; |
|
53 | + } |
|
54 | + |
|
55 | + /** |
|
56 | + * Returns the timestamp of the exectime for the first relevant queue item. |
|
57 | + * This can be used to determine the runtime |
|
58 | + * |
|
59 | + * @return int |
|
60 | + */ |
|
61 | + public function getTimeForFirstItem() { |
|
62 | + $queueRepository = new tx_crawler_domain_queue_repository(); |
|
63 | + $entry = $queueRepository->findYoungestEntryForProcess($this); |
|
64 | + |
|
65 | + return $entry->getExecutionTime(); |
|
66 | + } |
|
67 | + |
|
68 | + /** |
|
69 | + * Returns the timestamp of the exectime for the last relevant queue item. |
|
70 | + * This can be used to determine the runtime |
|
71 | + * |
|
72 | + * @return int |
|
73 | + */ |
|
74 | + public function getTimeForLastItem() { |
|
75 | + $queueRepository = new tx_crawler_domain_queue_repository(); |
|
76 | + $entry = $queueRepository->findOldestEntryForProcess($this); |
|
77 | + |
|
78 | + return $entry->getExecutionTime(); |
|
79 | + } |
|
80 | + |
|
81 | + /** |
|
82 | + * Returns the difference between first and last processed item |
|
83 | + * |
|
84 | + * @return int |
|
85 | + */ |
|
86 | + public function getRuntime() { |
|
87 | + return $this->getTimeForLastItem() - $this->getTimeForFirstItem(); |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Returns the ttl of the process |
|
92 | + * |
|
93 | + * @return int |
|
94 | + */ |
|
95 | + public function getTTL() { |
|
96 | + return $this->row['ttl']; |
|
97 | + } |
|
98 | + |
|
99 | + /** |
|
100 | + * Counts the number of items which need to be processed |
|
101 | + * |
|
102 | + * @author Timo Schmidt <[email protected]> |
|
103 | + * @param void |
|
104 | + * @return int |
|
105 | + */ |
|
106 | + public function countItemsProcessed() { |
|
107 | + $queueRepository = new tx_crawler_domain_queue_repository(); |
|
108 | + return $queueRepository->countExecutedItemsByProcess($this); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * Counts the number of items which still need to be processed |
|
113 | + * |
|
114 | + * @author Timo Schmidt <[email protected]> |
|
115 | + * @param void |
|
116 | + * @return int |
|
117 | + */ |
|
118 | + public function countItemsToProcess() { |
|
119 | + $queueRepository = new tx_crawler_domain_queue_repository(); |
|
120 | + return $queueRepository->countNonExecutedItemsByProcess($this); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Returns the Progress of a crawling process as a percentage value |
|
125 | + * |
|
126 | + * @param void |
|
127 | + * @return float |
|
128 | + */ |
|
129 | + public function getProgress() { |
|
130 | + $all = $this->countItemsAssigned(); |
|
131 | + if ($all<=0) { |
|
132 | + return 0; |
|
133 | + } |
|
134 | + |
|
135 | + $res = round((100 / $all) * $this->countItemsProcessed()); |
|
136 | + |
|
137 | + if ($res > 100.0) { |
|
138 | + return 100.0; |
|
139 | + } |
|
140 | + return $res; |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Returns the number of assigned Entrys |
|
145 | + * |
|
146 | + * @return int |
|
147 | + */ |
|
148 | + public function countItemsAssigned() { |
|
149 | + return $this->row['assigned_items_count']; |
|
150 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * Return the processes current state |
|
154 | + * |
|
155 | + * @param void |
|
156 | + * @return string 'running'|'cancelled'|'completed' |
|
157 | + */ |
|
158 | + public function getState() { |
|
159 | + if ($this->getActive() && $this->getProgress() < 100) { |
|
160 | + $stage = tx_crawler_domain_process::STATE_RUNNING; |
|
161 | + } elseif (!$this->getActive() && $this->getProgress() < 100) { |
|
162 | + $stage = tx_crawler_domain_process::STATE_CANCELLED; |
|
163 | + } else { |
|
164 | + $stage = tx_crawler_domain_process::STATE_COMPLETED; |
|
165 | + } |
|
166 | + return $stage; |
|
167 | + } |
|
168 | 168 | } |
169 | 169 | \ No newline at end of file |
@@ -128,7 +128,7 @@ |
||
128 | 128 | */ |
129 | 129 | public function getProgress() { |
130 | 130 | $all = $this->countItemsAssigned(); |
131 | - if ($all<=0) { |
|
131 | + if ($all <= 0) { |
|
132 | 132 | return 0; |
133 | 133 | } |
134 | 134 |
@@ -41,62 +41,62 @@ |
||
41 | 41 | */ |
42 | 42 | class tx_crawler_domain_process_collection extends ArrayObject { |
43 | 43 | |
44 | - /** |
|
45 | - * Method to retrieve an element from the collection. |
|
46 | - * @access public |
|
47 | - * @throws Exception |
|
48 | - * @return tx_crawler_domain_process |
|
49 | - */ |
|
50 | - public function offsetGet($index) { |
|
51 | - if (! parent::offsetExists($index)) { |
|
52 | - throw new Exception('Index "' . var_export($index, true) . '" for tx_crawler_domain_process are not available'); |
|
53 | - } |
|
54 | - return parent::offsetGet($index); |
|
55 | - } |
|
44 | + /** |
|
45 | + * Method to retrieve an element from the collection. |
|
46 | + * @access public |
|
47 | + * @throws Exception |
|
48 | + * @return tx_crawler_domain_process |
|
49 | + */ |
|
50 | + public function offsetGet($index) { |
|
51 | + if (! parent::offsetExists($index)) { |
|
52 | + throw new Exception('Index "' . var_export($index, true) . '" for tx_crawler_domain_process are not available'); |
|
53 | + } |
|
54 | + return parent::offsetGet($index); |
|
55 | + } |
|
56 | 56 | |
57 | - /** |
|
58 | - * Method to add an element to the collection- |
|
59 | - * |
|
60 | - * @param mixed $index |
|
61 | - * @param tx_crawler_domain_process $subject |
|
62 | - * @throws InvalidArgumentException |
|
63 | - * @return void |
|
64 | - */ |
|
65 | - public function offsetSet($index, $subject) { |
|
66 | - if (! $subject instanceof tx_crawler_domain_process ) { |
|
67 | - throw new InvalidArgumentException('Wrong parameter type given, "tx_crawler_domain_process" expected!'); |
|
68 | - } |
|
69 | - parent::offsetSet($index, $subject); |
|
70 | - } |
|
57 | + /** |
|
58 | + * Method to add an element to the collection- |
|
59 | + * |
|
60 | + * @param mixed $index |
|
61 | + * @param tx_crawler_domain_process $subject |
|
62 | + * @throws InvalidArgumentException |
|
63 | + * @return void |
|
64 | + */ |
|
65 | + public function offsetSet($index, $subject) { |
|
66 | + if (! $subject instanceof tx_crawler_domain_process ) { |
|
67 | + throw new InvalidArgumentException('Wrong parameter type given, "tx_crawler_domain_process" expected!'); |
|
68 | + } |
|
69 | + parent::offsetSet($index, $subject); |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Method to append an element to the collection |
|
74 | - * @param tx_crawler_domain_process $subject |
|
75 | - * @throws InvalidArgumentException |
|
76 | - * @return void |
|
77 | - */ |
|
78 | - public function append($subject) { |
|
79 | - if (! $subject instanceof tx_crawler_domain_process ) { |
|
80 | - throw new InvalidArgumentException('Wrong parameter type given, "tx_crawler_domain_process" expected!'); |
|
81 | - } |
|
82 | - parent::append($subject); |
|
83 | - } |
|
72 | + /** |
|
73 | + * Method to append an element to the collection |
|
74 | + * @param tx_crawler_domain_process $subject |
|
75 | + * @throws InvalidArgumentException |
|
76 | + * @return void |
|
77 | + */ |
|
78 | + public function append($subject) { |
|
79 | + if (! $subject instanceof tx_crawler_domain_process ) { |
|
80 | + throw new InvalidArgumentException('Wrong parameter type given, "tx_crawler_domain_process" expected!'); |
|
81 | + } |
|
82 | + parent::append($subject); |
|
83 | + } |
|
84 | 84 | |
85 | - /** |
|
86 | - * returns array of process ids of the current collection |
|
87 | - * @return array |
|
88 | - */ |
|
89 | - public function getProcessIds() { |
|
90 | - $result=array(); |
|
91 | - foreach ($this->getIterator() as $value) { |
|
92 | - $result[]=$value->getProcess_id(); |
|
93 | - } |
|
94 | - return $result; |
|
95 | - } |
|
85 | + /** |
|
86 | + * returns array of process ids of the current collection |
|
87 | + * @return array |
|
88 | + */ |
|
89 | + public function getProcessIds() { |
|
90 | + $result=array(); |
|
91 | + foreach ($this->getIterator() as $value) { |
|
92 | + $result[]=$value->getProcess_id(); |
|
93 | + } |
|
94 | + return $result; |
|
95 | + } |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | |
99 | 99 | if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/domain/process/class.tx_crawler_domain_process_collection.php']) { |
100 | - include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/domain/process/class.tx_crawler_domain_process_collection.php']); |
|
100 | + include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/crawler/domain/process/class.tx_crawler_domain_process_collection.php']); |
|
101 | 101 | } |
102 | 102 | ?> |
103 | 103 | \ No newline at end of file |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | * @return tx_crawler_domain_process |
49 | 49 | */ |
50 | 50 | public function offsetGet($index) { |
51 | - if (! parent::offsetExists($index)) { |
|
52 | - throw new Exception('Index "' . var_export($index, true) . '" for tx_crawler_domain_process are not available'); |
|
51 | + if (!parent::offsetExists($index)) { |
|
52 | + throw new Exception('Index "'.var_export($index, true).'" for tx_crawler_domain_process are not available'); |
|
53 | 53 | } |
54 | 54 | return parent::offsetGet($index); |
55 | 55 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * @return void |
64 | 64 | */ |
65 | 65 | public function offsetSet($index, $subject) { |
66 | - if (! $subject instanceof tx_crawler_domain_process ) { |
|
66 | + if (!$subject instanceof tx_crawler_domain_process) { |
|
67 | 67 | throw new InvalidArgumentException('Wrong parameter type given, "tx_crawler_domain_process" expected!'); |
68 | 68 | } |
69 | 69 | parent::offsetSet($index, $subject); |
@@ -76,7 +76,7 @@ discard block |
||
76 | 76 | * @return void |
77 | 77 | */ |
78 | 78 | public function append($subject) { |
79 | - if (! $subject instanceof tx_crawler_domain_process ) { |
|
79 | + if (!$subject instanceof tx_crawler_domain_process) { |
|
80 | 80 | throw new InvalidArgumentException('Wrong parameter type given, "tx_crawler_domain_process" expected!'); |
81 | 81 | } |
82 | 82 | parent::append($subject); |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @return array |
88 | 88 | */ |
89 | 89 | public function getProcessIds() { |
90 | - $result=array(); |
|
90 | + $result = array(); |
|
91 | 91 | foreach ($this->getIterator() as $value) { |
92 | - $result[]=$value->getProcess_id(); |
|
92 | + $result[] = $value->getProcess_id(); |
|
93 | 93 | } |
94 | 94 | return $result; |
95 | 95 | } |
@@ -24,14 +24,14 @@ |
||
24 | 24 | |
25 | 25 | interface tx_crawler_domain_events_observer { |
26 | 26 | |
27 | - /** |
|
28 | - * This method should be implemented by the observer to register events |
|
29 | - * that should be forwarded to the observer |
|
30 | - * |
|
31 | - * @param tx_crawler_domain_events_dispatcher $dispatcher |
|
32 | - * @return boolean |
|
33 | - */ |
|
34 | - public function registerObservers(tx_crawler_domain_events_dispatcher $dispatcher); |
|
27 | + /** |
|
28 | + * This method should be implemented by the observer to register events |
|
29 | + * that should be forwarded to the observer |
|
30 | + * |
|
31 | + * @param tx_crawler_domain_events_dispatcher $dispatcher |
|
32 | + * @return boolean |
|
33 | + */ |
|
34 | + public function registerObservers(tx_crawler_domain_events_dispatcher $dispatcher); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | ?> |
38 | 38 | \ No newline at end of file |