Passed
Pull Request — master (#78)
by
unknown
03:12
created
library/Trapdirector/Tables/TrapTable.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
 	// view limits
28 28
 	protected $limit;
29
-    protected $offset;
29
+	protected $offset;
30 30
 
31 31
 	// Used for rendering days in list
32 32
 	protected $columnCount;
@@ -34,55 +34,55 @@  discard block
 block discarded – undo
34 34
 	
35 35
 	// Filters 
36 36
 	
37
-    protected $filter;
38
-    protected $enforcedFilters = array();
39
-    protected $searchColumns = array();
37
+	protected $filter;
38
+	protected $enforcedFilters = array();
39
+	protected $searchColumns = array();
40 40
 	
41 41
 	
42 42
 	// Must return titles in array ( id => display_name )
43 43
 	abstract protected function getTitles();
44 44
 	// ****************** Day header
45
-    protected function renderDayIfNew($timestamp)
46
-    {
47
-        $view = $this->getView();
45
+	protected function renderDayIfNew($timestamp)
46
+	{
47
+		$view = $this->getView();
48 48
 
49 49
 		// Check for date local format
50
-        if (in_array(setlocale(LC_ALL, 0), array('en_US.UTF-8', 'C'))) {
51
-            $day = date('l, jS F Y', (int) $timestamp);
52
-        } else {
53
-            $day = strftime('%A, %e. %B, %Y', (int) $timestamp);
54
-        }
55
-
56
-        if ($this->lastDay === $day) {
57
-            return;
58
-        }
59
-
60
-        if ($this->lastDay === null) {
61
-            $htm = "<thead>\n  <tr>\n";
62
-        } else {
63
-            $htm = "</tbody>\n<thead>\n  <tr>\n";
64
-        }
65
-
66
-        if ($this->columnCount === null) {
67
-            $this->columnCount = count($this->getTitles());
68
-        }
69
-
70
-        $htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($day) . '</th>' . "\n";
71
-        if ($this->lastDay === null) {
72
-            $htm .= "  </tr>\n";
73
-        } else {
74
-            $htm .= "  </tr>\n</thead>\n";
75
-        }
76
-
77
-        $this->lastDay = $day;
78
-
79
-        return $htm . "<tbody>\n";
80
-    }		
50
+		if (in_array(setlocale(LC_ALL, 0), array('en_US.UTF-8', 'C'))) {
51
+			$day = date('l, jS F Y', (int) $timestamp);
52
+		} else {
53
+			$day = strftime('%A, %e. %B, %Y', (int) $timestamp);
54
+		}
55
+
56
+		if ($this->lastDay === $day) {
57
+			return;
58
+		}
59
+
60
+		if ($this->lastDay === null) {
61
+			$htm = "<thead>\n  <tr>\n";
62
+		} else {
63
+			$htm = "</tbody>\n<thead>\n  <tr>\n";
64
+		}
65
+
66
+		if ($this->columnCount === null) {
67
+			$this->columnCount = count($this->getTitles());
68
+		}
69
+
70
+		$htm .= '<th colspan="' . $this->columnCount . '">' . $view->escape($day) . '</th>' . "\n";
71
+		if ($this->lastDay === null) {
72
+			$htm .= "  </tr>\n";
73
+		} else {
74
+			$htm .= "  </tr>\n</thead>\n";
75
+		}
76
+
77
+		$this->lastDay = $day;
78
+
79
+		return $htm . "<tbody>\n";
80
+	}		
81 81
 	// ******************  Render table in html  
82
-    public function __toString()
83
-    {
84
-        return $this->render();
85
-    }
82
+	public function __toString()
83
+	{
84
+		return $this->render();
85
+	}
86 86
 	
87 87
 	abstract public function render();
88 88
 	
@@ -92,76 +92,76 @@  discard block
 block discarded – undo
92 92
 		$this->moduleConfig = $conf;
93 93
 	}
94 94
 	// ******************  View get/set
95
-    protected function getView()
96
-    {
97
-        if ($this->view === null) {
98
-            $this->view = Icinga::app()->getViewRenderer()->view;
99
-        }
100
-        return $this->view;
101
-    }
95
+	protected function getView()
96
+	{
97
+		if ($this->view === null) {
98
+			$this->view = Icinga::app()->getViewRenderer()->view;
99
+		}
100
+		return $this->view;
101
+	}
102 102
 
103
-    public function setView($view)
104
-    {
105
-        $this->view = $view;
106
-    }	
103
+	public function setView($view)
104
+	{
105
+		$this->view = $view;
106
+	}	
107 107
 	
108 108
 	// Limits
109 109
 	
110
-    public function limit($count = null, $offset = null)
111
-    {
112
-        $this->limit = $count;
113
-        $this->offset = $offset;
114
-
115
-        return $this;
116
-    }
117
-
118
-    public function hasLimit()
119
-    {
120
-        return $this->limit !== null;
121
-    }
122
-
123
-    public function getLimit()
124
-    {
125
-        return $this->limit;
126
-    }
127
-
128
-    public function hasOffset()
129
-    {
130
-        return $this->offset !== null;
131
-    }
132
-
133
-    public function getOffset()
134
-    {
135
-        return $this->offset;
136
-    }
110
+	public function limit($count = null, $offset = null)
111
+	{
112
+		$this->limit = $count;
113
+		$this->offset = $offset;
114
+
115
+		return $this;
116
+	}
117
+
118
+	public function hasLimit()
119
+	{
120
+		return $this->limit !== null;
121
+	}
122
+
123
+	public function getLimit()
124
+	{
125
+		return $this->limit;
126
+	}
127
+
128
+	public function hasOffset()
129
+	{
130
+		return $this->offset !== null;
131
+	}
132
+
133
+	public function getOffset()
134
+	{
135
+		return $this->offset;
136
+	}
137 137
 	#[\ReturnTypeWillChange]
138 138
 	abstract function count();
139 139
 	
140
-    public function getPaginator()
141
-    {
142
-        $paginator = new Paginator();
143
-        $paginator->setQuery($this);
140
+	public function getPaginator()
141
+	{
142
+		$paginator = new Paginator();
143
+		$paginator->setQuery($this);
144 144
 
145
-        return $paginator;
146
-    }
145
+		return $paginator;
146
+	}
147 147
 	
148 148
 	// ****************** DB connection and query
149 149
 	
150
-    public function setConnection(Selectable $connection)
151
-    {
152
-        $this->connection = $connection;
153
-        return $this;
154
-    }
150
+	public function setConnection(Selectable $connection)
151
+	{
152
+		$this->connection = $connection;
153
+		return $this;
154
+	}
155 155
 
156
-    protected function connection()
157
-    {
158
-        return $this->connection;
159
-    }
156
+	protected function connection()
157
+	{
158
+		return $this->connection;
159
+	}
160 160
 
161
-    protected function db()
162
-    {
163
-        return $this->connection()->getDbAdapter();
164
-    }
161
+	protected function db()
162
+	{
163
+		return $this->connection()->getDbAdapter();
164
+	}
165 165
 	
166 166
 	protected function getTable()
167 167
 	{
@@ -169,52 +169,52 @@  discard block
 block discarded – undo
169 169
 		
170 170
 		$query = $this->getBaseQuery();
171 171
 		
172
-       if ($this->hasLimit() || $this->hasOffset()) {
173
-            $query->limit($this->getLimit(), $this->getOffset());
174
-        }		
172
+	   if ($this->hasLimit() || $this->hasOffset()) {
173
+			$query->limit($this->getLimit(), $this->getOffset());
174
+		}		
175 175
 		
176 176
 		return $db->fetchAll($query);
177 177
 	}
178 178
 	 
179
-    abstract public function getBaseQuery(); 
179
+	abstract public function getBaseQuery(); 
180 180
 	
181 181
 	// ****************** Filters
182 182
 
183
-    protected function getSearchColumns()
184
-    {
185
-        return $this->getColumns();
186
-    }
183
+	protected function getSearchColumns()
184
+	{
185
+		return $this->getColumns();
186
+	}
187 187
 	
188 188
 	abstract public function getColumns();
189 189
 
190
-    public function setFilter($filter)
191
-    {
192
-        $this->filter = $filter;
193
-        return $this;
194
-    }
190
+	public function setFilter($filter)
191
+	{
192
+		$this->filter = $filter;
193
+		return $this;
194
+	}
195 195
 	
196 196
 	public function getFilterEditor(Request $request)
197
-    {
198
-        $filterEditor = Widget::create('filterEditor')
199
-            ->setColumns(array_keys($this->getColumns()))
200
-            ->setSearchColumns(array_keys($this->getSearchColumns()))
201
-            ->preserveParams('limit', 'sort', 'dir', 'view', 'backend')
202
-            ->ignoreParams('page')
203
-            ->handleRequest($request);
197
+	{
198
+		$filterEditor = Widget::create('filterEditor')
199
+			->setColumns(array_keys($this->getColumns()))
200
+			->setSearchColumns(array_keys($this->getSearchColumns()))
201
+			->preserveParams('limit', 'sort', 'dir', 'view', 'backend')
202
+			->ignoreParams('page')
203
+			->handleRequest($request);
204 204
 
205
-        $filter = $filterEditor->getFilter();
206
-        $this->setFilter($filter);
205
+		$filter = $filterEditor->getFilter();
206
+		$this->setFilter($filter);
207 207
 
208
-        return $filterEditor;
209
-    }
208
+		return $filterEditor;
209
+	}
210 210
 	
211 211
 	protected function renderFilter($filter)
212 212
 	{ // TODO : create a better filter wher user can choose host/oid to filter
213 213
 	}
214 214
 	
215
-    protected function applyFiltersToQuery($query)
216
-    {
217
-        /*
215
+	protected function applyFiltersToQuery($query)
216
+	{
217
+		/*
218 218
 		$filter = null;
219 219
         $enforced = $this->enforcedFilters;
220 220
         if ($this->filter && ! $this->filter->isEmpty()) {
@@ -230,7 +230,7 @@  discard block
 block discarded – undo
230 230
             $query->where($this->renderFilter($filter));
231 231
         }
232 232
 		*/
233
-        return $query;
234
-    }	
233
+		return $query;
234
+	}	
235 235
 
236 236
 }
Please login to merge, or discard this patch.