1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00

More work on the download plugin.

This commit is contained in:
Cameron 2013-06-23 03:46:27 -07:00
parent fd5fbf6718
commit 2b27fc6ad6
4 changed files with 201 additions and 38 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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
/**

View File

@ -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'] = "
</tbody>
</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'] = "<td style='width:80%' class='forumheader3'>{---}</td>";
@ -527,11 +528,7 @@ $DOWNLOAD_TEMPLATE['view']['nextprev'] = '
<div class="text-center">{DOWNLOAD_BACK_TO_LIST}</div>
';
// ##### ------------------------------------------------------------------------------------------
$DOWNLOAD_TEMPLATE['list']['start'] = "{DOWNLOAD_BREADCRUMB}
<div style='text-align:center'>
@ -556,6 +553,8 @@ $DOWNLOAD_TEMPLATE['list']['start'] = "{DOWNLOAD_BREADCRUMB}
<th>{DOWNLOAD_LIST_CAPTION=link}</th>
</tr>";
$DOWNLOAD_TEMPLATE['list']['item'] = "
<tr>
<td>
@ -581,6 +580,8 @@ $DOWNLOAD_TEMPLATE['list']['item'] = "
</td>
</tr>";
$DOWNLOAD_TEMPLATE['list']['end'] = "
<tr>
<td class='forumheader3' colspan='7' style='text-align:right;'>{DOWNLOAD_LIST_TOTAL_AMOUNT} {DOWNLOAD_LIST_TOTAL_FILES}</td>
@ -589,7 +590,8 @@ $DOWNLOAD_TEMPLATE['list']['end'] = "
</form>
</div>\n";
$DOWNLOAD_TEMPLATE['list']['nextprev'] = "
<div class='text-center'>
{DOWNLOAD_BACK_TO_CATEGORY_LIST}
@ -598,16 +600,57 @@ $DOWNLOAD_TEMPLATE['list']['nextprev'] = "
{DOWNLOAD_LIST_NEXTPREV}
</div>";
/*
$sc_style['DOWNLOAD_LIST_NEXTPREV']['pre'] = "<div class='nextprev'>";
$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>
";
// ##### ------------------------------------------------------------------------------------------
?>