Overview

Packages

  • Ansel
  • None

Classes

  • Ansel
  • Ansel_Ajax_Application
  • Ansel_Ajax_Imple_EditCaption
  • Ansel_Ajax_Imple_EditFaces
  • Ansel_Ajax_Imple_EditGalleryFaces
  • Ansel_Ajax_Imple_Embed
  • Ansel_Ajax_Imple_GallerySlugCheck
  • Ansel_Ajax_Imple_ImageSaveGeotag
  • Ansel_Ajax_Imple_LocationAutoCompleter
  • Ansel_Ajax_Imple_MapLayerSelect
  • Ansel_Ajax_Imple_TagActions
  • Ansel_Ajax_Imple_ToggleGalleryActions
  • Ansel_Ajax_Imple_ToggleOtherGalleries
  • Ansel_Ajax_Imple_UploadNotification
  • Ansel_Api
  • Ansel_Exception
  • Ansel_Faces
  • Ansel_Faces_Base
  • Ansel_Faces_Facedetect
  • Ansel_Faces_User
  • Ansel_Factory_Faces
  • Ansel_Factory_Storage
  • Ansel_Factory_Styles
  • Ansel_Form_Ecard
  • Ansel_Form_Image
  • Ansel_Form_ImageDate
  • Ansel_Form_Upload
  • Ansel_Gallery
  • Ansel_Gallery_Decorator_Date
  • Ansel_GalleryMode_Base
  • Ansel_GalleryMode_Date
  • Ansel_GalleryMode_Normal
  • Ansel_Image
  • Ansel_ImageGenerator
  • Ansel_ImageGenerator_Mini
  • Ansel_ImageGenerator_PolaroidThumb
  • Ansel_ImageGenerator_PolaroidThumbStack
  • Ansel_ImageGenerator_RoundedThumb
  • Ansel_ImageGenerator_RoundedThumbStack
  • Ansel_ImageGenerator_Screen
  • Ansel_ImageGenerator_ShadowThumb
  • Ansel_ImageGenerator_ShadowThumbStack
  • Ansel_ImageGenerator_SquareThumb
  • Ansel_ImageGenerator_Thumb
  • Ansel_LoginTasks_SystemTask_Upgrade
  • Ansel_Report
  • Ansel_Report_letter
  • Ansel_Report_mail
  • Ansel_Report_tickets
  • Ansel_Search
  • Ansel_Search_exif
  • Ansel_Search_Tag
  • Ansel_Storage
  • Ansel_Style
  • Ansel_Tagger
  • Ansel_Test
  • Ansel_Tile_DateGallery
  • Ansel_Tile_Gallery
  • Ansel_Tile_Image
  • Ansel_View_Ansel
  • Ansel_View_Base
  • Ansel_View_EmbeddedRenderer_GalleryLink
  • Ansel_View_EmbeddedRenderer_Mini
  • Ansel_View_EmbeddedRenderer_Slideshow
  • Ansel_View_Gallery
  • Ansel_View_GalleryProperties
  • Ansel_View_GalleryRenderer_Base
  • Ansel_View_GalleryRenderer_Gallery
  • Ansel_View_GalleryRenderer_GalleryLightbox
  • Ansel_View_Image
  • Ansel_View_List
  • Ansel_View_Results
  • Ansel_View_Slideshow
  • Ansel_View_Upload
  • Ansel_Widget
  • Ansel_Widget_Actions
  • Ansel_Widget_Base
  • Ansel_Widget_GalleryFaces
  • Ansel_Widget_Geotag
  • Ansel_Widget_ImageFaces
  • Ansel_Widget_Links
  • Ansel_Widget_OtherGalleries
  • Ansel_Widget_OwnerFaces
  • Ansel_Widget_SimilarPhotos
  • Ansel_Widget_Tags
  • Ansel_XPPublisher
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * Ansel_Tile_DateGallery:: class wraps display of thumbnail tile for the
  4:  * DateGallery psuedo gallery.
  5:  *
  6:  * @author   Michael J Rubinsky <mrubinsk@horde.org>
  7:  * @license  http://www.horde.org/licenses/gpl GPL
  8:  * @category Horde
  9:  * @package  Ansel
 10:  */
 11: class Ansel_Tile_DateGallery
 12: {
 13:     /**
 14:      * Outputs the html for a DateGallery tile.
 15:      *
 16:      * @param Ansel_DateGallery $dgallery  The Ansel_Gallery_Date we are
 17:      *                                     displaying.
 18:      * @param Ansel_Style $style           A style object.
 19:      * @param boolean $mini                Force the use of a mini thumbail?
 20:      * @param array $params                An array containing additional
 21:      *                                     parameters. Currently,
 22:      *                                     gallery_view_url and
 23:      *                                     image_view_url are used to override
 24:      *                                     the respective urls. %g and %i are
 25:      *                                     replaced with image id and gallery id,
 26:      *                                     respectively
 27:      *
 28:      * @return  Outputs the HTML for the tile.
 29:      */
 30:     public function getTile($dgallery, $style = null, $mini = false, $params = array())
 31:     {
 32:         // User's preferred date format
 33:         $date_format = $GLOBALS['prefs']->getValue('date_format');
 34:         $date_array = $dgallery->getDate();
 35:         if (empty($date_array['month'])) {
 36:             $date_array['month'] = 1;
 37:         }
 38:         if (empty($date_array['day'])) {
 39:             $date_array['day'] = 1;
 40:         }
 41:         $full_date = new Horde_Date($date_array);
 42: 
 43:         // Need the unaltered date part array
 44:         $date_array = $dgallery->getDate();
 45: 
 46:         // Figure out the needed link for the next drill down level. We *must*
 47:         // have at least a year since we are in a date tile.
 48:         if (empty($date_array['month'])) {
 49:             // unit == year
 50:             $caption = $full_date->strftime('%Y');
 51:             $next_date = array('year' => (int)$caption);
 52:         } elseif (empty($date_array['day'])) {
 53:             // unit == month
 54:             $caption = $full_date->strftime('%B %Y');
 55:             $next_date = array(
 56:                 'year' => date('Y', $full_date->timestamp()),
 57:                 'month' => date('n', $full_date->timestamp()));
 58:         } else {
 59:             // unit == day
 60:             $caption = $full_date->strftime($date_format);
 61:             $next_date = array('year' => date('Y', $full_date->timestamp()),
 62:                                'month' => date('n', $full_date->timestamp()),
 63:                                'day' => date('j', $full_date->timestamp()));
 64:         }
 65: 
 66:         // Check permissions on the gallery and get appropriate tile image
 67:         if ($dgallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
 68:             if (is_null($style)) {
 69:                 $style = $dgallery->getStyle();
 70:             }
 71: 
 72:             $thumbstyle = $mini ? 'mini' : 'thumb';
 73:             $gallery_image = Ansel::getImageUrl(
 74:                 $dgallery->getKeyImage(),
 75:                 $thumbstyle,
 76:                 true,
 77:                 $style);
 78: 
 79:             $gallery_image = '<img src="' . $gallery_image . '" alt="' . $caption . '" />' ;
 80:         } else {
 81:             $gallery_image = Horde::img('thumb-error.png');
 82:         }
 83: 
 84:         /* Check for being called via the api and generate correct view links */
 85:         if (!isset($params['gallery_view_url'])) {
 86:             if (empty($params['style'])) {
 87:                 $gstyle = $dgallery->getStyle();
 88:             } else {
 89:                 $gstyle = $params['style'];
 90:             }
 91:             $params = array('gallery' => $dgallery->id,
 92:                             'view' => 'Gallery',
 93:                             'slug' => $dgallery->get('slug'));
 94:             $params = array_merge($params, $next_date);
 95:             $view_link = Ansel::getUrlFor('view', $params)->link();
 96:         } else {
 97:             $view_link = new Horde_Url(str_replace(array('%g', '%s'),
 98:                                                    array($dgallery->id, $dgallery->get('slug')),
 99:                                                    urldecode($params['gallery_view_url'])));
100:             $view_link = $view_link->add($next_date)->link();
101:         }
102: 
103:         /* Variables used in the template file */
104:         $image_link = $view_link . $gallery_image . '</a>';
105:         $text_link = $view_link . htmlspecialchars($caption) . '</a>';
106:         $gallery_count = $dgallery->countImages(true);
107: 
108:         /* Background color is needed if displaying a mini tile */
109:         $background_color = $style->background;
110: 
111:         Horde::startBuffer();
112:         include ANSEL_TEMPLATES . '/tile/dategallery' . ($mini ? 'mini' : '') . '.inc';
113:         return Horde::endBuffer();
114:     }
115: }
116: 
API documentation generated by ApiGen