mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-24 18:55:30 +00:00
Extensions and themes now support GUID
This commit is contained in:
parent
a01c3ca0ce
commit
46a51f2abf
@ -14,6 +14,26 @@ php_value auto_append_file finish.php
|
||||
RewriteEngine On
|
||||
RewriteBase /YOURPATH/public/htdocs
|
||||
|
||||
# Compatiblity for v1 of extensions. The hardcoded URL's in the old
|
||||
# browsers need this to get to the right pages: (the strings are the GUIDs)
|
||||
# Old example URL:
|
||||
# /extensions/?application={3550f703-e582-4d05-9a08-453d09bdfdc6}
|
||||
# New:
|
||||
# /extensions.php?app={3550f703-e582-4d05-9a08-453d09bdfdc6}
|
||||
RewriteCond %{REQUEST_URI} /extensions/
|
||||
RewriteCond %{QUERY_STRING} ^application=(.*)$
|
||||
RewriteRule ^.*$ extensions.php?app=%1 [L]
|
||||
|
||||
# Compatiblity for v1 of extensions. The hardcoded URL's in the old
|
||||
# browsers need this to get to the right pages: (the strings are the GUIDs)
|
||||
# Old example URL:
|
||||
# /themes/?application={3550f703-e582-4d05-9a08-453d09bdfdc6}
|
||||
# New:
|
||||
# /themes.php?app={3550f703-e582-4d05-9a08-453d09bdfdc6}
|
||||
RewriteCond %{REQUEST_URI} /themes/
|
||||
RewriteCond %{QUERY_STRING} ^application=(.*)$
|
||||
RewriteRule ^.*$ themes.php?app=%1 [L]
|
||||
|
||||
# Send rss/* to rss.php.
|
||||
# Example:
|
||||
# /rss/firefox/extensions/popular/ -> rss.php?app=firefox&type=extensions&list=popular
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Home page for extensions, switchable on application.
|
||||
* Home page for extensions, switchable on application. Since v1 used GUIDs, the
|
||||
* flow on this page is a little confusing (we need to support both name and GUID.
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
@ -11,20 +12,38 @@ $currentTab = 'extensions';
|
||||
startProcessing('extensions.tpl', 'extensions', $compileId);
|
||||
require_once('includes.php');
|
||||
|
||||
// If app is not set or empty, set it to null for our switch.
|
||||
$clean['app'] = (!empty($_GET['app']) && ctype_alpha($_GET['app'])) ? $_GET['app'] : null;
|
||||
$_app = array_key_exists('app', $_GET) ? $_GET['app'] : null;
|
||||
|
||||
// $sql['app'] can equal $clean['app'] since it was assigned in a switch().
|
||||
// We have to ucfirst() it because the DB has caps.
|
||||
$sql['app'] = $clean['app'];
|
||||
// Determine our application.
|
||||
switch( $_app ) {
|
||||
case 'mozilla':
|
||||
$clean['app'] = 'Mozilla';
|
||||
break;
|
||||
case 'thunderbird':
|
||||
$clean['app'] = 'Thunderbird';
|
||||
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);
|
||||
} else {
|
||||
$newestExtensions = $amo->getNewestAddons($clean['app'],'E',10);
|
||||
$popularExtensions = $amo->getPopularAddons($clean['app'],'E',10);
|
||||
}
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'newestExtensions' => $amo->getNewestAddons($sql['app'],'E',10),
|
||||
'popularExtensions' => $amo->getPopularAddons($sql['app'],'E',10),
|
||||
'title' => $clean['app'].' Addons',
|
||||
array( 'newestExtensions' => $newestExtensions,
|
||||
'popularExtensions' => $popularExtensions,
|
||||
'title' => 'Addons',
|
||||
'currentTab' => $currentTab,
|
||||
'content' => 'extensions.tpl',
|
||||
'sidebar' => 'inc/category-sidebar.tpl',
|
||||
|
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* Home page for extensions, switchable on application.
|
||||
* Home page for themes, switchable on application. Since v1 used GUIDs, the
|
||||
* flow on this page is a little confusing (we need to support both name and GUID.
|
||||
*
|
||||
* @package amo
|
||||
* @subpackage docs
|
||||
@ -11,11 +12,10 @@ $currentTab = 'themes';
|
||||
startProcessing('themes.tpl', 'themes', $compileId);
|
||||
require_once('includes.php');
|
||||
|
||||
// If app is not set or empty, set it to null for our switch.
|
||||
$_GET['app'] = (!empty($_GET['app'])) ? $_GET['app'] : null;
|
||||
$_app = array_key_exists('app', $_GET) ? $_GET['app'] : null;
|
||||
|
||||
// Determine our application.
|
||||
switch( $_GET['app'] ) {
|
||||
switch( $_app ) {
|
||||
case 'mozilla':
|
||||
$clean['app'] = 'Mozilla';
|
||||
break;
|
||||
@ -28,17 +28,22 @@ switch( $_GET['app'] ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// $sql['app'] can equal $clean['app'] since it was assigned in a switch().
|
||||
// We have to ucfirst() it because the DB has caps.
|
||||
$sql['app'] = $clean['app'];
|
||||
|
||||
$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);
|
||||
} else {
|
||||
$newestThemes = $amo->getNewestAddons($clean['app'],'T',10);
|
||||
$popularThemes = $amo->getPopularAddons($clean['app'],'T',10);
|
||||
}
|
||||
|
||||
// Assign template variables.
|
||||
$tpl->assign(
|
||||
array( 'newestThemes' => $amo->getNewestAddons($sql['app'],'T',10),
|
||||
'popularThemes' => $amo->getPopularAddons($sql['app'],'T',10),
|
||||
'title' => $clean['app'].' Addons',
|
||||
array( 'newestThemes' => $newestThemes,
|
||||
'popularThemes' => $popularThemes,
|
||||
'title' => 'Addons',
|
||||
'currentTab' => $currentTab,
|
||||
'content' => 'themes.tpl',
|
||||
'sidebar' => 'inc/category-sidebar.tpl',
|
||||
|
@ -179,6 +179,56 @@ class AMO_Object
|
||||
return $this->db->record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get newest addons from GUID - this is for backwards compatibility with v1
|
||||
*
|
||||
* @param string $GUID
|
||||
* @param string $type
|
||||
* @param int $limit
|
||||
* @return array
|
||||
*/
|
||||
function getNewestAddonsByGuid($app='',$type='E',$limit=10) {
|
||||
|
||||
if(empty($app)) {
|
||||
return false;
|
||||
}
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// I realize we are running this through a regex, but this doesn't hurt.
|
||||
$app = mysql_real_escape_string($app);
|
||||
|
||||
// Get most popular extensions based on application.
|
||||
$this->db->query("
|
||||
SELECT
|
||||
m.ID ID,
|
||||
m.Name name,
|
||||
m.downloadcount dc,
|
||||
v.DateUpdated as dateupdated,
|
||||
v.version
|
||||
FROM
|
||||
main m
|
||||
INNER JOIN version v ON m.id = v.id
|
||||
INNER JOIN (
|
||||
SELECT v.id, v.appid, v.osid, max(v.vid) as mxvid
|
||||
FROM version v
|
||||
WHERE approved = 'YES' group by v.id, v.appid, v.osid) as vv
|
||||
ON vv.mxvid = v.vid AND vv.id = v.id
|
||||
INNER JOIN applications a ON a.appid = v.appid
|
||||
WHERE
|
||||
v.approved = 'yes' AND
|
||||
a.GUID = '{$app}' AND
|
||||
m.type = '{$type}'
|
||||
ORDER BY
|
||||
v.dateupdated DESC , downloadcount DESC, rating DESC
|
||||
LIMIT
|
||||
{$limit}
|
||||
", SQL_ALL, SQL_ASSOC);
|
||||
|
||||
return $this->db->record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get most popular addons.
|
||||
*
|
||||
@ -218,6 +268,56 @@ class AMO_Object
|
||||
return $this->db->record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get most popular addons from GUID - this is for backwards compatibility with
|
||||
* v1
|
||||
*
|
||||
* @param string $GUID
|
||||
* @param string $type
|
||||
* @param int $limit
|
||||
* @return array
|
||||
*/
|
||||
function getPopularAddonsByGuid($app='',$type='E', $limit=10) {
|
||||
|
||||
if(empty($app)) {
|
||||
return false;
|
||||
}
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// I realize we are running this through a regex, but this doesn't hurt.
|
||||
$app = mysql_real_escape_string($app);
|
||||
|
||||
// Return most popular addons.
|
||||
$this->db->query("
|
||||
SELECT
|
||||
m.ID ID,
|
||||
m.Name name,
|
||||
m.downloadcount dc,
|
||||
v.DateUpdated as dateupdated
|
||||
FROM
|
||||
main m
|
||||
INNER JOIN version v ON m.id = v.id
|
||||
INNER JOIN (
|
||||
SELECT v.id, v.appid, v.osid, max(v.vid) as mxvid
|
||||
FROM version v
|
||||
WHERE approved = 'YES' group by v.id, v.appid, v.osid) as vv
|
||||
ON vv.mxvid = v.vid AND vv.id = v.id
|
||||
INNER JOIN applications a ON a.appid = v.appid
|
||||
WHERE
|
||||
v.approved = 'yes' AND
|
||||
a.GUID = '{$app}' AND
|
||||
m.type = '{$type}'
|
||||
ORDER BY
|
||||
m.downloadcount DESC, m.rating DESC, v.dateupdated DESC
|
||||
LIMIT
|
||||
{$limit}
|
||||
", SQL_ALL, SQL_ASSOC);
|
||||
|
||||
return $this->db->record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get recommended addons.
|
||||
*
|
||||
@ -266,6 +366,64 @@ class AMO_Object
|
||||
return $this->db->record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get recommended addons by GUID - for backwards compatibility with v1.
|
||||
*
|
||||
* @param string $app
|
||||
* @param string $type
|
||||
* @param int $limit
|
||||
* @return array
|
||||
*/
|
||||
function getRecommendedAddonsByGuid($app='',$type='E', $limit=10) {
|
||||
|
||||
if(empty($app)) {
|
||||
return false;
|
||||
}
|
||||
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)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// I realize we are running this through a regex, but this doesn't hurt.
|
||||
$app = mysql_real_escape_string($app);
|
||||
|
||||
// Return most popular addons.
|
||||
$this->db->query("
|
||||
SELECT DISTINCT
|
||||
m.id,
|
||||
m.name,
|
||||
m.downloadcount,
|
||||
v.dateupdated,
|
||||
v.uri,
|
||||
r.body,
|
||||
r.title,
|
||||
v.size,
|
||||
v.version,
|
||||
p.previewuri
|
||||
FROM
|
||||
main m
|
||||
INNER JOIN version v ON m.ID = v.ID
|
||||
INNER JOIN applications TA ON v.AppID = TA.AppID
|
||||
INNER JOIN os o ON v.OSID = o.OSID
|
||||
INNER JOIN reviews r ON m.ID = r.ID
|
||||
INNER JOIN previews p ON p.ID = m.ID
|
||||
WHERE
|
||||
TA.GUID = '{$app}' AND
|
||||
downloadcount > '0' AND
|
||||
approved = 'YES' AND
|
||||
Type = '{$type}' AND
|
||||
r.featured = 'YES' AND
|
||||
p.preview = 'YES'
|
||||
GROUP BY
|
||||
m.ID
|
||||
ORDER BY
|
||||
m.Name
|
||||
LIMIT
|
||||
{$limit}
|
||||
", SQL_ALL, SQL_ASSOC);
|
||||
|
||||
return $this->db->record;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get feature for front page.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user