@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -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 |
@@ -52,32 +52,32 @@ discard block |
||
52 | 52 | */ |
53 | 53 | class tx_crawler_domain_events_dispatcher { |
54 | 54 | |
55 | - /** |
|
56 | - * @var array of tx_crawler_domain_events_observer objects; |
|
57 | - */ |
|
58 | - protected $observers; |
|
55 | + /** |
|
56 | + * @var array of tx_crawler_domain_events_observer objects; |
|
57 | + */ |
|
58 | + protected $observers; |
|
59 | 59 | |
60 | - /** |
|
61 | - * @var tx_crawler_domain_events_dispatcher |
|
62 | - */ |
|
63 | - protected static $instance; |
|
60 | + /** |
|
61 | + * @var tx_crawler_domain_events_dispatcher |
|
62 | + */ |
|
63 | + protected static $instance; |
|
64 | 64 | |
65 | - /** |
|
66 | - * The __constructor is private because the dispatcher is a singleton |
|
67 | - * |
|
68 | - * @param void |
|
69 | - * @return void |
|
70 | - */ |
|
65 | + /** |
|
66 | + * The __constructor is private because the dispatcher is a singleton |
|
67 | + * |
|
68 | + * @param void |
|
69 | + * @return void |
|
70 | + */ |
|
71 | 71 | protected function __construct() { |
72 | - $this->observers = array(); |
|
73 | - if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['crawler/domain/events/class.tx_crawler_domain_events_dispatcher.php']['registerObservers'])) { |
|
74 | - foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['crawler/domain/events/class.tx_crawler_domain_events_dispatcher.php']['registerObservers'] as $classRef) { |
|
75 | - $hookObj = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); |
|
76 | - if (method_exists($hookObj, 'registerObservers')) { |
|
77 | - $hookObj->registerObservers($this); |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
72 | + $this->observers = array(); |
|
73 | + if (is_array ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['crawler/domain/events/class.tx_crawler_domain_events_dispatcher.php']['registerObservers'])) { |
|
74 | + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['crawler/domain/events/class.tx_crawler_domain_events_dispatcher.php']['registerObservers'] as $classRef) { |
|
75 | + $hookObj = &\TYPO3\CMS\Core\Utility\GeneralUtility::getUserObj($classRef); |
|
76 | + if (method_exists($hookObj, 'registerObservers')) { |
|
77 | + $hookObj->registerObservers($this); |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -86,62 +86,62 @@ discard block |
||
86 | 86 | * @param void |
87 | 87 | * @return array array with registered events. |
88 | 88 | */ |
89 | - protected function getEvents() { |
|
90 | - return array_keys($this->observers); |
|
91 | - } |
|
89 | + protected function getEvents() { |
|
90 | + return array_keys($this->observers); |
|
91 | + } |
|
92 | 92 | |
93 | - /** |
|
94 | - * This method can be used to add an observer for an event to the dispatcher |
|
95 | - * |
|
96 | - * @param tx_crawler_domain_events_observer $observer_object |
|
97 | - * @param string $observer_method |
|
98 | - * @param string $event |
|
99 | - * @return void |
|
100 | - */ |
|
101 | - public function addObserver(tx_crawler_domain_events_observer $observer_object, $observer_method, $event) { |
|
102 | - $this->observers[$event][] = array('object' => $observer_object, 'method' => $observer_method); |
|
103 | - } |
|
93 | + /** |
|
94 | + * This method can be used to add an observer for an event to the dispatcher |
|
95 | + * |
|
96 | + * @param tx_crawler_domain_events_observer $observer_object |
|
97 | + * @param string $observer_method |
|
98 | + * @param string $event |
|
99 | + * @return void |
|
100 | + */ |
|
101 | + public function addObserver(tx_crawler_domain_events_observer $observer_object, $observer_method, $event) { |
|
102 | + $this->observers[$event][] = array('object' => $observer_object, 'method' => $observer_method); |
|
103 | + } |
|
104 | 104 | |
105 | - /** |
|
106 | - * Enables checking whether a certain event is observed by anyone |
|
107 | - * |
|
108 | - * @param string $event |
|
109 | - * @return boolean |
|
110 | - */ |
|
111 | - public function hasObserver($event) { |
|
112 | - return count($this->observers[$event]) > 0; |
|
113 | - } |
|
105 | + /** |
|
106 | + * Enables checking whether a certain event is observed by anyone |
|
107 | + * |
|
108 | + * @param string $event |
|
109 | + * @return boolean |
|
110 | + */ |
|
111 | + public function hasObserver($event) { |
|
112 | + return count($this->observers[$event]) > 0; |
|
113 | + } |
|
114 | 114 | |
115 | - /** |
|
116 | - * This method should be used to post a event to the dispatcher. Each |
|
117 | - * registered observer will be notified about the event. |
|
118 | - * |
|
119 | - * @param string $event |
|
120 | - * @param string $group |
|
121 | - * @param mixed $attachedData |
|
122 | - * @return void |
|
123 | - */ |
|
124 | - public function post($event, $group, $attachedData) { |
|
125 | - if(is_array($this->observers[$event])) { |
|
126 | - foreach($this->observers[$event] as $eventObserver) { |
|
127 | - call_user_func(array($eventObserver['object'],$eventObserver['method']),$event,$group,$attachedData); |
|
128 | - } |
|
129 | - } |
|
130 | - } |
|
115 | + /** |
|
116 | + * This method should be used to post a event to the dispatcher. Each |
|
117 | + * registered observer will be notified about the event. |
|
118 | + * |
|
119 | + * @param string $event |
|
120 | + * @param string $group |
|
121 | + * @param mixed $attachedData |
|
122 | + * @return void |
|
123 | + */ |
|
124 | + public function post($event, $group, $attachedData) { |
|
125 | + if(is_array($this->observers[$event])) { |
|
126 | + foreach($this->observers[$event] as $eventObserver) { |
|
127 | + call_user_func(array($eventObserver['object'],$eventObserver['method']),$event,$group,$attachedData); |
|
128 | + } |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - /** |
|
133 | - * Returns the instance of the dispatcher singleton |
|
134 | - * |
|
135 | - * @param void |
|
136 | - * @return tx_crawler_domain_events_dispatcher |
|
137 | - */ |
|
138 | - public static function getInstance() { |
|
132 | + /** |
|
133 | + * Returns the instance of the dispatcher singleton |
|
134 | + * |
|
135 | + * @param void |
|
136 | + * @return tx_crawler_domain_events_dispatcher |
|
137 | + */ |
|
138 | + public static function getInstance() { |
|
139 | 139 | |
140 | - if(!self::$instance instanceof tx_crawler_domain_events_dispatcher) { |
|
141 | - $dispatcher = new tx_crawler_domain_events_dispatcher(); |
|
142 | - self::$instance = $dispatcher; |
|
143 | - } |
|
140 | + if(!self::$instance instanceof tx_crawler_domain_events_dispatcher) { |
|
141 | + $dispatcher = new tx_crawler_domain_events_dispatcher(); |
|
142 | + self::$instance = $dispatcher; |
|
143 | + } |
|
144 | 144 | |
145 | - return self::$instance; |
|
146 | - } |
|
145 | + return self::$instance; |
|
146 | + } |
|
147 | 147 | } |
@@ -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 double |
|
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 double |
|
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 |
@@ -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 $pageId 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 double |
|
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 string $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 $pageId 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 double |
|
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 string $label |
|
413 | + * @return string |
|
414 | + */ |
|
415 | + protected function getLLLabel($label) { |
|
416 | + return $GLOBALS['LANG']->sL($label); |
|
417 | + } |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | ?> |