Completed
Push — issue/174-old ( 189131 )
by Tomas Norre
10:17 queued 01:09
created
domain/process/class.tx_crawler_domain_process.php 1 patch
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -24,145 +24,145 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
domain/process/class.tx_crawler_domain_process_collection.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -41,62 +41,62 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
domain/events/interface.tx_crawler_domain_events_observer.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@
 block discarded – undo
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
Please login to merge, or discard this patch.
domain/events/class.tx_crawler_domain_events_dispatcher.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -52,32 +52,32 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
view/class.tx_crawler_view_pagination.php 1 patch
Indentation   +115 added lines, -115 removed lines patch added patch discarded remove patch
@@ -24,121 +24,121 @@
 block discarded – undo
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
 
Please login to merge, or discard this patch.
domain/lib/class.tx_crawler_domain_lib_abstract_repository.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -24,36 +24,36 @@
 block discarded – undo
24 24
 
25 25
 abstract class tx_crawler_domain_lib_abstract_repository {
26 26
 
27
-	/**
28
-	 * @var string object class name
29
-	 */
30
-	protected $objectClassname;
27
+    /**
28
+     * @var string object class name
29
+     */
30
+    protected $objectClassname;
31 31
 
32
-	/**
33
-	 * @var string table name
34
-	 */
35
-	protected $tableName;
32
+    /**
33
+     * @var string table name
34
+     */
35
+    protected $tableName;
36 36
 
37
-	/**
38
-	 * Returns an instance of the TYPO3 database class.
39
-	 *
40
-	 * @return \TYPO3\CMS\Core\Database\DatabaseConnection
41
-	 */
42
-	protected function getDB() {
43
-		return $GLOBALS['TYPO3_DB'];
44
-	}
37
+    /**
38
+     * Returns an instance of the TYPO3 database class.
39
+     *
40
+     * @return \TYPO3\CMS\Core\Database\DatabaseConnection
41
+     */
42
+    protected function getDB() {
43
+        return $GLOBALS['TYPO3_DB'];
44
+    }
45 45
 
46
-	/**
47
-	 * Counts items by a given where clause
48
-	 *
49
-	 * @param  string $where    Where clause
50
-	 * @return integer
51
-	 */
52
-	protected function countByWhere($where) {
53
-		$db  = $this->getDB();
54
-		$rs  = $db->exec_SELECTquery('count(*) as anz', $this->tableName, $where);
55
-		$res = $db->sql_fetch_assoc($rs);
46
+    /**
47
+     * Counts items by a given where clause
48
+     *
49
+     * @param  string $where    Where clause
50
+     * @return integer
51
+     */
52
+    protected function countByWhere($where) {
53
+        $db  = $this->getDB();
54
+        $rs  = $db->exec_SELECTquery('count(*) as anz', $this->tableName, $where);
55
+        $res = $db->sql_fetch_assoc($rs);
56 56
 
57
-		return $res['anz'];
58
-	}
57
+        return $res['anz'];
58
+    }
59 59
 }
Please login to merge, or discard this patch.
domain/process/class.tx_crawler_domain_process_repository.php 1 patch
Indentation   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -24,97 +24,97 @@
 block discarded – undo
24 24
 
25 25
 class tx_crawler_domain_process_repository extends tx_crawler_domain_lib_abstract_repository {
26 26
 
27
-	/**
28
-	 * @var string object class name
29
-	 */
30
-	protected $objectClassname = 'tx_crawler_domain_process';
27
+    /**
28
+     * @var string object class name
29
+     */
30
+    protected $objectClassname = 'tx_crawler_domain_process';
31 31
 
32
-	/**
33
-	 * @var string
34
-	 */
35
-	protected $tableName = 'tx_crawler_process';
32
+    /**
33
+     * @var string
34
+     */
35
+    protected $tableName = 'tx_crawler_process';
36 36
 
37
-	/**
38
-	 * This method is used to find all cli processes within a limit.
39
-	 * 
40
-	 * @param  string  $orderField
41
-	 * @param  string  $orderDirection
42
-	 * @param  integer $itemCount
43
-	 * @param  integer $offset
44
-	 * @param  string  $where
45
-	 * @return tx_crawler_domain_process_collection
46
-	 */
47
-	public function findAll($orderField = '', $orderDirection = 'DESC', $itemCount = NULL, $offset = NULL, $where = '') {
48
-		/** @var tx_crawler_domain_process_collection $collection */
49
-		$collection = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_domain_process_collection');
37
+    /**
38
+     * This method is used to find all cli processes within a limit.
39
+     * 
40
+     * @param  string  $orderField
41
+     * @param  string  $orderDirection
42
+     * @param  integer $itemCount
43
+     * @param  integer $offset
44
+     * @param  string  $where
45
+     * @return tx_crawler_domain_process_collection
46
+     */
47
+    public function findAll($orderField = '', $orderDirection = 'DESC', $itemCount = NULL, $offset = NULL, $where = '') {
48
+        /** @var tx_crawler_domain_process_collection $collection */
49
+        $collection = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_crawler_domain_process_collection');
50 50
 
51
-		$orderField = trim($orderField);
52
-		$orderField = empty($orderField) ? 'process_id' : $orderField;
51
+        $orderField = trim($orderField);
52
+        $orderField = empty($orderField) ? 'process_id' : $orderField;
53 53
 
54
-		$orderDirection = strtoupper(trim($orderDirection));
55
-		$orderDirection = in_array($orderDirection, array('ASC', 'DESC')) ? $orderDirection : 'DESC';
54
+        $orderDirection = strtoupper(trim($orderDirection));
55
+        $orderDirection = in_array($orderDirection, array('ASC', 'DESC')) ? $orderDirection : 'DESC';
56 56
 
57
-		$rows = $this->getDB()->exec_SELECTgetRows(
58
-			'*',
59
-			$this->tableName,
60
-			$where,
61
-			'',
62
-			htmlspecialchars($orderField) . ' ' . htmlspecialchars($orderDirection),
63
-			self::getLimitFromItemCountAndOffset($itemCount, $offset)
64
-		);
57
+        $rows = $this->getDB()->exec_SELECTgetRows(
58
+            '*',
59
+            $this->tableName,
60
+            $where,
61
+            '',
62
+            htmlspecialchars($orderField) . ' ' . htmlspecialchars($orderDirection),
63
+            self::getLimitFromItemCountAndOffset($itemCount, $offset)
64
+        );
65 65
 
66
-		if (is_array($rows)) {
67
-			foreach($rows as $row) {
68
-				$collection->append(\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($this->objectClassname, $row));
69
-			}
70
-		}
66
+        if (is_array($rows)) {
67
+            foreach($rows as $row) {
68
+                $collection->append(\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance($this->objectClassname, $row));
69
+            }
70
+        }
71 71
 
72
-		return $collection;
73
-	}
72
+        return $collection;
73
+    }
74 74
 
75
-	/**
76
-	 * This method is used to count all processes in the process table.
77
-	 *
78
-	 * @param  string $where    Where clause
79
-	 * @return integer
80
-	 * @author Timo Schmidt <[email protected]>
81
-	 */
82
-	public function countAll($where = '1 = 1') {
83
-		return $this->countByWhere($where);
84
-	}
75
+    /**
76
+     * This method is used to count all processes in the process table.
77
+     *
78
+     * @param  string $where    Where clause
79
+     * @return integer
80
+     * @author Timo Schmidt <[email protected]>
81
+     */
82
+    public function countAll($where = '1 = 1') {
83
+        return $this->countByWhere($where);
84
+    }
85 85
 
86
-	/**
87
-	 * Returns the number of active processes.
88
-	 *
89
-	 * @return integer
90
-	 */
91
-	public function countActive() {
92
-		return $this->countByWhere('active = 1 AND deleted = 0');
93
-	}
86
+    /**
87
+     * Returns the number of active processes.
88
+     *
89
+     * @return integer
90
+     */
91
+    public function countActive() {
92
+        return $this->countByWhere('active = 1 AND deleted = 0');
93
+    }
94 94
 
95
-	/**
96
-	 * Returns the number of processes that live longer than the given timestamp.
97
-	 *
98
-	 * @param  integer $ttl
99
-	 * @return integer
100
-	 */
101
-	public function countNotTimeouted($ttl) {
102
-		return $this->countByWhere('deleted = 0 AND ttl > ' . intval($ttl));
103
-	}
95
+    /**
96
+     * Returns the number of processes that live longer than the given timestamp.
97
+     *
98
+     * @param  integer $ttl
99
+     * @return integer
100
+     */
101
+    public function countNotTimeouted($ttl) {
102
+        return $this->countByWhere('deleted = 0 AND ttl > ' . intval($ttl));
103
+    }
104 104
 
105
-	/**
106
-	 * Get limit clause
107
-	 *
108
-	 * @param  integer $itemCount   Item count
109
-	 * @param  integer $offset      Offset
110
-	 * @return string               Limit clause
111
-	 * @author Fabrizio Branca <[email protected]>
112
-	 */
113
-	public static function getLimitFromItemCountAndOffset($itemCount, $offset) {
114
-		$itemCount = filter_var($itemCount, FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'default' => 20)));
115
-		$offset = filter_var($offset, FILTER_VALIDATE_INT, array('options' => array('min_range' => 0, 'default' => 0)));
116
-		$limit = $offset . ', ' . $itemCount;
105
+    /**
106
+     * Get limit clause
107
+     *
108
+     * @param  integer $itemCount   Item count
109
+     * @param  integer $offset      Offset
110
+     * @return string               Limit clause
111
+     * @author Fabrizio Branca <[email protected]>
112
+     */
113
+    public static function getLimitFromItemCountAndOffset($itemCount, $offset) {
114
+        $itemCount = filter_var($itemCount, FILTER_VALIDATE_INT, array('options' => array('min_range' => 1, 'default' => 20)));
115
+        $offset = filter_var($offset, FILTER_VALIDATE_INT, array('options' => array('min_range' => 0, 'default' => 0)));
116
+        $limit = $offset . ', ' . $itemCount;
117 117
 
118
-		return $limit;
119
-	}
118
+        return $limit;
119
+    }
120 120
 }
Please login to merge, or discard this patch.
modfunc1/class.tx_crawler_modfunc1.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -203,23 +203,23 @@  discard block
 block discarded – undo
203 203
             $setId = intval(\TYPO3\CMS\Core\Utility\GeneralUtility::_GP('setID'));
204 204
 
205 205
             $h_func .= '<hr/>' .
206
-                       $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.display') . ': ' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id,
206
+                        $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.display') . ': ' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu($this->pObj->id,
207 207
                     'SET[log_display]', $this->pObj->MOD_SETTINGS['log_display'], $this->pObj->MOD_MENU['log_display'],
208 208
                     'index.php', '&setID=' . $setId) . ' - ' .
209
-                       $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showresultlog') . ': ' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,
209
+                        $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showresultlog') . ': ' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,
210 210
                     'SET[log_resultLog]', $this->pObj->MOD_SETTINGS['log_resultLog'], 'index.php',
211 211
                     '&setID=' . $setId . $quiPart) . ' - ' .
212
-                       $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showfevars') . ': ' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,
212
+                        $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.showfevars') . ': ' . \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncCheck($this->pObj->id,
213 213
                     'SET[log_feVars]', $this->pObj->MOD_SETTINGS['log_feVars'], 'index.php',
214 214
                     '&setID=' . $setId . $quiPart) . ' - ' .
215
-                       $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage') . ': ' .
216
-                       \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu(
217
-                           $this->pObj->id,
218
-                           'SET[itemsPerPage]',
219
-                           $this->pObj->MOD_SETTINGS['itemsPerPage'],
220
-                           $this->pObj->MOD_MENU['itemsPerPage'],
221
-                           'index.php'
222
-                       );
215
+                        $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.itemsPerPage') . ': ' .
216
+                        \TYPO3\CMS\Backend\Utility\BackendUtility::getFuncMenu(
217
+                            $this->pObj->id,
218
+                            'SET[itemsPerPage]',
219
+                            $this->pObj->MOD_SETTINGS['itemsPerPage'],
220
+                            $this->pObj->MOD_MENU['itemsPerPage'],
221
+                            'index.php'
222
+                        );
223 223
         }
224 224
 
225 225
         $theOutput = $this->pObj->doc->spacer(5);
@@ -353,9 +353,9 @@  discard block
 block discarded – undo
353 353
                         time()) . '<br />';
354 354
                 $output .= '<br />
355 355
 					<table class="lrPadding c-list url-table">' .
356
-                           $this->drawURLs_printTableHeader() .
357
-                           $code .
358
-                           '</table>';
356
+                            $this->drawURLs_printTableHeader() .
357
+                            $code .
358
+                            '</table>';
359 359
             } else {
360 360
                 $output .= count(array_keys($this->duplicateTrack)) . ' ' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.submitted') . '. <br /><br />';
361 361
                 $output .= '<input type="submit" name="_" value="' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.continue') . '" />';
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 				<input type="hidden" value="' . $showSetId . '" name="setID" />
547 547
 				<br />
548 548
 				Current server time: ' . date('H:i:s', time()) . '<br />' .
549
-                       'Status: ' . $resStatus . '<br />' .
550
-                       \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($q_entry);
549
+                        'Status: ' . $resStatus . '<br />' .
550
+                        \TYPO3\CMS\Core\Utility\DebugUtility::viewArray($q_entry);
551 551
         } else {    // Show list:
552 552
 
553 553
             // If either id or set id, show list:
@@ -609,9 +609,9 @@  discard block
 block discarded – undo
609 609
 
610 610
 
611 611
 						<table class="lrPadding c-list crawlerlog">' .
612
-                               $this->drawLog_printTableHeader() .
613
-                               $code .
614
-                               '</table>';
612
+                                $this->drawLog_printTableHeader() .
613
+                                $code .
614
+                                '</table>';
615 615
                 }
616 616
             } else {    // Otherwise show available sets:
617 617
                 $setList = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
                 $output .= '
647 647
 					<br /><br />
648 648
 					<table class="lrPadding c-list">' .
649
-                           $code .
650
-                           '</table>';
649
+                            $code .
650
+                            '</table>';
651 651
             }
652 652
         }
653 653
 
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
 				<td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.pagetitle') . ':</td>
867 867
 				<td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.qid') . ':</td>
868 868
 				<td>&nbsp;</td>' .
869
-                   ($this->pObj->MOD_SETTINGS['log_resultLog'] ? '
869
+                    ($this->pObj->MOD_SETTINGS['log_resultLog'] ? '
870 870
 				<td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.resultlog') . ':</td>' : '
871 871
 				<td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.scheduledtime') . ':</td>
872 872
 				<td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.runtime') . ':</td>') . '
@@ -875,7 +875,7 @@  discard block
 block discarded – undo
875 875
 				<td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.groups') . ':</td>
876 876
 				<td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.procinstr') . ':</td>
877 877
 				<td>' . $GLOBALS['LANG']->sL('LLL:EXT:crawler/modfunc1/locallang.xml:labels.setid') . ':</td>' .
878
-                   ($this->pObj->MOD_SETTINGS['log_feVars'] ? '
878
+                    ($this->pObj->MOD_SETTINGS['log_feVars'] ? '
879 879
 				<td>' . htmlspecialchars('TSFE->id') . '</td>
880 880
 				<td>' . htmlspecialchars('TSFE->gr_list') . '</td>
881 881
 				<td>' . htmlspecialchars('TSFE->no_cache') . '</td>' : '') . '
Please login to merge, or discard this patch.