Beispiel #1
0
if (!empty($db->record)) {
    $resultCount = $db->record[0];
}
if ($resultCount < $page['right']) {
    $page['right'] = $resultCount;
}
// If we have only one result, redirect to the addon page.
if ($resultCount == 1) {
    header('Location: ' . HTTP_HOST . WEB_PATH . '/' . $clean['app'] . '/' . $rawResults[0] . '/');
    exit;
} else {
    foreach ($rawResults as $id) {
        $results[] = new Addon($id);
    }
}
// Do we even have a next or previous page?
$page['previous'] = $page['left'] >= $clean['perpage'] ? $page['left'] - $clean['perpage'] : null;
$page['next'] = $page['left'] + $clean['perpage'] < $resultCount ? $page['left'] + $clean['perpage'] : null;
$page['resultCount'] = $resultCount;
$page['leftDisplay'] = $page['left'] + 1;
// Build the URL based on passed arguments.
foreach ($clean as $key => $val) {
    if (!empty($val)) {
        $buf[] = $key . '=' . $val;
    }
}
$page['url'] = implode('&amp;', $buf);
unset($buf);
// Pass variables to template object.
$tpl->assign(array('page' => $page, 'results' => $results, 'clean' => $clean, 'cats' => $amo->getCats(), 'platforms' => $amo->getPlatforms(), 'apps' => $appSelectList, 'dates' => $dates, 'sort' => $sort, 'perpage' => $perpage, 'content' => 'search.tpl', 'title' => 'Search', 'extraHeaders' => '<script src="' . WEB_PATH . '/js/search.js" type="text/javascript"></script>'));
Beispiel #2
0
switch ($_app) {
    case 'seamonkey':
    case 'mozilla':
        $clean['app'] = 'Mozilla';
        break;
    case 'thunderbird':
        $clean['app'] = 'Thunderbird';
        break;
    case 'sunbird':
        $clean['app'] = 'Sunbird';
        break;
    case 'firefox':
    default:
        $clean['app'] = 'Firefox';
        break;
}
$amo = new AMO_Object();
// Despite what $clean holds, GUIDs were used in v1 so we have to support them
if (preg_match('/^(\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}|[a-z0-9-\\._]*\\@[a-z0-9-\\._]+)$/i', $_app)) {
    $newestThemes = $amo->getNewestAddonsByGuid($_app, 'T', 10);
    $popularThemes = $amo->getPopularAddonsByGuid($_app, 'T', 10);
    /* This is a bit of a cheesy hack because of the way the templates are written.
     * It's looking for the name of the app in $_GET, so here we are...(clouserw)*/
    $_GET['app'] = strtolower($amo->getAppNameFromGuid($_app));
} else {
    $newestThemes = $amo->getNewestAddons($clean['app'], 'T', 10);
    $popularThemes = $amo->getPopularAddons($clean['app'], 'T', 10);
}
// Assign template variables.
$tpl->assign(array('newestThemes' => $newestThemes, 'popularThemes' => $popularThemes, 'title' => 'Add-ons', 'currentTab' => $currentTab, 'content' => 'themes.tpl', 'sidebar' => 'inc/category-sidebar.tpl', 'cats' => $amo->getCats('T'), 'type' => 'T'));
// Determine our application.
switch ($_app) {
    case 'mozilla':
        $clean['app'] = 'Mozilla';
        break;
    case 'thunderbird':
        $clean['app'] = 'Thunderbird';
        break;
    case 'sunbird':
        $clean['app'] = 'Sunbird';
        break;
    case 'firefox':
    default:
        $clean['app'] = 'Firefox';
        break;
}
$amo = new AMO_Object();
// Despite what $clean holds, GUIDs were used in v1 so we have to support them
if (preg_match('/^(\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}|[a-z0-9-\\._]*\\@[a-z0-9-\\._]+)$/i', $_app)) {
    $newestExtensions = $amo->getNewestAddonsByGuid($_app, 'E', 10);
    $popularExtensions = $amo->getPopularAddonsByGuid($_app, 'E', 10);
    /* This is a bit of a cheesy hack because of the way the templates are written.
     * It's looking for the name of the app in $_GET, so here we are...*/
    $_GET['app'] = strtolower($amo->getAppNameFromGuid($_app));
} else {
    $newestExtensions = $amo->getNewestAddons($clean['app'], 'E', 10);
    $popularExtensions = $amo->getPopularAddons($clean['app'], 'E', 10);
}
// Assign template variables.
$tpl->assign(array('newestExtensions' => $newestExtensions, 'popularExtensions' => $popularExtensions, 'title' => 'Add-ons', 'currentTab' => $currentTab, 'content' => 'extensions.tpl', 'sidebar' => 'inc/category-sidebar.tpl', 'cats' => $amo->getCats('E'), 'type' => 'E'));