public function showAction() { $output = ''; if (count($this->arguments)) { // prepare author name and page breadcrumb $author = revertAuthorNameCleanup($this->arguments[0]); $cleanAuthor = cleanupAuthorName($author); $this->pageRenderer->addRootlineItem(array('url' => createLinkUrl('author', $cleanAuthor), 'name' => $cleanAuthor)); $output .= '<h2>Browsing</h2><p>By author <strong>' . htmlspecialchars($cleanAuthor) . '</strong></p>'; $this->setPageTitle('Kodi Add-Ons by ' . htmlspecialchars($cleanAuthor)); // execute queries $limit = 40; $offset = max(0, isset($_GET['page']) ? intval($_GET['page']) - 1 : 0) * $limit; $addons = $this->db->get_results('SELECT * FROM addon WHERE FIND_IN_SET("' . $this->db->escape($author) . '", provider_name) ' . $this->configuration['addonExcludeClause'] . ' ORDER BY name ASC LIMIT ' . $offset . ', ' . $limit); $count = $this->db->get_var('SELECT count(*) FROM addon WHERE FIND_IN_SET("' . $this->db->escape($author) . '", provider_name) ' . $this->configuration['addonExcludeClause']); if ($addons && is_array($addons) && count($addons)) { $output .= $this->renderAddonList($addons, createLinkUrl('author', $cleanAuthor), $count, $limit); } else { $this->pageNotFound(); $output .= renderFlashMessage('No addons found', 'There are currently no addons available in this section'); } } else { $this->pageNotFound(); $this->forward('/'); } return $output; }
public function searchAction() { $output = ''; if ($_GET['keyword']) { // perform search query $limit = 40; $offset = max(0, isset($_GET['page']) ? intval($_GET['page']) - 1 : 0) * $limit; $keyword = $this->db->escape($_GET['keyword']); $whereClause = 'id LIKE "' . $keyword . '" OR name LIKE "%' . $keyword . '%" OR description LIKE "%' . $keyword . '" OR provider_name LIKE "%' . $keyword . '%"' . $this->configuration['addonExcludeClause']; $addons = $this->db->get_results('SELECT * FROM addon WHERE ' . $whereClause . ' ORDER BY name ASC LIMIT ' . $offset . ', ' . $limit); $count = $this->db->get_var('SELECT count(*) FROM addon WHERE ' . $whereClause); // render result $output .= '<h2>Search</h2><p>Search results for <strong>' . htmlspecialchars($_GET['keyword']) . '</strong></p>'; if ($addons && is_array($addons) && count($addons)) { $output .= $this->renderAddonList($addons, createLinkUrl('search', $_GET['keyword']), $count, $limit); } else { $output .= renderFlashMessage('No addons found', 'There where no addons found for this keyword.'); } } else { $output .= renderFlashMessage('How to search', 'Please enter the keyword you\'re looking for in the search field on the top right corner of the website.', 'info'); } return $output; }
// remove trailing and ending slashes if ($requestUri[0] == '/') { $requestUri = substr($requestUri, 1); } if (substr($requestUri, -1) == '/') { $requestUri = substr($requestUri, 0, -1); } // define default action and controller $controllerAndAction = $configuration['routes']['_default']; $pathSegments = array(); // check for action requested via URL if (strlen($requestUri) && $requestUri != 'index.php') { $pathSegments = explode('/', $requestUri); $controllerAndAction = resolvePathsegmentConfiguration($pathSegments); } // only proceed if action exists, else throw a 404 try { require_once 'includes/Controller/' . $controllerAndAction['controller'] . '.php'; $controller = new $controllerAndAction['controller'](); $controller->setArguments($pathSegments); $methodName = $controllerAndAction['action'] . 'Action'; $content = $controller->{$methodName}(); $content .= getDisclaimer(); } catch (Exception $e) { header('HTTP/1.0 404 Not Found'); $content = renderFlashMessage('Page not found', 'We\'re sorry, but the desired page could not be found.', 'error'); } // render and exit $page->setContent($content); echo $page->render(); shutdown();
public function showAction() { if (count($this->arguments)) { $result = $this->db->get_results('SELECT * FROM addon WHERE id = "' . $this->db->escape($this->arguments[0]) . '" LIMIT 1'); } $output = ''; if ($result) { // prepare variables and rootline $addon = current($result); $this->pageRenderer->addRootlineItem(array('url' => createLinkUrl('addon', $addon->id), 'name' => 'Details')); // prepare authors and create individual links if more are listed by the addon $authors = explode(',', $addon->provider_name); $authorLinks = array(); foreach ($authors as $author) { if ($author) { $author = cleanupAuthorName($author); $authorLinks[] = '<a href="' . createLinkUrl('author', $author) . '">' . htmlspecialchars($author) . '</a>'; } } // create details view $output .= '<div id="addonDetail"> <span class="thumbnail"><img src="' . getAddonThumbnail($addon->id, 'large') . '" alt="' . $addon->name . '" class="pic" /></span> <h2>' . htmlspecialchars($addon->name) . '</h2> <strong>Author:</strong> ' . implode(', ', $authorLinks); // Show the extra details of the Add-on $output .= '<br /><strong>Version:</strong> ' . $addon->version; $output .= '<br /><strong>Released:</strong> ' . $addon->updated; // Show repository details $repoConfig = getRepositoryConfiguration($addon->repository_id); if ($repoConfig) { if (count($this->configuration['repositories']) > 1) { $output .= '<br /><strong>Repository:</strong> '; $output .= $repoConfig['downloadUrl'] ? '<a href="' . $repoConfig['downloadUrl'] . '" rel="nofollow">' . $repoConfig['name'] . '</a>' : $repoConfig['name']; } if ($repoConfig['statsUrl'] && $addon->downloads > 0) { $output .= '<br /><strong>Downloads:</strong> ' . number_format($addon->downloads); } } // I can't seem to get the following code working. It should list the genres and create links to that each genre. /* $genres = $addon->genres; if ($genres) { $genres = explode(',', $genres ); $genreLinks = array(); foreach ($genres as $genre) { if ($genre) { $category_args = array(); $category_args[] = 'video'; //$addon->content_types; $category_args[] = $genres; $category = getCategoryFromArguments($category_args); $genreLinks[] = '<a href="' . createLinkUrl('category', $category_args) . '">' . $category['label'] . '</a>'; } } $output .= '<br /><strong>Genres:</strong> ' . implode(', ', $genreLinks); }*/ if ($addon->content_types) { $output .= '<br /><strong>Add-on Type:</strong> ' . str_replace('[CR]', '<br />', $addon->content_types); } if ($addon->genres) { $output .= '<br /><strong>Genres:</strong> ' . str_replace('[CR]', '<br />', $addon->genres); } if ($addon->license) { $output .= '<br /><strong>License:</strong> ' . str_replace('[CR]', '<br />', $addon->license); } if ($addon->platform) { $output .= '<br /><strong>Platforms:</strong> ' . str_replace('[CR]', '<br />', $addon->platform); } /* if ($addon->xbox_compatible) { $output .= '<br /><h2>XBMC4Xbox COMPATIBLE</h2> '; }*/ if ($addon->notes) { $output .= '<br /><strong>Notes:</strong> ' . str_replace('[CR]', '<br />', $addon->notes); } if ($addon->OverrideDesc) { $output .= '<br /><br /><br /><br /><br /><br /><br /><br /><div class="description"><h2>Description:</h2><h4>' . str_replace('[CR]', '<br />', $addon->mydescription) . '</h4></div>'; } else { $output .= '<br /><br /><br /><br /><br /><br /><br /><br /><div class="description"><h2>Description:</h2><h4>' . str_replace('[CR]', '<br />', $addon->description) . '</h4></div>'; } if ($addon->broken) { $output .= renderFlashMessage('This addon is reported as broken!', '<strong>Details:</strong> ' . htmlspecialchars($addon->broken) . '.', 'error'); } if ($addon->my_broken) { $output .= renderFlashMessage('This addon is reported as broken!', '<strong>Details:</strong> ' . htmlspecialchars($addon->my_broken) . '.', 'error'); } $output .= '<ul class="addonLinks">'; $output .= '<br /><h2>Resources:</h2>'; // Check forum link exists $forumLink = $addon->forum ? '<a href="' . $addon->forum . '" target="_blank"><img src="images/forum.png" alt="Forum discussion" /></a>' : '<img src="images/forumbw.png" alt="Forum discussion" />'; $output .= '<li><strong>Forum Discussion:</strong><br />' . $forumLink . '</li>'; // Auto Generate Wiki Link $output .= '<li><strong>Wiki Docs:</strong><br /><a href="http://wiki.xbmc.org/index.php?title=Add-on:' . $addon->name . '" target="_blank"><img src="images/wiki.png" alt="Wiki page of this addon" /></a></li>'; // Check sourcecode link exists $sourceLink = $addon->source ? '<a href="' . $addon->source . '" target="_blank"><img src="images/code.png" alt="Source code" /></a>' : '<img src="images/codebw.png" alt="Source code" />'; $output .= "<li><strong>Source Code:</strong><br />" . $sourceLink . '</li>'; // Check website link exists $websiteLink = $addon->website ? '<a href="' . $addon->website . '" target="_blank"><img src="images/website.png" alt="Website" /></a>' : '<img src="images/websitebw.png" alt="Website" />'; $output .= "<li><strong>Website:</strong><br />" . $websiteLink . '</li>'; // Show the Download link $downloadLink = getAddonDownloadLink($addon); if ($downloadLink) { $output .= '<li><strong>Direct Download:</strong><br />'; $output .= '<a href="' . $downloadLink . '" rel="nofollow"><img src="images/download_link.png" alt="Download" /></a></li>'; } // Check if any video links exist if ($addon->myvideopreview or $addon->video_preview or $addon->myvideoguide or $addon->video_guide) { $output .= '<br /><br /><br /><h2>Video Guides:</h2>'; } // Check video preview link exists if ($addon->myvideopreview) { $videopreviewLink = '<a href="' . $addon->myvideopreview . '"target="_blank"><img src="images/addons_preview.png" alt="Preview video" /></a>'; $output .= '<li>' . $videopreviewLink . '</li>'; } else { if ($addon->video_preview) { $videopreviewLink = $addon->video_preview ? '<a href="' . $addon->video_preview . '" target="_blank"><img src="images/addons_preview.png" alt="Preview video" /></a>' : '<img src="images/addons_preview.png" alt="Preview video" />'; $output .= '<li>' . $videopreviewLink . '</li>'; } } // Check video guide link exists if ($addon->myvideoguide) { $videoguideLink = '<a href="' . $addon->myvideoguide . '"target="_blank"><img src="images/addons_tutorial.png" alt="Tutorial video" /></a>'; $output .= '<li>' . $videoguideLink . '</li>'; } else { if ($addon->video_guide) { $videoguideLink = $addon->video_guide ? '<a href="' . $addon->video_guide . '" target="_blank"><img src="images/addons_tutorial.png" alt="Tutorial video" /></a>' : '<img src="images/addons_tutorial.png" alt="Tutorial video" />'; $output .= '<li>' . $videoguideLink . '</li>'; } } $output .= '</ul></div>'; } else { $this->pageNotFound(); } return $output; }
public function showAction() { if (count($this->arguments)) { $result = $this->db->get_results('SELECT * FROM addon WHERE id = "' . $this->db->escape($this->arguments[0]) . '" LIMIT 1'); } $output = ''; if ($result) { // prepare variables and rootline $addon = current($result); $this->pageRenderer->addRootlineItem(array('url' => createLinkUrl('addon', $addon->id), 'name' => 'Details')); $this->setPageTitle('"' . $addon->name . '" Add-On for Kodi'); $stats = getAddonStats($addon); // prepare authors and create individual links if more are listed by the addon $authors = explode(',', $addon->provider_name); $authorLinks = array(); foreach ($authors as $author) { if ($author) { $author = cleanupAuthorName($author); $authorLinks[] = '<a href="' . createLinkUrl('author', $author) . '">' . htmlspecialchars($author) . '</a>'; } } // create details view $output .= '<div id="addonDetail"> <span class="thumbnail"><img src="' . getAddonThumbnail($addon->id, 'large') . '" alt="' . htmlspecialchars($addon->name) . '" class="pic" /></span> <h2>' . htmlspecialchars($addon->name) . '</h2> <div id="addonMetaData"> <strong>Author:</strong> ' . implode(', ', $authorLinks); // Show the extra details of the Add-on $output .= '<br /><strong>Version:</strong> ' . $addon->version; if (is_array($stats) && $stats['Total']) { $output .= '<br /><strong>Downloads:</strong> ' . number_format($stats['Total']); } $output .= '<br /><strong>Released:</strong> ' . $addon->updated; // Show repository details $repoConfig = getRepositoryConfiguration($addon->repository_id); if ($repoConfig) { if (count($this->configuration['repositories']) > 1) { $output .= '<br /><strong>Repository:</strong> '; $output .= $repoConfig['downloadUrl'] ? '<a href="' . $repoConfig['downloadUrl'] . '" rel="nofollow">' . htmlspecialchars($repoConfig['name']) . '</a>' : $repoConfig['name']; } } if ($addon->license) { $output .= '<br /><strong>License:</strong> ' . str_replace('[CR]', '<br />', $addon->license); } $output .= '</div>'; $output .= '<div class="description"><h4>Description:</h4><p>' . str_replace('[CR]', '<br />', $addon->description) . '</p></div>'; if ($addon->broken) { $output .= renderFlashMessage('Warning', 'This addon is currently reported as broken! <br /><strong>Suggestion / Reason:</strong> ' . htmlspecialchars($addon->broken) . '.', 'error'); } $output .= '<ul class="addonLinks">'; // Check forum link exists $forumLink = $addon->forum ? '<a href="' . $addon->forum . '" target="_blank"><img src="images/forum.png" alt="Forum discussion" /></a>' : '<img src="images/forumbw.png" alt="Forum discussion" />'; $output .= '<li><strong>Forum Discussion:</strong><br />' . $forumLink . '</li>'; // Auto Generate Wiki Link $output .= '<li><strong>Wiki Docs:</strong><br /><a href="http://kodi.wiki/index.php?title=Add-on:' . $addon->name . '" target="_blank"><img src="images/wiki.png" alt="Wiki page of this addon" /></a></li>'; // Check sourcecode link exists $sourceLink = $addon->source ? '<a href="' . $addon->source . '" target="_blank"><img src="images/code.png" alt="Source code" /></a>' : '<img src="images/codebw.png" alt="Source code" />'; $output .= "<li><strong>Source Code:</strong><br />" . $sourceLink . '</li>'; // Check website link exists $websiteLink = $addon->website ? '<a href="' . $addon->website . '" target="_blank"><img src="images/website.png" alt="Website" /></a>' : '<img src="images/websitebw.png" alt="Website" />'; $output .= "<li><strong>Website:</strong><br />" . $websiteLink . '</li>'; // Show the Download link $downloadLink = getAddonDownloadLink($addon); if ($downloadLink) { $output .= '<li><strong>Direct Download:</strong><br />'; $output .= '<a href="' . $downloadLink . '" rel="nofollow"><img src="images/download_link.png" alt="Download" /></a></li>'; } $output .= '</ul></div>'; } else { $this->pageNotFound(); } return $output; }