From 709c1a80a6000a1d548ccd01133c236de4a24045 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sun, 23 Jun 2013 19:06:46 -0700 Subject: [PATCH] Download plugin clean-up mostly complete. (cache still needs to be done) --- e107_handlers/shortcode_handler.php | 4 +- e107_plugins/download/download.php | 698 ++---------------- e107_plugins/download/download_shortcodes.php | 629 +++++++++------- .../download/handlers/download_class.php | 349 ++++++--- .../download/templates/download_template.php | 14 +- 5 files changed, 626 insertions(+), 1068 deletions(-) diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index f942e4705..34ab60925 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -1247,11 +1247,11 @@ class e_shortcode /** * Set external array data to be used in the batch * Use setVars() - preferred. - * + * //XXX will soon become private. Use setVars() instead. * @param array $eVars * @return e_shortcode */ - public function setParserVars($eVars) //XXX will soon become private. Use setVars() instead. + public function setParserVars($eVars) { $this->var = $eVars; return $this; diff --git a/e107_plugins/download/download.php b/e107_plugins/download/download.php index 0542bd931..77f818a8a 100644 --- a/e107_plugins/download/download.php +++ b/e107_plugins/download/download.php @@ -2,16 +2,10 @@ /* * e107 website system * - * Copyright (C) 2008-2009 e107 Inc (e107.org) + * Copyright (C) 2008-2013 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * - * - * - * $Source: /cvs_backup/e107_0.8/e107_plugins/download/download.php,v $ - * $Revision$ - * $Date$ - * $Author$ */ if (!defined('e107_INIT')) @@ -24,664 +18,60 @@ if (!e107::isInstalled('download')) header("location:".e_BASE."index.php"); } -include_lan(e_PLUGIN.'download/languages/'.e_LANGUAGE.'/download.php'); -require_once(e_PLUGIN.'download/handlers/download_class.php'); -require_once(e_PLUGIN.'download/handlers/category_class.php'); -require_once(e_PLUGIN.'download/download_shortcodes.php'); -require_once(e_HANDLER.'comment_class.php'); - -$dl = new download(); -$cobj = new comment(); -$dl_text = ''; // Output variable - -if(!defined("USER_WIDTH")) { define("USER_WIDTH","width:100%"); } - -/* define images */ -define("IMAGE_DOWNLOAD", (file_exists(THEME."images/download.png") ? THEME."images/download.png" : e_IMAGE."generic/download.png")); -define("IMAGE_NEW", (file_exists(THEME."images/new.png") ? THEME."images/new.png" : e_IMAGE."generic/new.png")); - -$template_load_core = ' - $template_name = $load_template.".php"; - if (is_readable(THEME."templates/".$template_name)) - { - require_once(THEME."templates/".$template_name); - } - elseif (is_readable(THEME.$template_name)) - { - require_once(THEME.$template_name); - } - else - { - require_once(e_PLUGIN."download/templates/".$template_name); - } -'; - -$order_options = array('download_id','download_datestamp','download_requested','download_name','download_author','download_requested'); -$sort_options = array('ASC', 'DESC'); - -if (!e_QUERY || $_GET['elan']) -{ - $action = 'maincats'; // List categories - $maincatval = ''; // Show all main categories -} -else -{ // Get parameters from the query - $maincatval = ''; // Show all main categories - $tmp = explode(".", e_QUERY); - - $dl->init(); - - if(isset($_GET['action'])) // v2.x - { - $dl->init(); - $action = $_GET['action']; - $id = intval($_GET['id']); - } - elseif (is_numeric($tmp[0])) //legacy // $tmp[0] at least must be valid - { - $dl_from = intval($tmp[0]); - $action = varset(preg_replace("#\W#", "", $tp->toDB($tmp[1])),'list'); - $id = intval($tmp[2]); - $view = intval($tmp[3]); - $order = preg_replace("#\W#", "", $tp->toDB($tmp[4])); - $sort = preg_replace("#\W#", "", $tp->toDB($tmp[5])); - } - else - { - $action = preg_replace("#\W#", "", $tp->toDB($tmp[0])); - $id = intval($tmp[1]); - $errnum = intval(varset($tmp[2],0)); - } - - - - switch ($action) - { - case 'list' : // Category-based listing - - - if (isset($_GET['view'])) - { - // $view = intval($_GET['view']); - // $sort = varset($_GET['sort'],'DESC'); - // $order = varset($_POST['order']) ? 'download_'.$_POST['order'] : 'download_datestamp'; - - // $order = preg_replace("#\W#", "", $order); - // $sort = preg_replace("#\W#", "", $sort); - - - } - - if (!isset($dl_from)) $dl_from = 0; - - // Get category type, page title - if ($sql->db_Select("download_category", "download_category_name,download_category_description,download_category_parent,download_category_class", "(download_category_id='{$id}') AND (download_category_class IN (".USERCLASS_LIST."))") ) - { - $dlrow = $sql->db_Fetch(); - extract($dlrow); - $type = $download_category_name; - define("e_PAGETITLE", PAGE_NAME." / ".$download_category_name); - } - else - { // No access to this category - define("e_PAGETITLE", PAGE_NAME); - require_once(HEADERF); - $ns->tablerender(LAN_dl_18, "
".LAN_dl_3."
"); - require_once(FOOTERF); - exit; - } - if ($download_category_parent == 0) - { // It's a main category - change the listing type required - $action = 'maincats'; - $maincatval = $id; - } - break; - case 'view' : // Details of individual download - break; - case 'report' : - break; - case 'mirror' : - break; - case 'error' : // Errors passed from request.php - define("e_PAGETITLE", PAGE_NAME); - require_once(HEADERF); - switch ($errnum) - { - case 1 : // No permissions - if (strlen($pref['download_denied']) > 0) { - $errmsg = $tp->toHTML($pref['download_denied'],true); - } else { - $errmsg = LAN_dl_63; - } - break; - case 2 : // Quota exceeded - $errmsg = LAN_dl_62; - break; - default: - $errmsg = LAN_dl_61." ".$errnum; // Generic error - shouldn't happen - } - $ns->tablerender(LAN_dl_61, "
".$errmsg."
"); - require_once(FOOTERF); - exit; - } -} - -/* -if (isset($order) && !in_array($order,$order_options)) unset($order); -if (isset($sort) && !in_array($sort,$sort_options)) unset($sort); -if (!isset($order)) $order = vartrue($pref['download_order'],'download_datestamp'); -if (!isset($sort)) $sort = vartrue($pref['download_sort'], 'DESC'); -if (!isset($view)) $view = vartrue($pref['download_view'], '10'); -*/ - -//-------------------------------------------------- -// GENERATE DISPLAY TEXT -//-------------------------------------------------- -switch ($action) -{ // Displaying main category or categories - case 'maincats' : - // require_once(HEADERF); - /* - if ($cacheData = $e107cache->retrieve("download_cat".$maincatval,720)) // expires every 12 hours. //TODO make this an option - { - echo $cacheData; - require_once(FOOTERF); - exit; - } - // Load the theme - $load_template = 'download_template'; - if (!isset($DOWNLOAD_CAT_PARENT_TABLE)) eval($template_load_core); - if(!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:1px solid blue");} - // Read in tree of categories which this user is allowed to see - $dlcat = new downloadCategory(varset($pref['download_subsub'],1),USERCLASS_LIST,$maincatval,varset($pref['download_incinfo'],FALSE)); - if ($dlcat->down_count == 0) - { - $ns->tablerender(LAN_dl_18, "
".LAN_dl_2."
"); - require_once(FOOTERF); - exit; - } - $download_cat_table_string = ""; - foreach($dlcat->cat_tree as $dlrow) - { // Display main category headings, then sub-categories, optionally with sub-sub categories expanded - $download_cat_table_string .= $tp->parseTemplate($DOWNLOAD_CAT_PARENT_TABLE, TRUE, vartrue($download_shortcodes)); - foreach($dlrow['subcats'] as $dlsubrow) - { - $download_cat_table_string .= $tp->parseTemplate($DOWNLOAD_CAT_CHILD_TABLE, TRUE, $download_shortcodes); - foreach($dlsubrow['subsubcats'] as $dlsubsubrow) - { - $download_cat_table_string .= $tp->parseTemplate($DOWNLOAD_CAT_SUBSUB_TABLE, TRUE, $download_shortcodes); - } - } - } - $dl_text = $tp->parseTemplate($DOWNLOAD_CAT_TABLE_START, TRUE, $download_shortcodes); - $dl_text .= $download_cat_table_string; - $dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_END, TRUE, $download_shortcodes); - $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18)); - $dl_title = $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); - ob_start(); - $ns->tablerender($dl_title, $dl_text); - $cache_data = ob_get_flush(); - $e107cache->set("download_cat".$maincatval, $cache_data);*/ + include_lan(e_PLUGIN.'download/languages/'.e_LANGUAGE.'/download.php'); - // require_once(FOOTERF); - // exit; - // Add other 'cases' here -} // End switch ($action) + require_once(e_PLUGIN.'download/handlers/download_class.php'); + require_once(e_PLUGIN.'download/handlers/category_class.php'); -if (isset($_POST['commentsubmit'])) -{ - if (!$sql->db_Select("download", "download_comment", "download_id = '{$id}' ")) + $dl = new download(); + + + if(!defined("USER_WIDTH")) { define("USER_WIDTH","width:100%"); } + + /* define images */ + + /** @Deprecated **/ + define("IMAGE_DOWNLOAD", (file_exists(THEME."images/download.png") ? THEME."images/download.png" : e_IMAGE."generic/download.png")); + + /** @Deprecated **/ + define("IMAGE_NEW", (file_exists(THEME."images/new.png") ? THEME."images/new.png" : e_IMAGE."generic/new.png")); + + + $dl->init(); + + // Legacy Comment Save. + if (isset($_POST['commentsubmit'])) { - header("location:".e_BASE."index.php"); - exit; - } - else - { - $dlrow = $sql->db_Fetch(); - if ($dlrow['download_comment'] && (ANON === TRUE || USER === TRUE)) + if (!$sql->select("download", "download_comment", "download_id = '{$id}' ")) { - $clean_authorname = $_POST['author_name']; - $clean_comment = $_POST['comment']; - $clean_subject = $_POST['subject']; - - $cobj->enter_comment($clean_authorname, $clean_comment, "download", $id, $pid, $clean_subject); -// $e107cache->clear("comment.download.{$sub_action}"); $sub_action not used here - $e107cache->clear("comment.download"); + header("location:".e_BASE."index.php"); + exit; + } + else + { + $dlrow = $sql->fetch(); + if ($dlrow['download_comment'] && (ANON === TRUE || USER === TRUE)) + { + $clean_authorname = $_POST['author_name']; + $clean_comment = $_POST['comment']; + $clean_subject = $_POST['subject']; + + e107::getComment()->enter_comment($clean_authorname, $clean_comment, "download", $id, $pid, $clean_subject); + // $e107cache->clear("comment.download.{$sub_action}"); $sub_action not used here + $e107cache->clear("comment.download"); + } } } -} + $texts = $dl->render(); // Load before header. - -require_once (HEADERF); - - if($action == 'maincats') - { - $dl->renderCategories(); - } - - if($action == 'list') - { - $dl->renderList(); - } + require_once (HEADERF); - if($action == 'view') - { - $dl->renderView(); - } + echo $texts; + + require_once (FOOTERF); - if ($action == "report" && check_class($pref['download_reportbroken'])) - { - $dl->renderReport(); - } - if($action == 'mirror') - { - $dl->renderMirror(); - } - -require_once (FOOTERF); exit ; - - - - - - - -//==================================================== - //LIST//==================================================== - if($action == "list") - { - - - /* SHOW SUBCATS ... */ - /* - * - * - $total_downloads = $sql->db_Count("download", "(*)", "WHERE download_category = '{$id}' AND download_active > 0 AND download_visible REGEXP '" . e_CLASS_REGEXP . "'"); - - require_once (HEADERF); - - if($sql->db_Select("download_category", "download_category_id", "download_category_parent='{$id}' ")) - { - // there are subcats - display them ... - $qry = " - SELECT dc.*, dc2.download_category_name AS parent_name, dc2.download_category_icon as parent_icon, SUM(d.download_filesize) AS d_size, - COUNT(d.download_id) AS d_count, - MAX(d.download_datestamp) as d_last, - SUM(d.download_requested) as d_requests - FROM #download_category AS dc - LEFT JOIN #download AS d ON dc.download_category_id = d.download_category AND d.download_active > 0 AND d.download_visible IN (" . USERCLASS_LIST . ") - LEFT JOIN #download_category as dc2 ON dc2.download_category_id='{$id}' - WHERE dc.download_category_class IN (" . USERCLASS_LIST . ") AND dc.download_category_parent='{$id}' - GROUP by dc.download_category_id ORDER by dc.download_category_order - "; - - $sql->db_Select_gen($qry); - $scArray = $sql->db_getList(); - $load_template = 'download_template'; - - if(!isset($DOWNLOAD_CAT_PARENT_TABLE)) - { - eval($template_load_core); - } - - if(!defined("DL_IMAGESTYLE")) - { - define("DL_IMAGESTYLE", "border:1px solid blue"); - } - - $download_cat_table_string = ""; - $dl_text = $tp->parseTemplate($DOWNLOAD_CAT_TABLE_PRE, TRUE, $download_shortcodes); - $dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_START, TRUE, $download_shortcodes); - - foreach($scArray as $dlsubsubrow) - { - $dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_SUBSUB_TABLE, TRUE, $download_shortcodes); - } - - $dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_END, TRUE, $download_shortcodes); - - $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18 => e_SELF,$type)); - $dl_title = $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); - - $ns->tablerender($dl_title, $dl_text); - $text = ""; - // If other files, show in a separate block - $dl_title = ""; - // Cancel title once displayed - }// End of subcategory display - - // Now display individual downloads - if(!check_class($download_category_class)) - { - $ns->tablerender(LAN_dl_18, " -
- " . LAN_dl_3 . " -
"); - require_once (FOOTERF); - exit ; - } - if($total_downloads < $view) - { - $dl_from = 0; - } - - $load_template = 'download_template'; - if(!isset($DOWNLOAD_LIST_TABLE)) - eval($template_load_core); - if(!defined("DL_IMAGESTYLE")) - { - define("DL_IMAGESTYLE", "border:1px solid blue"); - } - - require_once (e_HANDLER . "rate_class.php"); - $dltdownloads = 0; - - // $dl_from - first entry to show (note - can get reset due to reuse of query, - // even if values overridden this time) - // $view - number of entries per page - // $total_downloads - total number of entries matching search criteria - $filetotal = $sql->select("download", "*", "download_category='{$id}' AND download_active > 0 AND download_visible IN (" . USERCLASS_LIST . ") ORDER BY {$order} {$sort} LIMIT {$dl_from}, {$view}"); - - if($filetotal) - { - // Only show list if some files in it - $dl_text = $tp->parseTemplate($DOWNLOAD_LIST_TABLE_START, TRUE, $download_shortcodes); - - $dlft = ($filetotal < $view? $filetotal: $view); - while($dlrow = $sql->db_Fetch()) - { - $agreetext = $tp->toHTML($pref['agree_text'], TRUE, 'DESCRIPTION'); - $current_row = ($current_row)? 0: 1; - // Alternating CSS for each row.(backwards compatible) - $template = ($current_row == 1)? $DOWNLOAD_LIST_TABLE: str_replace("forumheader3", "forumheader3 forumheader3_alt", $DOWNLOAD_LIST_TABLE); - $dl_text .= $tp->parseTemplate($template, TRUE, $download_shortcodes); - ; - $dltdownloads += $dlrow['download_requested']; - } - - $dl_text .= $tp->parseTemplate($DOWNLOAD_LIST_TABLE_END, TRUE, $download_shortcodes); - - if($sql->db_Select("download_category", "*", "download_category_id='{$download_category_parent}' ")) - { - $parent = $sql->db_Fetch(); - } - $dlbreadcrumb = $dl->getBreadcrumb(array( - LAN_dl_18 => e_SELF, - $parent['download_category_name'] => e_SELF . "?list." . $parent['download_category_id'], - $type - )); - $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); - $ns->tablerender($dl_title, $dl_text); - } - - if(!isset($DOWNLOAD_LIST_NEXTPREV)) - { - $sc_style['DOWNLOAD_LIST_NEXTPREV']['pre'] = " -
- "; - $sc_style['DOWNLOAD_LIST_NEXTPREV']['post'] = " -
"; - - $DOWNLOAD_LIST_NEXTPREV = " -
- {DOWNLOAD_BACK_TO_CATEGORY_LIST} -
-
- {DOWNLOAD_LIST_NEXTPREV} -
"; - } - - $nextprev_parms = $total_downloads . "," . $view . "," . $dl_from . "," . e_SELF . "?[FROM].list.{$id}.{$view}.{$order}.{$sort}."; - echo $tp->parseTemplate($DOWNLOAD_LIST_NEXTPREV, TRUE, $download_shortcodes); - */ - require_once (FOOTERF); - exit ; - } // end of action=="list" - -//==================================================== -// VIEW -//==================================================== -if ($action == "view") -{ - /* - $gen = new convert; - - $highlight_search = FALSE; - if (isset($_POST['highlight_search'])) { - $highlight_search = TRUE; - } - - $query = " - SELECT d.*, dc.* FROM #download AS d - LEFT JOIN #download_category AS dc ON d.download_category = dc.download_category_id - WHERE d.download_id = {$id} AND d.download_active > 0 - AND d.download_visible IN (".USERCLASS_LIST.") - AND dc.download_category_class IN (".USERCLASS_LIST.") - LIMIT 1"; - - if(!$sql->db_Select_gen($query)){ - require_once(HEADERF); - $ns->tablerender(LAN_dl_18, "
".LAN_dl_3."
"); - require_once(FOOTERF); - exit; - } - - $dlrow = $sql->db_Fetch(); - - $comment_edit_query = 'comment.download.'.$id; - - $load_template = 'download_template'; - if (!isset($DOWNLOAD_VIEW_TABLE)) eval($template_load_core); - if(!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:0px");} - if(!isset($DL_VIEW_PAGETITLE)) - { - $DL_VIEW_PAGETITLE = PAGE_NAME." / {DOWNLOAD_CATEGORY} / {DOWNLOAD_VIEW_NAME}"; - } - - $DL_TITLE = $tp->parseTemplate($DL_VIEW_PAGETITLE, TRUE, $download_shortcodes); - - define("e_PAGETITLE", $DL_TITLE); - - require_once(HEADERF); - $DL_TEMPLATE = $DOWNLOAD_VIEW_TABLE_START.$DOWNLOAD_VIEW_TABLE.$DOWNLOAD_VIEW_TABLE_END; - $text = $tp->parseTemplate($DL_TEMPLATE, TRUE, $download_shortcodes); - - if(!isset($DL_VIEW_NEXTPREV)) - { - $DL_VIEW_NEXTPREV = " -
- - - - - - -
{DOWNLOAD_VIEW_PREV}{DOWNLOAD_BACK_TO_LIST}{DOWNLOAD_VIEW_NEXT}
-
- "; - } - // ------- Next/Prev ----------- - $text .= $tp->parseTemplate($DL_VIEW_NEXTPREV,TRUE,$download_shortcodes); - - $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18=>e_SELF, $dlrow['download_category_name']=>e_SELF."?list.".$dlrow['download_category_id'], $dlrow['download_name'])); - $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); - $ns->tablerender($dl_title, $text); - - unset($text); - - if ($dlrow['download_comment']) { - $cobj->compose_comment("download", "comment", $id, $width,$dlrow['download_name'], $showrate=FALSE); - } - - require_once(FOOTERF); - exit; - */ -} - -//==================================================== -// REPORT BROKEN LINKS -//==================================================== -if ($action == "report" && check_class($pref['download_reportbroken'])) -{ -/* - $query = " - SELECT d.*, dc.* FROM #download AS d - LEFT JOIN #download_category AS dc ON d.download_category = dc.download_category_id - WHERE d.download_id = {$id} - AND download_active > 0 - LIMIT 1"; - - if(!$sql->db_Select_gen($query)) - { - //if (!$sql->db_Select("download", "*", "download_id = {$id} AND download_active > 0")) { - require_once(HEADERF); - require_once(FOOTERF); - exit; - } - - $dlrow = $sql->db_Fetch(); - extract($dlrow); - - if (isset($_POST['report_download'])) { - $report_add = $tp->toDB($_POST['report_add']); - $download_name = $tp->toDB($download_name); - $user = USER ? USERNAME : LAN_dl_52; - - if ($pref['download_email']) { // this needs to be moved into the NOTIFY, with an event. - require_once(e_HANDLER."mail.php"); - $subject = LAN_dl_60." ".SITENAME; - $report = LAN_dl_58." ".SITENAME.":\n".(substr(SITEURL, -1) == "/" ? SITEURL : SITEURL."/")."download.php?view.".$download_id."\n - ".LAN_dl_59." ".$user."\n".$report_add; - sendemail(SITEADMINEMAIL, $subject, $report); - } - - $sql->db_Insert('generic', "0, 'Broken Download', ".time().",'".USERID."', '{$download_name}', {$id}, '{$report_add}'"); - - define("e_PAGETITLE", PAGE_NAME." / ".LAN_dl_47); - require_once(HEADERF); - - $text = LAN_dl_48."

".LAN_dl_49.""; - $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18=>e_SELF, $dlrow['download_category_name']=>e_SELF."?list.".$dlrow['download_category_id'], $dlrow['download_name']=>e_SELF."?view.".$dlrow['download_id'], LAN_dl_50)); - $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); - $ns->tablerender($dl_title, $text); - } else { - define("e_PAGETITLE", PAGE_NAME." / ".LAN_dl_51." ".$download_name); - require_once(HEADERF); - - $text = "
- - - - - - - - - - - - -
- ".LAN_dl_32.": ".$download_name."
- - ".LAN_dl_53." - -
-
".LAN_dl_54."
".LAN_dl_55."
- -

- -
-
"; - $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18=>e_SELF, $dlrow['download_category_name']=>e_SELF."?list.".$dlrow['download_category_id'], $dlrow['download_name']=>e_SELF."?view.".$dlrow['download_id'], LAN_dl_50)); - $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); - $ns->tablerender($dl_title, $text); - }*/ - - require_once(FOOTERF); - exit; -} - -//==================================================== -// MIRRORS -//==================================================== - -//TODO Move into download_class.php - -if($action == "mirror") -{ - //require_once(HEADERF); - -/* - $load_template = 'download_template'; - if (!isset($DOWNLOAD_MIRROR_START)) eval($template_load_core); - - $sql->db_Select("download_mirror"); - $mirrorList = $sql->db_getList("ALL", 0, 200, "mirror_id"); - - $query = " - SELECT d.*, dc.* FROM #download AS d - LEFT JOIN #download_category AS dc ON d.download_category = dc.download_category_id - WHERE d.download_id = {$id} - LIMIT 1"; - - if($sql->db_Select_gen($query)) - { - $dlrow = $sql->db_Fetch(); - $array = explode(chr(1), $dlrow['download_mirror']); - if (2 == varset($pref['mirror_order'])) - { - // Order by name, sort array manually - usort($array, "sort_download_mirror_order"); - } - //elseif (1 == varset($pref['mirror_order'])) - //{ - // // Order by ID - do nothing order is as stored in DB - //} - elseif (0 == varset($pref['mirror_order'], 0)) - { - // Shuffle the mirror list into a random order - $c = count($array); - for ($i=1; $i<$c; $i++) - { - $d = mt_rand(0, $i); - $tmp = $array[$i]; - $array[$i] = $array[$d]; - $array[$d] = $tmp; - } - } - - $dl_text = $tp->parseTemplate($DOWNLOAD_MIRROR_START, TRUE, $download_shortcodes); - $download_mirror = 1; - foreach($array as $mirrorstring) - { - if($mirrorstring) - { - $dlmirrorfile = explode(",", $mirrorstring); - $dlmirror = $mirrorList[$dlmirrorfile[0]]; - $dl_text .= $tp->parseTemplate($DOWNLOAD_MIRROR, TRUE, $download_shortcodes); - } - } - $dl_text .= $tp->parseTemplate($DOWNLOAD_MIRROR_END, TRUE, $download_shortcodes); - $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18=>e_SELF, $dlrow['download_category_name']=>e_SELF."?list.".$dlrow['download_category_id'], $dlrow['download_name']=>e_SELF."?view.".$dlrow['download_id'], LAN_dl_67)); - $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); - $ns->tablerender($dl_title, $dl_text);*/ - - // require_once(FOOTERF); - //} -} - -function sort_download_mirror_order($a, $b) -{ - $a = explode(",", $a); - $b = explode(",", $b); - if ($a[1] == $b[1]) { - return 0; - } - return ($a[1] < $b[1]) ? -1 : 1; -} ?> \ No newline at end of file diff --git a/e107_plugins/download/download_shortcodes.php b/e107_plugins/download/download_shortcodes.php index 5e74f233f..51d8d7003 100644 --- a/e107_plugins/download/download_shortcodes.php +++ b/e107_plugins/download/download_shortcodes.php @@ -15,50 +15,49 @@ */ if (!defined('e107_INIT')) { exit; } -require_once(e_HANDLER.'shortcode_handler.php'); -//register_shortcode('download_shortcodes', true); -//initShortcodeClass('download_shortcodes'); /** * download_shortcodes */ class download_shortcodes extends e_shortcode { - var $e107; - var $postInfo; - var $qry; - + public $qry; + public $dlsubrow; + public $dlsubsubrow; + public $mirror; + /** * download_shortcodes constructor */ function __construct() { - $this->e107 = e107::getInstance(); - $this->postInfo = array(); + } function sc_download_breadcrumb($parm='') { $tp = e107::getParser(); $frm = e107::getForm(); - - global $dlrow; - + $breadcrumb = array(); switch ($this->qry['action']) { case 'mirror': - $breadcrumb[] = array('text' => LAN_dl_18, 'url' => e_SELF); - $breadcrumb[] = array('text' => $dlrow['download_category_name'], 'url' => e_SELF."?action=list&id=".$dlrow['download_category_id']); - $breadcrumb[] = array('text' => $dlrow['download_name'], 'url' => e_SELF."?action=view&id=".$dlrow['download_id']); - $breadcrumb[] = array('text' => LAN_dl_67, 'url' => null); + $breadcrumb[] = array('text' => LAN_dl_18, 'url' => e_SELF); + $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => e_SELF."?action=list&id=".$this->var['download_category_id']); + $breadcrumb[] = array('text' => $this->var['download_name'], 'url' => e_SELF."?action=view&id=".$this->var['download_id']); + $breadcrumb[] = array('text' => LAN_dl_67, 'url' => null); + break; + + case 'maincats': + $breadcrumb[] = array('text' => LAN_dl_18, 'url' => e_SELF); break; default: - $breadcrumb[] = array('text' => LAN_dl_18, 'url' => e_SELF); - $breadcrumb[] = array('text' => $dlrow['download_category_name'], 'url' => e_SELF."?action=list&id=".$dlrow['download_category_id']); - $breadcrumb[] = array('text' => $dlrow['download_name'], 'url' => null); + $breadcrumb[] = array('text' => LAN_dl_18, 'url' => e_SELF); + $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => e_SELF."?action=list&id=".$this->var['download_category_id']); + $breadcrumb[] = array('text' => $this->var['download_name'], 'url' => null); break; } @@ -68,95 +67,109 @@ class download_shortcodes extends e_shortcode // Category ************************************************************************************ - function sc_download_cat_main_name() { - global $tp, $dlrow; - return $tp->toHTML($dlrow['download_category_name'], FALSE, 'TITLE'); + function sc_download_cat_main_name() + { + $tp = e107::getParser(); + return $tp->toHTML($this->var['download_category_name'], FALSE, 'TITLE'); } - function sc_download_cat_main_description() { - global $tp, $dlrow; - return $tp->toHTML($dlrow['download_category_description'], TRUE, 'DESCRIPTION'); + + function sc_download_cat_main_description() + { + $tp = e107::getParser(); + return $tp->toHTML($this->var['download_category_description'], TRUE, 'DESCRIPTION'); } - function sc_download_cat_main_icon() { - global $dlrow; + + function sc_download_cat_main_icon() + { // Pass count as 1 to force non-empty icon - return $this->_sc_cat_icons($dlrow['download_category_icon'], 1, $dlrow['download_category_name']); + return $this->_sc_cat_icons($this->var['download_category_icon'], 1, $this->var['download_category_name']); } + // Sub-Category ******************************************************************************** - function sc_download_cat_sub_name() { - global $tp, $dlsubrow; - if ($dlsubrow['d_count']) + function sc_download_cat_sub_name() + { + $tp = e107::getParser(); + if ($this->dlsubrow['d_count']) { - return "".$tp->toHTML($dlsubrow['download_category_name'], FALSE, 'TITLE').""; + return "".$tp->toHTML($this->dlsubrow['download_category_name'], FALSE, 'TITLE').""; } else { - return $tp->toHTML($dlsubrow['download_category_name'], FALSE, 'TITLE'); + return $tp->toHTML($this->dlsubrow['download_category_name'], FALSE, 'TITLE'); } } - function sc_download_cat_sub_description() { - global $tp, $dlsubrow; - return $tp->toHTML($dlsubrow['download_category_description'], TRUE, 'DESCRIPTION'); + + function sc_download_cat_sub_description() + { + $tp = e107::getParser(); + return $tp->toHTML($this->dlsubrow['download_category_description'], TRUE, 'DESCRIPTION'); } - function sc_download_cat_sub_icon() { - global $dlsubrow; - return $this->_sc_cat_icons($dlsubrow['download_category_icon'], $dlsubrow['d_count'], $dlsubrow['download_category_name']); + + function sc_download_cat_sub_icon() + { + return $this->_sc_cat_icons($this->dlsubrow['download_category_icon'], $this->dlsubrow['d_count'], $this->dlsubrow['download_category_name']); } - function sc_download_cat_sub_new_icon() { - global $dlsubrow; - return $this->_check_new_download($dlsubrow['d_last_subs']); + + function sc_download_cat_sub_new_icon() + { + return $this->_check_new_download($this->dlsubrow['d_last_subs']); } - function sc_download_cat_sub_count() { - global $dlsubrow; - return $dlsubrow['d_count']; + + function sc_download_cat_sub_count() + { + return $this->dlsubrow['d_count']; } - function sc_download_cat_sub_size() { - global $e107, $dlsubrow; - return $this->e107->parseMemorySize($dlsubrow['d_size']); + + function sc_download_cat_sub_size() + { + return eHelper::parseMemorySize($this->dlsubrow['d_size']); } - function sc_download_cat_sub_downloaded() { - global $dlsubrow; - return intval($dlsubrow['d_requests']); + + function sc_download_cat_sub_downloaded() + { + return intval($this->dlsubrow['d_requests']); } // Sub-Sub-Category **************************************************************************** - function sc_download_cat_subsub_name() { - global $tp, $dlsubsubrow; - if ($dlsubsubrow['d_count']) + function sc_download_cat_subsub_name() + { + $tp = e107::getParser(); + if ($this->dlsubsubrow['d_count']) { - return "".$tp->toHTML($dlsubsubrow['download_category_name'], FALSE, 'TITLE').""; + return "".$tp->toHTML($this->dlsubsubrow['download_category_name'], FALSE, 'TITLE').""; } else { - return $tp->toHTML($dlsubsubrow['download_category_name'], FALSE, 'TITLE'); + return $tp->toHTML($this->dlsubsubrow['download_category_name'], FALSE, 'TITLE'); } } - function sc_download_cat_subsub_description() { - global $tp, $dlsubsubrow; - return $tp->toHTML($dlsubsubrow['download_category_description'], TRUE, 'DESCRIPTION'); + function sc_download_cat_subsub_description() + { + return e107::getParser()->toHTML($this->dlsubsubrow['download_category_description'], TRUE, 'DESCRIPTION'); } - function sc_download_cat_subsub_icon() { - global $dlsubsubrow; - return $this->_sc_cat_icons($dlsubsubrow['download_category_icon'], $dlsubsubrow['d_count'], $dlsubsubrow['download_category_name']); + function sc_download_cat_subsub_icon() + { + return $this->_sc_cat_icons($this->dlsubsubrow['download_category_icon'], $this->dlsubsubrow['d_count'], $this->dlsubsubrow['download_category_name']); } - function sc_download_cat_subsub_count() { - global $dlsubsubrow; - return $dlsubsubrow['d_count']; + function sc_download_cat_subsub_count() + { + return $this->dlsubsubrow['d_count']; } - function sc_download_cat_subsub_size() { - global $e107, $dlsubsubrow; - return $this->e107->parseMemorySize($dlsubsubrow['d_size']); + function sc_download_cat_subsub_size() + { + return eHelper::parseMemorySize($this->dlsubsubrow['d_size']); } - function sc_download_cat_subsub_downloaded() { - global $dlsubsubrow; - return intval($dlsubsubrow['d_requests']); + function sc_download_cat_subsub_downloaded() + { + return intval($this->dlsubsubrow['d_requests']); } @@ -216,71 +229,79 @@ class download_shortcodes extends e_shortcode - function sc_download_list_name() + function sc_download_list_name($parm='') { - global $dlrow,$tp,$pref,$parm; - if ($parm == "nolink"){ - return $tp->toHTML($dlrow['download_name'],TRUE,'LINKTEXT'); + $tp = e107::getParser(); + $pref = e107::getPref(); + + if ($parm == "nolink") + { + return $tp->toHTML($this->var['download_name'],TRUE,'LINKTEXT'); } - if ($parm == "request"){ + + if ($parm == "request") + { $agreetext = $tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION')); - if ($dlrow['download_mirror_type']){ - $text = ($pref['agree_flag'] ? "" : ""); - }else{ - $text = ($pref['agree_flag'] ? "" : ""); + + if ($this->var['download_mirror_type']) + { + $text = ($pref['agree_flag'] ? "" : ""); } - $text .= $tp->toHTML($dlrow['download_name'], FALSE, 'TITLE').""; + else + { + $text = ($pref['agree_flag'] ? "" : ""); + } + + $text .= $tp->toHTML($this->var['download_name'], FALSE, 'TITLE').""; + return $text; } - return "".$tp->toHTML($dlrow['download_name'],TRUE,'LINKTEXT').""; + return "".$tp->toHTML($this->var['download_name'],TRUE,'LINKTEXT').""; } function sc_download_list_author() { - global $dlrow; - return $dlrow['download_author']; + return $this->var['download_author']; } function sc_download_list_requested() { - global $dlrow; - return $dlrow['download_requested']; + return $this->var['download_requested']; } function sc_download_list_newicon() { - global $dlrow; - return (USER && $dlrow['download_datestamp'] > USERLV ? "*" : ""); + return (USER && $this->var['download_datestamp'] > USERLV ? "*" : ""); } function sc_download_list_recenticon() { - global $dlrow, $pref; + $pref = e107::getPref(); // convert "recent_download_days" to seconds - return ($dlrow['download_datestamp'] > time()-($pref['recent_download_days']*86400) ? '' : ''); + return ($this->var['download_datestamp'] > time()-($pref['recent_download_days']*86400) ? '' : ''); } function sc_download_list_filesize() { - global $dlrow, $e107; - return $e107->parseMemorySize($dlrow['download_filesize']); + return eHelper::parseMemorySize($this->var['download_filesize']); } function sc_download_list_datestamp() { - global $dlrow; + $tp = e107::getParser(); - return $tp->toDate($dlrow['download_datestamp'], "short"); + return $tp->toDate($this->var['download_datestamp'], "short"); } - function sc_download_list_thumb() + function sc_download_list_thumb($parm='') { - global $dlrow,$parm; $tp = e107::getParser(); - $img = ($dlrow['download_thumb']) ? "*" : ""; - if ($parm == "link" && $dlrow['download_thumb']){ - return "".$img.""; + $img = ($this->var['download_thumb']) ? "*" : ""; + + if ($parm == "link" && $this->var['download_thumb']) + { + return "".$img.""; } else { @@ -290,50 +311,44 @@ class download_shortcodes extends e_shortcode function sc_download_list_id() { - global $dlrow; - return $dlrow['download_id']; + return $this->var['download_id']; } function sc_download_list_rating() { - global $dlrow; - - return e107::getForm()->rate("download", $dlrow['download_id']); - - - $rater = new rater(); - $ratearray = $rater->getrating("download", $dlrow['download_id']); - if (!$ratearray[0]) { - return LAN_dl_13; - } - else - { - return ($ratearray[2] ? "{$ratearray[1]}.{$ratearray[2]}/{$ratearray[0]}" : "{$ratearray[1]}/{$ratearray[0]}"); - } + return e107::getForm()->rate("download", $this->var['download_id']); } - function sc_download_list_link() + function sc_download_list_link($parm='') { - global $tp, $dlrow, $pref, $parm; - $agreetext = $tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION')); + $tp = e107::getParser(); + $pref = e107::getPref(); - $img = "".LAN_dl_32.""; - if ($dlrow['download_mirror_type']) + $agreetext = $tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION')); + + $img = "".LAN_dl_32.""; + + if(deftrue('BOOTSTRAP')) + { + $img = ''; + } + + if ($this->var['download_mirror_type']) { - return "{$img}"; + return "{$img}"; } else { - return ($pref['agree_flag'] ? "{$img}" : "{$img}"); + return ($pref['agree_flag'] ? "{$img}" : "{$img}"); } } - function sc_download_list_icon() + function sc_download_list_icon($parm='') { - global $dlrow,$parm; - if ($parm == "link"){ - return "".$img.""; + if ($parm == "link") + { + return "".$img.""; } else { @@ -342,16 +357,14 @@ class download_shortcodes extends e_shortcode return; } - function sc_download_list_imagefull() + function sc_download_list_imagefull($parm='') { - global $dlrow,$parm; - $tp = e107::getParser(); + + $img = ($this->var['download_image']) ? "" : ""; - $img = ($dlrow['download_image']) ? "" : ""; - - if($parm == "link" && $dlrow['download_image']) + if($parm == "link" && $this->var['download_image']) { - return "".$img.""; + return "".$img.""; } else { @@ -362,16 +375,18 @@ class download_shortcodes extends e_shortcode function sc_download_list_nextprev() { - global $nextprev_parms,$tp; - return $tp->parseTemplate("{NEXTPREV={$nextprev_parms}}"); + global $nextprev_parms; + return e107::getParser()->parseTemplate("{NEXTPREV={$nextprev_parms}}"); } - function sc_download_list_total_amount() { + function sc_download_list_total_amount() + { global $dltdownloads; return intval($dltdownloads)." ".LAN_dl_16; } - function sc_download_list_total_files() { + function sc_download_list_total_files() + { global $dlft; return intval($dlft)." ".LAN_dl_17; } @@ -384,22 +399,23 @@ class download_shortcodes extends e_shortcode function sc_download_view_id() { - global $dlrow; - return $dlrow['download_id']; + return $this->var['download_id']; } + function sc_download_admin_edit() { - global $dlrow; - return (ADMIN && getperms('6')) ? "*" : ""; + return (ADMIN && getperms('6')) ? "*" : ""; } + function sc_download_category() { - global $dlrow; - return $dlrow['download_category_name']; + return $this->var['download_category_name']; } + function sc_download_category_description() { global $tp,$dl,$parm; + $text = $tp -> toHTML($dl['download_category_description'], TRUE,'DESCRIPTION'); if ($parm){ return substr($text,0,$parm); @@ -407,128 +423,164 @@ class download_shortcodes extends e_shortcode return $text; } } - function sc_download_view_name() + function sc_download_view_name($parm='') { - global $dlrow,$parm; - $link['view'] = "".$dlrow['download_name'].""; - $link['request'] = "".$dlrow['download_name'].""; - if ($parm){ - return $link[$parm]; + $tp = e107::getParser(); + + $link['view'] = "".$this->var['download_name'].""; + $link['request'] = "".$this->var['download_name'].""; + + if ($parm) + { + return $tp->toHTML($link[$parm],true, 'TITLE'); } - return $dlrow['download_name']; + + return $this->var['download_name']; } + function sc_download_view_name_linked() { - global $pref,$dl,$tp; - if ($pref['agree_flag'] == 1) { - return "toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."');\" title='".LAN_dl_46."'>".$dl['download_name'].""; - } else { - return "".$dl['download_name'].""; + global $dl; + $tp = e107::getParser(); + $pref = e107::getPref(); + + if ($pref['agree_flag'] == 1) + { + return "toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."');\" title='".LAN_dl_46."'>".$dl['download_name'].""; + } + else + { + return "".$dl['download_name'].""; } } + function sc_download_view_author() { - global $dlrow; - return ($dlrow['download_author'] ? $dlrow['download_author'] : ""); + return ($this->var['download_author'] ? $this->var['download_author'] : ""); } + function sc_download_view_authoremail() { - global $tp,$dlrow; - return ($dlrow['download_author_email']) ? $tp -> toHTML($dlrow['download_author_email'], TRUE, 'LINKTEXT') : ""; + return ($this->var['download_author_email']) ? e107::getParser()->toHTML($this->var['download_author_email'], TRUE, 'LINKTEXT') : ""; } + function sc_download_view_authorwebsite() { - global $tp,$dlrow; - return ($dlrow['download_author_website']) ? $tp -> toHTML($dlrow['download_author_website'], TRUE,'LINKTEXT') : ""; + return ($this->var['download_author_website']) ? e107::getParser()->toHTML($this->var['download_author_website'], TRUE,'LINKTEXT') : ""; } - function sc_download_view_description() + + function sc_download_view_description($parm='') { - global $tp,$dlrow,$parm; $maxlen = ($parm ? intval($parm) : 0); - $text = ($dlrow['download_description'] ? $tp->toHTML($dlrow['download_description'], TRUE, 'DESCRIPTION') : ""); - if ($maxlen){ + $text = ($this->var['download_description'] ? e107::getParser()->toHTML($this->var['download_description'], TRUE, 'DESCRIPTION') : ""); + + if ($maxlen) + { return substr($text, 0, $maxlen); - }else{ + } + else + { return $text; } + return $text; } - function sc_download_view_date() + + function sc_download_view_date($parm='') { - global $gen,$dlrow,$parm; - $tp = e107::getParser(); - return ($dlrow['download_datestamp']) ? $tp->toDate($dlrow['download_datestamp'], $parm) : ""; + return ($this->var['download_datestamp']) ? e107::getParser()->toDate($this->var['download_datestamp'], $parm) : ""; } + + /** + * @Deprecated DOWNLOAD_VIEW_DATE should be used instead. + */ function sc_download_view_date_short() { - // deprecated: DOWNLOAD_VIEW_DATE should be used instead. - global $gen,$dlrow; - return ($dlrow['download_datestamp']) ? $gen->convert_date($dlrow['download_datestamp'], "short") : ""; + return $this->sc_download_view_date('short'); } + + /** + * @Deprecated DOWNLOAD_VIEW_DATE should be used instead. + */ function sc_download_view_date_long() { - // deprecated: DOWNLOAD_VIEW_DATE should be used instead. - global $gen,$dlrow; - return ($dlrow['download_datestamp']) ? $gen->convert_date($dlrow['download_datestamp'], "long") : ""; + return $this->sc_download_view_date('long'); } + function sc_download_view_image() { - global $dlrow; $tp = e107::getParser(); - if ($dlrow['download_thumb']) { - return ($dlrow['download_image'] ? "*" : "*"); + if ($this->var['download_thumb']) + { + return ($this->var['download_image'] ? "*" : "*"); } - else if ($dlrow['download_image']) { - return "".LAN_dl_40.""; + elseif ($this->var['download_image']) + { + return "".LAN_dl_40.""; } else { return LAN_dl_75; } } + function sc_download_view_imagefull() { - global $dlrow; $tp = e107::getParser(); - return ($dlrow['download_image']) ? "*" : ""; + return ($this->var['download_image']) ? "*" : ""; } - function sc_download_view_link() - { - global $pref,$dlrow,$tp; - $click = ""; - if ($pref['agree_flag'] == 1) { - $click = " onclick='return confirm(\"".$tp->toJS($tp->toHTML($pref['agree_text'],true,'emotes, no_tags'))."\")'"; - } - $dnld_link = ""; - if ($dlrow['download_mirror']) - { - if ($dlrow['download_mirror_type']) - { - return "".LAN_dl_66.""; - } - else - { - return $dnld_link."*"; - } - } - else - { - return $dnld_link."*"; - } - } - function sc_download_view_filesize() - { - global $dlrow, $e107; - return ($dlrow['download_filesize']) ? $e107->parseMemorySize($dlrow['download_filesize']) : ""; - } - function sc_download_view_rating() - { - global $dlrow; + + function sc_download_view_link() + { + $tp = e107::getParser(); + $pref = e107::getPref(); + + $click = ""; + + $img = "".LAN_dl_32.""; + + if(deftrue('BOOTSTRAP')) + { + $img = ''; + } + + if ($pref['agree_flag'] == 1) + { + $click = " onclick='return confirm(\"".$tp->toJS($tp->toHTML($pref['agree_text'],true,'emotes, no_tags'))."\")'"; + } + $dnld_link = ""; + + if ($this->var['download_mirror']) + { + if ($this->var['download_mirror_type']) + { + return "".LAN_dl_66.""; + } + else + { + return $dnld_link.$img.""; + } + } + else + { + return $dnld_link.$img.""; + } + } + + function sc_download_view_filesize() + { + return ($this->var['download_filesize']) ? eHelper::parseMemorySize($this->var['download_filesize']) : ""; + } + + function sc_download_view_rating() + { + $frm = e107::getForm(); $options = array('label'=>' ','template'=>'RATE|VOTES|STATUS'); - return $frm->rate("download", $dlrow['download_id'],$options); + return $frm->rate("download", $this->var['download_id'], $options); + /* require_once(e_HANDLER."rate_class.php"); $rater = new rater; @@ -536,7 +588,7 @@ class download_shortcodes extends e_shortcode
"; - if ($ratearray = $rater->getrating("download", $dlrow['download_id'])) { + if ($ratearray = $rater->getrating("download", $this->var['download_id'])) { for($c = 1; $c <= $ratearray[1]; $c++) { $text .= "*"; } @@ -552,8 +604,8 @@ class download_shortcodes extends e_shortcode $text .= LAN_dl_13; } $text .= ""; - if (!$rater->checkrated("download", $dlrow['download_id']) && USER) { - $text .= $rater->rateselect("     ".LAN_dl_14, "download", $dlrow['download_id']).""; + if (!$rater->checkrated("download", $this->var['download_id']) && USER) { + $text .= $rater->rateselect("     ".LAN_dl_14, "download", $this->var['download_id']).""; } else if (!USER) { $text .= " "; @@ -562,85 +614,86 @@ class download_shortcodes extends e_shortcode } $text .= "
"; return $text; - } - function sc_download_report_link() - { - global $dlrow,$pref; - return (check_class($pref['download_reportbroken'])) ? "".LAN_dl_45."" : ""; - } + */ + } + + function sc_download_report_link() + { + $pref = e107::getPref(); + return (check_class($pref['download_reportbroken'])) ? "".LAN_dl_45."" : ""; + } - function sc_download_view_caption() - { - global $dlrow; - $text = $dlrow['download_category_name']; - $text .= ($dlrow['download_category_description']) ? " [ ".$dlrow['download_category_description']." ]" : ""; - return $text; - } + function sc_download_view_caption() + { + $text = $this->var['download_category_name']; + $text .= ($this->var['download_category_description']) ? " [ ".$this->var['download_category_description']." ]" : ""; + return $text; + } // Mirror ************************************************************************************** function sc_download_mirror_request() { - global $dlrow; - return $dlrow['download_name']; + return $this->var['download_name']; } function sc_download_mirror_request_icon() { - global $dlrow; - $tp = e107::getParser(); - return ($dlrow['download_thumb'] ? "*" : ""); + return ($this->var['download_thumb'] ? "*" : ""); } function sc_download_mirror_name() { - global $dlmirror; - return "".$dlmirror['mirror_name'].""; + return "".$this->mirror['dlmirror']['mirror_name'].""; } function sc_download_mirror_image() { - global $dlrow, $dlmirror; $tp = e107::getParser(); - return ($dlmirror['mirror_image'] ? "*" : ""); + return ($this->mirror['dlmirror']['mirror_image'] ? "*" : ""); } - function sc_download_mirror_location() { - global $dlmirror; - return ($dlmirror['mirror_location'] ? $dlmirror['mirror_location'] : ""); + function sc_download_mirror_location() + { + return ($this->mirror['dlmirror']['mirror_location'] ? $this->mirror['dlmirror']['mirror_location'] : ""); } function sc_download_mirror_description() { - global $dlmirror,$tp; - return ($dlmirror['mirror_description'] ? $tp->toHTML($dlmirror['mirror_description'], TRUE) : ""); + return ($this->mirror['dlmirror']['mirror_description'] ? e107::getParser()->toHTML($this->mirror['dlmirror']['mirror_description'], TRUE) : ""); } function sc_download_mirror_filesize() { - global $e107, $dlmirrorfile; - return $e107->parseMemorySize($dlmirrorfile[3]); + return eHelper::parseMemorySize($this->mirror['dlmirrorfile'][3]); } function sc_download_mirror_link() { - global $dlrow, $dlmirrorfile, $tp, $pref; - $click = " onclick='return confirm(\"".$tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."\")'"; - return " - *"; + $tp = e107::getParser(); + $pref = e107::getPref(); + + $click = " onclick='return confirm(\"".$tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."\")'"; + + $img = "".LAN_dl_32.""; + + if(deftrue('BOOTSTRAP')) + { + $img = ''; + } + + return "mirror['dlmirrorfile'][0]}' title='".LAN_dl_32."'{$click}>".$img.""; } function sc_download_mirror_requests() { - global $dlmirrorfile; - return (ADMIN ? LAN_dl_73.$dlmirrorfile[2] : ""); + return (ADMIN ? LAN_dl_73.$this->mirror['dlmirrorfile'][2] : ""); } function sc_download_total_mirror_requests() { - global $dlmirror; - return (ADMIN ? LAN_dl_74.$dlmirror['mirror_count'] : ""); + return (ADMIN ? LAN_dl_74.$this->mirror['dlmirror']['mirror_count'] : ""); } @@ -648,26 +701,26 @@ class download_shortcodes extends e_shortcode function sc_download_view_author_lan() { - global $dlrow; - return ($dlrow['download_author']) ? LAN_dl_24 : ""; + + return ($this->var['download_author']) ? LAN_dl_24 : ""; } function sc_download_view_authoremail_lan() { - global $dlrow; - return ($dlrow['download_author_email']) ? LAN_dl_30 : ""; + + return ($this->var['download_author_email']) ? LAN_dl_30 : ""; } function sc_download_view_authorwebsite_lan() { - global $dlrow; - return ($dlrow['download_author_website']) ? LAN_dl_31 : ""; + + return ($this->var['download_author_website']) ? LAN_dl_31 : ""; } function sc_download_view_date_lan() { - global $dlrow; - return ($dlrow['download_datestamp']) ? LAN_dl_22 : ""; + + return ($this->var['download_datestamp']) ? LAN_dl_22 : ""; } function sc_download_view_image_lan() @@ -677,8 +730,8 @@ class download_shortcodes extends e_shortcode function sc_download_view_requested() { - global $dlrow; - return $dlrow['download_requested']; + + return $this->var['download_requested']; } function sc_download_view_rating_lan() @@ -711,33 +764,43 @@ class download_shortcodes extends e_shortcode function sc_download_view_prev() { - global $dlrow,$sql; - $dlrow_id = intval($dlrow['download_id']); - if ($sql->db_Select("download", "*", "download_category='".intval($dlrow['download_category_id'])."' AND download_id < {$dlrow_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp DESC LIMIT 1")) { - $dlrowrow = $sql->db_Fetch(); - return "<< ".LAN_dl_33." [".$dlrowrow['download_name']."]\n"; - } else { + $sql = e107::getDb(); + + $dlrow_id = intval($this->var['download_id']); + + if ($sql->select("download", "*", "download_category='".intval($this->var['download_category_id'])."' AND download_id < {$dlrow_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp DESC LIMIT 1")) + { + $dlrowrow = $sql->fetch(); + + return "<< ".LAN_dl_33." [".$dlrowrow['download_name']."]\n"; + } + else + { return " "; } } - function sc_download_view_next() - { - global $dlrow,$sql; - $dlrow_id = intval($dlrow['download_id']); - if ($sql->db_Select("download", "*", "download_category='".intval($dlrow['download_category_id'])."' AND download_id > {$dlrow_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp ASC LIMIT 1")) { - $dlrowrow = $sql->db_Fetch(); + function sc_download_view_next() + { + $sql = e107::getDb(); + $dlrow_id = intval($this->var['download_id']); + + if ($sql->select("download", "*", "download_category='".intval($this->var['download_category_id'])."' AND download_id > {$dlrow_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp ASC LIMIT 1")) + { + $dlrowrow = $sql->fetch(); extract($dlrowrow); - return "[".$dlrowrow['download_name']."] ".LAN_dl_34." >>\n"; - } else { + + return "[".$dlrowrow['download_name']."] ".LAN_dl_34." >>\n"; + } + else + { return " "; } - } + } function sc_download_back_to_list() { - global $dlrow; - return "".LAN_dl_35.""; + return "".LAN_dl_35.""; } function sc_download_back_to_category_list() diff --git a/e107_plugins/download/handlers/download_class.php b/e107_plugins/download/handlers/download_class.php index 51da6c839..2bdc7309a 100644 --- a/e107_plugins/download/handlers/download_class.php +++ b/e107_plugins/download/handlers/download_class.php @@ -13,16 +13,12 @@ if (!e107::isInstalled('download')) { exit(); } class download { - var $e107; - private $qry = array(); private $orderOptions = array('download_id','download_datestamp','download_filesize','download_name','download_author','download_requested'); function __construct() { - $this->e107 = e107::getInstance(); - require_once(e_PLUGIN."download/download_shortcodes.php"); } @@ -31,35 +27,17 @@ class download { $tp = e107::getParser(); + $pref = e107::getPref(); $tmp = explode('.', e_QUERY); - - $pref = e107::getPref(); - + // Set Defaults + $this->qry['action'] = 'maincats'; $this->qry['order'] = vartrue($pref['download_order'],'download_datestamp'); $this->qry['sort'] = vartrue($pref['download_sort'], 'desc'); $this->qry['view'] = vartrue($pref['download_view'], 10); - - - // v1.x - if (is_numeric($tmp[0])) //legacy // $tmp[0] at least must be valid - { - $dl_from = intval($tmp[0]); - $this->qry['action'] = varset(preg_replace("#\W#", "", $tp->toDB($tmp[1])),'list'); - $this->qry['id'] = intval($tmp[2]); - $this->qry['view'] = intval($tmp[3]); - $this->qry['order'] = preg_replace("#\W#", "", $tp->toDB($tmp[4])); - $this->qry['sort'] = preg_replace("#\W#", "", $tp->toDB($tmp[5])); - } - elseif($tmp[1]) - { - $this->qry['action'] = preg_replace("#\W#", "", $tp->toDB($tmp[0])); - $this->qry['id'] = intval($tmp[1]); - // $errnum = intval(varset($tmp[2],0)); - } - - + $this->qry['from'] = 0; + // v2.x if(varset($_GET['action'])) { @@ -68,6 +46,25 @@ class download $this->qry['id'] = intval($_GET['id']); $this->qry['order'] = vartrue($_GET['order']) && in_array("download_".$_GET['order'],$this->orderOptions) ? $_GET['order'] : 'datestamp'; $this->qry['sort'] = (varset($_GET['sort']) == 'asc') ? "asc" : 'desc'; + $this->qry['from'] = vartrue($_GET['from'],0); + } + else // v1.x Legacy URL support. + { + if (is_numeric($tmp[0])) //legacy // $tmp[0] at least must be valid + { + $this->qry['action'] = varset(preg_replace("#\W#", "", $tp->toDB($tmp[1])),'list'); + $this->qry['id'] = intval($tmp[2]); + $this->qry['view'] = intval($tmp[3]); + $this->qry['order'] = preg_replace("#\W#", "", $tp->toDB($tmp[4])); + $this->qry['sort'] = preg_replace("#\W#", "", $tp->toDB($tmp[5])); + } + elseif($tmp[1]) + { + $this->qry['action'] = preg_replace("#\W#", "", $tp->toDB($tmp[0])); + $this->qry['id'] = intval($tmp[1]); + $this->qry['error'] = intval(varset($tmp[2],0)); + } + } // v1.x @@ -78,15 +75,66 @@ class download $this->qry['sort'] = (strtolower($_POST['sort']) == 'asc') ? "asc" : 'desc'; } - + } - public function renderCategories() + + + /** + * Auto-detected Render of the appropriate download page. + */ + public function render() { + $pref = e107::getPref(); + + if($this->qry['action'] == 'maincats') + { + return $this->renderCategories(); + } + + if($this->qry['action'] == 'list') + { + return $this->renderList(); + } + + if($this->qry['action'] == 'view') + { + return $this->renderView(); + } + + if ($this->qry['action'] == "report" && check_class($pref['download_reportbroken'])) + { + return $this->renderReport(); + } + + if($this->qry['action'] == 'mirror') + { + return $this->renderMirror(); + } + + if($this->qry['action'] == 'error') + { + return $this->renderError(); + } + + } + + + + + + + /** + * Render Download Categories. + * @todo Cache + */ + private function renderCategories() + { $tp = e107::getParser(); $ns = e107::getRender(); + $pref = e107::getPref(); // if ($cacheData = $e107cache->retrieve("download_cat".$maincatval,720)) // expires every 12 hours. //TODO make this an option @@ -128,7 +176,8 @@ class download } } - $download_shortcodes = new download_shortcodes; + $download_shortcodes = e107::getScBatch('download',true); + $download_shortcodes->wrapper('download/categories'); $download_shortcodes->qry = $this->qry; @@ -140,25 +189,25 @@ class download if ($dlcat->down_count == 0) { - $ns->tablerender(LAN_dl_18, "
".LAN_dl_2."
"); - return; - // require_once(FOOTERF); - // exit; + return $ns->tablerender(LAN_dl_18, "
".LAN_dl_2."
",'download-categories',true); } - - global $dlrow, $dlsubrow; - + $download_cat_table_string = ""; foreach($dlcat->cat_tree as $dlrow) // Display main category headings, then sub-categories, optionally with sub-sub categories expanded - { + { + $download_shortcodes->setVars($dlrow); $download_cat_table_string .= $tp->parseTemplate($DOWNLOAD_CAT_PARENT_TABLE, TRUE, vartrue($download_shortcodes)); foreach($dlrow['subcats'] as $dlsubrow) { + $download_shortcodes->dlsubrow = $dlsubrow; + + $download_cat_table_string .= $tp->parseTemplate($DOWNLOAD_CAT_CHILD_TABLE, TRUE, $download_shortcodes); foreach($dlsubrow['subsubcats'] as $dlsubsubrow) { + $download_shortcodes->dlsubsubrow = $dlsubsubrow; $download_cat_table_string .= $tp->parseTemplate($DOWNLOAD_CAT_SUBSUB_TABLE, TRUE, $download_shortcodes); } } @@ -172,7 +221,7 @@ class download //ob_start(); - $ns->tablerender($caption, $dl_text); + return $ns->tablerender($caption, $dl_text, 'download-categories',true); // $cache_data = ob_get_flush(); // $e107cache->set("download_cat".$maincatval, $cache_data); @@ -188,8 +237,11 @@ class download - - public function renderView() + /** + * Render a single download + * @todo cache + */ + private function renderView() { if(deftrue('BOOTSTRAP')) // v2.x { @@ -199,7 +251,7 @@ class download $DOWNLOAD_VIEW_TABLE = $template['item']; $DOWNLOAD_VIEW_TABLE_END = varset($template['end']); $DL_VIEW_NEXTPREV = varset($template['nextprev']); - $DL_VIEW_PAGETITLE = varset($template['pagetitle']); + // $DL_VIEW_PAGETITLE = varset($template['pagetitle']); $DL_VIEW_CAPTION = varset($template['caption'],"{DOWNLOAD_VIEW_CAPTION}"); } else // Legacy v1.x @@ -225,8 +277,9 @@ class download $ns = e107::getRender(); $gen = new convert; - - $download_shortcodes = new download_shortcodes; + + $download_shortcodes = e107::getScBatch('download',true); + $download_shortcodes->wrapper('download/view'); $download_shortcodes->qry = $this->qry; $highlight_search = FALSE; @@ -246,19 +299,19 @@ class download if(!$sql->gen($query)) { //require_once(HEADERF); - $ns->tablerender(LAN_dl_18, "
".LAN_dl_3."
"); - return; + return $ns->tablerender(LAN_dl_18, "
".LAN_dl_3."
", 'download-view', true); //require_once(FOOTERF); //exit; } - global $dlrow; $dlrow = $sql->fetch(); + $download_shortcodes->setVars($dlrow); $comment_edit_query = 'comment.download.'.$id; if(!defined("DL_IMAGESTYLE")){ define("DL_IMAGESTYLE","border:0px");} + if(!isset($DL_VIEW_PAGETITLE)) { $DL_VIEW_PAGETITLE = PAGE_NAME." / {DOWNLOAD_CATEGORY} / {DOWNLOAD_VIEW_NAME}"; @@ -294,16 +347,22 @@ class download $caption = $tp->parseTemplate($DL_VIEW_CAPTION, TRUE, $download_shortcodes); - $ns->tablerender($caption, $text); + $ret = $ns->tablerender($caption, $text, 'download-view', true); unset($text); if ($dlrow['download_comment']) { - e107::getComment()->compose_comment("download", "comment", $id, $width,$dlrow['download_name'], $showrate=FALSE); + $comments = e107::getComment()->compose_comment("download", "comment", $id, $width,$dlrow['download_name'], FALSE, true); + $ret .= $ns->tablerender($comments['caption'], $comments['comment'].$comments['comment_form'], 'download-comments', true); } + + // print_a($comments); + + return $ret; + } @@ -316,8 +375,11 @@ class download - - public function renderList() + /** + * Render a list of files in a particular download category. + * + */ + private function renderList() { if(deftrue('BOOTSTRAP')) // v2.x @@ -352,14 +414,42 @@ class download $tp = e107::getParser(); $ns = e107::getRender(); - $download_shortcodes = new download_shortcodes; + // $download_shortcodes = new download_shortcodes; + $download_shortcodes = e107::getScBatch('download',true); + $download_shortcodes->wrapper('download/list'); $download_shortcodes->qry = $this->qry; - + + + + //if (!isset($this->qry['from'])) $this->qry['from'] = 0; + + // Get category type, page title + if ($sql->select("download_category", "download_category_name,download_category_description,download_category_parent,download_category_class", "(download_category_id='{$this->qry['id']}') AND (download_category_class IN (".USERCLASS_LIST."))") ) + { + $dlrow = $sql->fetch(); + $download_shortcodes->setVars($dlrow); // Used below for header / breadcrumb. + $type = $dlrow['download_category_name']; + define("e_PAGETITLE", PAGE_NAME." / ".$dlrow['download_category_name']); + } + else + { // No access to this category + define("e_PAGETITLE", PAGE_NAME); + return $ns->tablerender(LAN_dl_18, "
".LAN_dl_3."
",'download-list',true); + } + + if ($dlrow['download_category_parent'] == 0) // It's a main category - change the listing type required + { + $action = 'maincats'; + $maincatval = $id; + } + + $total_downloads = $sql->count("download", "(*)", "WHERE download_category = '{$this->qry['id']}' AND download_active > 0 AND download_visible REGEXP '" . e_CLASS_REGEXP . "'"); /* SHOW SUBCATS ... */ $qry = "SELECT download_category_id,download_category_class FROM #download_category WHERE download_category_parent=".intval($this->qry['id']); + if($sql->gen($qry)) { /* there are subcats - display them ... */ @@ -385,10 +475,11 @@ class download eval($template_load_core); } - if(!defined("DL_IMAGESTYLE")) - { - define("DL_IMAGESTYLE", "border:1px solid blue"); - } + /** @DEPRECATED **/ + // if(!defined("DL_IMAGESTYLE")) + // { + // define("DL_IMAGESTYLE", "border:1px solid blue"); + // } $download_cat_table_string = ""; @@ -402,14 +493,9 @@ class download $dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_END, TRUE, $download_shortcodes); - $dlbreadcrumb = $this->getBreadcrumb(array(LAN_dl_18 => e_SELF,$type)); - $dl_title = $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); + $text = $ns->tablerender($dl_title, $dl_text, 'download-list', true); + - $ns->tablerender($dl_title, $dl_text); - $text = ""; - // If other files, show in a separate block - $dl_title = ""; - // Cancel title once displayed }// End of subcategory display // Now display individual downloads @@ -430,7 +516,7 @@ class download } if($total_downloads < $this->qry['view']) { - $dl_from = 0; + $this->qry['from'] = 0; } @@ -442,23 +528,25 @@ class download require_once (e_HANDLER . "rate_class.php"); $dltdownloads = 0; - // $dl_from - first entry to show (note - can get reset due to reuse of query, + // $this->qry['from'] - first entry to show (note - can get reset due to reuse of query, // even if values overridden this time) // $this->qry['view'] - number of entries per page // $total_downloads - total number of entries matching search criteria - $filetotal = $sql->select("download", "*", "download_category='{$this->qry['id']}' AND download_active > 0 AND download_visible IN (" . USERCLASS_LIST . ") ORDER BY download_{$this->qry['order']} {$this->qry['sort']} LIMIT {$dl_from}, ".$this->qry['view']); + $filetotal = $sql->select("download", "*", "download_category='{$this->qry['id']}' AND download_active > 0 AND download_visible IN (" . USERCLASS_LIST . ") ORDER BY download_{$this->qry['order']} {$this->qry['sort']} LIMIT {$this->qry['from']}, ".$this->qry['view']); if($filetotal) { // Only show list if some files in it $dl_text = $tp->parseTemplate($DOWNLOAD_LIST_TABLE_START, TRUE, $download_shortcodes); - global $dlrow, $dlft, $dltdownloads; + global $dlft, $dltdownloads; $dlft = ($filetotal < $this->qry['view'] ? $filetotal: $this->qry['view']); while($dlrow = $sql->fetch()) { + $download_shortcodes->setVars($dlrow); + $agreetext = $tp->toHTML($pref['agree_text'], TRUE, 'DESCRIPTION'); $current_row = ($current_row)? 0: 1; // Alternating CSS for each row.(backwards compatible) @@ -479,7 +567,7 @@ class download } - $ns->tablerender(LAN_dl_18, $dl_text, 'download-list'); + $text = $ns->tablerender(LAN_dl_18, $dl_text, 'download-list', true); } if(!isset($DOWNLOAD_LIST_NEXTPREV)) @@ -501,16 +589,20 @@ class download global $nextprev_parms; - $nextprev_parms = $total_downloads . "," . $this->qry['view'] . "," . $dl_from . "," . e_SELF . "?[FROM].list.{$this->qry['id']}.{$this->qry['view']}.{$this->qry['order']}.{$this->qry['sort']}."; - - echo $tp->parseTemplate($DOWNLOAD_LIST_NEXTPREV, TRUE, $download_shortcodes); + $nextprev_parms = $total_downloads . "," . $this->qry['view'] . "," . $this->qry['from'] . "," . e_SELF . "?[FROM].list.{$this->qry['id']}.{$this->qry['view']}.{$this->qry['order']}.{$this->qry['sort']}."; + $text .= $tp->parseTemplate($DOWNLOAD_LIST_NEXTPREV, TRUE, $download_shortcodes); + return $text; } - function renderReport() + + /** + * Render a 'Broken Download' Report form. + */ + private function renderReport() { $sql = e107::getDb(); $tp = e107::getParser(); @@ -553,13 +645,11 @@ class download define("e_PAGETITLE", PAGE_NAME." / ".LAN_dl_47); - // require_once(HEADERF); - $text = LAN_dl_48."

".LAN_dl_49.""; - // $dlbreadcrumb = $dl->getBreadcrumb(array(LAN_dl_18=>e_SELF, $dlrow['download_category_name']=>e_SELF."?list.".$dlrow['download_category_id'], $dlrow['download_name']=>e_SELF."?view.".$dlrow['download_id'], LAN_dl_50)); - // $dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes); + $text = LAN_dl_48."

".LAN_dl_49.""; + - $ns->tablerender(LAN_dl_18, $text); + return $ns->tablerender(LAN_dl_18, $text, 'download-report', true); } else { @@ -585,13 +675,15 @@ class download "; - $ns->tablerender(LAN_dl_18, $text); + return $ns->tablerender(LAN_dl_18, $text, 'download-report', true); } } - - function renderMirror() + /** + * Render Download Mirrors for the selected file. + */ + private function renderMirror() { $sql = e107::getDb(); @@ -625,7 +717,9 @@ class download } } - $download_shortcodes = new download_shortcodes; + + $download_shortcodes = e107::getScBatch('download',true); + $download_shortcodes->wrapper('download/mirror'); $download_shortcodes->qry = $this->qry; // $load_template = 'download_template'; @@ -640,12 +734,15 @@ class download WHERE d.download_id = ".$this->qry['id']." LIMIT 1"; - global $dlmirrorfile, $dlrow, $dlmirror; + // global $dlmirrorfile, $dlmirror; if($sql->gen($query)) { $dlrow = $sql->fetch(); + // $dlrow['mirrorlist'] = $mirrorList; + $download_shortcodes->setVars($dlrow); + $array = explode(chr(1), $dlrow['download_mirror']); @@ -681,7 +778,10 @@ class download if($mirrorstring) { $dlmirrorfile = explode(",", $mirrorstring); - $dlmirror = $mirrorList[$dlmirrorfile[0]]; + // $dlmirror = $mirrorList[$dlmirrorfile[0]]; + + $download_shortcodes->mirror['dlmirrorfile'] = $dlmirrorfile; + $download_shortcodes->mirror['dlmirror'] = $mirrorList[$dlmirrorfile[0]]; $dl_text .= $tp->parseTemplate($DOWNLOAD_MIRROR, TRUE, $download_shortcodes); } @@ -689,7 +789,7 @@ class download $dl_text .= $tp->parseTemplate($DOWNLOAD_MIRROR_END, TRUE, $download_shortcodes); - $ns->tablerender(LAN_dl_18, $dl_text); + return $ns->tablerender(LAN_dl_18, $dl_text, 'download-mirror', true); } @@ -698,43 +798,38 @@ class download } - - - - - - - - - - - - - - - /** - * @DEPRECATED - */ - function getBreadcrumb($arr) - { - $dlbreadcrumb = array(); - $ix = 0; - foreach ($arr as $key=>$crumb) { - $dlbreadcrumb[$ix]['sep'] = " :: "; - $ix++; - if (is_int($key)) - { - $dlbreadcrumb[$ix]['value'] = $crumb; - } - else - { - $dlbreadcrumb[$ix]['value'] = "".$key.""; - } - } - $dlbreadcrumb['fieldlist'] = implode(",", array_keys($dlbreadcrumb)); - return $dlbreadcrumb; - } - + /** + * Render Download Errors. + */ + private function renderError() + { + $ns = e107::getRender(); + $pref = e107::getPref(); + + switch ($this->qry['error']) + { + case 1 : // No permissions + if (strlen($pref['download_denied']) > 0) + { + $errmsg = $tp->toHTML($pref['download_denied'],true); + } + else + { + $errmsg = LAN_dl_63; + } + break; + + case 2 : // Quota exceeded + $errmsg = LAN_dl_62; + break; + + default: // Generic error - shouldn't happen + $errmsg = LAN_dl_61." ".$this->qry['error']; + } + + $ns->tablerender(LAN_dl_61, "
".$errmsg."
"); + + } @@ -836,4 +931,14 @@ class download return $boxinfo; } } + +function sort_download_mirror_order($a, $b) +{ + $a = explode(",", $a); + $b = explode(",", $b); + if ($a[1] == $b[1]) { + return 0; + } + return ($a[1] < $b[1]) ? -1 : 1; +} ?> \ No newline at end of file diff --git a/e107_plugins/download/templates/download_template.php b/e107_plugins/download/templates/download_template.php index fd4707286..7a863b5dd 100644 --- a/e107_plugins/download/templates/download_template.php +++ b/e107_plugins/download/templates/download_template.php @@ -351,7 +351,7 @@ if(!isset($DOWNLOAD_MIRROR_END)) // v2.x Bootstrap Template. - Overrides the above templates. -$DOWNLOAD_TEMPLATE['categories']['start'] = " +$DOWNLOAD_TEMPLATE['categories']['start'] = "{DOWNLOAD_BREADCRUMB} @@ -460,7 +460,7 @@ $DOWNLOAD_TEMPLATE['view']['item'] = " {DOWNLOAD_VIEW_AUTHOR_LAN} @@ -550,7 +550,7 @@ $DOWNLOAD_TEMPLATE['list']['start'] = "{DOWNLOAD_BREADCRUMB} - + "; @@ -575,7 +575,7 @@ $DOWNLOAD_TEMPLATE['list']['item'] = " - "; @@ -584,7 +584,7 @@ $DOWNLOAD_TEMPLATE['list']['item'] = " $DOWNLOAD_TEMPLATE['list']['end'] = " - +
- {DOWNLOAD_VIEW_NAME} {DOWNLOAD_ADMIN_EDIT} +

{DOWNLOAD_VIEW_NAME} {DOWNLOAD_ADMIN_EDIT}

{DOWNLOAD_LIST_CAPTION=filesize} {DOWNLOAD_LIST_CAPTION=requested} {DOWNLOAD_LIST_CAPTION=rating}{DOWNLOAD_LIST_CAPTION=link}{DOWNLOAD_LIST_CAPTION=link}
{DOWNLOAD_LIST_RATING} + {DOWNLOAD_LIST_LINK}
{DOWNLOAD_LIST_TOTAL_AMOUNT} {DOWNLOAD_LIST_TOTAL_FILES}{DOWNLOAD_LIST_TOTAL_AMOUNT} {DOWNLOAD_LIST_TOTAL_FILES}
@@ -619,7 +619,7 @@ $DOWNLOAD_TEMPLATE['mirror']['start'] = "{DOWNLOAD_BREADCRUMB} {DOWNLOAD_MIRROR_REQUEST_ICON} - ".LAN_dl_72."{DOWNLOAD_MIRROR_REQUEST} +

{DOWNLOAD_MIRROR_REQUEST}

".LAN_dl_68." @@ -644,7 +644,7 @@ $DOWNLOAD_TEMPLATE['mirror']['item'] = " {DOWNLOAD_MIRROR_DESCRIPTION} {DOWNLOAD_MIRROR_LOCATION} {DOWNLOAD_MIRROR_FILESIZE} - {DOWNLOAD_MIRROR_LINK} + {DOWNLOAD_MIRROR_LINK} ";