Completed
Push — 3.2.x ( fad44e...f56b46 )
by Erwan
01:58
created
controller/categories.php 2 patches
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -50,20 +50,20 @@  discard block
 block discarded – undo
50 50
 	protected $link;
51 51
 
52 52
 	/**
53
-	* Constructor
54
-	*
55
-	* @param \phpbb\db\driver\driver_interface					$db			Database object
56
-	* @param \phpbb\config\config								$config		Config object
57
-	* @param \phpbb\language\language							$language	Language object
58
-	* @param \phpbb\template\template							$template	Template object
59
-	* @param \phpbb\user										$user		User object
60
-	* @param \phpbb\controller\helper							$helper		Controller helper object
61
-	* @param \phpbb\request\request								$request	Request object
62
-	* @param \phpbb\auth\auth									$auth		Auth object
63
-	* @param \phpbb\pagination									$pagination	Pagination object
64
-	* @param \ernadoo\phpbbdirectory\core\categorie				$categorie	PhpBB Directory extension categorie object
65
-	* @param \ernadoo\phpbbdirectory\core\link					$link		PhpBB Directory extension link object
66
-	*/
53
+	 * Constructor
54
+	 *
55
+	 * @param \phpbb\db\driver\driver_interface					$db			Database object
56
+	 * @param \phpbb\config\config								$config		Config object
57
+	 * @param \phpbb\language\language							$language	Language object
58
+	 * @param \phpbb\template\template							$template	Template object
59
+	 * @param \phpbb\user										$user		User object
60
+	 * @param \phpbb\controller\helper							$helper		Controller helper object
61
+	 * @param \phpbb\request\request								$request	Request object
62
+	 * @param \phpbb\auth\auth									$auth		Auth object
63
+	 * @param \phpbb\pagination									$pagination	Pagination object
64
+	 * @param \ernadoo\phpbbdirectory\core\categorie				$categorie	PhpBB Directory extension categorie object
65
+	 * @param \ernadoo\phpbbdirectory\core\link					$link		PhpBB Directory extension link object
66
+	 */
67 67
 	public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\language\language $language, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\link $link)
68 68
 	{
69 69
 		$this->db			= $db;
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 	}
87 87
 
88 88
 	/**
89
-	* Base controller to be accessed with the URL /directory
90
-	*
91
-	* @return	\Symfony\Component\HttpFoundation\Response	A Symfony Response object
92
-	*/
89
+	 * Base controller to be accessed with the URL /directory
90
+	 *
91
+	 * @return	\Symfony\Component\HttpFoundation\Response	A Symfony Response object
92
+	 */
93 93
 	public function base()
94 94
 	{
95 95
 		$this->categorie->display();
@@ -99,19 +99,19 @@  discard block
 block discarded – undo
99 99
 	}
100 100
 
101 101
 	/**
102
-	* Legacy view controller for display a category
103
-	* Used with /directory/categorie/{cat_id}
104
-	* @deprecated 2.0.0 No longer used since dynamic routing.
105
-	*
106
-	* @param	int		$cat_id		The category ID
107
-	* @param	int		$page		Page number taken from the URL
108
-	* @param	int		$sort_days	Specifies the maximum amount of days a link may be old
109
-	* @param	string	$sort_key	is the key of $sort_by_sql for the selected sorting: a|t|r|s|v
110
-	* @param	string	$sort_dir	is either a or d representing ASC and DESC (ascending|descending)
111
-	* @param	string	$mode		watch|unwatch
112
-	* @return	\Symfony\Component\HttpFoundation\Response	A Symfony Response object
113
-	* @throws	\phpbb\exception\http_exception
114
-	*/
102
+	 * Legacy view controller for display a category
103
+	 * Used with /directory/categorie/{cat_id}
104
+	 * @deprecated 2.0.0 No longer used since dynamic routing.
105
+	 *
106
+	 * @param	int		$cat_id		The category ID
107
+	 * @param	int		$page		Page number taken from the URL
108
+	 * @param	int		$sort_days	Specifies the maximum amount of days a link may be old
109
+	 * @param	string	$sort_key	is the key of $sort_by_sql for the selected sorting: a|t|r|s|v
110
+	 * @param	string	$sort_dir	is either a or d representing ASC and DESC (ascending|descending)
111
+	 * @param	string	$mode		watch|unwatch
112
+	 * @return	\Symfony\Component\HttpFoundation\Response	A Symfony Response object
113
+	 * @throws	\phpbb\exception\http_exception
114
+	 */
115 115
 	public function view($cat_id, $page, $sort_days, $sort_key, $sort_dir, $mode = '')
116 116
 	{
117 117
 		if (false === $this->categorie->get($cat_id))
@@ -125,17 +125,17 @@  discard block
 block discarded – undo
125 125
 	}
126 126
 
127 127
 	/**
128
-	* View controller for display a category
129
-	*
130
-	* @param	int		$cat_id		The category ID
131
-	* @param	int		$page		Page number taken from the URL
132
-	* @param	int		$sort_days	Specifies the maximum amount of days a link may be old
133
-	* @param	string	$sort_key	is the key of $sort_by_sql for the selected sorting: a|t|r|s|v|p
134
-	* @param	string	$sort_dir	is either a or d representing ASC and DESC (ascending|descending)
135
-	* @param	string	$mode		watch|unwatch
136
-	* @return	\Symfony\Component\HttpFoundation\Response	A Symfony Response object
137
-	* @throws	\phpbb\exception\http_exception
138
-	*/
128
+	 * View controller for display a category
129
+	 *
130
+	 * @param	int		$cat_id		The category ID
131
+	 * @param	int		$page		Page number taken from the URL
132
+	 * @param	int		$sort_days	Specifies the maximum amount of days a link may be old
133
+	 * @param	string	$sort_key	is the key of $sort_by_sql for the selected sorting: a|t|r|s|v|p
134
+	 * @param	string	$sort_dir	is either a or d representing ASC and DESC (ascending|descending)
135
+	 * @param	string	$mode		watch|unwatch
136
+	 * @return	\Symfony\Component\HttpFoundation\Response	A Symfony Response object
137
+	 * @throws	\phpbb\exception\http_exception
138
+	 */
139 139
 	public function view_route($cat_id, $page = 1, $sort_days = 0, $sort_key = '', $sort_dir = '', $mode = '')
140 140
 	{
141 141
 		if (false === $this->categorie->get($cat_id))
@@ -390,11 +390,11 @@  discard block
 block discarded – undo
390 390
 	}
391 391
 
392 392
 	/**
393
-	* date controller for return a date
394
-	*
395
-	* @return	\phpbb\json_response	A Json Response
396
-	* @throws	\phpbb\exception\http_exception
397
-	*/
393
+	 * date controller for return a date
394
+	 *
395
+	 * @return	\phpbb\json_response	A Json Response
396
+	 * @throws	\phpbb\exception\http_exception
397
+	 */
398 398
 	public function return_date()
399 399
 	{
400 400
 		if (!$this->request->is_ajax())
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
 	}
412 412
 
413 413
 	/**
414
-	* slug controller for return a slugify category name
415
-	*
416
-	* @return	\phpbb\json_response	A Json Response
417
-	* @throws	\phpbb\exception\http_exception
418
-	*/
414
+	 * slug controller for return a slugify category name
415
+	 *
416
+	 * @return	\phpbb\json_response	A Json Response
417
+	 * @throws	\phpbb\exception\http_exception
418
+	 */
419 419
 	public function return_slug()
420 420
 	{
421 421
 		if (!$this->request->is_ajax())
Please login to merge, or discard this patch.
Spacing   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -66,16 +66,16 @@  discard block
 block discarded – undo
66 66
 	*/
67 67
 	public function __construct(\phpbb\db\driver\driver_interface $db, \phpbb\config\config $config, \phpbb\language\language $language, \phpbb\template\template $template, \phpbb\user $user, \phpbb\controller\helper $helper, \phpbb\request\request $request, \phpbb\auth\auth $auth, \phpbb\pagination $pagination, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\link $link)
68 68
 	{
69
-		$this->db			= $db;
70
-		$this->config		= $config;
69
+		$this->db = $db;
70
+		$this->config = $config;
71 71
 		$this->language		= $language;
72 72
 		$this->template		= $template;
73 73
 		$this->user			= $user;
74
-		$this->helper		= $helper;
75
-		$this->request		= $request;
74
+		$this->helper = $helper;
75
+		$this->request = $request;
76 76
 		$this->auth			= $auth;
77
-		$this->pagination	= $pagination;
78
-		$this->categorie	= $categorie;
77
+		$this->pagination = $pagination;
78
+		$this->categorie = $categorie;
79 79
 		$this->link			= $link;
80 80
 
81 81
 		$language->add_lang('directory', 'ernadoo/phpbbdirectory');
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 			throw new \phpbb\exception\http_exception(404, 'DIR_ERROR_NO_CATS');
120 120
 		}
121 121
 
122
-		$url = $this->helper->route('ernadoo_phpbbdirectory_dynamic_route_' . $cat_id, array('page' => $page));
122
+		$url = $this->helper->route('ernadoo_phpbbdirectory_dynamic_route_'.$cat_id, array('page' => $page));
123 123
 
124 124
 		return new RedirectResponse($url, 301);
125 125
 	}
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 
146 146
 		$start = ($page - 1) * $this->config['dir_show'];
147 147
 
148
-		$default_sort_days	= 0;
148
+		$default_sort_days = 0;
149 149
 		$default_sort_key	= (string) substr($this->config['dir_default_order'], 0, 1);
150 150
 		$default_sort_dir	= (string) substr($this->config['dir_default_order'], 2);
151 151
 
152 152
 		$sort_days	= (!$sort_days) ? $this->request->variable('st', $default_sort_days) : $sort_days;
153 153
 		$sort_key 	= (!$sort_key) ? $this->request->variable('sk', $default_sort_key) : $sort_key;
154
-		$sort_dir	= (!$sort_dir) ? $this->request->variable('sd', $default_sort_dir) : $sort_dir;
154
+		$sort_dir = (!$sort_dir) ? $this->request->variable('sd', $default_sort_dir) : $sort_dir;
155 155
 		$link_list = $rowset = array();
156 156
 
157 157
 		// Categorie ordering options
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 			$min_post_time = time() - ($sort_days * 86400);
190 190
 
191 191
 			$sql = 'SELECT COUNT(link_id) AS nb_links
192
-				FROM ' . $this->links_table . '
193
-				WHERE link_cat = ' . (int) $cat_id . '
192
+				FROM ' . $this->links_table.'
193
+				WHERE link_cat = ' . (int) $cat_id.'
194 194
 					AND link_time >= ' . $min_post_time;
195 195
 			$result = $this->db->sql_query($sql);
196 196
 			$nb_links = (int) $this->db->sql_fetchfield('nb_links');
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 		else
206 206
 		{
207 207
 			$sql_limit_time = '';
208
-			$nb_links		= (int) $this->categorie->data['cat_links'];
208
+			$nb_links = (int) $this->categorie->data['cat_links'];
209 209
 		}
210 210
 
211 211
 		// Make sure $start is set to the last page if it exceeds the amount
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 		$this->categorie->make_cat_jumpbox();
219 219
 
220 220
 		$base_url = array(
221
-			'routes'	=> 'ernadoo_phpbbdirectory_dynamic_route_' . $cat_id,
221
+			'routes'	=> 'ernadoo_phpbbdirectory_dynamic_route_'.$cat_id,
222 222
 			'params'	=> array_merge(array('cat_id' => $cat_id), $u_sort_param),
223 223
 		);
224 224
 
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 			'S_SELECT_SORT_KEY'		=> $s_sort_key,
232 232
 			'S_SELECT_SORT_DAYS'	=> $s_limit_days,
233 233
 			'S_CATLIST'				=> $this->categorie->make_cat_select($cat_id),
234
-			'S_PAGE_ACTION'			=> $this->helper->route('ernadoo_phpbbdirectory_dynamic_route_' . $cat_id, array('page' => $page)),
234
+			'S_PAGE_ACTION'			=> $this->helper->route('ernadoo_phpbbdirectory_dynamic_route_'.$cat_id, array('page' => $page)),
235 235
 			'S_CAT_ID'				=> $cat_id,
236 236
 
237 237
 			'TOTAL_LINKS'			=> $this->language->lang('DIR_NB_LINKS', (int) $nb_links),
238 238
 
239 239
 			'U_NEW_SITE' 			=> $this->helper->route('ernadoo_phpbbdirectory_new_controller', array('cat_id' => $cat_id)),
240 240
 
241
-			'U_VIEW_CAT'			=> $this->helper->route('ernadoo_phpbbdirectory_dynamic_route_' . $cat_id),
241
+			'U_VIEW_CAT'			=> $this->helper->route('ernadoo_phpbbdirectory_dynamic_route_'.$cat_id),
242 242
 			'U_WATCH_CAT'			=> $s_watching_categorie['link'],
243 243
 			'U_WATCH_CAT_TOGGLE'	=> $s_watching_categorie['link_toggle'],
244 244
 			'S_WATCH_CAT_TITLE'		=> $s_watching_categorie['title'],
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
 
269 269
 		if (is_array($sort_by_sql[$sort_key]))
270 270
 		{
271
-			$sql_sort_order = implode(' ' . $direction . ', ', $sort_by_sql[$sort_key]) . ' ' . $direction;
271
+			$sql_sort_order = implode(' '.$direction.', ', $sort_by_sql[$sort_key]).' '.$direction;
272 272
 		}
273 273
 		else
274 274
 		{
275
-			$sql_sort_order = $sort_by_sql[$sort_key] . ' ' . $direction;
275
+			$sql_sort_order = $sort_by_sql[$sort_key].' '.$direction;
276 276
 		}
277 277
 
278 278
 		// Grab just the sorted link ids
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 						),
316 316
 						array(
317 317
 							'FROM'	=> array($this->votes_table => 'v'),
318
-							'ON'	=> 'l.link_id = v.vote_link_id AND v.vote_user_id = ' . $this->user->data['user_id']
318
+							'ON'	=> 'l.link_id = v.vote_link_id AND v.vote_user_id = '.$this->user->data['user_id']
319 319
 						)
320 320
 				),
321 321
 				'WHERE'		=> $this->db->sql_in_set('l.link_id', $link_list)
@@ -332,8 +332,8 @@  discard block
 block discarded – undo
332 332
 
333 333
 			$link_list = ($store_reverse) ? array_reverse($link_list) : $link_list;
334 334
 
335
-			$votes_status 		= ($this->categorie->data['cat_allow_votes']) ? true : false;
336
-			$comments_status 	= ($this->categorie->data['cat_allow_comments']) ? true : false;
335
+			$votes_status = ($this->categorie->data['cat_allow_votes']) ? true : false;
336
+			$comments_status = ($this->categorie->data['cat_allow_comments']) ? true : false;
337 337
 
338 338
 			foreach ($link_list as $link_id)
339 339
 			{
@@ -343,10 +343,10 @@  discard block
 block discarded – undo
343 343
 				$s_note		= $this->link->display_note($site['link_note'], $site['link_vote'], $votes_status);
344 344
 				$s_thumb	= $this->link->display_thumb($site);
345 345
 				$s_vote		= $this->link->display_vote($site);
346
-				$s_banner	= $this->link->display_bann($site);
347
-				$s_rss		= $this->link->display_rss($site);
346
+				$s_banner = $this->link->display_bann($site);
347
+				$s_rss = $this->link->display_rss($site);
348 348
 
349
-				$edit_allowed 	= ($this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_dir') || ($this->user->data['user_id'] == $site['link_user_id'] && $this->auth->acl_get('u_edit_dir'))));
349
+				$edit_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_edit_dir') || ($this->user->data['user_id'] == $site['link_user_id'] && $this->auth->acl_get('u_edit_dir'))));
350 350
 				$delete_allowed = ($this->user->data['is_registered'] && ($this->auth->acl_get('m_delete_dir') || ($this->user->data['user_id'] == $site['link_user_id'] && $this->auth->acl_get('u_delete_dir'))));
351 351
 
352 352
 				$this->template->assign_block_vars('site', array(
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
 			$this->template->assign_block_vars('no_draw_link', array());
383 383
 		}
384 384
 
385
-		$page_title = $this->language->lang('DIRECTORY') . ' - ' . $this->categorie->data['cat_name'];
385
+		$page_title = $this->language->lang('DIRECTORY').' - '.$this->categorie->data['cat_name'];
386 386
 
387 387
 		$this->categorie->display();
388 388
 
Please login to merge, or discard this patch.