1
0

Added moduleorder and navcarousel

This commit is contained in:
hukoeth 2010-08-03 19:26:22 +02:00 committed by Bharat Mediratta
parent d917430aec
commit fa134d1313
19 changed files with 856 additions and 0 deletions

View File

@ -0,0 +1,105 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Admin_Moduleorder_Controller extends Admin_Controller {
public function index() {
print $this->_get_view();
}
private function _get_view() {
$view = new Admin_View("admin.html");
$view->page_title = t("Manage Module Order");
$view->content = new View("admin_moduleorder.html");
$view->content->csrf = access::csrf_token();
$view->content->available = new View("admin_moduleorder_blocks.html");
$view->content->active = new View("admin_moduleorder_blocks.html");
$view->content->available->modules = $this->_get_modules();
return $view;
}
public function update() {
//Get the ordered list of modules
$modulerawlist = explode("&", trim($_POST['modulelist'], "&"));
//Make sure that gallery and user modules are first in the list
$currentindex = 2;
$indent_provider = module::get_var("gallery", "identity_provider")
foreach ($modulerawlist as $row) {
$currentry = explode("=", $row);
$currentry = explode(":", $currentry[1]);
if ($currentry[0] == "gallery") {
$modulelist[0] = $row;
} elseif ($currentry[0] == $indent_provider) {
$modulelist[1] = $row;
} else {
$modulelist[$currentindex] = $row;
$currentindex++;
}
}
ksort($modulelist);
//Get the highest used index
$highestindex = 0;
foreach ($modulelist as $row) {
$currentry = explode(":", $row);
if ($currentry[1] > $highestindex) {
$highestindex = $currentry[1];
}
}
$highestindex++; //Have a safety margin just in case
//To avoid conflicts on the index we now rewrite all indices of all modules
foreach ($modulelist as $row) {
$highestindex++;
$currentry = explode("=", $row);
$currentry = explode(":", $currentry[1]);
db::build()
->update("modules")
->set("id", $highestindex)
->where("name", "=", $currentry[0])
->execute();
}
//Now we are ready to write the correct id values
$highestindex = 0;
foreach ($modulelist as $row) {
$highestindex++;
$currentry = explode("=", $row);
$currentry = explode(":", $currentry[1]);
db::build()
->update("modules")
->set("id", $highestindex)
->where("name", "=", $currentry[0])
->execute();
}
//As last step we optimize the table
db::query("OPTIMIZE TABLE `modules`")
->execute();
message::success(t("Your settings have been saved."));
url::redirect("admin/moduleorder");
print $this->_get_view();
}
private function _get_modules() {
$active_blocks = array();
$available_modules = module_manager::get_available_site_modules();
return $available_modules;
}
}

View File

@ -0,0 +1,33 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class module_manager_Core {
static function get_available_site_modules() {
return self::_get_modules();
}
private static function _get_modules() {
$modules = array();
foreach (db::query("SELECT * FROM `modules` ORDER BY `id`")
->execute() as $row) {
$modules["{$row->name}:$row->id"] = $row->name;
}
return $modules;
}
}

View File

@ -0,0 +1,28 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class moduleorder_event_Core {
static function admin_menu($menu, $theme) {
$menu->get("settings_menu")
->append(Menu::factory("link")
->id("moduleorder_menu")
->label(t("Manage Module Order"))
->url(url::site("admin/moduleorder")));
}
}

View File

@ -0,0 +1,3 @@
name = "Module Order"
description = "Allows you to change the order in which modules are executed"
version = 1

View File

@ -0,0 +1,56 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<script type="text/javascript">
$(document).ready(function(){
$(".g-admin-blocks-list").height($(".g-admin-blocks-list").height());
});
$(function() {
$(".g-admin-blocks-list ul").sortable({
connectWith: ".g-sortable-blocks",
opacity: .7,
placeholder: "g-target",
update: function(event,ui) {
}
}).disableSelection();
});
function buildmodulelist () {
var active_modules = "";
$("ul#g-active-blocks li").each(function(i) {
active_modules += "&modules["+i+"]="+$(this).attr("ref");
});
document.moduleorder.modulelist.value = active_modules;
document.moduleorder.submit();
}
</script>
<div id="g-block-admin" class="g-block ui-helper-clearfix">
<h1> <?= t("Manage Module Order") ?> </h1>
<p>
<?= t("Select and drag blocks to change the order. Click 'Save' to save your changes.") ?>
</p>
<h2> <?= t("Important notes") ?> </h2>
<p>
<?= t("You will only need to change this order in rare circumstances (e.g. if two modules display content at the bottom of the image and you want to change the order in which this content is being shown). If everything on your Gallery Site is looking normal then please do not touch this.") ?>
</p>
<p>
<?= t("The core module ('gallery') and the identity provider module (default is 'user') cannot be sorted. When saving, these two modules will be automatically put at the top of the list.") ?>
</p>
<div class="g-block-content">
<div id="g-site-blocks">
<div class="g-admin-blocks-list g-left">
<h3><?= t("Installed Modules") ?></h3>
<div>
<ul id="g-active-blocks" class="g-sortable-blocks">
<?= $available ?>
</ul>
</div>
</div>
</div>
</div>
<form name="moduleorder" action="<?= url::site("admin/moduleorder/update?csrf={$csrf}") ?>" method="post">
<input type="hidden" name="modulelist" value="">
</form>
<a class="ui-state-default ui-corner-all" style="padding: 5px;" href="javascript: buildmodulelist()">Save</a>
</div>

View File

@ -0,0 +1,9 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? $indent_provider = module::get_var("gallery", "identity_provider") ?>
<? foreach ($modules as $ref => $text): ?>
<? if ($text == "gallery" || $text == $indent_provider): ?>
<li style="background-color:#A8A8A8; margin:0.5em; padding:0.3em 0.8em;" ref="<?= $ref ?>"><?= $text ?></li>
<? else: ?>
<li class="g-draggable" ref="<?= $ref ?>"><?= $text ?></li>
<? endif ?>
<? endforeach ?>

View File

@ -0,0 +1,130 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Admin_Navcarousel_Controller extends Admin_Controller {
public function index() {
print $this->_get_view();
}
public function handler() {
access::verify_csrf();
$form = $this->_get_form();
if ($form->validate()) {
$scrollsize = intval($form->navcarousel->scrollsize->value);
$showelements = intval($form->navcarousel->showelements->value);
$carouselwidth = intval($form->navcarousel->carouselwidth->value);
$thumbsize = intval($form->thumbsettings->thumbsize->value);
if ($showelements < 1) {
$showelements = 1;
message::error(t("You must show at least one item."));
}
if ($scrollsize < 1) {
$scrollsize = 1;
message::error(t("You must scroll by at least one item."));
}
if ($thumbsize > 150 || $thumbsize < 25) {
$thumbsize = 50;
message::error(t("The size of the thumbnails must be between 25 and 150 pixel."));
}
if ($carouselwidth < ($thumbsize + 75) && $carouselwidth > 0) {
$carouselwidth = $thumbsize + 75;
message::error(t("The carousel must be at least %pixel wide.", array("pixel" => $carouselwidth)));
}
if ($carouselwidth > 0) {
if ($carouselwidth < ((($thumbsize + 11) * $showelements) + 64)) {
$showelements = ($carouselwidth - 64) / ($thumbsize + 11);
$showelements = intval(floor($showelements));
message::error(t("With the selected carousel width and thumbnail size you can show a maximum of %itemno items.", array("itemno" => $showelements)));
}
} else {
message::warning(t("The maximum number of displayable items cannot be calculated when the carousel width is set to 0."));
}
if ($scrollsize > $showelements) {
$scrollsize = $showelements;
message::error(t("The number of items to scroll must not exceed the number of items to show."));
}
module::set_var(
"navcarousel", "scrollsize", $scrollsize);
module::set_var(
"navcarousel", "showelements", $showelements);
module::set_var(
"navcarousel", "carouselwidth", $carouselwidth);
module::set_var(
"navcarousel", "thumbsize", $thumbsize);
module::set_var(
"navcarousel", "abovephoto", $form->navcarousel->abovephoto->value, true);
module::set_var(
"navcarousel", "noajax", $form->navcarousel->noajax->value, true);
module::set_var(
"navcarousel", "maintainaspect", $form->thumbsettings->maintainaspect->value, true);
module::set_var(
"navcarousel", "nomouseover", $form->thumbsettings->nomouseover->value, true);
module::set_var(
"navcarousel", "noresize", $form->thumbsettings->noresize->value, true);
message::success(t("Your settings have been saved."));
url::redirect("admin/navcarousel");
}
print $this->_get_view($form);
}
private function _get_view($form=null) {
$v = new Admin_View("admin.html");
$v->content = new View("admin_navcarousel.html");
$v->content->form = empty($form) ? $this->_get_form() : $form;
return $v;
}
private function _get_form() {
$form = new Forge("admin/navcarousel/handler", "", "post", array("id" => "g-admin-form"));
$group = $form->group("navcarousel")->label(t("Navigation carousel settings"));
$group->input("scrollsize")->label(t('Enter how many items you want to scroll when clicking next or previous'))
->value(module::get_var("navcarousel", "scrollsize", "7"))
->rules("valid_numeric|length[1,2]");
$group->input("showelements")->label(t('Enter how many items you want to be visible'))
->value(module::get_var("navcarousel", "showelements", "7"))
->rules("valid_numeric|length[1,2]");
$group->input("carouselwidth")->label(t('Carousel width (in pixel). If set to 0 the carousel will use the full available width.'))
->value(module::get_var("navcarousel", "carouselwidth", "600"))
->rules("valid_numeric|length[1,3]");
$group->checkbox("abovephoto")->label(t("Show carousel above photo"))
->checked(module::get_var("navcarousel", "abovephoto", false));
$group->checkbox("noajax")->label(t("Disable dynamic loading of thumbnails (might be slow for big albums)"))
->checked(module::get_var("navcarousel", "noajax", false));
$group = $form->group("thumbsettings")->label(t("Change how thumnails are displayed"));
$group->input("thumbsize")->label(t('Thumbnail size (in pixel)'))
->value(module::get_var("navcarousel", "thumbsize", "50"))
->rules("valid_numeric|length[1,3]");
$group->checkbox("nomouseover")->label(t("Do not show item title and number on mouse over"))
->checked(module::get_var("navcarousel", "nomouseover", false));
$group->checkbox("noresize")->label(t("Crop thumbails instead of resizing them."))
->onClick("changeaspectstate()")
->id("noresize")
->checked(module::get_var("navcarousel", "noresize", false));
$group->checkbox("maintainaspect")->label(t("Maintain aspect ratio of the items for the thumbnails."))
->id("maintainaspect")
->checked(module::get_var("navcarousel", "maintainaspect", false));
$form->submit("submit")->value(t("Save"));
return $form;
}
}

View File

@ -0,0 +1,62 @@
<?php //defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Navcarousel_Controller extends Controller {
public function item($itemid) {
// This function creates the xml file for jCarousel
$curritem = ORM::factory("item", $itemid);
$parent = $curritem->parent();
$item_count = -1;
// Array indexes are 0-based, jCarousel positions are 1-based.
$first = max(0, intval($_GET['first']) - 1);
$last = max($first + 1, intval($_GET['last']) - 1);
$length = $last - $first + 1;
// Build the array with the thumbnail URLs
foreach ($parent->viewable()->children() as $photo) {
if (!$photo->is_album()) {
$item_count++;
$itemlist[$item_count] = $photo->thumb_url();
}
}
$total = count($itemlist);
$selected = array_slice($itemlist, $first, $length);
// ---
header('Content-Type: text/xml');
echo '<data>';
// Return total number of images so the callback
// can set the size of the carousel.
echo ' <total>' . $total . '</total>';
foreach ($selected as $img) {
echo ' <image>' . $img . '</image>';
}
echo '</data>';
}
}

View File

@ -0,0 +1 @@
Button images copyright by Tango Icon Library Team (http://tango.freedesktop.org/Tango_Icon_Library)

View File

@ -0,0 +1,124 @@
.jcarousel-skin-tango .jcarousel-container {
-moz-border-radius: 10px;
background: transparent;
border: 0;
}
.jcarousel-skin-tango .jcarousel-container-horizontal {
padding: 0 60px;
margin: 0 auto;
}
.jcarousel-skin-tango .jcarousel-item {
background-color: transparent !important;
}
.jcarousel-skin-tango .jcarousel-item-horizontal {
margin-right: 2px;
margin-right: 2px;
padding-top: 2px;
text-align: center;
}
.jcarousel-skin-tango .jcarousel-item-placeholder {
background: #fff;
color: #000;
}
/**
* Horizontal Buttons
*/
.jcarousel-skin-tango .jcarousel-next-horizontal {
position: absolute;
right: 18px;
width: 32px;
height: 32px;
cursor: pointer;
background: transparent url('../images/next-horizontal.png') no-repeat 0 0;
visibility: hidden;
}
.jcarousel-skin-tango .jcarousel-next-horizontal:hover {
background-position: -32px 0;
}
.jcarousel-skin-tango .jcarousel-next-horizontal:active {
background-position: -64px 0;
}
.jcarousel-skin-tango .jcarousel-next-disabled-horizontal,
.jcarousel-skin-tango .jcarousel-next-disabled-horizontal:hover,
.jcarousel-skin-tango .jcarousel-next-disabled-horizontal:active {
cursor: default;
background-position: -96px 0;
}
.jcarousel-skin-tango .jcarousel-prev-horizontal {
position: absolute;
left: 18px;
width: 32px;
height: 32px;
cursor: pointer;
background: transparent url('../images/prev-horizontal.png') no-repeat 0 0;
visibility: hidden;
}
.jcarousel-skin-tango .jcarousel-prev-horizontal:hover {
background-position: -32px 0;
}
.jcarousel-skin-tango .jcarousel-prev-horizontal:active {
background-position: -64px 0;
}
.jcarousel-skin-tango .jcarousel-prev-disabled-horizontal,
.jcarousel-skin-tango .jcarousel-prev-disabled-horizontal:hover,
.jcarousel-skin-tango .jcarousel-prev-disabled-horizontal:active {
cursor: default;
background-position: -96px 0;
}
.carousel-thumbnail {
padding: 5px;
margin: 0 !important;
}
.carousel-thumbnail:hover {
box-shadow: 1px 0px 8px #d7e1fa;
-moz-box-shadow: 1px 0px 8px #d7e1fa;
-webkit-box-shadow: 1px 0px 8px #d7e1fa;
behavior: url(ie-css3.htc);
}
.carousel-current {
box-shadow: 1px 0px 8px #d7e1fa;
-moz-box-shadow: 1px 0px 8px #d7e1fa;
-webkit-box-shadow: 1px 0px 8px #d7e1fa;
behavior: url(ie-css3.htc);
padding: 5px;
margin: 0 !important;
}
#navcarousel-wrapper {
width: 100%;
background: url('../images/ajax-loader.gif') no-repeat center center;
}
#navcarousel {
visibility: hidden;
}
/**
* RTL Support
*/
.jcarousel-skin-tango .jcarousel-direction-rtl {direction:rtl;}
.jcarousel-skin-tango .jcarousel-direction-rtl .jcarousel-item-horizontal{ margin-right:0; margin-left:10px;}
/*horizontal buttons*/
.jcarousel-skin-tango .jcarousel-direction-rtl .jcarousel-next-horizontal{
background-image:url('../images/prev-horizontal.png'); right:auto; left:5px;
}
.jcarousel-skin-tango .jcarousel-direction-rtl .jcarousel-prev-horizontal{
background-image:url('../images/next-horizontal.png'); left:auto; right:5px;
}

View File

@ -0,0 +1,28 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2009 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class navcarousel_event_Core {
static function admin_menu($menu, $theme) {
$menu->get("settings_menu")
->append(Menu::factory("link")
->id("navcarousel_menu")
->label(t("Navigation carousel"))
->url(url::site("admin/navcarousel")));
}
}

View File

@ -0,0 +1,121 @@
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
* Copyright (C) 2000-2010 Bharat Mediratta
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class navcarousel_theme_Core {
static function head($theme) {
if ($theme->page_type == "item") {
if (locales::is_rtl()) {
$rtl_support = "horizontalDirection: 'rtl',\n";
} else {
$rtl_support = "";
}
$carouselwidth = module::get_var("navcarousel", "carouselwidth", "600");
if ($carouselwidth == 0) {
$carouselwidth = "100%";
$containerwidth = "";
} else {
$carouselwidth = $carouselwidth ."px";
$containerwidth = ".jcarousel-skin-tango .jcarousel-container-horizontal {\n
width: ". $carouselwidth .";\n
}\n";
}
$thumbsize = module::get_var("navcarousel", "thumbsize", "50");
$theme->script("jquery.jcarousel.min.js");
$theme->css("skin.css");
$showelements = module::get_var("navcarousel", "showelements", "7");
$childcount = $theme->item->parent()->viewable()->children_count();
$itemoffset = intval(floor($showelements / 2));
if ($childcount <= $showelements) {
$itemoffset = 1;
} else {
$itempos = $theme->item->parent()->get_position($theme->item);
$itemoffset = $itempos - $itemoffset;
if ($itemoffset < 1) {
$itemoffset = 1;
}
if (($itemoffset + $showelements) > $childcount) {
$itemoffset = $childcount - $showelements + 1;
}
}
if (module::get_var("navcarousel", "noajax", false)) {
$ajaxhandler = "";
} else {
$ajaxhandler = "itemLoadCallback: navcarousel_itemLoadCallback,\n";
}
Return "\n<!-- Navcaoursel -->
<style type=\"text/css\">\n
". $containerwidth ."
.jcarousel-skin-tango .jcarousel-clip-horizontal {\n
width: ". $carouselwidth .";\n
height: ". ($thumbsize + 25) ."px;\n
}\n
.jcarousel-skin-tango .jcarousel-item {\n
width: ". ($thumbsize + 25) ."px;\n
height: ". ($thumbsize + 25) ."px;\n
}\n
#navcarousel-loader {\n
height: ". ($thumbsize + 25) ."px;\n
}\n
.jcarousel-skin-tango .jcarousel-next-horizontal {
top: ". (intval(floor($thumbsize / 2.8))) ."px;
}
.jcarousel-skin-tango .jcarousel-prev-horizontal {
top: ". (intval(floor($thumbsize / 2.8))) ."px;
}
</style>\n
<script type=\"text/javascript\">\n
jQuery(document).ready(function() {\n
jQuery('#navcarousel').jcarousel({\n
". $ajaxhandler ."
start: ". $itemoffset .",\n
size: ". $childcount .",\n
visible: ". $showelements .",\n
". $rtl_support ."
scroll: ". module::get_var("navcarousel", "scrollsize", "7") ."\n
});\n
});\n
$(window).load(function () {\n
$(\".jcarousel-prev-horizontal\").css(\"visibility\", \"visible\");\n
$(\".jcarousel-next-horizontal\").css(\"visibility\", \"visible\");\n
$(\"#navcarousel\").css(\"visibility\", \"visible\");\n
$(\"#navcarousel-wrapper\").css(\"background\", \"none\");\n
$(\"#navcarousel-wrapper\").css(\"float\", \"left\");\n
});\n
</script>\n
<!-- Navcaoursel -->";
}
}
static function photo_bottom($theme) {
if (!module::get_var("navcarousel", "abovephoto", false)) {
if ($theme->page_type == "item") {
return new View("navcarousel.html");
}
}
}
static function photo_top($theme) {
if (module::get_var("navcarousel", "abovephoto", false)) {
if ($theme->page_type == "item") {
return new View("navcarousel.html");
}
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,3 @@
name = "Navigation Carousel"
description = "Adds a navigation carousel under the photo."
version = 3

View File

@ -0,0 +1,17 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<script type="text/javascript">
function changeaspectstate() {
var noresizecheck = document.getElementById('noresize');
var maintainaspectcheck = document.getElementById('maintainaspect');
changestate = noresizecheck.checked ? maintainaspectcheck.disabled=true : maintainaspectcheck.disabled=false;
}
window.onload=changeaspectstate;
</script>
<div id="g-admin-navcarousel">
<h2><?= t("Navigation carousel administration") ?></h2>
<h3><?= t("Notes:") ?></h3>
<p><?= t("There is a known bug with the positioning and scrolling of the album.<br />
If you are experiencing this bug then please enable the option 'Disable dynamic loading of thumbnails'.<br />
I am working on fixing this bug and will release an update as soon as possible.") ?></p>
<?= $form ?>
</div>

View File

@ -0,0 +1,118 @@
<?php defined("SYSPATH") or die("No direct script access.");
$thumbsize = module::get_var("navcarousel", "thumbsize", "50");
$parent = $item->parent();
$item_counter = 0;
$item_offset = 0;
$maintain_aspect = module::get_var("navcarousel", "maintainaspect", false);
$no_resize = module::get_var("navcarousel", "noresize", false);
$no_ajax = module::get_var("navcarousel", "noajax", false);
?>
<div id="navcarousel-wrapper">
<ul id="navcarousel" class="jcarousel-skin-tango">
<?php
if (!$no_ajax) {
?>
</ul>
</div>
<script type="text/javascript">
function navcarousel_itemLoadCallback(carousel, state)
{
// Check if the requested items already exist
if (carousel.has(carousel.first, carousel.last)) {
return;
}
jQuery.get(
'<?= url::site("navcarousel/item/". $item->id) ?>',
{
first: carousel.first,
last: carousel.last
},
function(xml) {
navcarousel_itemAddCallback(carousel, carousel.first, carousel.last, xml);
},
'xml'
);
};
function navcarousel_itemAddCallback(carousel, first, last, xml)
{
// Set the size of the carousel
carousel.size(parseInt(jQuery('total', xml).text()));
jQuery('image', xml).each(function(i) {
carousel.add(first + i, navcarousel_getItemHTML(jQuery(this).text()));
});
};
function navcarousel_getItemHTML(url)
{
var thisurl='<?= $item->thumb_url() ?>';
var linkCollection = new Object;
<?php
}
$totalitems = ORM::factory("item")->where("parent_id", "=", $parent->id)->where("type", "=", "photo")->count_all();
foreach ($parent->viewable()->children() as $photo) {
if ($photo->is_album()) {
continue;
}
if ($photo->id == $item->id) {
$navcar_size_addition = 10;
} else {
$navcar_size_addition = 0;
}
if ($no_resize) {
$navcar_divsize = "style=\"width: ". ($thumbsize + $navcar_size_addition) ."px; height: ". ($thumbsize + $navcar_size_addition) ."px;\"";
if ($photo->width > $photo->height) {
$navcar_thumbsize = "height=\"". ($thumbsize + $navcar_size_addition) ."\"";
} else {
$navcar_thumbsize = "width=\"". ($thumbsize + $navcar_size_addition) ."\"";
}
} else {
$navcar_divsize = "";
if ($maintain_aspect) {
$navcar_thumbsize = photo::img_dimensions($photo->width, $photo->height, $thumbsize + $navcar_size_addition);
} else {
$navcar_thumbsize = "width=\"". ($thumbsize + $navcar_size_addition) ."\" height=\"". ($thumbsize + $navcar_size_addition) ."\"";
}
}
if ($no_ajax) {
if (module::get_var("navcarousel", "nomouseover", false)) {
$img_title = "";
} else {
$img_title = " title=\"". html::purify($photo->title)->for_html_attr() ." (". $parent->get_position($photo) . t("%position of %total", array("position" => "", "total" => $totalitems)) .")\"";
}
if ($item->id == $photo->id) {
echo "<li><div class=\"g-button ui-corner-all ui-icon-left ui-state-hover carousel-current\" ". $navcar_divsize ."><div style=\"width: 100%; height: 100%; overflow: hidden;\"><img src=\"". $photo->thumb_url() ."\" alt=\"". html::purify($photo->title)->for_html_attr() ."\"". $img_title ." ". $navcar_thumbsize ." /></div></div></li>\n";
} else {
echo "<li><div class=\"g-button ui-corner-all ui-icon-left ui-state-default carousel-thumbnail\" ". $navcar_divsize ."><div style=\"width: 100%; height: 100%; overflow: hidden;\"><a href=\"". $photo->abs_url() ."\"><img src=\"". $photo->thumb_url() ."\" alt=\"". html::purify($photo->title)->for_html_attr() ."\"". $img_title ." ". $navcar_thumbsize ." /></a></div></div></li>\n";
}
} else {
echo ("linkCollection['". $photo->thumb_url() ."'] = ['". $photo->abs_url() ."', '". html::purify($photo->title)->for_html_attr() ."', '". $parent->get_position($photo) ."', '". $navcar_thumbsize ."', '". $navcar_divsize ."'];\n");
}
}
if ($no_ajax) {
echo "
</ul>\n
</div>\n";
} else {
if (module::get_var("navcarousel", "nomouseover", false)) {
$img_title = "";
} else {
$img_title = " title=\"' + linkCollection[url][1] + ' (' + linkCollection[url][2] + '". t("%position of %total", array("position" => "", "total" => $totalitems)) .")\"";
}
?>
if (thisurl==url)
{
return '<div class="g-button ui-corner-all ui-icon-left ui-state-hover carousel-current" ' + linkCollection[url][4] + '><div style="width: 100%; height: 100%; overflow: hidden;"><img src="' + url + '" alt="' + linkCollection[url][1] + '"<?= $img_title ?> ' + linkCollection[url][3] + ' /></div></div>';
}
else
{
return '<div class="g-button ui-corner-all ui-icon-left ui-state-default carousel-thumbnail" ' + linkCollection[url][4] + '><div style="width: 100%; height: 100%; overflow: hidden;"><a href="' + linkCollection[url][0] + '"><img src="' + url + '" alt="' + linkCollection[url][1] + '"<?= $img_title ?> ' + linkCollection[url][3] + ' /></a></div></div>';
}
};
</script>
<?php
}