mirror of
https://github.com/e107inc/e107.git
synced 2025-08-03 21:27:25 +02:00
Gallery pagination
This commit is contained in:
@@ -244,17 +244,32 @@ class e_media
|
|||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the total number of Images in a particular category
|
||||||
|
*/
|
||||||
|
public function countImages($cat)
|
||||||
|
{
|
||||||
|
$query = "SELECT media_id FROM #core_media WHERE media_category = '".$cat."' ";
|
||||||
|
return e107::getDb()->db_Select_gen($query);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array of Images in a particular category
|
* Return an array of Images in a particular category
|
||||||
*/
|
*/
|
||||||
public function getImages($cat,$from='',$amount='')
|
public function getImages($cat, $from=0, $amount=null)
|
||||||
{
|
{
|
||||||
if(!$cat) return;
|
if(!$cat) return;
|
||||||
// TODO check the category is valid.
|
// TODO check the category is valid.
|
||||||
|
// TODO check userclasses.
|
||||||
$ret = array();
|
$ret = array();
|
||||||
e107::getDb()->db_Select_gen("SELECT * FROM #core_media WHERE media_category = '".$cat."' ORDER BY media_name");
|
$query = "SELECT * FROM #core_media WHERE media_category = '".$cat."' ORDER BY media_name";
|
||||||
|
|
||||||
|
if($amount)
|
||||||
|
{
|
||||||
|
$query .= " LIMIT ".$from." ,".$amount;
|
||||||
|
}
|
||||||
|
e107::getDb()->db_Select_gen($query);
|
||||||
while($row = e107::getDb()->db_Fetch(mySQL_ASSOC))
|
while($row = e107::getDb()->db_Fetch(mySQL_ASSOC))
|
||||||
{
|
{
|
||||||
$id = $row['media_id'];
|
$id = $row['media_id'];
|
||||||
|
@@ -74,18 +74,28 @@ class gallery
|
|||||||
function showImages($cat)
|
function showImages($cat)
|
||||||
{
|
{
|
||||||
$mes = e107::getMessage();
|
$mes = e107::getMessage();
|
||||||
|
$tp = e107::getParser();
|
||||||
$template = e107::getTemplate('gallery');
|
$template = e107::getTemplate('gallery');
|
||||||
$list = e107::getMedia()->getImages($cat);
|
|
||||||
$sc = e107::getScBatch('gallery',TRUE);
|
$sc = e107::getScBatch('gallery',TRUE);
|
||||||
|
|
||||||
$text = "";
|
$sc->total = e107::getMedia()->countImages($cat);
|
||||||
|
$sc->amount = 9; // TODO Add Pref.
|
||||||
|
$sc->curCat = $cat;
|
||||||
|
$sc->from = ($_GET['frm']) ? intval($_GET['frm']) : 0;
|
||||||
|
|
||||||
|
$list = e107::getMedia()->getImages($cat,$sc->from,$sc->amount);
|
||||||
|
|
||||||
|
$inner = "";
|
||||||
|
|
||||||
foreach($list as $row)
|
foreach($list as $row)
|
||||||
{
|
{
|
||||||
$sc->setParserVars($row);
|
$sc->setParserVars($row);
|
||||||
$text .= e107::getParser()->parseTemplate($template['LIST_ITEM'],TRUE);
|
$inner .= $tp->parseTemplate($template['LIST_ITEM'],TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = $template['LIST_START'].$text.$template['LIST_END'];
|
$text = $tp->parseTemplate($template['LIST_START'],TRUE);
|
||||||
|
$text .= $inner;
|
||||||
|
$text .= $tp->parseTemplate($template['LIST_END'],TRUE);
|
||||||
|
|
||||||
e107::getRender()->tablerender("Gallery :: ".str_replace("_"," ",$cat),$mes->render().$text);
|
e107::getRender()->tablerender("Gallery :: ".str_replace("_"," ",$cat),$mes->render().$text);
|
||||||
|
|
||||||
|
@@ -22,4 +22,8 @@
|
|||||||
|
|
||||||
.gallery-cat-title { text-align:center; }
|
.gallery-cat-title { text-align:center; }
|
||||||
|
|
||||||
|
.gallery-list-nextprev { text-align:center; }
|
||||||
|
|
||||||
|
.gallery-list-back { }
|
||||||
|
|
||||||
|
|
||||||
|
@@ -11,6 +11,12 @@ if (!defined('e107_INIT')) { exit; }
|
|||||||
|
|
||||||
class gallery_shortcodes extends e_shortcode
|
class gallery_shortcodes extends e_shortcode
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public $total = 0;
|
||||||
|
public $amount = 3;
|
||||||
|
public $from = 0;
|
||||||
|
public $curCat = null;
|
||||||
|
|
||||||
function sc_gallery_caption($parm='')
|
function sc_gallery_caption($parm='')
|
||||||
{
|
{
|
||||||
$text = "<a href='".e107::getParser()->replaceConstants($this->eParserVars['media_url'])."' rel='external shadowbox' >";
|
$text = "<a href='".e107::getParser()->replaceConstants($this->eParserVars['media_url'])."' rel='external shadowbox' >";
|
||||||
@@ -46,5 +52,13 @@ class gallery_shortcodes extends e_shortcode
|
|||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function sc_gallery_nextprev($parm='')
|
||||||
|
{
|
||||||
|
$url = e_SELF."?cat=".$this->curCat."--AMP--frm=--FROM--";
|
||||||
|
$parm = 'total='.$this->total.'&amount='.$this->amount.'¤t='.$this->from.'&url='.$url; // .'&url='.$url;
|
||||||
|
$text .= e107::getParser()->parseTemplate("{NEXTPREV=".$parm."}");
|
||||||
|
return $text;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -21,7 +21,8 @@ $GALLERY_TEMPLATE['LIST_ITEM'] =
|
|||||||
$GALLERY_TEMPLATE['LIST_END'] =
|
$GALLERY_TEMPLATE['LIST_END'] =
|
||||||
"</div>
|
"</div>
|
||||||
<div class='gallery-list-end' >
|
<div class='gallery-list-end' >
|
||||||
<a href='".e_SELF."'>Back to Categories</a>
|
<div class='gallery-list-nextprev'>{GALLERY_NEXTPREV}</div>
|
||||||
|
<div class='gallery-list-back'><a href='".e_SELF."'>Back to Categories</a></div>
|
||||||
</div>
|
</div>
|
||||||
";
|
";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user