@@ -26,12 +26,12 @@ discard block |
||
| 26 | 26 | protected $categories_table; |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | - * Constructor |
|
| 30 | - * |
|
| 31 | - * @param \phpbb\db\driver\driver_interface $db Database connection |
|
| 32 | - * @param string $categories_table Table name |
|
| 33 | - * @access public |
|
| 34 | - */ |
|
| 29 | + * Constructor |
|
| 30 | + * |
|
| 31 | + * @param \phpbb\db\driver\driver_interface $db Database connection |
|
| 32 | + * @param string $categories_table Table name |
|
| 33 | + * @access public |
|
| 34 | + */ |
|
| 35 | 35 | public function __construct(\phpbb\db\driver\driver_interface $db, $categories_table) |
| 36 | 36 | { |
| 37 | 37 | $this->db = $db; |
@@ -39,10 +39,10 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * {@inheritdoc} |
|
| 43 | - * |
|
| 44 | - * @api |
|
| 45 | - */ |
|
| 42 | + * {@inheritdoc} |
|
| 43 | + * |
|
| 44 | + * @api |
|
| 45 | + */ |
|
| 46 | 46 | public function load($resource, $type = null) |
| 47 | 47 | { |
| 48 | 48 | $routes = new RouteCollection(); |
@@ -78,10 +78,10 @@ discard block |
||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | /** |
| 81 | - * {@inheritdoc} |
|
| 82 | - * |
|
| 83 | - * @api |
|
| 84 | - */ |
|
| 81 | + * {@inheritdoc} |
|
| 82 | + * |
|
| 83 | + * @api |
|
| 84 | + */ |
|
| 85 | 85 | public function supports($resource, $type = null) |
| 86 | 86 | { |
| 87 | 87 | return $type === 'ernadoo_phpbbdirectory_route'; |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | */ |
| 35 | 35 | public function __construct(\phpbb\db\driver\driver_interface $db, $categories_table) |
| 36 | 36 | { |
| 37 | - $this->db = $db; |
|
| 37 | + $this->db = $db; |
|
| 38 | 38 | $this->categories_table = $categories_table; |
| 39 | 39 | } |
| 40 | 40 | |
@@ -67,10 +67,10 @@ discard block |
||
| 67 | 67 | while ($row = $this->db->sql_fetchrow($result)) |
| 68 | 68 | { |
| 69 | 69 | $defaults['cat_id'] = $row['cat_id']; |
| 70 | - $path = 'directory/' . $row['cat_route'] . '/{page}/{sort_days}/{sort_key}/{sort_dir}'; |
|
| 70 | + $path = 'directory/'.$row['cat_route'].'/{page}/{sort_days}/{sort_key}/{sort_dir}'; |
|
| 71 | 71 | |
| 72 | 72 | $route = new Route($path, $defaults, $requirements); |
| 73 | - $routes->add('ernadoo_phpbbdirectory_dynamic_route_' . $row['cat_id'], $route); |
|
| 73 | + $routes->add('ernadoo_phpbbdirectory_dynamic_route_'.$row['cat_id'], $route); |
|
| 74 | 74 | } |
| 75 | 75 | $this->db->sql_freeresult(); |
| 76 | 76 | |
@@ -69,18 +69,18 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | 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\search\fulltext_directory $search, \ernadoo\phpbbdirectory\core\categorie $categorie, \ernadoo\phpbbdirectory\core\link $link) |
| 71 | 71 | { |
| 72 | - $this->db = $db; |
|
| 73 | - $this->config = $config; |
|
| 72 | + $this->db = $db; |
|
| 73 | + $this->config = $config; |
|
| 74 | 74 | $this->language = $language; |
| 75 | 75 | $this->template = $template; |
| 76 | 76 | $this->user = $user; |
| 77 | - $this->helper = $helper; |
|
| 78 | - $this->request = $request; |
|
| 77 | + $this->helper = $helper; |
|
| 78 | + $this->request = $request; |
|
| 79 | 79 | $this->auth = $auth; |
| 80 | - $this->pagination = $pagination; |
|
| 81 | - $this->search = $search; |
|
| 82 | - $this->categorie = $categorie; |
|
| 83 | - $this->link = $link; |
|
| 80 | + $this->pagination = $pagination; |
|
| 81 | + $this->search = $search; |
|
| 82 | + $this->categorie = $categorie; |
|
| 83 | + $this->link = $link; |
|
| 84 | 84 | |
| 85 | 85 | $language->add_lang('directory', 'ernadoo/phpbbdirectory'); |
| 86 | 86 | $language->add_lang('search'); |
@@ -104,18 +104,18 @@ discard block |
||
| 104 | 104 | throw new \phpbb\exception\http_exception(403, 'DIR_ERROR_NOT_AUTH'); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - $cat_id = $this->request->variable('cat_id', 0); |
|
| 108 | - $keywords = $this->request->variable('keywords', '', true); |
|
| 107 | + $cat_id = $this->request->variable('cat_id', 0); |
|
| 108 | + $keywords = $this->request->variable('keywords', '', true); |
|
| 109 | 109 | $search_terms = $this->request->variable('terms', 'all'); |
| 110 | - $search_category = $this->request->variable('cid', array(0)); |
|
| 111 | - $search_fields = $this->request->variable('sf', 'all'); |
|
| 110 | + $search_category = $this->request->variable('cid', array(0)); |
|
| 111 | + $search_fields = $this->request->variable('sf', 'all'); |
|
| 112 | 112 | $search_child = $this->request->variable('sc', true); |
| 113 | - $sort_days = $this->request->variable('st', 0); |
|
| 113 | + $sort_days = $this->request->variable('st', 0); |
|
| 114 | 114 | $sort_key = $this->request->variable('sk', 't'); |
| 115 | 115 | $sort_dir = $this->request->variable('sd', 'd'); |
| 116 | - $start = ($page - 1) * (int) $this->config['dir_show']; |
|
| 116 | + $start = ($page - 1) * (int) $this->config['dir_show']; |
|
| 117 | 117 | |
| 118 | - $default_sort_days = 0; |
|
| 118 | + $default_sort_days = 0; |
|
| 119 | 119 | $default_sort_key = (string) substr($this->config['dir_default_order'], 0, 1); |
| 120 | 120 | $default_sort_dir = (string) substr($this->config['dir_default_order'], 2); |
| 121 | 121 | |
@@ -164,12 +164,12 @@ discard block |
||
| 164 | 164 | |
| 165 | 165 | $u_hilit = urlencode(htmlspecialchars_decode(str_replace('|', ' ', $hilit))); |
| 166 | 166 | |
| 167 | - ($u_hilit) ? $u_search['keywords'] = urlencode(htmlspecialchars_decode($keywords)) : ''; |
|
| 168 | - ($search_terms != 'all') ? $u_search['terms'] = $search_terms : ''; |
|
| 169 | - ($cat_id) ? $u_search['cat_id'] = $cat_id : ''; |
|
| 170 | - ($search_category) ? $u_search['cid'] = $search_category : ''; |
|
| 171 | - (!$search_child) ? $u_search['sc'] = 0 : ''; |
|
| 172 | - ($search_fields != 'all') ? $u_search['sf'] = $search_fields : ''; |
|
| 167 | + ($u_hilit) ? $u_search['keywords'] = urlencode(htmlspecialchars_decode($keywords)) : ''; |
|
| 168 | + ($search_terms != 'all') ? $u_search['terms'] = $search_terms : ''; |
|
| 169 | + ($cat_id) ? $u_search['cat_id'] = $cat_id : ''; |
|
| 170 | + ($search_category) ? $u_search['cid'] = $search_category : ''; |
|
| 171 | + (!$search_child) ? $u_search['sc'] = 0 : ''; |
|
| 172 | + ($search_fields != 'all') ? $u_search['sf'] = $search_fields : ''; |
|
| 173 | 173 | |
| 174 | 174 | $base_url = array( |
| 175 | 175 | 'routes' => 'ernadoo_phpbbdirectory_search_controller', |
@@ -199,7 +199,7 @@ discard block |
||
| 199 | 199 | { |
| 200 | 200 | $this->template->assign_vars(array( |
| 201 | 201 | 'SEARCH_CATEGORY' => $this->language->lang('RETURN_TO', \ernadoo\phpbbdirectory\core\categorie::getname((int) $cat_id)), |
| 202 | - 'U_SEARCH_CATEGORY' => $this->helper->route('ernadoo_phpbbdirectory_dynamic_route_' . $cat_id), |
|
| 202 | + 'U_SEARCH_CATEGORY' => $this->helper->route('ernadoo_phpbbdirectory_dynamic_route_'.$cat_id), |
|
| 203 | 203 | )); |
| 204 | 204 | } |
| 205 | 205 | |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | |
| 244 | 244 | foreach ($rowset as $data) |
| 245 | 245 | { |
| 246 | - $s_banner = $this->link->display_bann($data); |
|
| 246 | + $s_banner = $this->link->display_bann($data); |
|
| 247 | 247 | $s_thumb = $this->link->display_thumb($data); |
| 248 | 248 | $s_flag = $this->link->display_flag($data); |
| 249 | 249 | |
@@ -251,8 +251,8 @@ discard block |
||
| 251 | 251 | |
| 252 | 252 | if ($hilit) |
| 253 | 253 | { |
| 254 | - $data['link_name'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#isu', '<span class="posthilit">$1</span>', $data['link_name']); |
|
| 255 | - $data['link_description'] = preg_replace('#(?!<.*)(?<!\w)(' . $hilit . ')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#isu', '<span class="posthilit">$1</span>', $data['link_description']); |
|
| 254 | + $data['link_name'] = preg_replace('#(?!<.*)(?<!\w)('.$hilit.')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#isu', '<span class="posthilit">$1</span>', $data['link_name']); |
|
| 255 | + $data['link_description'] = preg_replace('#(?!<.*)(?<!\w)('.$hilit.')(?!\w|[^<>]*(?:</s(?:cript|tyle))?>)#isu', '<span class="posthilit">$1</span>', $data['link_description']); |
|
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | $this->template->assign_block_vars('results', array( |
@@ -312,7 +312,7 @@ discard block |
||
| 312 | 312 | private function _get_exclude_categories(&$search_category, $search_child) |
| 313 | 313 | { |
| 314 | 314 | $sql = 'SELECT cat_id, parent_id, right_id |
| 315 | - FROM ' . $this->categories_table . ' |
|
| 315 | + FROM ' . $this->categories_table.' |
|
| 316 | 316 | ORDER BY left_id'; |
| 317 | 317 | $result = $this->db->sql_query($sql); |
| 318 | 318 | |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | /** |
| 37 | 37 | * Define the extensions to be tested |
| 38 | 38 | * |
| 39 | - * @return array vendor/name of extension(s) to test |
|
| 39 | + * @return string[] vendor/name of extension(s) to test |
|
| 40 | 40 | */ |
| 41 | 41 | static protected function setup_extensions() |
| 42 | 42 | { |
@@ -221,6 +221,9 @@ discard block |
||
| 221 | 221 | $this->core_categorie->set_extension_manager($phpbb_extension_manager); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | + /** |
|
| 225 | + * @param \ernadoo\phpbbdirectory\cron\task\core\prune_categorie[] $tasks |
|
| 226 | + */ |
|
| 224 | 227 | private function create_cron_manager($tasks) |
| 225 | 228 | { |
| 226 | 229 | global $phpbb_root_path, $phpEx; |
@@ -34,10 +34,10 @@ |
||
| 34 | 34 | protected $user; |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | - * Define the extensions to be tested |
|
| 38 | - * |
|
| 39 | - * @return array vendor/name of extension(s) to test |
|
| 40 | - */ |
|
| 37 | + * Define the extensions to be tested |
|
| 38 | + * |
|
| 39 | + * @return array vendor/name of extension(s) to test |
|
| 40 | + */ |
|
| 41 | 41 | static protected function setup_extensions() |
| 42 | 42 | { |
| 43 | 43 | return array('ernadoo/phpbbdirectory'); |
@@ -51,8 +51,8 @@ discard block |
||
| 51 | 51 | |
| 52 | 52 | parent::setUp(); |
| 53 | 53 | |
| 54 | - $table_categories = 'phpbb_directory_cats'; |
|
| 55 | - $tables_comments = 'phpbb_directory_comments'; |
|
| 54 | + $table_categories = 'phpbb_directory_cats'; |
|
| 55 | + $tables_comments = 'phpbb_directory_comments'; |
|
| 56 | 56 | $tables_links = 'phpbb_directory_links'; |
| 57 | 57 | $tables_votes = 'phpbb_directory_votes'; |
| 58 | 58 | $tables_watch = 'phpbb_directory_watch'; |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $this->helper->expects($this->any()) |
| 102 | 102 | ->method('render') |
| 103 | - ->willReturnCallback(function ($template_file, $page_title = '', $status_code = 200, $display_online_list = false) { |
|
| 103 | + ->willReturnCallback(function($template_file, $page_title = '', $status_code = 200, $display_online_list = false) { |
|
| 104 | 104 | return new \Symfony\Component\HttpFoundation\Response($template_file, $status_code); |
| 105 | 105 | }); |
| 106 | 106 | $this->helper |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | $phpbb_container->set('path_helper', $phpbb_path_helper); |
| 132 | 132 | $phpbb_container->set('ext.manager', $phpbb_extension_manager); |
| 133 | 133 | $phpbb_container->set('user', $this->user); |
| 134 | - $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path . 'cache/' . PHPBB_ENVIRONMENT . '/'); |
|
| 134 | + $phpbb_container->setParameter('core.cache_dir', $phpbb_root_path.'cache/'.PHPBB_ENVIRONMENT.'/'); |
|
| 135 | 135 | |
| 136 | 136 | $context = new \phpbb\template\context(); |
| 137 | 137 | $twig_extension = new \phpbb\template\twig\extension($context, $this->lang); |
@@ -100,7 +100,8 @@ |
||
| 100 | 100 | |
| 101 | 101 | $this->helper->expects($this->any()) |
| 102 | 102 | ->method('render') |
| 103 | - ->willReturnCallback(function ($template_file, $page_title = '', $status_code = 200, $display_online_list = false) { |
|
| 103 | + ->willReturnCallback(function ($template_file, $page_title = '', $status_code = 200, $display_online_list = false) |
|
| 104 | + { |
|
| 104 | 105 | return new \Symfony\Component\HttpFoundation\Response($template_file, $status_code); |
| 105 | 106 | }); |
| 106 | 107 | $this->helper |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * Setup test environment |
|
| 26 | - */ |
|
| 25 | + * Setup test environment |
|
| 26 | + */ |
|
| 27 | 27 | public function setUp() |
| 28 | 28 | { |
| 29 | 29 | parent::setUp(); |
@@ -61,10 +61,10 @@ discard block |
||
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | - * Test data for the test_display_base() function |
|
| 65 | - * |
|
| 66 | - * @return array Array of test data |
|
| 67 | - */ |
|
| 64 | + * Test data for the test_display_base() function |
|
| 65 | + * |
|
| 66 | + * @return array Array of test data |
|
| 67 | + */ |
|
| 68 | 68 | public function display_base_data() |
| 69 | 69 | { |
| 70 | 70 | return array( |
@@ -73,10 +73,10 @@ discard block |
||
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
| 76 | - * Test controller display |
|
| 77 | - * |
|
| 78 | - * @dataProvider display_base_data |
|
| 79 | - */ |
|
| 76 | + * Test controller display |
|
| 77 | + * |
|
| 78 | + * @dataProvider display_base_data |
|
| 79 | + */ |
|
| 80 | 80 | public function test_display_base($status_code, $page_content) |
| 81 | 81 | { |
| 82 | 82 | $controller = $this->get_controller(); |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
| 90 | - * Test base case scenario |
|
| 91 | - * |
|
| 92 | - */ |
|
| 90 | + * Test base case scenario |
|
| 91 | + * |
|
| 92 | + */ |
|
| 93 | 93 | public function test_for_root_categories() |
| 94 | 94 | { |
| 95 | 95 | $this->template->expects($this->exactly(2)) |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function getDataSet() |
| 20 | 20 | { |
| 21 | - return $this->createMySQLXMLDataSet(__DIR__ . '/fixtures/fixture_base.xml'); |
|
| 21 | + return $this->createMySQLXMLDataSet(__DIR__.'/fixtures/fixture_base.xml'); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -22,8 +22,8 @@ discard block |
||
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | - * Setup test environment |
|
| 26 | - */ |
|
| 25 | + * Setup test environment |
|
| 26 | + */ |
|
| 27 | 27 | public function setUp() |
| 28 | 28 | { |
| 29 | 29 | parent::setUp(); |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | - * Test data for the test_display_cat_by_id() function |
|
| 69 | - * |
|
| 70 | - * @return array Array of test data |
|
| 71 | - */ |
|
| 68 | + * Test data for the test_display_cat_by_id() function |
|
| 69 | + * |
|
| 70 | + * @return array Array of test data |
|
| 71 | + */ |
|
| 72 | 72 | public function display_cat_by_id_data() |
| 73 | 73 | { |
| 74 | 74 | return array( |
@@ -77,10 +77,10 @@ discard block |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | /** |
| 80 | - * Test controller display |
|
| 81 | - * |
|
| 82 | - * @dataProvider display_cat_by_id_data |
|
| 83 | - */ |
|
| 80 | + * Test controller display |
|
| 81 | + * |
|
| 82 | + * @dataProvider display_cat_by_id_data |
|
| 83 | + */ |
|
| 84 | 84 | public function test_display_cat_by_id($cat_id, $page, $status_code) |
| 85 | 85 | { |
| 86 | 86 | $controller = $this->get_controller(); |
@@ -121,10 +121,10 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | - * Test data for the test_display_cat_fails() function |
|
| 125 | - * |
|
| 126 | - * @return array Array of test data |
|
| 127 | - */ |
|
| 124 | + * Test data for the test_display_cat_fails() function |
|
| 125 | + * |
|
| 126 | + * @return array Array of test data |
|
| 127 | + */ |
|
| 128 | 128 | public function display_cat_fails_data() |
| 129 | 129 | { |
| 130 | 130 | return array( |
@@ -133,10 +133,10 @@ discard block |
||
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | /** |
| 136 | - * Test controller display throws 404 exceptions |
|
| 137 | - * |
|
| 138 | - * @dataProvider display_cat_fails_data |
|
| 139 | - */ |
|
| 136 | + * Test controller display throws 404 exceptions |
|
| 137 | + * |
|
| 138 | + * @dataProvider display_cat_fails_data |
|
| 139 | + */ |
|
| 140 | 140 | public function test_display_cat_fails($cat_id, $page, $status_code, $page_content) |
| 141 | 141 | { |
| 142 | 142 | $controller = $this->get_controller(); |
@@ -153,10 +153,10 @@ discard block |
||
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
| 156 | - * Test data for the test_category_one_page() function |
|
| 157 | - * |
|
| 158 | - * @return array Array of test data |
|
| 159 | - */ |
|
| 156 | + * Test data for the test_category_one_page() function |
|
| 157 | + * |
|
| 158 | + * @return array Array of test data |
|
| 159 | + */ |
|
| 160 | 160 | public function category_one_page_data() |
| 161 | 161 | { |
| 162 | 162 | return array( |
@@ -165,10 +165,10 @@ discard block |
||
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | /** |
| 168 | - * Test base case scenario |
|
| 169 | - * |
|
| 170 | - * @dataProvider category_one_page_data |
|
| 171 | - */ |
|
| 168 | + * Test base case scenario |
|
| 169 | + * |
|
| 170 | + * @dataProvider category_one_page_data |
|
| 171 | + */ |
|
| 172 | 172 | function test_category_one_page($cat_id, $cat_name, $parent_cat_id, $nb_links) |
| 173 | 173 | { |
| 174 | 174 | $controller = $this->get_controller(); |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | /** |
| 181 | - * Test data for the test_category_no_links() function |
|
| 182 | - * |
|
| 183 | - * @return array Array of test data |
|
| 184 | - */ |
|
| 181 | + * Test data for the test_category_no_links() function |
|
| 182 | + * |
|
| 183 | + * @return array Array of test data |
|
| 184 | + */ |
|
| 185 | 185 | public function category_no_links_data() |
| 186 | 186 | { |
| 187 | 187 | return array( |
@@ -190,10 +190,10 @@ discard block |
||
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | /** |
| 193 | - * Test base case scenario |
|
| 194 | - * |
|
| 195 | - * @dataProvider category_no_links_data |
|
| 196 | - */ |
|
| 193 | + * Test base case scenario |
|
| 194 | + * |
|
| 195 | + * @dataProvider category_no_links_data |
|
| 196 | + */ |
|
| 197 | 197 | function test_category_no_links($cat_id, $cat_name, $nb_links) |
| 198 | 198 | { |
| 199 | 199 | $this->template->expects($this->at(3)) |
@@ -209,10 +209,10 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | /** |
| 212 | - * Test data for the test_category_with_pages() function |
|
| 213 | - * |
|
| 214 | - * @return array Array of test data |
|
| 215 | - */ |
|
| 212 | + * Test data for the test_category_with_pages() function |
|
| 213 | + * |
|
| 214 | + * @return array Array of test data |
|
| 215 | + */ |
|
| 216 | 216 | public function category_with_pages_data() |
| 217 | 217 | { |
| 218 | 218 | return array( |
@@ -222,10 +222,10 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
| 225 | - * Test base case scenario |
|
| 226 | - * |
|
| 227 | - * @dataProvider category_with_pages_data |
|
| 228 | - */ |
|
| 225 | + * Test base case scenario |
|
| 226 | + * |
|
| 227 | + * @dataProvider category_with_pages_data |
|
| 228 | + */ |
|
| 229 | 229 | public function test_category_with_pages($cat_id, $cat_name, $parent_cat_id, $parent_cat_name, $nb_links, $page = 1, $sort_days = 0) |
| 230 | 230 | { |
| 231 | 231 | $controller = $this->get_controller(); |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | { |
| 19 | 19 | public function getDataSet() |
| 20 | 20 | { |
| 21 | - return $this->createMySQLXMLDataSet(__DIR__ . '/fixtures/fixture_categories.xml'); |
|
| 21 | + return $this->createMySQLXMLDataSet(__DIR__.'/fixtures/fixture_categories.xml'); |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -13,10 +13,10 @@ discard block |
||
| 13 | 13 | class categories_routing_loader_test extends \phpbb_database_test_case |
| 14 | 14 | { |
| 15 | 15 | /** |
| 16 | - * Define the extensions to be tested |
|
| 17 | - * |
|
| 18 | - * @return array vendor/name of extension(s) to test |
|
| 19 | - */ |
|
| 16 | + * Define the extensions to be tested |
|
| 17 | + * |
|
| 18 | + * @return array vendor/name of extension(s) to test |
|
| 19 | + */ |
|
| 20 | 20 | static protected function setup_extensions() |
| 21 | 21 | { |
| 22 | 22 | return array('ernadoo/phpbbdirectory'); |
@@ -50,10 +50,10 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * Get the route collection from the categories_loader |
|
| 54 | - * |
|
| 55 | - * @return \Symfony\Component\Routing\RouteCollection |
|
| 56 | - */ |
|
| 53 | + * Get the route collection from the categories_loader |
|
| 54 | + * |
|
| 55 | + * @return \Symfony\Component\Routing\RouteCollection |
|
| 56 | + */ |
|
| 57 | 57 | public function get_categories_route_collection() |
| 58 | 58 | { |
| 59 | 59 | $collection = $this->loader->load('ernadoo_phpbbdirectory_route_controller', 'pages_extension'); |
@@ -65,10 +65,10 @@ discard block |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
| 68 | - * Data set for test_page_loader |
|
| 69 | - * |
|
| 70 | - * @return array |
|
| 71 | - */ |
|
| 68 | + * Data set for test_page_loader |
|
| 69 | + * |
|
| 70 | + * @return array |
|
| 71 | + */ |
|
| 72 | 72 | public function page_loader_data() |
| 73 | 73 | { |
| 74 | 74 | return array( |
@@ -79,11 +79,11 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | /** |
| 82 | - * @dataProvider page_loader_data |
|
| 83 | - * |
|
| 84 | - * @param int $id Id of a categorie |
|
| 85 | - * @param string $expected Expected route of a categorie |
|
| 86 | - */ |
|
| 82 | + * @dataProvider page_loader_data |
|
| 83 | + * |
|
| 84 | + * @param int $id Id of a categorie |
|
| 85 | + * @param string $expected Expected route of a categorie |
|
| 86 | + */ |
|
| 87 | 87 | public function test_page_loader($id, $expected) |
| 88 | 88 | { |
| 89 | 89 | // Get a route instance |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | public function getDataSet() |
| 35 | 35 | { |
| 36 | - return $this->createMySQLXMLDataSet(__DIR__ . '/fixtures/categories.xml'); |
|
| 36 | + return $this->createMySQLXMLDataSet(__DIR__.'/fixtures/categories.xml'); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function setUp() |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | public function test_page_loader($id, $expected) |
| 88 | 88 | { |
| 89 | 89 | // Get a route instance |
| 90 | - $route = $this->collection->get('ernadoo_phpbbdirectory_dynamic_route_' . $id); |
|
| 90 | + $route = $this->collection->get('ernadoo_phpbbdirectory_dynamic_route_'.$id); |
|
| 91 | 91 | |
| 92 | 92 | // Assert the roue is an instance of Route |
| 93 | 93 | $this->assertInstanceOf('Symfony\Component\Routing\Route', $route, 'A route instance could not be made.'); |
@@ -50,20 +50,20 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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()) |
@@ -66,16 +66,16 @@ discard block |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 |
||
| 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 | |