diff --git a/e107_plugins/download/download.php b/e107_plugins/download/download.php index 6de3ad188..0542bd931 100644 --- a/e107_plugins/download/download.php +++ b/e107_plugins/download/download.php @@ -166,11 +166,13 @@ else } } +/* 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 @@ -254,7 +256,6 @@ if (isset($_POST['commentsubmit'])) require_once (HEADERF); - if($action == 'maincats') { $dl->renderCategories(); @@ -274,6 +275,11 @@ require_once (HEADERF); { $dl->renderReport(); } + + if($action == 'mirror') + { + $dl->renderMirror(); + } require_once (FOOTERF); exit ; @@ -288,14 +294,16 @@ exit ; //LIST//==================================================== if($action == "list") { - $total_downloads = $sql->db_Count("download", "(*)", "WHERE download_category = '{$id}' AND download_active > 0 AND download_visible REGEXP '" . e_CLASS_REGEXP . "'"); - - require_once (HEADERF); - echo "WOWO"; - $dl->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 ... @@ -601,10 +609,14 @@ if ($action == "report" && check_class($pref['download_reportbroken'])) //==================================================== // MIRRORS //==================================================== + +//TODO Move into download_class.php + if($action == "mirror") { - require_once(HEADERF); + //require_once(HEADERF); +/* $load_template = 'download_template'; if (!isset($DOWNLOAD_MIRROR_START)) eval($template_load_core); @@ -657,9 +669,10 @@ if($action == "mirror") $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); - } + $ns->tablerender($dl_title, $dl_text);*/ + + // require_once(FOOTERF); + //} } function sort_download_mirror_order($a, $b) diff --git a/e107_plugins/download/download_shortcodes.php b/e107_plugins/download/download_shortcodes.php index 1360a6722..5e74f233f 100644 --- a/e107_plugins/download/download_shortcodes.php +++ b/e107_plugins/download/download_shortcodes.php @@ -41,15 +41,26 @@ class download_shortcodes extends e_shortcode { $tp = e107::getParser(); $frm = e107::getForm(); - - $frm->select(); - + global $dlrow; - + $breadcrumb = array(); - $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); + + 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); + 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); + break; + } return $frm->breadcrumb($breadcrumb); diff --git a/e107_plugins/download/handlers/download_class.php b/e107_plugins/download/handlers/download_class.php index 4d76e5c25..51da6c839 100644 --- a/e107_plugins/download/handlers/download_class.php +++ b/e107_plugins/download/handlers/download_class.php @@ -590,12 +590,111 @@ class download } - //TODO + function renderMirror() { + $sql = e107::getDb(); + $tp = e107::getParser(); + $ns = e107::getRender(); + + if(deftrue('BOOTSTRAP')) // v2.x + { + $template = e107::getTemplate('download','download','mirror'); + + $DOWNLOAD_MIRROR_START = $template['start']; + $DOWNLOAD_MIRROR = $template['item']; + $DOWNLOAD_MIRROR_END = $template['end']; + + } + else // Legacy v1.x + { + $template_name = 'download_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); + } + + } + $download_shortcodes = new download_shortcodes; + $download_shortcodes->qry = $this->qry; + + // $load_template = 'download_template'; + // if (!isset($DOWNLOAD_MIRROR_START)) eval($template_load_core); + + $sql->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 = ".$this->qry['id']." + LIMIT 1"; + + global $dlmirrorfile, $dlrow, $dlmirror; + + + if($sql->gen($query)) + { + $dlrow = $sql->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); + + $ns->tablerender(LAN_dl_18, $dl_text); + } + + } @@ -611,9 +710,6 @@ class download - - - /** diff --git a/e107_plugins/download/templates/download_template.php b/e107_plugins/download/templates/download_template.php index d62c92427..fd4707286 100644 --- a/e107_plugins/download/templates/download_template.php +++ b/e107_plugins/download/templates/download_template.php @@ -345,7 +345,7 @@ if(!isset($DOWNLOAD_MIRROR_END)) "; } - +// ##### ------------------------------------------------------------------------------------------ // v2.x Bootstrap Template. - Overrides the above templates. @@ -434,9 +434,10 @@ $DOWNLOAD_TEMPLATE['categories']['end'] = " \n"; +// ##### ------------------------------------------------------------------------------------------ - +//FIXME - not being utilized at the moment. $DOWNLOAD_WRAPPER['view']['DOWNLOAD_VIEW_AUTHOR_LAN'] = "{---}"; $DOWNLOAD_WRAPPER['view']['DOWNLOAD_VIEW_AUTHOR'] = "{---}"; @@ -527,11 +528,7 @@ $DOWNLOAD_TEMPLATE['view']['nextprev'] = '
{DOWNLOAD_BACK_TO_LIST}
'; - - - - - +// ##### ------------------------------------------------------------------------------------------ $DOWNLOAD_TEMPLATE['list']['start'] = "{DOWNLOAD_BREADCRUMB}
@@ -556,6 +553,8 @@ $DOWNLOAD_TEMPLATE['list']['start'] = "{DOWNLOAD_BREADCRUMB} {DOWNLOAD_LIST_CAPTION=link} "; + + $DOWNLOAD_TEMPLATE['list']['item'] = " @@ -581,6 +580,8 @@ $DOWNLOAD_TEMPLATE['list']['item'] = " "; + + $DOWNLOAD_TEMPLATE['list']['end'] = " {DOWNLOAD_LIST_TOTAL_AMOUNT} {DOWNLOAD_LIST_TOTAL_FILES} @@ -589,7 +590,8 @@ $DOWNLOAD_TEMPLATE['list']['end'] = "
\n"; - + + $DOWNLOAD_TEMPLATE['list']['nextprev'] = "
{DOWNLOAD_BACK_TO_CATEGORY_LIST} @@ -598,16 +600,57 @@ $DOWNLOAD_TEMPLATE['list']['nextprev'] = " {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} -
"; +*/ + +// ##### ------------------------------------------------------------------------------------------ + + +$DOWNLOAD_TEMPLATE['mirror']['start'] = "{DOWNLOAD_BREADCRUMB} + + + + + + + + + + + + + + + + + + + + "; + + +$DOWNLOAD_TEMPLATE['mirror']['item'] = " + + + + + + + + + "; + +$DOWNLOAD_TEMPLATE['mirror']['end'] = " +
{DOWNLOAD_MIRROR_REQUEST_ICON}".LAN_dl_72."{DOWNLOAD_MIRROR_REQUEST}
".LAN_dl_68."".LAN_dl_71."".LAN_dl_70."".LAN_dl_21."".LAN_dl_32."
{DOWNLOAD_MIRROR_IMAGE} + {DOWNLOAD_MIRROR_NAME}
+ + {DOWNLOAD_MIRROR_REQUESTS} +
{DOWNLOAD_TOTAL_MIRROR_REQUESTS} +
+
{DOWNLOAD_MIRROR_DESCRIPTION}{DOWNLOAD_MIRROR_LOCATION}{DOWNLOAD_MIRROR_FILESIZE}{DOWNLOAD_MIRROR_LINK}
+ "; + -// ##### ------------------------------------------------------------------------------------------ ?> \ No newline at end of file