.htaccess
added comments and config line for include_path, which is important for install
inc/finish.php, inc/init.php
adjusted how globals were set up
tried working with non-global db/tpl but it was not scalable so it was switched back
faq.php, index.php, developers/index.php
smarty -> tpl
lib/addon.class.php
proper constructor now in place
lib/amo.class.php
object definition for all basic objects
sets up tpl,db globals for use in all extending classes
addon.php
home page for an addon
item.php
too generic, nuked it
git-svn-id: svn://10.0.0.236/trunk@176188 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -4,5 +4,5 @@ php_value include_path /home/morgamic/public_html/v2/inc:.:/usr/share/pear
|
||||
# Init script to set up required libraries.
|
||||
php_value auto_prepend_file init.php
|
||||
|
||||
# Finish script closes connections and begins output.
|
||||
# Finish script that calls $tpl->display for global Smarty object.
|
||||
php_value auto_append_file finish.php
|
||||
|
||||
5
mozilla/webtools/addons/addon.php
Normal file
5
mozilla/webtools/addons/addon.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$foo = new AddOn();
|
||||
print_r($foo->getAddOn(10));
|
||||
$foo->finish();
|
||||
?>
|
||||
@@ -5,7 +5,7 @@
|
||||
* @subpackage docs
|
||||
*/
|
||||
// Assign content template.
|
||||
$smarty->assign('content','developers/index.tpl');
|
||||
$tpl->assign('content','developers/index.tpl');
|
||||
|
||||
// Set custom wrapper for this page.
|
||||
$wrapper = 'inc/wrappers/nonav.tpl';
|
||||
|
||||
@@ -34,7 +34,7 @@ $links = array(
|
||||
);
|
||||
|
||||
// Send FAQ data to Smarty object.
|
||||
$smarty->assign(
|
||||
$tpl->assign(
|
||||
array( 'faq' => $faq,
|
||||
'links' => $links,
|
||||
'sidebar' => 'inc/nav.tpl',
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<?php
|
||||
// Close database connection.
|
||||
/**
|
||||
* Finish script.
|
||||
*/
|
||||
|
||||
// Disconnect from our database.
|
||||
$db->disconnect();
|
||||
|
||||
// If our $wrapper var is not set, fallback to default.
|
||||
if (!isset($wrapper)) {
|
||||
$wrapper = 'inc/wrappers/default.tpl';
|
||||
}
|
||||
// Set our wrapper if it has not been set.
|
||||
$wrapper = (!isset($wrapper)) ? 'inc/wrappers/nonav.tpl' : $wrapper;
|
||||
|
||||
// Display output.
|
||||
$smarty->display($wrapper);
|
||||
?>
|
||||
$tpl->display($wrapper);
|
||||
|
||||
@@ -11,6 +11,7 @@ ini_set('magic_quotes_gpc',0);
|
||||
// Include required libraries and classes.
|
||||
require_once('DB.php');
|
||||
require_once(LIB.'/smarty/libs/Smarty.class.php');
|
||||
require_once(LIB.'/amo.class.php');
|
||||
require_once(LIB.'/addon.class.php');
|
||||
require_once(LIB.'/auth.class.php');
|
||||
require_once(LIB.'/rdf.class.php');
|
||||
@@ -20,45 +21,45 @@ require_once(LIB.'/sql.class.php');
|
||||
require_once(LIB.'/user.class.php');
|
||||
require_once(LIB.'/version.class.php');
|
||||
|
||||
// Instantiate Smarty class.
|
||||
$smarty = new Smarty();
|
||||
// Smarty configuration.
|
||||
class AMO_Smarty extends Smarty
|
||||
{
|
||||
function AMO_Smarty()
|
||||
{
|
||||
$this->template_dir = TEMPLATE_DIR;
|
||||
$this->compile_dir = COMPILE_DIR;
|
||||
$this->cache_dir = CACHE_DIR;
|
||||
$this->config_dir = CONFIG_DIR;
|
||||
|
||||
// Set up smarty.
|
||||
$smarty->template_dir = TEMPLATE_DIR;
|
||||
$smarty->compile_dir = COMPILE_DIR;
|
||||
$smarty->cache_dir = CACHE_DIR;
|
||||
$smarty->config_dir = CONFIG_DIR;
|
||||
|
||||
// Pass config variables to Smarty object.
|
||||
$smarty->assign('config',
|
||||
array( 'webpath' => WEB_PATH,
|
||||
'rootpath' => ROOT_PATH,
|
||||
'repo' => REPO_DIR)
|
||||
);
|
||||
|
||||
// Instantiate SQL class.
|
||||
$db = new SQL();
|
||||
|
||||
// Define PEAR options.
|
||||
$dsn = array (
|
||||
'phptype' => 'mysql',
|
||||
'dbsyntax' => 'mysql',
|
||||
'username' => DB_USER,
|
||||
'password' => DB_PASS,
|
||||
'hostspec' => DB_HOST,
|
||||
'database' => DB_NAME
|
||||
);
|
||||
|
||||
// Try to connect. If we do not connect, show standard 'gone fishing' error page.
|
||||
if (!$db->connect($dsn)) {
|
||||
$wrapper = 'inc/wrappers/nonav.tpl';
|
||||
$smarty->assign(
|
||||
array(
|
||||
'content'=>'site-down.tpl',
|
||||
'error'=>$db->error
|
||||
)
|
||||
);
|
||||
$smarty->display($wrapper);
|
||||
exit;
|
||||
// Pass config variables to Smarty object.
|
||||
$this->assign('config',
|
||||
array( 'webpath' => WEB_PATH,
|
||||
'rootpath' => ROOT_PATH,
|
||||
'repo' => REPO_DIR)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Database configuration.
|
||||
class AMO_SQL extends SQL
|
||||
{
|
||||
function AMO_SQL()
|
||||
{
|
||||
$dsn = array (
|
||||
'phptype' => 'mysql',
|
||||
'dbsyntax' => 'mysql',
|
||||
'username' => DB_USER,
|
||||
'password' => DB_PASS,
|
||||
'hostspec' => DB_HOST,
|
||||
'database' => DB_NAME
|
||||
);
|
||||
$this->connect($dsn);
|
||||
}
|
||||
}
|
||||
|
||||
// Global template object.
|
||||
$tpl = new AMO_Smarty();
|
||||
|
||||
// Global DB object.
|
||||
$db = new AMO_SQL();
|
||||
?>
|
||||
|
||||
@@ -74,13 +74,10 @@ $db->query("
|
||||
$newest = $db->record;
|
||||
|
||||
// Assign template variables.
|
||||
$smarty->assign(
|
||||
$tpl->assign(
|
||||
array( 'popularExtensions' => $popularExtensions,
|
||||
'popularThemes' => $popularThemes,
|
||||
'newest' => $newest,
|
||||
'content' => 'index.tpl')
|
||||
);
|
||||
|
||||
// Set custom wrapper for this page.
|
||||
$wrapper = 'inc/wrappers/nonav.tpl';
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* Addon super class. The class to end all classes.
|
||||
* @package amo
|
||||
* @subpackage lib
|
||||
*/
|
||||
class AddOn extends AMO_Object
|
||||
{
|
||||
var $ID;
|
||||
var $GUID;
|
||||
var $Name;
|
||||
var $Type;
|
||||
var $DateAdded;
|
||||
var $DateUpdated;
|
||||
var $Homepage;
|
||||
var $Description;
|
||||
var $Rating;
|
||||
var $downloadcount;
|
||||
var $TotalDownloads;
|
||||
var $devcomments;
|
||||
var $db;
|
||||
var $tpl;
|
||||
|
||||
/**
|
||||
* Class constructor.
|
||||
*/
|
||||
function AddOn()
|
||||
{
|
||||
// Our DB and Smarty objects are global to save cycles.
|
||||
global $db, $tpl;
|
||||
|
||||
// Pass by reference in order to save memory.
|
||||
$this->db =& $db;
|
||||
$this->tpl =& $tpl;
|
||||
}
|
||||
|
||||
function getAddOn($ID)
|
||||
{
|
||||
$this->db->query("SELECT * FROM main WHERE ID = '{$ID}'", SQL_ALL, SQL_ASSOC);
|
||||
return $this->db->record;
|
||||
}
|
||||
}
|
||||
|
||||
41
mozilla/webtools/addons/lib/amo.class.php
Normal file
41
mozilla/webtools/addons/lib/amo.class.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* AMO master class. This class contains global application logic.
|
||||
*/
|
||||
class AMO_Object
|
||||
{
|
||||
var $wrapper;
|
||||
|
||||
function AMO_Object()
|
||||
{
|
||||
// Our DB and Smarty objects are global to save cycles.
|
||||
global $db, $tpl;
|
||||
|
||||
// Pass by reference in order to save memory.
|
||||
$this->db =& $db;
|
||||
$this->tpl =& $tpl;
|
||||
|
||||
// Default wrapper for AMO template.
|
||||
$this->wrapper = 'inc/wrappers/default.tpl';
|
||||
|
||||
if (DB::isError($this->db)) {
|
||||
$this->tpl->assign(
|
||||
array(
|
||||
'content'=>'site-down.tpl',
|
||||
'error'=>$this->db->error
|
||||
)
|
||||
);
|
||||
$this->tpl->display($this->wrapper);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Close database connection and display output.
|
||||
*/
|
||||
function finish()
|
||||
{
|
||||
$this->db->disconnect();
|
||||
$this->tpl->display($this->wrapper);
|
||||
}
|
||||
}
|
||||
@@ -106,6 +106,5 @@ class SQL {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
<link rel="stylesheet" type="text/css" href="{$config.webpath}/css/base/template.css" media="screen">
|
||||
<link rel="stylesheet" type="text/css" href="{$config.webpath}/css/cavendish/template.css" title="Cavendish" media="screen">
|
||||
<link rel="home" title="Home" href="https://addons.mozilla.org/">
|
||||
<link rel="alternate" type="application/rss+xml" title="New Firefox Extensions Additions" href="../rss/?application=firefox&type=E&list=newest">
|
||||
<link rel="alternate" type="application/rss+xml" title="New Firefox Extensions Additions" href="../rss/?app=firefox&type=E&list=newest">
|
||||
<link rel="icon" href="/favicon.ico" type="image/png">
|
||||
</head>
|
||||
|
||||
@@ -55,17 +55,17 @@
|
||||
<div id="key-menu">
|
||||
<dl id="menu-firefox">
|
||||
<dt>Firefox:</dt>
|
||||
<dd><a href="{$config.webpath}/overview.php?application=firefox&type=E" title="Get Extensions for the Firefox Browser">Extensions</a>, <a href="{$config.webpath}/overview.php?application=firefox&type=T" title="Get Themes for the Firefox Browser">Themes</a>, <a href="{$config.webpath}/plugins/" title="Get Plugins for Firefox">Plugins</a></dd>
|
||||
<dd><a href="{$config.webpath}/overview.php?app=firefox&type=E" title="Get Extensions for the Firefox Browser">Extensions</a>, <a href="{$config.webpath}/overview.php?app=firefox&type=T" title="Get Themes for the Firefox Browser">Themes</a>, <a href="https://pfs.mozilla.org/plugins/" title="Get Plugins for Firefox">Plugins</a></dd>
|
||||
|
||||
</dl>
|
||||
<dl id="menu-thunderbird">
|
||||
<dt>Thunderbird:</dt>
|
||||
<dd><a href="{$config.webpath}/overview.php?application=thunderbird&type=T" title="Get Extensions for Thunderbird Email">Extensions</a>, <a href="{$config.webpath}/overview.php?application=thunderbird&type=T" title="Get Themes for Thunderbird Email">Themes</a></dd>
|
||||
<dd><a href="{$config.webpath}/overview.php?app=thunderbird&type=T" title="Get Extensions for Thunderbird Email">Extensions</a>, <a href="{$config.webpath}/overview.php?app=thunderbird&type=T" title="Get Themes for Thunderbird Email">Themes</a></dd>
|
||||
</dl>
|
||||
<dl id="menu-mozillasuite">
|
||||
<dt>Mozilla Suite:</dt>
|
||||
|
||||
<dd><a href="{$config.webpath}/overview.php?application=mozilla&type=E" title="Get Extensions for the Mozilla Suite">Extensions</a>, <a href="{$config.webpath}/overview.php?application=mozilla&type=T" title="Get Themes for the Mozilla Suite">Themes</a>, <a href="{$config.webpath}/plugins/" title="Get Plugins for Mozilla Suite">Plugins</a></dd>
|
||||
<dd><a href="{$config.webpath}/overview.php?app=mozilla&type=E" title="Get Extensions for the Mozilla Suite">Extensions</a>, <a href="{$config.webpath}/overview.php?app=mozilla&type=T" title="Get Themes for the Mozilla Suite">Themes</a>, <a href="https://pfs.mozilla.org/plugins/" title="Get Plugins for Mozilla Suite">Plugins</a></dd>
|
||||
</dl>
|
||||
<div class="ie-clear-menu"> </div>
|
||||
</div>
|
||||
|
||||
@@ -28,7 +28,7 @@ New graphics and colors. Browse themes for:
|
||||
<dd>Plugins are programs that allow websites to provide content to
|
||||
you and have it appear in your browser. Examples of Plugins are Flash,
|
||||
RealPlayer, and Java. Browse plug-ins for:
|
||||
<a href="./plugins/">Mozilla Suite & Firefox</a>
|
||||
<a href="https://pfs.mozilla.org/plugins/">Mozilla Suite & Firefox</a>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
@@ -38,21 +38,21 @@ RealPlayer, and Java. Browse plug-ins for:
|
||||
<h2>Popular Extensions</h2>
|
||||
<ol class="popularlist">
|
||||
{section name=pe loop=$popularExtensions}
|
||||
<li><a href="./item.php?id={$popularExtensions[pe].id}">{$popularExtensions[pe].name}</a> <span class="downloads">({$popularExtensions[pe].dc} downloads)</span></li>
|
||||
<li><a href="./addon.php?id={$popularExtensions[pe].id}">{$popularExtensions[pe].name}</a> <span class="downloads">({$popularExtensions[pe].dc} downloads)</span></li>
|
||||
{/section}
|
||||
</ol>
|
||||
|
||||
<h2>Popular Themes</h2>
|
||||
<ol class="popularlist">
|
||||
{section name=pt loop=$popularThemes}
|
||||
<li><a href="./item.php?id={$popularThemes[pt].id}">{$popularThemes[pt].name}</a> <span class="downloads">({$popularThemes[pt].dc} downloads)</span></li>
|
||||
<li><a href="./addon.php?id={$popularThemes[pt].id}">{$popularThemes[pt].name}</a> <span class="downloads">({$popularThemes[pt].dc} downloads)</span></li>
|
||||
{/section}
|
||||
</ol>
|
||||
|
||||
<h2>Newest Addons</h2>
|
||||
<ol class="popularlist">
|
||||
{section name=new loop=$newest}
|
||||
<li><a href="./item.php?id={$newest[new].ID}">{$newest[new].Name} {$newest[new].Version}</a> ({$newest[new].DateAdded|date_format})</li>
|
||||
<li><a href="./addon.php?id={$newest[new].ID}">{$newest[new].Name} {$newest[new].Version}</a> ({$newest[new].DateAdded|date_format})</li>
|
||||
{/section}
|
||||
</ol>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user