mirror of
https://github.com/e107inc/e107.git
synced 2025-07-15 12:06:19 +02:00
More work on the download plugin.
This commit is contained in:
@ -166,11 +166,13 @@ else
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
if (isset($order) && !in_array($order,$order_options)) unset($order);
|
if (isset($order) && !in_array($order,$order_options)) unset($order);
|
||||||
if (isset($sort) && !in_array($sort,$sort_options)) unset($sort);
|
if (isset($sort) && !in_array($sort,$sort_options)) unset($sort);
|
||||||
if (!isset($order)) $order = vartrue($pref['download_order'],'download_datestamp');
|
if (!isset($order)) $order = vartrue($pref['download_order'],'download_datestamp');
|
||||||
if (!isset($sort)) $sort = vartrue($pref['download_sort'], 'DESC');
|
if (!isset($sort)) $sort = vartrue($pref['download_sort'], 'DESC');
|
||||||
if (!isset($view)) $view = vartrue($pref['download_view'], '10');
|
if (!isset($view)) $view = vartrue($pref['download_view'], '10');
|
||||||
|
*/
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// GENERATE DISPLAY TEXT
|
// GENERATE DISPLAY TEXT
|
||||||
@ -254,7 +256,6 @@ if (isset($_POST['commentsubmit']))
|
|||||||
|
|
||||||
require_once (HEADERF);
|
require_once (HEADERF);
|
||||||
|
|
||||||
|
|
||||||
if($action == 'maincats')
|
if($action == 'maincats')
|
||||||
{
|
{
|
||||||
$dl->renderCategories();
|
$dl->renderCategories();
|
||||||
@ -275,6 +276,11 @@ require_once (HEADERF);
|
|||||||
$dl->renderReport();
|
$dl->renderReport();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($action == 'mirror')
|
||||||
|
{
|
||||||
|
$dl->renderMirror();
|
||||||
|
}
|
||||||
|
|
||||||
require_once (FOOTERF);
|
require_once (FOOTERF);
|
||||||
exit ;
|
exit ;
|
||||||
|
|
||||||
@ -288,14 +294,16 @@ exit ;
|
|||||||
//LIST//====================================================
|
//LIST//====================================================
|
||||||
if($action == "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 ... */
|
/* 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}' "))
|
if($sql->db_Select("download_category", "download_category_id", "download_category_parent='{$id}' "))
|
||||||
{
|
{
|
||||||
// there are subcats - display them ...
|
// there are subcats - display them ...
|
||||||
@ -601,10 +609,14 @@ if ($action == "report" && check_class($pref['download_reportbroken']))
|
|||||||
//====================================================
|
//====================================================
|
||||||
// MIRRORS
|
// MIRRORS
|
||||||
//====================================================
|
//====================================================
|
||||||
|
|
||||||
|
//TODO Move into download_class.php
|
||||||
|
|
||||||
if($action == "mirror")
|
if($action == "mirror")
|
||||||
{
|
{
|
||||||
require_once(HEADERF);
|
//require_once(HEADERF);
|
||||||
|
|
||||||
|
/*
|
||||||
$load_template = 'download_template';
|
$load_template = 'download_template';
|
||||||
if (!isset($DOWNLOAD_MIRROR_START)) eval($template_load_core);
|
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);
|
$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));
|
$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);
|
$dl_title .= $tp->parseTemplate("{BREADCRUMB=dlbreadcrumb}", TRUE, $download_shortcodes);
|
||||||
$ns->tablerender($dl_title, $dl_text);
|
$ns->tablerender($dl_title, $dl_text);*/
|
||||||
require_once(FOOTERF);
|
|
||||||
}
|
// require_once(FOOTERF);
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
function sort_download_mirror_order($a, $b)
|
function sort_download_mirror_order($a, $b)
|
||||||
|
@ -42,14 +42,25 @@ class download_shortcodes extends e_shortcode
|
|||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
|
|
||||||
$frm->select();
|
|
||||||
|
|
||||||
global $dlrow;
|
global $dlrow;
|
||||||
|
|
||||||
$breadcrumb = array();
|
$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);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
$breadcrumb[] = array('text' => LAN_dl_18, 'url' => e_SELF);
|
$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_category_name'], 'url' => e_SELF."?action=list&id=".$dlrow['download_category_id']);
|
||||||
$breadcrumb[] = array('text' => $dlrow['download_name'], 'url' => null);
|
$breadcrumb[] = array('text' => $dlrow['download_name'], 'url' => null);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return $frm->breadcrumb($breadcrumb);
|
return $frm->breadcrumb($breadcrumb);
|
||||||
|
|
||||||
|
@ -590,16 +590,112 @@ class download
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//TODO
|
|
||||||
function renderMirror()
|
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);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ if(!isset($DOWNLOAD_MIRROR_END))
|
|||||||
";
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ##### ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// v2.x Bootstrap Template. - Overrides the above templates.
|
// v2.x Bootstrap Template. - Overrides the above templates.
|
||||||
@ -434,9 +434,10 @@ $DOWNLOAD_TEMPLATE['categories']['end'] = "
|
|||||||
</tbody>
|
</tbody>
|
||||||
</table>\n";
|
</table>\n";
|
||||||
|
|
||||||
|
// ##### ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
//FIXME - not being utilized at the moment.
|
||||||
|
|
||||||
$DOWNLOAD_WRAPPER['view']['DOWNLOAD_VIEW_AUTHOR_LAN'] = "<tr><td style='width:20%' class='forumheader3'>{---}</td>";
|
$DOWNLOAD_WRAPPER['view']['DOWNLOAD_VIEW_AUTHOR_LAN'] = "<tr><td style='width:20%' class='forumheader3'>{---}</td>";
|
||||||
$DOWNLOAD_WRAPPER['view']['DOWNLOAD_VIEW_AUTHOR'] = "<td style='width:80%' class='forumheader3'>{---}</td>";
|
$DOWNLOAD_WRAPPER['view']['DOWNLOAD_VIEW_AUTHOR'] = "<td style='width:80%' class='forumheader3'>{---}</td>";
|
||||||
@ -527,11 +528,7 @@ $DOWNLOAD_TEMPLATE['view']['nextprev'] = '
|
|||||||
<div class="text-center">{DOWNLOAD_BACK_TO_LIST}</div>
|
<div class="text-center">{DOWNLOAD_BACK_TO_LIST}</div>
|
||||||
';
|
';
|
||||||
|
|
||||||
|
// ##### ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$DOWNLOAD_TEMPLATE['list']['start'] = "{DOWNLOAD_BREADCRUMB}
|
$DOWNLOAD_TEMPLATE['list']['start'] = "{DOWNLOAD_BREADCRUMB}
|
||||||
<div style='text-align:center'>
|
<div style='text-align:center'>
|
||||||
@ -556,6 +553,8 @@ $DOWNLOAD_TEMPLATE['list']['start'] = "{DOWNLOAD_BREADCRUMB}
|
|||||||
<th>{DOWNLOAD_LIST_CAPTION=link}</th>
|
<th>{DOWNLOAD_LIST_CAPTION=link}</th>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$DOWNLOAD_TEMPLATE['list']['item'] = "
|
$DOWNLOAD_TEMPLATE['list']['item'] = "
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
@ -581,6 +580,8 @@ $DOWNLOAD_TEMPLATE['list']['item'] = "
|
|||||||
</td>
|
</td>
|
||||||
</tr>";
|
</tr>";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$DOWNLOAD_TEMPLATE['list']['end'] = "
|
$DOWNLOAD_TEMPLATE['list']['end'] = "
|
||||||
<tr>
|
<tr>
|
||||||
<td class='forumheader3' colspan='7' style='text-align:right;'>{DOWNLOAD_LIST_TOTAL_AMOUNT} {DOWNLOAD_LIST_TOTAL_FILES}</td>
|
<td class='forumheader3' colspan='7' style='text-align:right;'>{DOWNLOAD_LIST_TOTAL_AMOUNT} {DOWNLOAD_LIST_TOTAL_FILES}</td>
|
||||||
@ -590,6 +591,7 @@ $DOWNLOAD_TEMPLATE['list']['end'] = "
|
|||||||
</div>\n";
|
</div>\n";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$DOWNLOAD_TEMPLATE['list']['nextprev'] = "
|
$DOWNLOAD_TEMPLATE['list']['nextprev'] = "
|
||||||
<div class='text-center'>
|
<div class='text-center'>
|
||||||
{DOWNLOAD_BACK_TO_CATEGORY_LIST}
|
{DOWNLOAD_BACK_TO_CATEGORY_LIST}
|
||||||
@ -598,16 +600,57 @@ $DOWNLOAD_TEMPLATE['list']['nextprev'] = "
|
|||||||
{DOWNLOAD_LIST_NEXTPREV}
|
{DOWNLOAD_LIST_NEXTPREV}
|
||||||
</div>";
|
</div>";
|
||||||
|
|
||||||
|
/*
|
||||||
$sc_style['DOWNLOAD_LIST_NEXTPREV']['pre'] = "<div class='nextprev'>";
|
$sc_style['DOWNLOAD_LIST_NEXTPREV']['pre'] = "<div class='nextprev'>";
|
||||||
$sc_style['DOWNLOAD_LIST_NEXTPREV']['post'] = " </div>";
|
$sc_style['DOWNLOAD_LIST_NEXTPREV']['post'] = " </div>";
|
||||||
$DOWNLOAD_LIST_NEXTPREV = "
|
*/
|
||||||
<div style='text-align:center;margin-left:auto;margin-right:auto'>
|
|
||||||
{DOWNLOAD_BACK_TO_CATEGORY_LIST}
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
{DOWNLOAD_LIST_NEXTPREV}
|
|
||||||
</div>";
|
|
||||||
|
|
||||||
// ##### ------------------------------------------------------------------------------------------
|
// ##### ------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
$DOWNLOAD_TEMPLATE['mirror']['start'] = "{DOWNLOAD_BREADCRUMB}
|
||||||
|
<table class='table table-striped'>
|
||||||
|
<colgroup>
|
||||||
|
<col style='width:1%'/>
|
||||||
|
<col style='width:29%'/>
|
||||||
|
<col style='width:40%'/>
|
||||||
|
<col style='width:20%'/>
|
||||||
|
<col style='width:10%'/>
|
||||||
|
</colgroup>
|
||||||
|
<tr>
|
||||||
|
<th class='fcaption'>{DOWNLOAD_MIRROR_REQUEST_ICON}</th>
|
||||||
|
<th class='fcaption' colspan='5'>".LAN_dl_72."{DOWNLOAD_MIRROR_REQUEST}</th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class='forumheader' colspan='2'>".LAN_dl_68."</th>
|
||||||
|
<th class='forumheader'>".LAN_dl_71."</th>
|
||||||
|
<th class='forumheader'>".LAN_dl_70."</th>
|
||||||
|
<th class='forumheader'>".LAN_dl_21."</th>
|
||||||
|
<th class='forumheader'>".LAN_dl_32."</th>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
|
||||||
|
|
||||||
|
$DOWNLOAD_TEMPLATE['mirror']['item'] = "
|
||||||
|
<tr>
|
||||||
|
<td>{DOWNLOAD_MIRROR_IMAGE}</td>
|
||||||
|
<td>
|
||||||
|
{DOWNLOAD_MIRROR_NAME}<br />
|
||||||
|
<small>
|
||||||
|
{DOWNLOAD_MIRROR_REQUESTS}
|
||||||
|
<br/>{DOWNLOAD_TOTAL_MIRROR_REQUESTS}
|
||||||
|
</small>
|
||||||
|
</td>
|
||||||
|
<td>{DOWNLOAD_MIRROR_DESCRIPTION}</td>
|
||||||
|
<td>{DOWNLOAD_MIRROR_LOCATION}</td>
|
||||||
|
<td>{DOWNLOAD_MIRROR_FILESIZE}</td>
|
||||||
|
<td>{DOWNLOAD_MIRROR_LINK}</td>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
|
||||||
|
$DOWNLOAD_TEMPLATE['mirror']['end'] = "
|
||||||
|
</table>
|
||||||
|
";
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user