diff options
author | wclouser@mozilla.com <wclouser@mozilla.com@4eb1ac78-321c-0410-a911-ec516a8615a5> | 2009-02-03 23:32:24 (GMT) |
---|---|---|
committer | wclouser@mozilla.com <wclouser@mozilla.com@4eb1ac78-321c-0410-a911-ec516a8615a5> | 2009-02-03 23:32:24 (GMT) |
commit | c3aadfa3f65e9646298233437279fa72938350c4 (patch) | |
tree | 6357398d172b7b0657964476b9a39c5ac11f1d74 | |
parent | ef0acfaff6c6157b42db8e7efe8be0fbe16adc6d (diff) |
Push wenzel's patch for bug 473681; adds permalinks to latest versions
git-svn-id: http://svn.mozilla.org/addons/trunk@21977 4eb1ac78-321c-0410-a911-ec516a8615a5
-rw-r--r-- | site/app/controllers/downloads_controller.php | 3 | ||||
-rw-r--r-- | site/app/views/addons/display.thtml | 1 | ||||
-rw-r--r-- | site/app/views/addons/policy.thtml | 1 | ||||
-rw-r--r-- | site/app/views/elements/addon_listitem.thtml | 1 | ||||
-rw-r--r-- | site/app/views/elements/feature.thtml | 1 | ||||
-rw-r--r-- | site/app/views/elements/install.thtml | 28 |
6 files changed, 23 insertions, 12 deletions
diff --git a/site/app/controllers/downloads_controller.php b/site/app/controllers/downloads_controller.php index cf3d0b7..fc182db 100644 --- a/site/app/controllers/downloads_controller.php +++ b/site/app/controllers/downloads_controller.php @@ -142,10 +142,11 @@ class DownloadsController extends AppController // Get the id of the latest public file $file_id = $this->File->getLatestFileByAddonId($addon_id, $platform_id); + $file_data = $this->File->findById($file_id); if (!empty($file_id)) { // Use normal download method if file is found - $this->file($file_id, $type); + $this->redirect("/downloads/file/{$file_id}/{$type}/{$file_data['File']['filename']}"); } else { // File wasn't found diff --git a/site/app/views/addons/display.thtml b/site/app/views/addons/display.thtml index 8cf2e36..f302b47 100644 --- a/site/app/views/addons/display.thtml +++ b/site/app/views/addons/display.thtml @@ -129,6 +129,7 @@ if (in_array($addon['Addon']['status'], $experimental_status)) { 'addonName' => $addon['Translation']['name']['string'], 'addonId' => $addon['Addon']['id'], 'addonFiles' => ($hasversion?$addon['Version'][0]['File']:''), + 'is_latest' => true, 'addonEULA' => $addon['Translation']['eula']['string'], 'addonStatus' => $addon['Addon']['status'], 'addonType' => $addon['Addon']['addontype_id'], diff --git a/site/app/views/addons/policy.thtml b/site/app/views/addons/policy.thtml index 2f3051a..46e38df 100644 --- a/site/app/views/addons/policy.thtml +++ b/site/app/views/addons/policy.thtml @@ -89,6 +89,7 @@ else 'addonFiles' => $addon['Version'][0]['File'], 'addonEULA' => '', 'addonStatus' => $addon['Addon']['status'], + 'is_latest' => ($addon['Addon']['status'] == STATUS_PUBLIC), 'addonType' => $addon['Addon']['addontype_id'], 'allPlatforms' => $platforms, 'buttonMessage' => $buttonMessage diff --git a/site/app/views/elements/addon_listitem.thtml b/site/app/views/elements/addon_listitem.thtml index 4b934ae..ccbb11c 100644 --- a/site/app/views/elements/addon_listitem.thtml +++ b/site/app/views/elements/addon_listitem.thtml @@ -114,6 +114,7 @@ $_install_render_options = array( 'addonFiles' => $addonFiles, 'addonEULA' => $addonEULA, 'addonStatus' => $addon['Addon']['status'], + 'is_latest' => ($addon['Addon']['status'] == STATUS_PUBLIC), 'addonType' => $addon['Addon']['addontype_id'], 'compatible_apps' => $addon['compatible_apps'], 'allPlatforms' => $platforms, diff --git a/site/app/views/elements/feature.thtml b/site/app/views/elements/feature.thtml index 33373ec..17ac654 100644 --- a/site/app/views/elements/feature.thtml +++ b/site/app/views/elements/feature.thtml @@ -120,6 +120,7 @@ echo (_('addon_downloads_weekly') == 'addon_downloads_weekly') ? _('addon_downlo 'addonFiles' => $addonFiles, 'addonEULA' => $addonEULA, 'addonStatus' => $addonStatus, + 'is_latest' => ($addonStatus == STATUS_PUBLIC), 'compatible_apps' => $compatible_apps, 'allPlatforms' => $allPlatforms, 'addonType' => $addonType diff --git a/site/app/views/elements/install.thtml b/site/app/views/elements/install.thtml index 036dd51..206cef5 100644 --- a/site/app/views/elements/install.thtml +++ b/site/app/views/elements/install.thtml @@ -45,6 +45,7 @@ * - $addonName * - $addonId * - $addonFiles + * - $is_latest -- link to "download/latest" shortcut (default false) * - $addonEULA * - $addonStatus * - $allPlatforms - There should only be one platform in the list when this is used on the eula view. @@ -59,6 +60,9 @@ if (!isset($addonType)) $addonType = ADDON_EXTENSION; /* logged in users can install experimental add-ons */ $loggedin = $this->controller->Session->check('User'); +/* use "latest public file" permalink if this is the latest version. Defaults to false. */ +if (!isset($is_latest)) $is_latest = false; + /* "Install" for browser apps, "Download" for non-browser apps */ if (!isset($buttonMessage)) { if (!in_array(APP_ID, $browser_apps)) { @@ -168,21 +172,25 @@ if (count($addonFiles) < 1) { /** * For logged-in users or public add-ons. */ + if ($loggedin || !in_array($file['status'], $experimental_status)): ?> - - - - <?php if ($loggedin || !in_array($file['status'], $experimental_status)): ?> <p class="install-button <?=$_class_platform_string?>"> <?php if (empty($addonEULA)) { // wipe disallowed characters off the displayed filename $addon_filename = $html->entities(preg_replace( INVALID_FILENAME_CHARS, '_', $html->unsanitize($file['filename']))); - echo $html->linkFile($file['id'], '<span><span><span><strong>' - .sprintf(_('a_download'),$_install_platform_string) - .'</strong></span></span></span>', null, $linkOptions, - false, $addon_filename); + + // if this is the latest public version, use perma-URL. Otherwise, link directly to file. + $linktitle = '<span><span><span><strong>'.sprintf(_('a_download'),$_install_platform_string).'</strong></span></span></span>'; + if ($is_latest && $file['status'] == STATUS_PUBLIC) { + $latest_permalink = "/downloads/latest/{$addonId}"; + if ($file['platform_id'] != PLATFORM_ALL) $latest_permalink .= "/platform:{$file['platform_id']}"; + echo $html->link($linktitle, $latest_permalink, $linkOptions); + } else { + echo $html->linkFile($file['id'], $linktitle, null, + $linkOptions, false, $addon_filename); + } } else { $eula_attributes = array('id' => $installTriggerName, 'addonName' => $addonName, @@ -201,10 +209,8 @@ if (count($addonFiles) < 1) { /** * For sandbox add-ons. */ + else: /* don't allow install of experimental add-ons before login */ ?> - - - <?php else: /* don't allow install of experimental add-ons before login */ ?> <div class="exp-loggedout install"> <p class="install-button <?=$_class_platform_string?>"> <?php |