summaryrefslogtreecommitdiff
path: root/modules/gallery/libraries
diff options
context:
space:
mode:
Diffstat (limited to 'modules/gallery/libraries')
-rw-r--r--modules/gallery/libraries/Breadcrumb.php70
-rw-r--r--modules/gallery/libraries/Form_Uploadify.php15
-rw-r--r--modules/gallery/libraries/Gallery_View.php55
-rw-r--r--modules/gallery/libraries/IdentityProvider.php12
-rw-r--r--modules/gallery/libraries/InPlaceEdit.php8
-rw-r--r--modules/gallery/libraries/MY_Pagination.php35
-rw-r--r--modules/gallery/libraries/Theme_View.php47
7 files changed, 153 insertions, 89 deletions
diff --git a/modules/gallery/libraries/Breadcrumb.php b/modules/gallery/libraries/Breadcrumb.php
new file mode 100644
index 00000000..e151890d
--- /dev/null
+++ b/modules/gallery/libraries/Breadcrumb.php
@@ -0,0 +1,70 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2011 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 Breadcrumb_Core {
+ public $title;
+ public $url;
+ public $first;
+ public $last;
+
+ static function instance($title, $url) {
+ return new Breadcrumb($title, $url);
+ }
+
+ public function __construct($title, $url) {
+ $this->title = $title;
+ $this->url = $url;
+ $this->first = false;
+ $this->last = false;
+ }
+
+ /**
+ * Return an array of Breadcrumb instances build from the parents of a given item.
+ * The first and last Breadcrumb instances will be marked first/last as appropriate.
+ * Each breadcrumb will have a ?show= query parameter that refers to the id of the next
+ * item in line.
+ *
+ * @return array Breadcrumb instances
+ */
+ static function array_from_item_parents($item) {
+ if ($item->id == item::root()->id) {
+ return array();
+ }
+
+ $bc = array_merge($item->parents()->as_array(), array($item));
+ for ($i = 0; $i < count($bc) - 1; $i++) {
+ $bc[$i] = new Breadcrumb($bc[$i]->title, $bc[$i]->url("show={$bc[$i+1]->id}"));
+ }
+ $bc[$i] = new Breadcrumb($item->title, $item->url());
+
+ $bc[0]->set_first();
+ end($bc)->set_last();
+ return $bc;
+ }
+
+ public function set_first() {
+ $this->first = true;
+ return $this;
+ }
+
+ public function set_last() {
+ $this->last = true;
+ return $this;
+ }
+}
diff --git a/modules/gallery/libraries/Form_Uploadify.php b/modules/gallery/libraries/Form_Uploadify.php
index 27ab9684..450320b3 100644
--- a/modules/gallery/libraries/Form_Uploadify.php
+++ b/modules/gallery/libraries/Form_Uploadify.php
@@ -47,7 +47,22 @@ class Form_Uploadify_Core extends Form_Input {
$v->script_data = $this->data["script_data"];
$v->simultaneous_upload_limit = module::get_var("gallery", "simultaneous_upload_limit");
$v->movies_allowed = (bool) movie::find_ffmpeg();
+ $v->extensions = legal_file::get_filters();
$v->suhosin_session_encrypt = (bool) ini_get("suhosin.session.encrypt");
+
+ list ($toolkit_max_filesize_bytes, $toolkit_max_filesize) = graphics::max_filesize();
+
+ $upload_max_filesize = trim(ini_get("upload_max_filesize"));
+ $upload_max_filesize_bytes = num::convert_to_bytes($upload_max_filesize);
+
+ if ($upload_max_filesize_bytes < $toolkit_max_filesize_bytes) {
+ $v->size_limit_bytes = $upload_max_filesize_bytes;
+ $v->size_limit = $upload_max_filesize;
+ } else {
+ $v->size_limit_bytes = $toolkit_max_filesize_bytes;
+ $v->size_limit = $toolkit_max_filesize;
+ }
+
return $v;
}
diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php
index 562f7929..e04b9169 100644
--- a/modules/gallery/libraries/Gallery_View.php
+++ b/modules/gallery/libraries/Gallery_View.php
@@ -31,6 +31,52 @@ class Gallery_View_Core extends View {
}
/**
+ * Set up the data and render a pager.
+ *
+ * See themes/wind/views/pager.html for documentation on the variables generated here.
+ */
+ public function paginator() {
+ $v = new View("paginator.html");
+ $v->page_type = $this->page_type;
+ $v->page_subtype = $this->page_subtype;
+ $v->first_page_url = null;
+ $v->previous_page_url = null;
+ $v->next_page_url = null;
+ $v->last_page_url = null;
+
+ if ($this->page_type == "collection") {
+ $v->page = $this->page;
+ $v->max_pages = $this->max_pages;
+ $v->total = $this->children_count;
+
+ if ($this->page != 1) {
+ $v->first_page_url = url::site(url::merge(array("page" => 1)));
+ $v->previous_page_url = url::site(url::merge(array("page" => $this->page - 1)));
+ }
+
+ if ($this->page != $this->max_pages) {
+ $v->next_page_url = url::site(url::merge(array("page" => $this->page + 1)));
+ $v->last_page_url = url::site(url::merge(array("page" => $this->max_pages)));
+ }
+
+ $v->first_visible_position = ($this->page - 1) * $this->page_size + 1;
+ $v->last_visible_position = min($this->page * $this->page_size, $v->total);
+ } else if ($this->page_type == "item") {
+ $v->position = $this->position;
+ $v->total = $this->sibling_count;
+ if ($this->previous_item) {
+ $v->previous_page_url = $this->previous_item->url();
+ }
+
+ if ($this->next_item) {
+ $v->next_page_url = $this->next_item->url();
+ }
+ }
+
+ return $v;
+ }
+
+ /**
* Begin gather up scripts or css files so that they can be combined into a single request.
*
* @param $types a comma separated list of types to combine, eg "script,css"
@@ -111,6 +157,8 @@ class Gallery_View_Core extends View {
$contents = $cache->get($key);
if (empty($contents)) {
+ module::event("before_combine", $type, $this->combine_queue[$type][$group]);
+
$contents = "";
foreach (array_keys($this->combine_queue[$type][$group]) as $path) {
if ($type == "css") {
@@ -120,6 +168,8 @@ class Gallery_View_Core extends View {
}
}
+ module::event("after_combine", $type, $contents);
+
$cache->set($key, $contents, array($type), 30 * 84600);
$use_gzip = function_exists("gzencode") &&
@@ -128,9 +178,13 @@ class Gallery_View_Core extends View {
$cache->set("{$key}_gz", gzencode($contents, 9, FORCE_GZIP),
array($type, "gzip"), 30 * 84600);
}
+
}
unset($this->combine_queue[$type][$group]);
+ if (empty($this->combine_queue[$type])) {
+ unset($this->combine_queue[$type]);
+ }
if ($type == "css") {
return html::stylesheet("combined/css/$key", "screen,print,projection", true);
@@ -158,6 +212,7 @@ class Gallery_View_Core extends View {
$replace[] = "url('" . url::abs_file($relative) . "')";
} else {
Kohana_Log::add("error", "Missing URL reference '{$match[1]}' in CSS file '$css_file'");
+
}
}
$replace = str_replace(DIRECTORY_SEPARATOR, "/", $replace);
diff --git a/modules/gallery/libraries/IdentityProvider.php b/modules/gallery/libraries/IdentityProvider.php
index 153446e6..3f995923 100644
--- a/modules/gallery/libraries/IdentityProvider.php
+++ b/modules/gallery/libraries/IdentityProvider.php
@@ -110,11 +110,11 @@ class IdentityProvider_Core {
Kohana_Log::add("error", "Error restoring original identity provider\n" .
$e2->getMessage() . "\n" . $e2->getTraceAsString());
}
-
+
message::error(
t("Error attempting to enable \"%new_provider\" identity provider, reverted to \"%old_provider\" identity provider",
array("new_provider" => $new_provider, "old_provider" => $current_provider)));
-
+
$restore_already_running = false;
}
throw $e;
@@ -260,14 +260,14 @@ class IdentityProvider_Core {
/**
* @see IdentityProvider_Driver::add_user_to_group.
*/
- public function add_user_to_group($user, $group_id) {
- return $this->driver->add_user_to_group($user, $group_id);
+ public function add_user_to_group($user, $group) {
+ return $this->driver->add_user_to_group($user, $group);
}
/**
* @see IdentityProvider_Driver::remove_user_to_group.
*/
- public function remove_user_from_group($user, $group_id) {
- return $this->driver->remove_user_from_group($user, $group_id);
+ public function remove_user_from_group($user, $group) {
+ return $this->driver->remove_user_from_group($user, $group);
}
} // End Identity
diff --git a/modules/gallery/libraries/InPlaceEdit.php b/modules/gallery/libraries/InPlaceEdit.php
index 88c30494..739cbb61 100644
--- a/modules/gallery/libraries/InPlaceEdit.php
+++ b/modules/gallery/libraries/InPlaceEdit.php
@@ -56,8 +56,12 @@ class InPlaceEdit_Core {
}
public function validate() {
- $post = Validation::factory($_POST)
- ->add_callbacks("input", $this->callback);
+ $post = Validation::factory($_POST);
+
+ if (!empty($this->callback)) {
+ $post->add_callbacks("input", $this->callback);
+ }
+
foreach ($this->rules as $rule) {
$post->add_rules("input", $rule);
}
diff --git a/modules/gallery/libraries/MY_Pagination.php b/modules/gallery/libraries/MY_Pagination.php
deleted file mode 100644
index e697c0bd..00000000
--- a/modules/gallery/libraries/MY_Pagination.php
+++ /dev/null
@@ -1,35 +0,0 @@
-<?php defined("SYSPATH") or die("No direct script access.");
-/**
- * Gallery - a web based photo album viewer and editor
- * Copyright (C) 2000-2011 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 Pagination extends Pagination_Core {
- public function render($style=NULL) {
- // Hide single page pagination
- if ($this->auto_hide === TRUE AND $this->total_pages <= 1) {
- return "";
- }
-
- if ($style === NULL) {
- // Use default style
- $style = $this->style;
- }
-
- // Return rendered pagination view
- return View::factory("pager.html", get_object_vars($this))->render();
- }
-}
diff --git a/modules/gallery/libraries/Theme_View.php b/modules/gallery/libraries/Theme_View.php
index d0b35d3e..13e58004 100644
--- a/modules/gallery/libraries/Theme_View.php
+++ b/modules/gallery/libraries/Theme_View.php
@@ -38,6 +38,7 @@ class Theme_View_Core extends Gallery_View {
$this->item = null;
$this->tag = null;
$this->set_global(array("theme" => $this,
+ "theme_info" => theme::get_info($this->theme_name),
"user" => identity::active_user(),
"page_type" => $page_type,
"page_subtype" => $page_subtype,
@@ -142,52 +143,6 @@ class Theme_View_Core extends Gallery_View {
}
/**
- * Set up the data and render a pager.
- *
- * See themes/wind/views/pager.html for documentation on the variables generated here.
- */
- public function paginator() {
- $v = new View("paginator.html");
- $v->page_type = $this->page_type;
- $v->page_subtype = $this->page_subtype;
- $v->first_page_url = null;
- $v->previous_page_url = null;
- $v->next_page_url = null;
- $v->last_page_url = null;
-
- if ($this->page_type == "collection") {
- $v->page = $this->page;
- $v->max_pages = $this->max_pages;
- $v->total = $this->children_count;
-
- if ($this->page != 1) {
- $v->first_page_url = url::site(url::merge(array("page" => 1)));
- $v->previous_page_url = url::site(url::merge(array("page" => $this->page - 1)));
- }
-
- if ($this->page != $this->max_pages) {
- $v->next_page_url = url::site(url::merge(array("page" => $this->page + 1)));
- $v->last_page_url = url::site(url::merge(array("page" => $this->max_pages)));
- }
-
- $v->first_visible_position = ($this->page - 1) * $this->page_size + 1;
- $v->last_visible_position = min($this->page * $this->page_size, $v->total);
- } else if ($this->page_type == "item") {
- $v->position = $this->position;
- $v->total = $this->sibling_count;
- if ($this->previous_item) {
- $v->previous_page_url = $this->previous_item->url();
- }
-
- if ($this->next_item) {
- $v->next_page_url = $this->next_item->url();
- }
- }
-
- return $v;
- }
-
- /**
* Print out any site wide status information.
*/
public function site_status() {