summaryrefslogtreecommitdiff
path: root/modules/info
diff options
context:
space:
mode:
authorTristan Zur <tzur@webserver.ccwn.org>2015-06-10 20:55:53 +0200
committerTristan Zur <tzur@webserver.ccwn.org>2015-06-10 20:55:53 +0200
commit406abd7c4df1ace2cd3e4e17159e8941a2e8c0c4 (patch)
treea324be16021f44f2fd6d55e609f47024e945b1db /modules/info
Initial import
Diffstat (limited to 'modules/info')
-rw-r--r--modules/info/helpers/info_block.php93
-rw-r--r--modules/info/helpers/info_installer.php45
-rw-r--r--modules/info/helpers/info_theme.php41
-rw-r--r--modules/info/module.info7
-rw-r--r--modules/info/views/info_block.html.php8
5 files changed, 194 insertions, 0 deletions
diff --git a/modules/info/helpers/info_block.php b/modules/info/helpers/info_block.php
new file mode 100644
index 0000000..e4b5adf
--- /dev/null
+++ b/modules/info/helpers/info_block.php
@@ -0,0 +1,93 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 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 info_block_Core {
+ static function get_site_list() {
+ return array("metadata" => t("Metadata"));
+ }
+
+ static function get($block_id, $theme) {
+ $block = "";
+ switch ($block_id) {
+ case "metadata":
+ if ($theme->item()) {
+ $block = new Block();
+ $block->css_id = "g-metadata";
+ $block->title = $theme->item()->is_album() ? t("Album info") :
+ ($theme->item()->is_movie() ? t("Movie info") : t("Photo info"));
+ $block->content = new View("info_block.html");
+ if ($theme->item->title && module::get_var("info", "show_title")) {
+ $info["title"] = array(
+ "label" => t("Title:"),
+ "value" => html::purify($theme->item->title)
+ );
+ }
+ if ($theme->item->description && module::get_var("info", "show_description")) {
+ $info["description"] = array(
+ "label" => t("Description:"),
+ "value" => nl2br(html::purify($theme->item->description))
+ );
+ }
+ if (!$theme->item->is_album() && module::get_var("info", "show_name")) {
+ $info["file_name"] = array(
+ "label" => t("File name:"),
+ "value" => html::clean($theme->item->name)
+ );
+ }
+ if ($theme->item->captured && module::get_var("info", "show_captured")) {
+ $info["captured"] = array(
+ "label" => t("Captured:"),
+ "value" => gallery::date_time($theme->item->captured)
+ );
+ }
+ if ($theme->item->owner && module::get_var("info", "show_owner")) {
+ $display_name = $theme->item->owner->display_name();
+ if ($theme->item->owner->url) {
+ $info["owner"] = array(
+ "label" => t("Owner:"),
+ "value" => html::anchor(
+ html::clean($theme->item->owner->url),
+ html::clean($display_name))
+ );
+ } else {
+ $info["owner"] = array(
+ "label" => t("Owner:"),
+ "value" => html::clean($display_name)
+ );
+ }
+ }
+ if (($theme->item->width && $theme->item->height) &&
+ module::get_var("info", "show_dimensions")) {
+ $info["size"] = array(
+ "label" => t("Dimensions:"),
+ "value" => t(
+ "%width x %height px",
+ array("width" => $theme->item->width, "height" => $theme->item->height))
+ );
+ }
+
+ $block->content->metadata = $info;
+
+ module::event("info_block_get_metadata", $block, $theme->item);
+ }
+ break;
+ }
+ return $block;
+ }
+} \ No newline at end of file
diff --git a/modules/info/helpers/info_installer.php b/modules/info/helpers/info_installer.php
new file mode 100644
index 0000000..2d06a0e
--- /dev/null
+++ b/modules/info/helpers/info_installer.php
@@ -0,0 +1,45 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 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 info_installer {
+
+ static function install() {
+ module::set_var("info", "show_title", 1);
+ module::set_var("info", "show_description", 1);
+ module::set_var("info", "show_owner", 1);
+ module::set_var("info", "show_name", 1);
+ module::set_var("info", "show_captured", 1);
+ module::set_var("info", "show_dimensions", 1);
+ }
+
+ static function upgrade($version) {
+ if ($version == 1) {
+ module::set_var("info", "show_title", 1);
+ module::set_var("info", "show_description", 1);
+ module::set_var("info", "show_owner", 1);
+ module::set_var("info", "show_name", 1);
+ module::set_var("info", "show_captured", 1);
+ module::set_version("info", $version = 2);
+ }
+ if ($version == 2) {
+ module::set_var("info", "show_dimensions", 1);
+ module::set_version("info", $version = 3);
+ }
+ }
+}
diff --git a/modules/info/helpers/info_theme.php b/modules/info/helpers/info_theme.php
new file mode 100644
index 0000000..457d330
--- /dev/null
+++ b/modules/info/helpers/info_theme.php
@@ -0,0 +1,41 @@
+<?php defined("SYSPATH") or die("No direct script access.");
+/**
+ * Gallery - a web based photo album viewer and editor
+ * Copyright (C) 2000-2013 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 info_theme_Core {
+ static function thumb_info($theme, $item) {
+ $results = "";
+ if ($item->view_count) {
+ $results .= "<li>";
+ $results .= t("Views: %view_count", array("view_count" => $item->view_count));
+ $results .= "</li>";
+ }
+ if ($item->owner) {
+ $results .= "<li>";
+ if ($item->owner->url) {
+ $results .= t("By: <a href=\"%owner_url\">%owner_name</a>",
+ array("owner_name" => $item->owner->display_name(),
+ "owner_url" => $item->owner->url));
+ } else {
+ $results .= t("By: %owner_name", array("owner_name" => $item->owner->display_name()));
+ }
+ $results .= "</li>";
+ }
+ return $results;
+ }
+} \ No newline at end of file
diff --git a/modules/info/module.info b/modules/info/module.info
new file mode 100644
index 0000000..33b1622
--- /dev/null
+++ b/modules/info/module.info
@@ -0,0 +1,7 @@
+name = "Info"
+description = "Display extra information about photos and albums"
+version = 3
+author_name = "Gallery Team"
+author_url = "http://codex.galleryproject.org/Gallery:Team"
+info_url = "http://codex.galleryproject.org/Gallery3:Modules:info"
+discuss_url = "http://galleryproject.org/forum_module_info"
diff --git a/modules/info/views/info_block.html.php b/modules/info/views/info_block.html.php
new file mode 100644
index 0000000..b296fa1
--- /dev/null
+++ b/modules/info/views/info_block.html.php
@@ -0,0 +1,8 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<ul class="g-metadata">
+ <? foreach($metadata as $info): ?>
+ <li>
+ <strong class="caption"><?= $info["label"] ?></strong> <?= $info["value"] ?>
+ </li>
+ <? endforeach; ?>
+</ul>