diff --git a/mozilla/webtools/addons/.htaccess b/mozilla/webtools/addons/.htaccess index 5c04818810b..4a8418b7b91 100644 --- a/mozilla/webtools/addons/.htaccess +++ b/mozilla/webtools/addons/.htaccess @@ -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 diff --git a/mozilla/webtools/addons/addon.php b/mozilla/webtools/addons/addon.php new file mode 100644 index 00000000000..1f8ca2d064e --- /dev/null +++ b/mozilla/webtools/addons/addon.php @@ -0,0 +1,5 @@ +getAddOn(10)); +$foo->finish(); +?> diff --git a/mozilla/webtools/addons/developers/index.php b/mozilla/webtools/addons/developers/index.php index 1a02afa2b6e..0607f06d372 100644 --- a/mozilla/webtools/addons/developers/index.php +++ b/mozilla/webtools/addons/developers/index.php @@ -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'; diff --git a/mozilla/webtools/addons/faq.php b/mozilla/webtools/addons/faq.php index 92fdf26a2c5..98dcaf3acc1 100644 --- a/mozilla/webtools/addons/faq.php +++ b/mozilla/webtools/addons/faq.php @@ -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', diff --git a/mozilla/webtools/addons/inc/finish.php b/mozilla/webtools/addons/inc/finish.php index 6e0bd21a541..ae5e8abd718 100644 --- a/mozilla/webtools/addons/inc/finish.php +++ b/mozilla/webtools/addons/inc/finish.php @@ -1,12 +1,13 @@ 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); diff --git a/mozilla/webtools/addons/inc/init.php b/mozilla/webtools/addons/inc/init.php index 13686ce8fad..6f829a68782 100644 --- a/mozilla/webtools/addons/inc/init.php +++ b/mozilla/webtools/addons/inc/init.php @@ -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(); ?> diff --git a/mozilla/webtools/addons/index.php b/mozilla/webtools/addons/index.php index 7bdd39ad709..1d51168ae42 100644 --- a/mozilla/webtools/addons/index.php +++ b/mozilla/webtools/addons/index.php @@ -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'; ?> diff --git a/mozilla/webtools/addons/item.php b/mozilla/webtools/addons/item.php deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/mozilla/webtools/addons/lib/addon.class.php b/mozilla/webtools/addons/lib/addon.class.php index e69de29bb2d..190312d28e2 100644 --- a/mozilla/webtools/addons/lib/addon.class.php +++ b/mozilla/webtools/addons/lib/addon.class.php @@ -0,0 +1,42 @@ +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; + } +} diff --git a/mozilla/webtools/addons/lib/amo.class.php b/mozilla/webtools/addons/lib/amo.class.php new file mode 100644 index 00000000000..55fec0a7c6f --- /dev/null +++ b/mozilla/webtools/addons/lib/amo.class.php @@ -0,0 +1,41 @@ +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); + } +} diff --git a/mozilla/webtools/addons/lib/sql.class.php b/mozilla/webtools/addons/lib/sql.class.php index 34687d03566..360ca9195ff 100644 --- a/mozilla/webtools/addons/lib/sql.class.php +++ b/mozilla/webtools/addons/lib/sql.class.php @@ -106,6 +106,5 @@ class SQL { } } - } ?> diff --git a/mozilla/webtools/addons/tpl/inc/header.tpl b/mozilla/webtools/addons/tpl/inc/header.tpl index 58567cf3cab..acb57b60b01 100644 --- a/mozilla/webtools/addons/tpl/inc/header.tpl +++ b/mozilla/webtools/addons/tpl/inc/header.tpl @@ -11,7 +11,7 @@ - + @@ -55,17 +55,17 @@
 
diff --git a/mozilla/webtools/addons/tpl/index.tpl b/mozilla/webtools/addons/tpl/index.tpl index 65bd99d2a99..e63f49b8a44 100644 --- a/mozilla/webtools/addons/tpl/index.tpl +++ b/mozilla/webtools/addons/tpl/index.tpl @@ -28,7 +28,7 @@ New graphics and colors. Browse themes for:
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: -Mozilla Suite & Firefox +Mozilla Suite & Firefox
@@ -38,21 +38,21 @@ RealPlayer, and Java. Browse plug-ins for:

Popular Extensions

    {section name=pe loop=$popularExtensions} -
  1. {$popularExtensions[pe].name} ({$popularExtensions[pe].dc} downloads)
  2. +
  3. {$popularExtensions[pe].name} ({$popularExtensions[pe].dc} downloads)
  4. {/section}

Popular Themes

    {section name=pt loop=$popularThemes} -
  1. {$popularThemes[pt].name} ({$popularThemes[pt].dc} downloads)
  2. +
  3. {$popularThemes[pt].name} ({$popularThemes[pt].dc} downloads)
  4. {/section}

Newest Addons

    {section name=new loop=$newest} -
  1. {$newest[new].Name} {$newest[new].Version} ({$newest[new].DateAdded|date_format})
  2. +
  3. {$newest[new].Name} {$newest[new].Version} ({$newest[new].DateAdded|date_format})
  4. {/section}