This is my second attempt to update about_this_photo to V3 and to add the new module about_this_album. Hopefully I have pulled all upstream changes this time.
This commit is contained in:
parent
05ee3bfe78
commit
878ba14230
@ -0,0 +1,76 @@
|
||||
<?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 about_this_album_block_Core {
|
||||
|
||||
static function get_site_list() {
|
||||
return array("aboutthisalbum" => t("About This Album"));
|
||||
}
|
||||
|
||||
static function get($block_id, $theme) {
|
||||
switch ($block_id) {
|
||||
case "aboutthisalbum":
|
||||
$item = $theme->item;
|
||||
if ((!$item) or (!$theme->item->is_album())) {
|
||||
return "";
|
||||
}
|
||||
if ($theme->item->is_album()) {
|
||||
$block = new Block();
|
||||
$block->css_id = "g-about-this-album";
|
||||
$block->content = new View("about_this_album.html");
|
||||
|
||||
if ($theme->item()->id == item::root()->id) {
|
||||
$block->title = t("About this Site");
|
||||
$block->content->album_count = ORM::factory("item")->where("type", "=", "album")->where("id", "<>", 1)->count_all();
|
||||
$block->content->photo_count = ORM::factory("item")->where("type", "=", "photo")->count_all();
|
||||
$block->content->vcount = Database::instance()->query("SELECT SUM({items}.view_count) as c FROM {items} WHERE type=\"photo\"")->current()->c;
|
||||
} Else {
|
||||
$block->title = t("About this Album");
|
||||
$block->content->album_count = $item->descendants_count(array(array("type", "=", "album")));
|
||||
$block->content->photo_count = $item->descendants_count(array(array("type", "=", "photo")));
|
||||
// $block->content->vcount= $theme->item()->view_count;
|
||||
$descds = $item->descendants();
|
||||
$descds_view = 0;
|
||||
foreach ($descds as $descd) {
|
||||
if ($descd->is_photo()) {
|
||||
$descds_view += $descd->view_count;
|
||||
}
|
||||
}
|
||||
$block->content->vcount = $descds_view;
|
||||
if ($item->description) {
|
||||
$block->content->description = html::clean($item->description);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$all_tags = ORM::factory("tag")
|
||||
->join("items_tags", "items_tags.tag_id", "tags.id")
|
||||
->join("items", "items.id", "items_tags.item_id", "LEFT")
|
||||
->where("items.parent_id", "=", $item->id)
|
||||
->order_by("tags.id", "ASC")
|
||||
->find_all();
|
||||
if (count($all_tags) > 0) {
|
||||
$block->content->all_tags = $all_tags;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
}
|
3
3.0/modules/about_this_album/module.info
Normal file
3
3.0/modules/about_this_album/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "About this Album"
|
||||
description = "Show some simple, specific and useful info about a given album"
|
||||
version = 1
|
68
3.0/modules/about_this_album/views/about_this_album.html.php
Normal file
68
3.0/modules/about_this_album/views/about_this_album.html.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<? date_default_timezone_set('Australia/ACT'); ?>
|
||||
<div class="g-metadata">
|
||||
<span class="g-about-this">
|
||||
<table cellspacing="0" cellpadding="0" border="0">
|
||||
<? if ($album_count > 0): ?>
|
||||
<tr>
|
||||
<td><strong class="caption"><?= t("Albums: ") ?></strong></td>
|
||||
<td><?= $album_count ?></td>
|
||||
</tr>
|
||||
<? endif ?>
|
||||
<tr>
|
||||
<td><strong class="caption"><?= t("Images: ") ?></strong></td>
|
||||
<td><?= $photo_count ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong class="caption"><?= t("Views: ") ?></strong></td>
|
||||
<td><?= $vcount ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<span >
|
||||
|
||||
<!--This Div will insert a margin either side of the desciption if there are tags to display-->
|
||||
<? if (count($all_tags) > 0): ?>
|
||||
<div style="margin-top: 10px; margin-bottom: 10px;">
|
||||
<? endif ?>
|
||||
|
||||
<? if ($description <> ""): ?>
|
||||
<strong class="caption"><?= t("Details: ") ?></strong>
|
||||
<?= $description ?>
|
||||
</span ><br>
|
||||
<? endif ?>
|
||||
|
||||
<? if (count($all_tags) > 0): ?>
|
||||
</div>
|
||||
<span >
|
||||
<strong class=="caption"><?= t("Tags: ") ?></strong>
|
||||
</span >
|
||||
<?
|
||||
// Create an array to store the tag names and urls in.
|
||||
$display_tags = array();
|
||||
|
||||
// Loop through all tags in the album, copying their
|
||||
// names and urls into the array and skipping duplicates.
|
||||
$last_tagid = "";
|
||||
foreach ($all_tags as $one_tag) {
|
||||
if ($last_tagid != $one_tag->id) {
|
||||
$tag = ORM::factory("tag", $one_tag->id);
|
||||
$display_tags[] = array(html::clean($tag->name), $tag->url());
|
||||
$last_tagid = $one_tag->id;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the array.
|
||||
asort($display_tags);
|
||||
|
||||
// Print out the list of tags as clickable links.
|
||||
$not_first = 0;
|
||||
foreach ($display_tags as $one_tag) {
|
||||
if ($not_first++ > 0) {
|
||||
print ", ";
|
||||
}
|
||||
print "<a href=\"" . $one_tag[1] . "\">" . $one_tag[0] . "</a>";
|
||||
}
|
||||
?>
|
||||
<? endif ?>
|
||||
</span>
|
||||
</div>
|
@ -54,7 +54,7 @@ class about_this_photo_block_Core {
|
||||
$record = ORM::factory("iptc_record")->where("item_id", "=", $theme->item()->id)->find();
|
||||
if ($record->loaded()) {
|
||||
$record = unserialize($record->data);
|
||||
$block->content->source = $record["Source"];
|
||||
$block->content->name = $record["ObjectName"];
|
||||
$block->content->caption = $record["Caption"];
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
name = "About this Photo"
|
||||
description = "Show some simple, specific and useful info about a given photo"
|
||||
version = 2
|
||||
version = 3
|
||||
|
@ -16,14 +16,14 @@
|
||||
<td><?= $vcount ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong class="caption"><?= t("Image ID: ") ?></strong></td>
|
||||
<td><?= $source ?></td>
|
||||
<td><strong class="caption"><?= t("Name: ") ?></strong></td>
|
||||
<td><?= $name ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<span >
|
||||
<div style="margin-top: 10px; margin-bottom: 10px;">
|
||||
<strong class="caption"><?= t("Caption: ") ?></strong>
|
||||
<?= $caption ?>
|
||||
</span ><br>
|
||||
</div >
|
||||
<span >
|
||||
<strong class=="caption"><?= t("Tags: ") ?></strong>
|
||||
<? foreach ($tags as $tag): ?>
|
||||
|
@ -0,0 +1,76 @@
|
||||
<?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 about_this_album_block_Core {
|
||||
|
||||
static function get_site_list() {
|
||||
return array("aboutthisalbum" => t("About This Album"));
|
||||
}
|
||||
|
||||
static function get($block_id, $theme) {
|
||||
switch ($block_id) {
|
||||
case "aboutthisalbum":
|
||||
$item = $theme->item;
|
||||
if ((!$item) or (!$theme->item->is_album())) {
|
||||
return "";
|
||||
}
|
||||
if ($theme->item->is_album()) {
|
||||
$block = new Block();
|
||||
$block->css_id = "g-about-this-album";
|
||||
$block->content = new View("about_this_album.html");
|
||||
|
||||
if ($theme->item()->id == item::root()->id) {
|
||||
$block->title = t("About this Site");
|
||||
$block->content->album_count = ORM::factory("item")->where("type", "=", "album")->where("id", "<>", 1)->count_all();
|
||||
$block->content->photo_count = ORM::factory("item")->where("type", "=", "photo")->count_all();
|
||||
$block->content->vcount = Database::instance()->query("SELECT SUM({items}.view_count) as c FROM {items} WHERE type=\"photo\"")->current()->c;
|
||||
} Else {
|
||||
$block->title = t("About this Album");
|
||||
$block->content->album_count = $item->descendants_count(array(array("type", "=", "album")));
|
||||
$block->content->photo_count = $item->descendants_count(array(array("type", "=", "photo")));
|
||||
// $block->content->vcount= $theme->item()->view_count;
|
||||
$descds = $item->descendants();
|
||||
$descds_view = 0;
|
||||
foreach ($descds as $descd) {
|
||||
if ($descd->is_photo()) {
|
||||
$descds_view += $descd->view_count;
|
||||
}
|
||||
}
|
||||
$block->content->vcount = $descds_view;
|
||||
if ($item->description) {
|
||||
$block->content->description = html::clean($item->description);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$all_tags = ORM::factory("tag")
|
||||
->join("items_tags", "items_tags.tag_id", "tags.id")
|
||||
->join("items", "items.id", "items_tags.item_id", "LEFT")
|
||||
->where("items.parent_id", "=", $item->id)
|
||||
->order_by("tags.id", "ASC")
|
||||
->find_all();
|
||||
if (count($all_tags) > 0) {
|
||||
$block->content->all_tags = $all_tags;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
return $block;
|
||||
}
|
||||
}
|
3
3.1/modules/about_this_album/module.info
Normal file
3
3.1/modules/about_this_album/module.info
Normal file
@ -0,0 +1,3 @@
|
||||
name = "About this Album"
|
||||
description = "Show some simple, specific and useful info about a given album"
|
||||
version = 1
|
68
3.1/modules/about_this_album/views/about_this_album.html.php
Normal file
68
3.1/modules/about_this_album/views/about_this_album.html.php
Normal file
@ -0,0 +1,68 @@
|
||||
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
||||
<? date_default_timezone_set('Australia/ACT'); ?>
|
||||
<div class="g-metadata">
|
||||
<span class="g-about-this">
|
||||
<table cellspacing="0" cellpadding="0" border="0">
|
||||
<? if ($album_count > 0): ?>
|
||||
<tr>
|
||||
<td><strong class="caption"><?= t("Albums: ") ?></strong></td>
|
||||
<td><?= $album_count ?></td>
|
||||
</tr>
|
||||
<? endif ?>
|
||||
<tr>
|
||||
<td><strong class="caption"><?= t("Images: ") ?></strong></td>
|
||||
<td><?= $photo_count ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong class="caption"><?= t("Views: ") ?></strong></td>
|
||||
<td><?= $vcount ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<span >
|
||||
|
||||
<!--This Div will insert a margin either side of the desciption if there are tags to display-->
|
||||
<? if (count($all_tags) > 0): ?>
|
||||
<div style="margin-top: 10px; margin-bottom: 10px;">
|
||||
<? endif ?>
|
||||
|
||||
<? if ($description <> ""): ?>
|
||||
<strong class="caption"><?= t("Details: ") ?></strong>
|
||||
<?= $description ?>
|
||||
</span ><br>
|
||||
<? endif ?>
|
||||
|
||||
<? if (count($all_tags) > 0): ?>
|
||||
</div>
|
||||
<span >
|
||||
<strong class=="caption"><?= t("Tags: ") ?></strong>
|
||||
</span >
|
||||
<?
|
||||
// Create an array to store the tag names and urls in.
|
||||
$display_tags = array();
|
||||
|
||||
// Loop through all tags in the album, copying their
|
||||
// names and urls into the array and skipping duplicates.
|
||||
$last_tagid = "";
|
||||
foreach ($all_tags as $one_tag) {
|
||||
if ($last_tagid != $one_tag->id) {
|
||||
$tag = ORM::factory("tag", $one_tag->id);
|
||||
$display_tags[] = array(html::clean($tag->name), $tag->url());
|
||||
$last_tagid = $one_tag->id;
|
||||
}
|
||||
}
|
||||
|
||||
// Sort the array.
|
||||
asort($display_tags);
|
||||
|
||||
// Print out the list of tags as clickable links.
|
||||
$not_first = 0;
|
||||
foreach ($display_tags as $one_tag) {
|
||||
if ($not_first++ > 0) {
|
||||
print ", ";
|
||||
}
|
||||
print "<a href=\"" . $one_tag[1] . "\">" . $one_tag[0] . "</a>";
|
||||
}
|
||||
?>
|
||||
<? endif ?>
|
||||
</span>
|
||||
</div>
|
@ -54,7 +54,7 @@ class about_this_photo_block_Core {
|
||||
$record = ORM::factory("iptc_record")->where("item_id", "=", $theme->item()->id)->find();
|
||||
if ($record->loaded()) {
|
||||
$record = unserialize($record->data);
|
||||
$block->content->source = $record["Source"];
|
||||
$block->content->name = $record["ObjectName"];
|
||||
$block->content->caption = $record["Caption"];
|
||||
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
name = "About this Photo"
|
||||
description = "Show some simple, specific and useful info about a given photo"
|
||||
version = 2
|
||||
version = 3
|
||||
|
@ -16,14 +16,14 @@
|
||||
<td><?= $vcount ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong class="caption"><?= t("Image ID: ") ?></strong></td>
|
||||
<td><?= $source ?></td>
|
||||
<td><strong class="caption"><?= t("Name: ") ?></strong></td>
|
||||
<td><?= $name ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<span >
|
||||
<div style="margin-top: 10px; margin-bottom: 10px;">
|
||||
<strong class="caption"><?= t("Caption: ") ?></strong>
|
||||
<?= $caption ?>
|
||||
</span ><br>
|
||||
</div >
|
||||
<span >
|
||||
<strong class=="caption"><?= t("Tags: ") ?></strong>
|
||||
<? foreach ($tags as $tag): ?>
|
||||
|
Reference in New Issue
Block a user