/** * Downloads the addons images like the icon * * @param string $addonId * @param string $repositoryId * @param boolean $forceUpdate * @return void */ function cacheAddonData($addonId, $repositoryId, $forceUpdate = FALSE) { global $configuration; $repoConfig = getRepositoryConfiguration($repositoryId); if ($repoConfig) { $addonWritePath = $configuration['cache']['pathWrite'] . 'Addons' . DIRECTORY_SEPARATOR . $addonId . DIRECTORY_SEPARATOR; $addonThumbnailPath = $addonWritePath . 'icon.png'; if (!file_exists($addonWritePath)) { mkdir($addonWritePath, 0777, TRUE); } if (!file_exists($addonThumbnailPath) || $forceUpdate) { $tempDownloadName = $addonWritePath . 'temp-icon.png'; $downloadUrl = $repoConfig['dataUrl'] . $addonId . '/icon.png'; $fp = fopen($tempDownloadName, 'w'); if ($fp) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $downloadUrl); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HTTPGET, 'GET'); #curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_FAILONERROR, 1); $followLocation = @curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_FILE, $fp); $data = curl_exec($ch); curl_close($ch); fclose($fp); if ($data) { if (file_exists($addonThumbnailPath)) { unlink($addonThumbnailPath); } rename($tempDownloadName, $addonThumbnailPath); } else { unlink($tempDownloadName); } } } } }
/** * Downloads the addons images like the icon * * @param string $addonId * @param string $repositoryId * @param boolean $forceUpdate * @return void */ function cacheAddonData($addonId, $repositoryId, $forceUpdate = FALSE) { global $configuration; $repoConfig = getRepositoryConfiguration($repositoryId); if ($repoConfig) { $addonWritePath = $configuration['cache']['pathWrite'] . 'Addons' . DIRECTORY_SEPARATOR . $addonId . DIRECTORY_SEPARATOR; $imageTypes = array('icon.png', 'fanart.jpg'); foreach ($imageTypes as $imageType) { $addonThumbnailPath = $addonWritePath . $imageType; $downloadUrl = $repoConfig['dataUrl'] . $addonId . '/' . $imageType; cacheFile($downloadUrl, $addonThumbnailPath, $forceUpdate); } } }
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; }