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_View_EmbeddedRenderer_Mini
  4:  *
  5:  * Copyright 2008-2012 Horde LLC (http://www.horde.org/)
  6:  *
  7:  * See the enclosed file COPYING for license information (GPL). If you
  8:  * did not receive this file, see http://www.horde.org/licenses/gpl.
  9:  *
 10:  * @author  Michael J. Rubinsky <mrubinsk@horde.org>
 11:  * @package Ansel
 12:  */
 13: class Ansel_View_EmbeddedRenderer_Mini extends Ansel_View_Base
 14: {
 15:     /**
 16:      * Build the javascript that will render the view.
 17:      *
 18:      * @return string  A string containing valid javascript.
 19:      */
 20:     public function html()
 21:     {
 22:         // Required
 23:         $node = $this->_params['container'];
 24:         if (empty($node)) {
 25:             return '';
 26:         }
 27: 
 28:         // Optional
 29:         $gallery_slug = !empty($this->_params['gallery_slug']) ?
 30:             $this->_params['gallery_slug'] :
 31:             '';
 32: 
 33:         $gallery_id = !empty($this->_params['gallery_id'])
 34:             ? $this->_params['gallery_id'] :
 35:             null;
 36: 
 37:         $start = isset($this->_params['start']) ?
 38:         $this->_params['start'] :
 39:         0;
 40: 
 41:         $count = isset($this->_params['count']) ?
 42:         $this->_params['count'] :
 43:         0;
 44: 
 45:         $perpage = isset($this->_params['perpage']) ?
 46:             $this->_params['perpage'] :
 47:             0;
 48: 
 49:         $thumbsize = !empty($this->_params['thumbsize']) ?
 50:             $this->_params['thumbsize'] :
 51:             'mini';
 52: 
 53:         if ($thumbsize != 'mini' && $thumbsize != 'thumb' && $thumbsize != 'screen') {
 54:              $thumbsize = 'mini';
 55:         }
 56:         $thumbtype = !empty($this->_params['thumbtype']) ?
 57:             $this->_params['thumbtype'] :
 58:             'squarethumb';
 59: 
 60:         // Do we have a gallery, imagelist or user?
 61:         $images = (!empty($this->_params['images'])) ?
 62:             $this->_params['images'] :
 63:             array();
 64:         if (!empty($images)) {
 65:             // Images are filtered for age and password protected galleries
 66:             // in the ::getImageJson() call since they could all be from different
 67:             // galleries.
 68:             $images = explode(':', $images);
 69:         } elseif (!empty($this->_params['user'])) {
 70:             // User's most recent images.
 71:             $galleries = array();
 72:             $gs = $GLOBALS['injector']
 73:                 ->getInstance('Ansel_Storage')
 74:                 ->listGalleries(array('attributes' => $this->_params['user']));
 75:             foreach ($gs as $gallery) {
 76:                 $galleries[] = $gallery->id;
 77:             }
 78:             $images = array();
 79:             $is = $GLOBALS['injector']
 80:                 ->getInstance('Ansel_Storage')
 81:                 ->getRecentImages($galleries, $count);
 82:             foreach ($is as $i) {
 83:                 $images[] = $i->id;
 84:             }
 85:         } else {
 86:             try {
 87:                 $this->gallery = $this->_getGallery($gallery_id, $gallery_slug);
 88:             } catch (Exception $e) {
 89:                 Horde::logMessage($e, 'ERR');
 90:                 exit;
 91:             }
 92: 
 93:             // We don't allow age restricted or password locked galleries to be
 94:             // viewed via the mini embedded view since it shows *all* the images
 95:             if (!$this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ) ||
 96:                 !$this->gallery->isOldEnough() ||
 97:                 $this->gallery->hasPasswd()) {
 98: 
 99:                 return '';
100:             }
101:         }
102: 
103:         if (empty($images)) {
104:             $images =
105:             $json = self::json($this->gallery,
106:                                 array('full' => true,
107:                                       'from' => $start,
108:                                       'count' => $count,
109:                                       'image_view' => $thumbsize,
110:                                       'view_links' => true,
111:                                       'generator' => $thumbtype));
112:             $json_full = self::json($this->gallery,
113:                                      array('full' => true,
114:                                            'from' => $start,
115:                                            'count' => $count,
116:                                            'view_links' => true));
117:         } else {
118:             if ($thumbsize == 'thumb') {
119:                 $style = Ansel::getStyleDefinition('ansel_default');
120:                 $style->thumbstyle = $thumbtype;
121:             } else {
122:                 $style = null;
123:             }
124: 
125:             $json = $GLOBALS['injector']
126:                 ->getInstance('Ansel_Storage')
127:                 ->getImageJson($images, $style, true, $thumbsize, true);
128: 
129:             $json_full = $GLOBALS['injector']
130:                 ->getInstance('Ansel_Storage')
131:                 ->getImageJson($images, $style, true, 'screen', true);
132:         }
133: 
134:         $horde_css = $GLOBALS['injector']->getInstance('Horde_Themes_Css');
135:         $horde_css->addThemeStylesheet('embed.css');
136: 
137:         /* Some paths */
138:         $js_path = $GLOBALS['registry']->get('jsuri', 'horde');
139:         $pturl = Horde::url($js_path . '/prototype.js', true);
140:         $hjsurl = Horde::url($js_path . '/tooltips.js', true);
141:         $ansel_js_path = $GLOBALS['registry']->get('jsuri', 'ansel');
142:         $jsurl = Horde::url($ansel_js_path . '/embed.js', true);
143:         $hideLinks = (bool)!empty($this->_params['hidelinks']);
144: 
145:         /* Lightbox specific URLs */
146:         if (!empty($this->_params['lightbox'])) {
147:             $effectsurl = Horde::url($js_path . '/effects.js', true);
148:             $lbjsurl = Horde::url($ansel_js_path . '/lightbox.js', true);
149:             $horde_css->addThemeStylesheet('lightbox.css');
150:         }
151: 
152:         Horde::startBuffer();
153:         Horde::includeStylesheetFiles(array(
154:             'nobase' => true), true);
155:         $css = Horde::endBuffer();
156: 
157:         /* Start building the javascript */
158:         $html = <<<EOT
159:             //<![CDATA[
160:             // Old fashioned way to play nice with Safari 2 (Adding script inline with the
161:             // DOM won't work).  Need two seperate files output here since the incldued
162:             // files don't seem to be parsed until after the entire page is loaded, so we
163:             // can't include prototype on the same page it's needed.
164: 
165:             if (typeof anseljson == 'undefined') {
166:                 if (typeof Prototype == 'undefined') {
167:                     document.write('<script type="text/javascript" src="$pturl"></script>');
168:                 }
169:                 if (typeof Horde_ToolTips == 'undefined') {
170:                     document.write('<script type="text/javascript" src="$hjsurl"></script>');
171:                 }
172: 
173:                 anselnodes = new Array();
174:                 anseljson = new Object();
175:                 document.write('$css');
176:                 document.write('<script type="text/javascript" src="$jsurl"></script>');
177:             }
178:             anselnodes[anselnodes.length] = '$node';
179:             anseljson['$node'] = new Object();
180:             anseljson['$node']['data'] = $json;
181:             anseljson['$node']['perpage'] = $perpage;
182:             anseljson['$node']['page'] = 0;
183:             anseljson['$node']['hideLinks'] = '$hideLinks';
184:             //]]>
185: 
186: EOT;
187:             /* Special requirements for lightbox */
188:             if (!empty($lbjsurl)) {
189:                 $loading_img = Horde_Themes::img('lightbox/loading.gif');
190:                 $close_img = Horde_Themes::img('lightbox/closelabel.gif');
191:                 $imageText = _("Photo");
192:                 $labelOf = _("of");
193:                 $html .= <<<EOT
194:                 if (typeof Effect == 'undefined') {
195:                     document.write('<script type="text/javascript" src="$effectsurl"></script>');
196:                 }
197: 
198:                 /* Make sure we only include this stuff once */
199:                 if (typeof lbOptions == 'undefined') {
200: 
201:                     document.write('<script type="text/javascript" src="$lbjsurl"></script>');
202: 
203:                     lbOptions = {
204:                         fileLoadingImage: '$loading_img',
205:                         fileBottomNavCloseImage: '$close_img',
206:                         overlayOpacity: 0.8,
207:                         animate: true,
208:                         resizeSpeed: 7,
209:                         borderSize: 10,
210:                         labelImage: '$imageText',
211:                         labelOf: '$labelOf',
212:                         returnURL: '#',
213:                         startPage: 0
214:                     }
215:                 }
216:                 anseljson['$node']['lightbox'] = $json_full;
217: EOT;
218:         }
219: 
220:         return $html;
221:     }
222: 
223: }
224: 
API documentation generated by ApiGen