Mercurial > hg > mgallery
changeset 7:dec931d9e860
Implement configurable navigation controls.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 30 May 2015 12:08:39 +0300 |
parents | 405a02586fc2 |
children | 0a284f2ccc73 |
files | mgallery.inc.php mgallery.php |
diffstat | 2 files changed, 27 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/mgallery.inc.php Sat May 30 11:49:32 2015 +0300 +++ b/mgallery.inc.php Sat May 30 12:08:39 2015 +0300 @@ -70,6 +70,10 @@ "image_navigation" => array(MG_INT, GNAV_TOP | GNAV_BOTTOM | GNAV_SIDE_IMG | GNAV_TEXT | GNAV_JAVASCRIPT | GNAV_BREADCRUMBS), "album_navigation" => array(MG_INT, GNAV_BREADCRUMBS), + "navi_ctrl_up" => array(MG_STR, "^^"), + "navi_ctrl_prev" => array(MG_STR, "<<"), + "navi_ctrl_next" => array(MG_STR, ">>"), + "album_row_limit" => array(MG_INT, 5), "album_page_limit" => array(MG_INT, 100),
--- a/mgallery.php Sat May 30 11:49:32 2015 +0300 +++ b/mgallery.php Sat May 30 12:08:39 2015 +0300 @@ -78,23 +78,35 @@ } -function mgGetControl($str, $class, &$galIndex, $index, $delta, $naviFlags) +function mgGetControlText($id, $active, $url, $naviFlags) +{ + if ($naviFlags & GNAV_TEXT) + { + $str = chentities(mgGetSetting("navi_ctrl_".$id)); + return + "<span class=\"naviControl ".$id."\">[". + ($active ? "<a href=\"".$url."\">".$str."</a>" : $str). + "]</span>"; + } + else + return ""; +} + + +function mgGetControl($id, &$galIndex, $index, $delta, $naviFlags) { $active = mgGetNaviActive($galIndex, $index, $delta, $res, $url, TRUE); if ($active && ($naviFlags & GNAV_IMG)) - $img = mgGetNaviControlImage($galIndex, $res, $class, $url); + $img = mgGetNaviControlImage($galIndex, $res, $id, $url); else $img = ""; - if ($naviFlags & GNAV_TEXT) - $str = "<span class=\"naviControl ".$class."\">[".($active ? "<a href=\"".$url."\">".$str."</a>" : $str)."]</span>"; - else - $str = ""; + $text = mgGetControlText($id, $active, $url, $naviFlags); if ($delta < 0) - return $img.$str; + return $img.$text; else - return $str.$img; + return $text.$img; } @@ -104,9 +116,9 @@ return "<div class=\"naviControls\">". - mgGetControl("<<", "prev", $galIndex, $index, -1, $naviFlags). - "[<a href=\"".mgGetURL($galPath, FALSE)."\">^^</a>]". - mgGetControl(">>", "next", $galIndex, $index, 1, $naviFlags). + mgGetControl("prev", $galIndex, $index, -1, $naviFlags). + mgGetControlText("up", TRUE, mgGetURL($galPath, FALSE), $naviFlags). + mgGetControl("next", $galIndex, $index, 1, $naviFlags). "</div>\n"; }