public function showAction() { $arguments = $this->arguments; $category = getCategoryFromArguments($arguments); $output = ''; // only continue if we have a valid category if ($category) { // prepare labels and page rootline $categoryLabels = array(); foreach ($category['rootline'] as $categoryData) { $categoryLabels[] = $categoryData['label']; $this->pageRenderer->addRootlineItem(array('url' => createLinkUrl('category', array_keys($categoryData['rootline'])), 'name' => $categoryData['label'])); } $output .= '<h2>Browsing</h2><p>Category <strong>' . htmlspecialchars(implode(' / ', $categoryLabels)) . '</strong></p>'; if (isset($category['pageTitle']) && $category['pageTitle']) { $this->setPageTitle($category['pageTitle']); } // render subcategories if available if (isset($category['subCategories'])) { $output .= $this->renderCategoryList($category['subCategories']); // render category content } else { $controller = 'AddonController'; $action = 'list'; // allow categories to use their own controller and action for rendering if (isset($category['controller']) && isset($category['action']) && $category['controller'] && $category['action']) { $controller = $category['controller']; $action = $category['action']; } require_once 'includes/Controller/' . $controller . '.php'; $controller = new $controller(); $controller->setArguments($this->arguments); $methodName = $action . 'Action'; $output .= $controller->{$methodName}($category); } } else { $this->pageNotFound(); $this->forward('/'); } return $output; }
public function categoryAction() { $arguments = $this->arguments; $category = getCategoryFromArguments($arguments); // only continue if we have a valid category if ($category) { // prepare labels and page rootline $categoryLabels = array(); foreach ($category['rootline'] as $categoryData) { $categoryLabels[] = $categoryData['label']; $this->pageRenderer->addRootlineItem(array('url' => createLinkUrl('category', array_keys($categoryData['rootline'])), 'name' => $categoryData['label'])); } $output .= '<form action="search/" id="searchform"> <div> <input type="text" id="t" name="keyword" placeholder="Search" value=""/> <input type="submit" value="Search" id="searchsubmit"/> </div> </form> <h2>Help build the XBMC community</h2>If you know of any new addons or repositories not already listed or you find an addon that\'s listed but you know for a fact it\'s now depreciated please let us know so we can update the database. The Xbox compatibility list is currently being created but it\'s a slow process, if you can help with any testing please get in contact. Thanks!<br /><br /><br />'; // render subcategories if available if (isset($category['subCategories'])) { $output .= $this->renderCategoryList($category['subCategories']); // show addons if no subcategories } else { $whereClause = '1=1'; if (isset($category['extensionPoint'])) { $whereClause .= ' AND extension_point = "' . $this->db->escape($category['extensionPoint']) . '"'; } if (isset($category['xboxCompatible'])) { $whereClause .= ' AND xbox_compatible = "' . $this->db->escape($category['xboxCompatible']) . '"'; } if (isset($category['contentType'])) { $whereClause .= ' AND FIND_IN_SET("' . $category['contentType'] . '", content_types)'; } if (isset($category['genreType'])) { $whereClause .= ' AND FIND_IN_SET("' . $category['genreType'] . '", genres)'; } if (isset($category['platformType'])) { $whereClause .= ' AND FIND_IN_SET("' . $category['platformType'] . '", platform)'; } if (isset($category['depreciated'])) { $whereClause .= ' AND my_delete = "' . $this->db->escape($category['depreciated']) . '"'; } if (isset($category['broken_addons'])) { $whereClause .= ' AND broken !="" OR my_broken !=""'; } if (isset($category['not_adult'])) { $whereClause .= ' AND visible = "' . $this->db->escape($category['not_adult']) . '"'; } if (isset($category['xbox_untested'])) { $whereClause .= ' AND untested = "' . $this->db->escape($category['xbox_untested']) . '"'; } // execute queries $limit = 40; $offset = max(0, isset($_GET['page']) ? intval($_GET['page']) - 1 : 0) * $limit; if (isset($category['genreType']) && $category['genreType']) { $addons = $this->db->get_results('SELECT * FROM addon WHERE ' . $whereClause . $this->configuration['addonExcludeClause'] . ' ORDER BY name ASC LIMIT ' . $offset . ', ' . $limit); $count = $this->db->get_var('SELECT count(*) FROM addon WHERE ' . $whereClause . $this->configuration['addonExcludeClause']); } else { $addons = $this->db->get_results('SELECT * FROM addon WHERE ' . $whereClause . $this->configuration['addonExcludeClause'] . ' ORDER BY name ASC LIMIT ' . $offset . ', ' . $limit); $count = $this->db->get_var('SELECT count(*) FROM addon WHERE ' . $whereClause . $this->configuration['addonExcludeClause']); } if ($addons && is_array($addons) && count($addons)) { $output .= $this->renderAddonList($addons, createLinkUrl('category', array_keys($category['rootline'])), $count, $limit); } else { $output .= renderFlashMessage('No addons found', 'There are currently no addons available in this section'); } } } else { $this->pageNotFound(); $this->forward('index'); } return $output; }