1
0
This repository has been archived on 2021-04-26. You can view files and clone it, but cannot push or open issues or pull requests.
gallery3-contrib/3.0/themes/three_nids/helpers/three_nids.php

125 lines
5.1 KiB
PHP
Raw Normal View History

2009-11-27 23:11:10 +00:00
<?php defined("SYSPATH") or die("No direct script access.");
/**
* Gallery - a web based photo album viewer and editor
2012-02-27 18:04:35 +00:00
* Copyright (C) 2000-2012 Bharat Mediratta
2009-11-27 23:11:10 +00:00
*
* 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 three_nids_Core {
2010-06-26 19:06:58 +00:00
static function fancylink($item, $view_type="album", $group_img = true,
2009-11-27 23:11:10 +00:00
$display_comment = true, $parent_title_class = "h2") {
// view_type = album || dynamic || header
$link = "";
access::required("view", $item);
$photo_size = module::get_var("three_nids", "photo_size");
if ($photo_size == "full" || $item->is_movie()){
2009-11-27 23:11:10 +00:00
$width = $item->width;
$height = $item->height;
}else{
$width = $item->resize_width;
$height = $item->resize_height;
}
$description_mode = module::get_var("three_nids", "description");
2009-11-27 23:11:10 +00:00
$description = "";
$tags = tag::item_tags($item);
if(count($tags) && $description_mode == "tags"){
2009-11-28 00:31:15 +00:00
$description = " || " . implode(", ", $tags);
2009-11-27 23:11:10 +00:00
} else if ($description_mode == "item" && $item->description != ""){
$description = " || " . str_replace("\"","&quot;",$item->description);
} else if (($description_mode == "parent" ||
$description_mode == "item") && $item->parent()->description != ""){
$description = " || " . str_replace("\"", "&quot;", $item->parent()->description);
}
$title_mode = module::get_var("three_nids", "title");
2009-11-27 23:11:10 +00:00
if ($title_mode == "parent"){
$title = html::clean($item->parent()->title);
} else {
$title = html::clean($item->title);
}
$rel = "";
if ($group_img == true) {
$rel = " rel=\"fancygroup\" ";
}
if ($item->is_photo() || $item->is_movie()){
2009-11-27 23:11:10 +00:00
$fancymodule = "";
if (module::is_active("exif")) {
$fancymodule .= "exif::" . url::site("exif/show/{$item->id}") . ";;";
}
if (module::is_active("comment")) {
$fancymodule .= "comment::" . url::site("three_nids/show_comments/{$item->id}") .
";;comment_count::" . three_nids::comment_count($item) . ";;";
2009-11-27 23:11:10 +00:00
}
if ($item->is_photo()){
2009-11-27 23:27:13 +00:00
$link .= "<a href=\"" . url::site("photos/{$item->id}") ."/?w=" . $width .
2009-11-27 23:11:10 +00:00
"xewx&h=" . $height . "xehx\" " . $rel . " class=\"fancyclass iframe\" title=\"" .
2009-11-28 00:31:15 +00:00
$title . $description ."\" name=\"" . $fancymodule . " \">";
2009-11-27 23:11:10 +00:00
} else {
2009-11-27 23:27:13 +00:00
$link .= "<a href=\"" . url::site("movies/{$item->id}") . "/?w=" .
2009-11-27 23:11:10 +00:00
strval(20 + $width) . "xewx&h=" . strval(50 + $height) . "xehx\" " . $rel .
" class=\"fancyclass iframe\" title=\"" . $item->parent()->title . $description .
2009-11-28 00:31:15 +00:00
"\" name=\"" . $fancymodule . " \">";
2009-11-27 23:11:10 +00:00
}
} else if ($item->is_album() && $view_type != "header") {
$link .= "<a href=\"" . $item->url() . "\">";
} else {
// NOTE: we don't want to open an <a> here because $view_type is "header", but lower down
// we're going to close one, so that's going to generate a mismatch. For now, just open a
// link anyway.
// @todo: figure out what we really should be doing here.
$link .= "<a href=\"" . $item->url() . "\">";
2009-11-27 23:11:10 +00:00
}
if ($view_type != "header") {
$link .= $item->thumb_img(array("class" => "g-thumbnail")) . "</a>";
2009-11-28 00:31:15 +00:00
if ($item->is_album() && $view_type == "album") {
2009-11-27 23:11:10 +00:00
$link .= "<a href=\"" . $item->url() . "?show=" . $item->id .
"\"><$parent_title_class><span></span>" . html::clean($item->title) .
"</$parent_title_class></a>";
2009-11-28 00:31:15 +00:00
} else if (!($item->is_album()) && $view_type == "dynamic") {
2009-11-27 23:11:10 +00:00
$link .= "<a href=\"" . $item->parent()->url() . "?show=" . $item->id .
"\" class=\"g-parent-album\"><$parent_title_class><span></span>" .
html::clean($item->parent()->title) . "</$parent_title_class></a>";
}
if (($item->is_photo() || $item->is_movie()) && $display_comment &&
module::is_active("comment")) {
$link .= "<ul class=\"g-metadata\"><li><a href=\"" .
url::site("three_nids/show_comments/{$item->id}") .
"\" class=\"iframe fancyclass g-hidden\">" . three_nids::comment_count($item) .
2009-11-27 23:11:10 +00:00
" " . t("comments") . "</a></li></ul>";
}
} else {
$link .= "</a>";
}
return $link;
}
2010-06-26 19:06:58 +00:00
static function comment_count($item) {
access::required("view", $item);
return ORM::factory("comment")
->where("item_id", "=", $item->id)
->where("state", "=", "published")
->order_by("created", "DESC")
->count_all();
}
2009-11-27 23:11:10 +00:00
}
?>