mirror of
https://github.com/e107inc/e107.git
synced 2025-04-13 09:01:59 +02:00
Download breadcrumb fix.
This commit is contained in:
parent
0846180664
commit
c581b89aa1
@ -2995,9 +2995,14 @@ class e_form
|
||||
|
||||
$text = '<ul class="breadcrumb">
|
||||
<li>';
|
||||
|
||||
|
||||
foreach($array as $val)
|
||||
{
|
||||
if($val['url'] === e_REQUEST_URI) // automatic link removal for current page.
|
||||
{
|
||||
$val['url']= null;
|
||||
}
|
||||
|
||||
$ret = "";
|
||||
$ret .= vartrue($val['url']) ? "<a href='".$val['url']."'>" : "";
|
||||
$ret .= vartrue($val['text'],'');
|
||||
|
@ -25,6 +25,9 @@ class download_shortcodes extends e_shortcode
|
||||
public $dlsubrow;
|
||||
public $dlsubsubrow;
|
||||
public $mirror;
|
||||
|
||||
public $parent;
|
||||
public $grandparent;
|
||||
|
||||
/**
|
||||
* download_shortcodes constructor
|
||||
@ -43,6 +46,7 @@ class download_shortcodes extends e_shortcode
|
||||
|
||||
$breadcrumb = array();
|
||||
|
||||
|
||||
switch ($this->qry['action'])
|
||||
{
|
||||
case 'mirror':
|
||||
@ -58,6 +62,17 @@ class download_shortcodes extends e_shortcode
|
||||
|
||||
default:
|
||||
$breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => $url->create('download/index'));
|
||||
|
||||
if(!empty($this->grandparent))
|
||||
{
|
||||
$breadcrumb[] = array('text' => $this->grandparent['download_category_name'], 'url' => ($this->grandparent['download_category_id']) ? $url->create('download/list/category', array('id'=>$this->grandparent['download_category_id'],'name'=>$this->grandparent['download_category_sef'])) : null);
|
||||
}
|
||||
|
||||
if(!empty($this->parent))
|
||||
{
|
||||
$breadcrumb[] = array('text' => $this->parent['download_category_name'], 'url' => ($this->parent['download_category_id']) ? $url->create('download/list/category', array('id'=>$this->parent['download_category_id'],'name'=>$this->parent['download_category_sef'])) : null);
|
||||
}
|
||||
|
||||
$breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => ($this->var['download_category_id']) ? $url->create('download/list/category', array('id'=>$this->var['download_category_id'],'name'=>$this->var['download_category_sef'])) : null);
|
||||
$breadcrumb[] = array('text' => $this->var['download_name'], 'url' => null);
|
||||
break;
|
||||
@ -154,7 +169,9 @@ class download_shortcodes extends e_shortcode
|
||||
$tp = e107::getParser();
|
||||
if ($this->dlsubsubrow['d_count'])
|
||||
{
|
||||
return "<a class='".$class."' href='".e_PLUGIN_ABS."download/download.php?action=list&id=".$this->dlsubsubrow['download_category_id']."'>".$tp->toHTML($this->dlsubsubrow['download_category_name'], FALSE, 'TITLE')."</a>";
|
||||
$url = e107::getUrl()->create('download/list/category', array('id'=>$this->dlsubsubrow['download_category_id'], 'name'=> vartrue($this->dlsubsubrow['download_category_sef'],'--sef-not-set--')));
|
||||
// e_PLUGIN_ABS."download/download.php?action=list&id=".$this->dlsubsubrow['download_category_id']
|
||||
return "<a class='".$class."' href='".$url."'>".$tp->toHTML($this->dlsubsubrow['download_category_name'], FALSE, 'TITLE')."</a>";
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -944,7 +961,18 @@ class download_shortcodes extends e_shortcode
|
||||
|
||||
function sc_download_back_to_category_list()
|
||||
{
|
||||
return "<a class='btn btn-default btn-xs btn-mini' href='".e_SELF."'>".LAN_dl_9."</a>";
|
||||
$url = e107::getUrl();
|
||||
|
||||
if(!empty($this->parent))
|
||||
{
|
||||
$link = $url->create('download/list/category', array('id'=>$this->parent['download_category_id'],'name'=>$this->parent['download_category_sef']));
|
||||
}
|
||||
else
|
||||
{
|
||||
$link = ($this->var['download_category_id']) ? $url->create('download/list/category', array('id'=>$this->var['download_category_id'],'name'=>$this->var['download_category_sef'])) : null;
|
||||
}
|
||||
|
||||
return "<a class='btn btn-default btn-xs btn-mini' href='".$link."'>".LAN_dl_9."</a>";
|
||||
}
|
||||
|
||||
|
||||
|
@ -19,6 +19,9 @@ class download
|
||||
|
||||
private $templateHeader = '';
|
||||
private $templateFooter = '';
|
||||
|
||||
private $subCategories = array();
|
||||
private $categories = array();
|
||||
|
||||
function __construct()
|
||||
{
|
||||
@ -35,7 +38,53 @@ class download
|
||||
$this->templateHeader = '';
|
||||
$this->templateFooter = '';
|
||||
}
|
||||
|
||||
|
||||
$pref = e107::getPref();
|
||||
|
||||
// $catObj = new downloadCategory(varset($pref['download_subsub'],1),USERCLASS_LIST,null, varset($pref['download_incinfo'], false));
|
||||
// $this->categories = $catObj->cat_tree;
|
||||
$this->loadCategories();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function loadCategories()
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
$data = $sql->retrieve("download_category", '*', 'ORDER BY download_category_order',true);
|
||||
|
||||
foreach($data as $row)
|
||||
{
|
||||
|
||||
$id = $row['download_category_parent'];
|
||||
$sub= $row['download_category_id'];
|
||||
|
||||
$this->subCategories[$id][$sub] = $row;
|
||||
if(check_class($row['download_category_class']))
|
||||
{
|
||||
$this->categories[$sub] = $row;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
private function getCategory($id)
|
||||
{
|
||||
return !empty($this->categories[$id]) ? $this->categories[$id] : false;
|
||||
|
||||
}
|
||||
|
||||
private function getParent($id)
|
||||
{
|
||||
$parent = $this->categories[$id]['download_category_parent'];
|
||||
return $this->getCategory($parent);
|
||||
}
|
||||
|
||||
private function getChildren($parent)
|
||||
{
|
||||
return !empty($this->subCategories[$parent]) ? $this->subCategories[$parent] : false;
|
||||
}
|
||||
|
||||
public function init()
|
||||
@ -158,13 +207,14 @@ class download
|
||||
$ns = e107::getRender();
|
||||
$pref = e107::getPref();
|
||||
|
||||
|
||||
|
||||
// if ($cacheData = $e107cache->retrieve("download_cat".$maincatval,720)) // expires every 12 hours. //TODO make this an option
|
||||
{
|
||||
// echo $cacheData;
|
||||
// return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(deftrue('BOOTSTRAP')) // v2.x
|
||||
{
|
||||
@ -182,6 +232,13 @@ class download
|
||||
}
|
||||
else // Legacy v1.x
|
||||
{
|
||||
$DOWNLOAD_CAT_TABLE_START = null;
|
||||
$DOWNLOAD_CAT_PARENT_TABLE = null;
|
||||
$DOWNLOAD_CAT_CHILD_TABLE = null;
|
||||
$DOWNLOAD_CAT_SUBSUB_TABLE = null;
|
||||
$DOWNLOAD_CAT_TABLE_END = null;
|
||||
|
||||
|
||||
$template_name = 'download_template.php';
|
||||
|
||||
if (is_readable(THEME."templates/".$template_name))
|
||||
@ -234,8 +291,11 @@ class download
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
e107::getDebug()->log($dlcat->cat_tree);
|
||||
|
||||
|
||||
$dl_text .= $tp->parseTemplate($this->templateHeader, TRUE, $sc);
|
||||
$dl_text = $tp->parseTemplate($this->templateHeader, TRUE, $sc);
|
||||
$dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_START, TRUE, $sc);
|
||||
$dl_text .= $download_cat_table_string;
|
||||
$dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_END, TRUE, $sc);
|
||||
@ -426,8 +486,8 @@ class download
|
||||
$DOWNLOAD_LIST_NEXTPREV = $template['list']['nextprev'];
|
||||
|
||||
$DOWNLOAD_CAT_TABLE_START = varset($template['categories']['start']);
|
||||
$DOWNLOAD_CAT_PARENT_TABLE = $template['categories']['parent'];
|
||||
$DOWNLOAD_CAT_CHILD_TABLE = $template['categories']['child'];
|
||||
// $DOWNLOAD_CAT_PARENT_TABLE = $template['categories']['parent'];
|
||||
// $DOWNLOAD_CAT_CHILD_TABLE = $template['categories']['child'];
|
||||
$DOWNLOAD_CAT_SUBSUB_TABLE = $template['categories']['subchild'];
|
||||
$DOWNLOAD_CAT_TABLE_END = varset($template['categories']['end']);
|
||||
}
|
||||
@ -460,16 +520,29 @@ class download
|
||||
$sc->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_sef,download_category_description,download_category_parent,download_category_class", "(download_category_id='{$this->qry['id']}') AND (download_category_class IN (".USERCLASS_LIST."))") )
|
||||
// if ($sql->select("download_category", "download_category_name,download_category_sef,download_category_description,download_category_parent,download_category_class", "(download_category_id='{$this->qry['id']}') AND (download_category_class IN (".USERCLASS_LIST."))") )
|
||||
|
||||
if($dlrow = $this->getCategory($this->qry['id']))
|
||||
{
|
||||
$dlrow = $sql->fetch();
|
||||
$sc->setVars($dlrow); // Used below for header / breadcrumb.
|
||||
$type = $dlrow['download_category_name'];
|
||||
|
||||
// $dlrow = $sql->fetch();
|
||||
|
||||
|
||||
$sc->setVars($dlrow); // Used below for header / breadcrumb.
|
||||
|
||||
$sc->parent = $this->getParent($this->qry['id']);
|
||||
|
||||
if(!empty( $sc->parent['download_category_parent']))
|
||||
{
|
||||
$sc->grandparent = $this->getParent( $sc->parent['download_category_id']);
|
||||
}
|
||||
|
||||
// $type = $dlrow['download_category_name'];
|
||||
|
||||
|
||||
$this->qry['name'] = $dlrow['download_category_sef'];
|
||||
|
||||
define("e_PAGETITLE", LAN_PLUGIN_DOWNLOAD_NAME." / ".$dlrow['download_category_name']);
|
||||
@ -477,7 +550,7 @@ class download
|
||||
else
|
||||
{ // No access to this category
|
||||
define("e_PAGETITLE", LAN_PLUGIN_DOWNLOAD_NAME);
|
||||
return $ns->tablerender(LAN_PLUGIN_DOWNLOAD_NAME, "<div class='alert alert-info' style='text-align:center'>".LAN_dl_3."</div>",'download-list',true);
|
||||
return $ns->tablerender(LAN_PLUGIN_DOWNLOAD_NAME, "<div class='alert alert-info' style='text-align:center'>".LAN_NO_RECORDS_FOUND."</div>",'download-list',true);
|
||||
}
|
||||
|
||||
if ($dlrow['download_category_parent'] == 0) // It's a main category - change the listing type required
|
||||
@ -492,12 +565,9 @@ class download
|
||||
|
||||
|
||||
/* 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))
|
||||
if($this->getChildren($this->qry['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,
|
||||
@ -515,6 +585,8 @@ class download
|
||||
{
|
||||
|
||||
$scArray = $sql->db_getList();
|
||||
|
||||
$subText = "";
|
||||
|
||||
/** @DEPRECATED **/
|
||||
// if(!defined("DL_IMAGESTYLE"))
|
||||
@ -523,20 +595,24 @@ class download
|
||||
// }
|
||||
|
||||
$download_cat_table_string = "";
|
||||
|
||||
$dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_PRE, TRUE, $sc);
|
||||
$dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_START, TRUE, $sc);
|
||||
|
||||
if(!empty($DOWNLOAD_CAT_TABLE_PRE)) // 0.8 BC Fix.
|
||||
{
|
||||
$subText .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_PRE, TRUE, $sc);
|
||||
}
|
||||
$subText .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_START, TRUE, $sc);
|
||||
|
||||
foreach($scArray as $dlsubsubrow)
|
||||
{
|
||||
$sc->dlsubsubrow = $dlsubsubrow;
|
||||
$dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_SUBSUB_TABLE, TRUE, $sc);
|
||||
$sc->dlsubrow = $dlsubsubrow;
|
||||
$subText .= $tp->parseTemplate($DOWNLOAD_CAT_SUBSUB_TABLE, TRUE, $sc);
|
||||
|
||||
}
|
||||
|
||||
$dl_text .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_END, TRUE, $sc);
|
||||
$subText .= $tp->parseTemplate($DOWNLOAD_CAT_TABLE_END, TRUE, $sc);
|
||||
|
||||
$text = $ns->tablerender($dl_title, $dl_text, 'download-list', true);
|
||||
$dl_text .= $ns->tablerender($dl_title, $subText, 'download-list', true);
|
||||
}
|
||||
|
||||
}// End of subcategory display
|
||||
@ -546,23 +622,15 @@ class download
|
||||
|
||||
if(!check_class($download_category_class))
|
||||
{
|
||||
|
||||
|
||||
$ns->tablerender(LAN_PLUGIN_DOWNLOAD_NAME, "
|
||||
<div style='text-align:center'>
|
||||
" . LAN_dl_3 . "
|
||||
</div>");
|
||||
|
||||
return;
|
||||
// require_once (FOOTERF);
|
||||
// exit ;
|
||||
$ns->tablerender(LAN_PLUGIN_DOWNLOAD_NAME, "<div class='alert alert-info'> " . LAN_NO_RECORDS_FOUND . "</div>");
|
||||
return null;
|
||||
}
|
||||
|
||||
if($total_downloads < $this->qry['view'])
|
||||
{
|
||||
$this->qry['from'] = 0;
|
||||
}
|
||||
|
||||
|
||||
if(!defined("DL_IMAGESTYLE"))
|
||||
{
|
||||
define("DL_IMAGESTYLE", "border:1px solid blue");
|
||||
@ -576,20 +644,27 @@ class download
|
||||
// $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 {$this->qry['from']}, ".$this->qry['view']);
|
||||
|
||||
if($filetotal)
|
||||
|
||||
|
||||
$caption = varset($DOWNLOAD_LIST_CAPTION) ? $tp->parseTemplate($DOWNLOAD_LIST_CAPTION, TRUE, $sc) : LAN_PLUGIN_DOWNLOAD_NAME;
|
||||
|
||||
if(empty($filetotal))
|
||||
{
|
||||
$caption = varset($DOWNLOAD_LIST_CAPTION) ? $tp->parseTemplate($DOWNLOAD_LIST_CAPTION, TRUE, $sc) : LAN_PLUGIN_DOWNLOAD_NAME;
|
||||
|
||||
// Only show list if some files in it
|
||||
$dl_text .= $tp->parseTemplate($DOWNLOAD_LIST_TABLE_START, TRUE, $sc);
|
||||
|
||||
global $dlft, $dltdownloads;
|
||||
|
||||
$dlft = ($filetotal < $this->qry['view'] ? $filetotal: $this->qry['view']);
|
||||
$dl_text .= $tp->parseTemplate($this->templateFooter, TRUE, $sc);
|
||||
return ($dl_text) ? $ns->tablerender($caption, $dl_text, 'download-list', true) : '';
|
||||
}
|
||||
|
||||
while($dlrow = $sql->fetch())
|
||||
{
|
||||
|
||||
// Only show list if some files in it
|
||||
$dl_text .= $tp->parseTemplate($DOWNLOAD_LIST_TABLE_START, TRUE, $sc);
|
||||
|
||||
global $dlft, $dltdownloads;
|
||||
|
||||
$dlft = ($filetotal < $this->qry['view'] ? $filetotal: $this->qry['view']);
|
||||
|
||||
while($dlrow = $sql->fetch())
|
||||
{
|
||||
$sc->setVars($dlrow);
|
||||
|
||||
$agreetext = $tp->toHTML($pref['agree_text'], TRUE, 'DESCRIPTION');
|
||||
@ -603,20 +678,14 @@ class download
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
$dl_text .= $tp->parseTemplate($DOWNLOAD_LIST_TABLE_END, TRUE, $sc);
|
||||
|
||||
if($sql->select("download_category", "*", "download_category_id='{$download_category_parent}' "))
|
||||
{
|
||||
$parent = $sql->fetch();
|
||||
}
|
||||
|
||||
$dl_text .= $tp->parseTemplate($this->templateFooter, TRUE, $sc);
|
||||
|
||||
$text .= $ns->tablerender($caption, $dl_text, 'download-list', true);
|
||||
}
|
||||
|
||||
$dl_text .= $tp->parseTemplate($DOWNLOAD_LIST_TABLE_END, TRUE, $sc);
|
||||
$dl_text .= $tp->parseTemplate($this->templateFooter, TRUE, $sc);
|
||||
|
||||
$text = $ns->tablerender($caption, $dl_text, 'download-list', true);
|
||||
|
||||
|
||||
if(!isset($DOWNLOAD_LIST_NEXTPREV))
|
||||
{
|
||||
$sc_style['DOWNLOAD_LIST_NEXTPREV']['pre'] = "
|
||||
|
@ -419,7 +419,7 @@ $DOWNLOAD_TEMPLATE['categories']['end'] = "
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class='clearfix'>
|
||||
<div class='clearfix table'>
|
||||
<div class='pull-left'><small>{DOWNLOAD_CAT_NEWDOWNLOAD_TEXT}</small></div>
|
||||
<div class='pull-right'>{DOWNLOAD_CAT_SEARCH}</div>
|
||||
</div>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user