<?php

/**
 * Overview provides an inside look at what is going on for an application.
 *
 * @package amo
 * @subpackage docs
 */
$currentTab = 'home';
setApp();
$pageType = $clean['app'] === 'Firefox' ? 'rustico' : 'nonav';
startProcessing('index.tpl', 'home', $compileId, $pageType);
require_once 'includes.php';
$amo = new AMO_Object();
header("Cache-Control: max-age=120, must-revalidate");
// Assign template variables.
$tpl->assign(array('popularExtensions' => $amo->getPopularAddons($sql['app'], 'E', 5), 'feature' => $amo->getFeature($sql['app']), 'currentTab' => $currentTab, 'app' => $sql['app']));
// Determine our application.
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'));
$_app = array_key_exists('app', $_GET) ? $_GET['app'] : null;
// 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'));