diff options
Diffstat (limited to 'site/app/views/elements/install.thtml')
-rw-r--r-- | site/app/views/elements/install.thtml | 212 |
1 files changed, 94 insertions, 118 deletions
diff --git a/site/app/views/elements/install.thtml b/site/app/views/elements/install.thtml index fb0b6af..60a5055 100644 --- a/site/app/views/elements/install.thtml +++ b/site/app/views/elements/install.thtml @@ -50,17 +50,13 @@ * - $addonStatus * - $allPlatforms - There should only be one platform in the list when this is used on the eula view. * - $addonType - default ADDON_EXTENSION - * - $collection_uuid - if this add-on download is collection related, this will set a tracking code in the download ID. default null * - $buttonMessage - default 'a_install' - * - $showInstructions - Show install instructions for Thunderbird or Seamonkey, defaults to true */ global $browser_apps, $experimental_status, $valid_status; /* prepare add-on type */ if (!isset($addonType)) $addonType = ADDON_EXTENSION; -if (!isset($showInstructions)) $showInstructions = true; - /* logged in users can install experimental add-ons */ $loggedin = $this->controller->Session->check('User'); @@ -100,13 +96,13 @@ if (count($addonFiles) < 1) { // If we're looking at thunderbird pages, and there is no EULA, show the TB // install instructions. Bug 401272 fixed the button so it downloads instead of // installs, but it doesn't hurt to have these instructions still. - if (APP_ID == APP_THUNDERBIRD && empty($addonEULA) && $showInstructions) { + if (APP_ID == APP_THUNDERBIRD && empty($addonEULA)) { echo '<div class="app_install">'; echo '<h3>'._('addons_install_in_thunderbird_title').'</h3>'; echo _('addons_install_in_thunderbird'); echo '</div>'; } - if (APP_ID == APP_SUNBIRD && empty($addonEULA) && $showInstructions) { + if (APP_ID == APP_SUNBIRD && empty($addonEULA)) { echo '<div class="app_install">'; echo '<h3>'._('addons_install_in_sunbird_title').'</h3>'; echo _('addons_install_in_sunbird'); @@ -147,116 +143,94 @@ if (count($addonFiles) < 1) { if ($addonType != ADDON_SEARCH) { /* install for search */ if (in_array(APP_ID, $browser_apps)) { - // prepare link options for browser apps + // prepare onclick install for browser apps $linkOptions = array( 'id' => $installTriggerName, 'title' => sprintf(_('install_button_title'), $addonName, APP_PRETTYNAME), 'addonName' => $addonName, 'addonIcon' => $addonIconPath, 'addonHash' => $file['hash'], - 'jsInstallMethod' => 'browser_app_addon_install', + 'onclick' => "return install(event," + ."document.getElementById('{$installTriggerName}').getAttribute('addonName'), " + ."document.getElementById('{$installTriggerName}').getAttribute('addonIcon'), " + ."document.getElementById('{$installTriggerName}').getAttribute('addonHash'));" ); } else { - // prepare link options for non-browser apps + // prepare onclick install for non-browser apps $linkOptions = array('id' => $installTriggerName, 'title'=>sprintf(_('install_download'),$addonName)); } } else { - /* prepare link options for search engines */ + /* special install javascript for search engines */ $linkOptions = array( 'id' => $installTriggerName, 'title' => sprintf(_('install_button_title'), $addonName, APP_PRETTYNAME), - 'engineURL' => FULL_BASE_URL . $html->urlFile($file['id'], $file['filename'], @$collection_uuid), - // search engines use a special install method - 'jsInstallMethod' => 'search_engine_install', + 'onclick' => "return addEngine('".FULL_BASE_URL.$html->urlFile($file['id'], $file['filename'])."');" ); } ?> - <?php - $install_button_html = ''; - if (empty($addonEULA)) { - // wipe disallowed characters off the displayed filename - $addon_filename = $html->entities(preg_replace( - INVALID_FILENAME_CHARS, '_', $html->unsanitize($file['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']}"; - - $file_id = $this->controller->File->getLatestFileByAddonId($addonId); - $file_data = $this->controller->File->findById($file_id); - $path_info = pathinfo($file_data['File']['filename']); - - $latest_permalink .= "/addon-${addonId}-latest.".$path_info['extension']; - - if (!empty($collection_uuid)) $latest_permalink .= "?collection_id={$collection_uuid}"; - - $install_button_html .= $html->link($linktitle, $latest_permalink, $linkOptions); - } else { - $install_button_html .= $html->linkFile($file['id'], $linktitle, null, - $linkOptions, false, $addon_filename, @$collection_uuid); - } - } else { - $eula_attributes = array('id' => $installTriggerName, - 'addonName' => $addonName, - 'title' => sprintf(_('install_button_title'), $addonName, APP_PRETTYNAME), - 'isEULAPageLink' => 'true'); - $install_button_html .= $html->link('<span><span><span><strong>' - .sprintf(_('a_download'),$_install_platform_string) - .'</strong></span></span></span>', - "/addons/policy/0/{$addonId}/{$file['id']}", - $eula_attributes, false, false); - } - /** - * For logged-in users or public add-ons, show the standard install button. - */ - if ($loggedin || !in_array($file['status'], $experimental_status) || (isset($is_eula_page) && isset($_GET['confirmed']))): - ?> - <p class="install-button <?=$_class_platform_string?>"> - <?= $install_button_html ?> - </p> <?php /** - * For sandbox add-ons, show a frozen version of the standard install button. - * Users unfreeze the button client-side by checking a confirmation box. - * Non-JS users must unfreeze by logging in. + * For logged-in users or public add-ons. */ - else: + if ($loggedin || !in_array($file['status'], $experimental_status)): ?> - <div class="exp-loggedout install"> - <div class="exp-confirm-install" style="display: none"> - <input type="checkbox" name="confirm-<?= $addonId ?>" /> - <div class="exp-desc"> - <label for="exp-confirm-install-checkbox-<?=$addonId?>"></label> - <span><?= sprintf(___('install_button_confirm_exp_install'), $html->url('/pages/faq#experimental-addons')) ?></span> - </div> - </div> - - <p class="install-button <?=$_class_platform_string?>" style="display: none"> - <?= $install_button_html ?> - </p> - - <noscript> - <p class="install-button <?=$_class_platform_string?>"> - <?php - $login_url = $html->login_url('/'.LANG.'/'.APP_SHORTNAME."/addon/{$addonId}", false); - $attributes = array('id' => $installTriggerName, + <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']))); + + // 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, 'title' => sprintf(_('install_button_title'), $addonName, APP_PRETTYNAME)); echo $html->link('<span><span><span><strong>' .sprintf(_('a_download'),$_install_platform_string) .'</strong></span></span></span>', - $login_url, $attributes, false, false); + "/addons/policy/0/{$addonId}/{$file['id']}", + $eula_attributes, false, false); + } + ?> + </p> - $exp_addon_url = "/pages/faq#experimental-addons"; - ?> - </p> - <?= sprintf(___('install_a_login_to_install'), $html->url($login_url), $html->url($exp_addon_url)); ?> - </noscript> + + <?php + /** + * For sandbox add-ons. + */ + else: /* don't allow install of experimental add-ons before login */ + ?> + <div class="exp-loggedout install"> + <p class="install-button <?=$_class_platform_string?>"> + <?php + $login_url = $html->login_url('/'.LANG.'/'.APP_SHORTNAME."/addon/{$addonId}", false); + $attributes = array('id' => $installTriggerName, + 'addonName' => $addonName, + 'title' => sprintf(_('install_button_title'), $addonName, APP_PRETTYNAME)); + echo $html->link('<span><span><span><strong>' + .sprintf(_('a_download'),$_install_platform_string) + .'</strong></span></span></span>', + $login_url, $attributes, false, false); + ?> + </p> + <?php + $exp_addon_url = "/pages/faq#experimental-addons"; + echo sprintf(___('install_a_login_to_install'), $html->url($login_url), $html->url($exp_addon_url)); + ?> </div> <?php endif; ?> <script type="text/javascript"> @@ -265,42 +239,44 @@ if (count($addonFiles) < 1) { <?php } echo "</div>"; + ?> - // show all add-on versions for all platforms on the - // "all versions" page - // This script will detect which install button should show, and hide the rest - echo '<script type="text/javascript">'. - 'setTimeout(function() {'; - echo "initExpConfirm('{$versionId}');"; - $versionsPage = false; - if (!($this->name == 'Addons' && $this->action == 'versions')) { - echo "fixPlatformLinks('{$versionId}', document.getElementById('{$installTriggerName}').getAttribute('addonName'));"; - } else { - $versionsPage = true; - } + <?php + + if ($loggedin || !in_array($file['status'], $experimental_status)) { + // show all add-on versions for all platforms on the + // "all versions" page + // This script will detect which install button should show, and hide the rest + echo '<script type="text/javascript">'. + 'setTimeout(function() {'; + $versionsPage = false; + if (!($this->name == 'Addons' && $this->action == 'versions')) { + + echo "fixPlatformLinks('{$versionId}', document.getElementById('{$installTriggerName}').getAttribute('addonName'));"; + } else { + $versionsPage = true; + } - // show add-on compatibility hints for Firefox - if (APP_ID == APP_FIREFOX && !empty($compatible_apps)) { - $fromVer = $toVer = null; - foreach ($compatible_apps as $app) { - if ($app['Application']['application_id'] == APP_FIREFOX) { - $fromVer = $app['Min_Version']['version']; - $toVer = $app['Max_Version']['version']; + // show add-on compatibility hints for Firefox + if (APP_ID == APP_FIREFOX && !empty($compatible_apps)) { + $fromVer = $toVer = null; + foreach ($compatible_apps as $app) { + if ($app['Application']['application_id'] == APP_FIREFOX) { + $fromVer = $app['Min_Version']['version']; + $toVer = $app['Max_Version']['version']; + } + } + if ($fromVer && $toVer) { + // show "ignore" link for logged in users only + $_loggedin = $this->controller->Session->check('User'); + echo "addCompatibilityHints('{$addonId}', '{$versionId}', " + ."'{$fromVer}', '{$toVer}', '{$_loggedin}', '{$versionsPage}');"; + } } - } - if ($fromVer && $toVer) { - // show "ignore" link for logged in users only - $_loggedin = $this->controller->Session->check('User'); - echo "addCompatibilityHints('{$addonId}', '{$versionId}', " - ."'{$fromVer}', '{$toVer}', '{$_loggedin}', '{$versionsPage}');"; - } + echo "},0);" + .'</script>'; + } - echo "},0);". - '</script>'; - ?> - - -<?php } ?> |