1
0

Updated to reflect the fact that we've gotten rid of REST_Controller

Updated for changes in the paginator..
This commit is contained in:
Bharat Mediratta 2009-11-27 15:13:17 -08:00
parent f9cdd21db0
commit 97db9f478e
9 changed files with 109 additions and 173 deletions

View File

@ -17,14 +17,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Comments_3nids_Controller extends REST_Controller {
protected $resource_type = "comment";
class Comments_3nids_Controller extends Items_Controller {
/**
* Display comments based on criteria.
* @see REST_Controller::_index()
*/
public function _index() {
$item_id = $this->input->get('item_id');
$item = ORM::factory("item", $item_id);

View File

@ -17,22 +17,17 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Movie_3nids_Controller extends REST_Controller {
protected $resource_type = "movie_3nids";
class Movie_3nids_Controller extends Items_Controller {
/**
* Display comments based on criteria.
* @see REST_Controller::_index()
*/
public function show($item_id) {
$item = ORM::factory("item", $item_id);
$item = ORM::factory("item", $item_id);
access::required("view", $item);
$view = new Theme_View("movie_3nids.html", "other", "page");
$view->item = $item;
$view->attrs = array("class" => "g-movie", "id" => "g-movie-id-{$item->id}", "style" => "display:block;width:{$item->width}px;height:{$item->height}px");
print $view;
break;
}
$view->item = $item;
$view->attrs = array(
"class" => "g-movie", "id" => "g-movie-id-{$item->id}",
"style" => "display:block;width:{$item->width}px;height:{$item->height}px");
print $view;
}
}

View File

@ -17,27 +17,20 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
*/
class Photo_3nids_Controller extends REST_Controller {
protected $resource_type = "photo_3nids";
class Photo_3nids_Controller extends Items_Controller {
/**
* Display comments based on criteria.
* @see REST_Controller::_index()
*/
public function show($item_id) {
$item = ORM::factory("item", $item_id);
access::required("view", $item);
$view = new Theme_View("photo_3nids.html", "other", "page");
$view->item = $item;
$photo_size = module::get_var("theme_3nids","photo_size");
if ($photo_size == "full"){
$view->item_url = $item->file_url();
}else{
$view->item_url = $item->resize_url();
}
print $view;
break;
$view = new Theme_View("photo_3nids.html", "other", "page");
$view->item = $item;
$photo_size = module::get_var("theme_3nids","photo_size");
if ($photo_size == "full"){
$view->item_url = $item->file_url();
} else {
$view->item_url = $item->resize_url();
}
print $view;
}
}

View File

@ -1,90 +0,0 @@
<?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 theme_3nids_Core {
public function fancylink($item, $view_type="album", $group_img = true, $display_comment = true, $parent_title_class = "h2") {
// view_type = album || dynamic || header
$link = "";
access::required("view", $item);
$photo_size = module::get_var("theme_3nids", "photo_size");
if ($photo_size == "full"){
$width = $item->width;
$height = $item->height;
}else{
$width = $item->resize_width;
$height = $item->resize_height;
}
$desriptionMode = module::get_var("theme_3nids", "description");
$description = "";
$tags = tag::item_tags($item);
if(count($tags) && $desriptionMode == "tags"){
$description = " || " . implode(", ", $tags);
}elseif($desriptionMode == "item" && $item->description != ""){
$description = " || " . str_replace("\"","&quot;",$item->description);
}elseif (($desriptionMode == "parent" || $desriptionMode == "item") && $item->parent()->description != ""){
$description = " || " . str_replace("\"","&quot;",$item->parent()->description);
}
$titleMode = module::get_var("theme_3nids", "title");
if ($titleMode == "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()) && module::is_active("theme_3nids")){
$fancymodule = "";
if (module::is_active("exif")){
$fancymodule .= "exif::" . url::site("exif/show/{$item->id}") . ";;";}
if (module::is_active("comment") && module::is_active("theme_3nids")){
$fancymodule .= "comment::" . url::site("comments_3nids?item_id={$item->id}") . ";;comment_count::" . comment_3nids::count($item) . ";;" ;}
if ($item->is_photo()){
$link .= "<a href=\"" . url::site("photo_3nids/show/{$item->id}") ."/?w=" . $width . "xewx&h=" . $height . "xehx\" " . $rel . " class=\"fancyclass iframe\" title=\"" . $title . $description ."\" name=\"" . $fancymodule . " \">";
}else{
$link .= "<a href=\"" . url::site("movie_3nids/show/{$item->id}") . "/?w=" . strval(20+($width)) . "xewx&h=" . strval(50+($height)) . "xehx\" " . $rel . " class=\"fancyclass iframe\" title=\"" . $item->parent()->title . $description ."\" name=\"" . $fancymodule . " \">";
}
} elseif( $item->is_album() && $view_type != "header"){
$link .= "<a href=\"" . $item->url() . "\">";
}
if($view_type != "header"){
$link .= $item->thumb_img(array("class" => "g-thumbnail")) . "</a>";
if( $item->is_album() && $view_type == "album" ){
$link .= "<a href=\"" . $item->url() . "?show=" . $item->id . "\"><$parent_title_class><span></span>" . html::clean($item->title) . "</$parent_title_class></a>";
} elseif ( !($item->is_album()) && $view_type == "dynamic") {
$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==true && module::is_active("comment") && module::is_active("theme_3nids")) {
$link .= "<ul class=\"g-metadata\"><li><a href=\"" . url::site("comments_3nids?item_id={$item->id}") ."\" class=\"iframe fancyclass g-hidden\">" . comment_3nids::count($item) . " " . t("comments") . "</a></li></ul>";
}
}else{
$link .= "</a>";
}
return $link;
}
}
?>

View File

@ -18,7 +18,7 @@
<? endfor ?>
<? foreach ($children as $i => $child): ?>
<!--<li class="g-Item <?= $child->is_album() ? "g-album" : "" ?>">!-->
<li id="g-item-id-<?= $child->id ?>" class="g-item g-album">
<?= $theme->thumb_top($child) ?>
@ -34,4 +34,4 @@
<? endfor ?>
<?= $theme->dynamic_bottom() ?>
<?= $theme->pager() ?>
<?= $theme->paginator() ?>

View File

@ -1,43 +0,0 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<? // See http://docs.kohanaphp.com/libraries/pagination ?>
<ul class="g-pager ui-helper-clearfix">
<? /* @todo This message isn't easily localizable */
$from_to_msg = t2("%current_page / %total_pages",
"%current_page / %total_pages",
$total_items,
array("total_pages" => $total_pages,
"current_page" => $current_page)) ?>
<li>
<? if ($first_page): ?>
<a href="<?= str_replace('{page}', 1, $url) ?>" class="g-button ui-icon-left ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-seek-first"></span><?= t("first") ?></a>
<? else: ?>
<a class="g-button ui-icon-left ui-state-disabled ui-corner-all">
<span class="ui-icon ui-icon-seek-first"></span><?= t("first") ?></a>
<? endif ?>
<? if ($previous_page): ?>
<a href="<?= str_replace('{page}', $previous_page, $url) ?>" class="g-button ui-icon-left ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-seek-prev"></span><?= t("previous") ?></a>
<? else: ?>
<a class="g-button ui-icon-left ui-state-disabled ui-corner-all">
<span class="ui-icon ui-icon-seek-prev"></span><?= t("previous") ?></a>
<? endif ?>
</li>
<li class="g-info"><?= $from_to_msg ?></li>
<li class="g-text-right">
<? if ($next_page): ?>
<a href="<?= str_replace('{page}', $next_page, $url) ?>" class="g-button ui-icon-right ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-seek-next"></span><?= t("next") ?></a>
<? else: ?>
<a class="g-button ui-state-disabled ui-icon-right ui-corner-all">
<span class="ui-icon ui-icon-seek-next"></span><?= t("next") ?></a>
<? endif ?>
<? if ($last_page): ?>
<a href="<?= str_replace('{page}', $last_page, $url) ?>" class="g-button ui-icon-right ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-seek-end"></span><?= t("last") ?></a>
<? else: ?>
<a class="g-button ui-state-disabled ui-icon-right ui-corner-all">
<span class="ui-icon ui-icon-seek-end"></span><?= t("last") ?></a>
<? endif ?>
</li>
</ul>

View File

@ -0,0 +1,87 @@
<?php defined("SYSPATH") or die("No direct script access.") ?>
<?
// This is a generic paginator for album, photo and movie pages. Depending on the page type,
// there are different sets of variables available. With this data, you can make a paginator
// that lets you say "You're viewing photo 5 of 35", or "You're viewing photos 10 - 18 of 37"
// for album views.
//
// Available variables for all page types:
// $page_type - "collection", "item", or "other"
// $page_subtype - "album", "movie", "photo", "tag", etc.
// $previous_page_url - the url to the previous page, if there is one
// $next_page_url - the url to the next page, if there is one
// $total - the total number of photos in this album
//
// Available for the "collection" page types:
// $page - what page number we're on
// $max_pages - the maximum page number
// $page_size - the page size
// $first_page_url - the url to the first page, or null if we're on the first page
// $last_page_url - the url to the last page, or null if we're on the last page
// $first_visible_position - the position number of the first visible photo on this page
// $last_visible_position - the position number of the last visible photo on this page
//
// Available for "item" page types:
// $position - the position number of this photo
//
?>
<ul class="g-paginator ui-helper-clearfix">
<li class="g-first">
<? if ($page_type == "collection"): ?>
<? if (isset($first_page_url)): ?>
<a href="<?= $first_page_url ?>" class="g-button ui-icon-left ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-seek-first"></span><?= t("First") ?></a>
<? else: ?>
<a class="g-button ui-icon-left ui-state-disabled ui-corner-all">
<span class="ui-icon ui-icon-seek-first"></span><?= t("First") ?></a>
<? endif ?>
<? endif ?>
<? if (isset($previous_page_url)): ?>
<a href="<?= $previous_page_url ?>" class="g-button ui-icon-left ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-seek-prev"></span><?= t("Previous") ?></a>
<? else: ?>
<a class="g-button ui-icon-left ui-state-disabled ui-corner-all">
<span class="ui-icon ui-icon-seek-prev"></span><?= t("Previous") ?></a>
<? endif ?>
</li>
<li class="g-info">
<? if ($total): ?>
<? if ($page_type == "collection"): ?>
<?= /* @todo This message isn't easily localizable */
t2("Photo %from_number of %count",
"Photos %from_number - %to_number of %count",
$total,
array("from_number" => $first_visible_position,
"to_number" => $last_visible_position,
"count" => $total)) ?>
<? else: ?>
<?= t("%position of %total", array("position" => $position, "total" => $total)) ?>
<? endif ?>
<? else: ?>
<?= t("No photos") ?>
<? endif ?>
</li>
<li class="g-text-right">
<? if (isset($next_page_url)): ?>
<a href="<?= $next_page_url ?>" class="g-button ui-icon-right ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-seek-next"></span><?= t("Next") ?></a>
<? else: ?>
<a class="g-button ui-state-disabled ui-icon-right ui-corner-all">
<span class="ui-icon ui-icon-seek-next"></span><?= t("Next") ?></a>
<? endif ?>
<? if ($page_type == "collection"): ?>
<? if (isset($last_page_url)): ?>
<a href="<?= $last_page_url ?>" class="g-button ui-icon-right ui-state-default ui-corner-all">
<span class="ui-icon ui-icon-seek-end"></span><?= t("Last") ?></a>
<? else: ?>
<a class="g-button ui-state-disabled ui-icon-right ui-corner-all">
<span class="ui-icon ui-icon-seek-end"></span><?= t("Last") ?></a>
<? endif ?>
<? endif ?>
</li>
</ul>

View File

@ -28,7 +28,7 @@
<?= theme_3nids::fancylink($child,"header") ?>
<? endfor ?>
</ul>
<?= $theme->pager() ?>
<?= $theme->paginator() ?>
<? else: ?>
<p>