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_Widget_Actions:: class to wrap the display of gallery actions
  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:  * @TODO: Use Horde_View for html template output.
 11:  * 
 12:  * @author Michael J. Rubinsky <mrubinsk@horde.org>
 13:  * @package Ansel
 14:  */
 15: class Ansel_Widget_Actions extends Ansel_Widget_Base
 16: {
 17:     /**
 18:      * @var string
 19:      */
 20:     protected $_supported_views = array('Gallery');
 21: 
 22:     /**
 23:      * @param array $params
 24:      */
 25:     public function __construct($params)
 26:     {
 27:         $this->_title = _("Gallery Actions");
 28:         parent::__construct($params);
 29:     }
 30: 
 31:     /**
 32:      *
 33:      * @see ansel/lib/Widget/Ansel_Widget_Base#html()
 34:      */
 35:     public function html()
 36:     {
 37:         $html = $this->_htmlBegin();
 38:         $id = $this->_view->gallery->id;
 39:         $galleryurl = Horde::url('gallery.php')->add('gallery', $id);
 40: 
 41:         if ($this->_view->gallery->hasFeature('upload')) {
 42:             $uploadurl = Horde::url('img/upload.php')->add(
 43:                 array('gallery' => $id,
 44:                       'page' => !empty($this->_view->_params['page']) ? $this->_view->_params['page'] : 0));
 45:         }
 46: 
 47:         $html .= '<ul style="list-style-type:none;">';
 48:         if (empty($this->_params['hide_slideshow']) &&
 49:             $this->_view->gallery->hasFeature('slideshow') &&
 50:             $this->_view->gallery->countImages()) {
 51: 
 52:             /* Slideshow link */
 53:             if (!empty($this->_params['slideshow_link'])) {
 54:                 $slideshow_url = str_replace(array('%i', '%g'),
 55:                                              array(array_pop($this->_view->gallery->listImages(0, 1)), $id),
 56:                                              urldecode($this->_params['slideshow_link']));
 57:             } else {
 58:                 /* Get any date info the gallery has */
 59:                 $date = $this->_view->gallery->getDate();
 60:                 $slideshow_url = Horde::url('view.php')->add(
 61:                     array_merge(array('gallery' => $id,
 62:                                       'image' => array_pop($this->_view->gallery->listImages(0, 1)),
 63:                                       'view' => 'Slideshow'),
 64:                                 $date));
 65:             }
 66:             $html .= '<li>' . $slideshow_url->link(array('class' => 'widget')) . Horde::img('slideshow_play.png', _("Start Slideshow")) . ' ' . _("Start Slideshow") . '</a></li>';
 67:         }
 68:         
 69:         /* Upload and new subgallery Urls */
 70:         if (!empty($uploadurl) && $this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
 71:             $html .= '<li>' . $uploadurl->link(array('class' => 'widget')) . Horde::img('image_add.png') . ' ' . _("Upload photos") . '</a></li>';
 72: 
 73:             /* Subgalleries */
 74:             if ($this->_view->gallery->hasFeature('subgalleries')) {
 75:                 $html .= '<li>' . $galleryurl->copy()->add('actionID', 'addchild')->link(array('class' => 'widget')) . Horde::img('add.png', '[icon]') . ' ' . _("Create a subgallery") . '</a></li>';
 76:             }
 77:         }
 78:         $html .= '</ul>';
 79:         $html .= $this->_getGalleryActions();
 80: 
 81:         $selfurl = Horde::selfUrl(true, true);
 82:         $html .=  '<div class="control">'
 83:                  . $selfurl->add('actionID', 'show_actions')->link(array('id' => 'gallery-actions-toggle', 'class' => ($GLOBALS['prefs']->getValue('show_actions') ? 'hide' : 'show')))
 84:                  . '&nbsp;</a></div>' . "\n";
 85: 
 86:         $html .= $this->_htmlEnd();
 87:         return $html;
 88:     }
 89: 
 90:     /**
 91:      * Helper function for generating the gallery actions selection widget.
 92:      *
 93:      * @return string  The HTML
 94:      */
 95:     protected function _getGalleryActions()
 96:     {
 97:         global $registry, $conf;
 98: 
 99:         $id = $this->_view->gallery->id;
100:         $galleryurl = Horde::url('gallery.php')->add('gallery', $id);
101:         $selfurl = Horde::selfUrl(true, false, true);
102:         $count = $this->_view->gallery->countImages();
103:         $date = $this->_view->gallery->getDate();
104: 
105:         $html = '<div style="display:' . (($GLOBALS['prefs']->getValue('show_actions')) ? 'block' : 'none') . ';" id="gallery-actions">';
106: 
107:         /* Attach the ajax action */
108:         Horde::startBuffer();
109:         $GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create(array('ansel', 'ToggleGalleryActions'), array(
110:             'bindTo' => 'gallery-actions'
111:         ));
112:         $html .= Horde::endBuffer();
113: 
114:         /* Buid the url parameters to the zip link */
115:         $view_params = array(
116:             'gallery' => $this->_view->gallery->id,
117:             'view' => 'Gallery',
118:             'slug' => $this->_view->gallery->get('slug'),
119:             'page' => (!empty($this->_view->_params['page']) ? $this->_view->_params['page'] : 0));
120: 
121:         /* Append the date information to the parameters if we need it */
122:         $view_params = array_merge($view_params, $date);
123: 
124:         $html .= '<ul style="list-style-type:none;">';
125: 
126:         /* Bookmark link */
127:         if ($registry->hasMethod('bookmarks/getAddUrl')) {
128:             $api_params = array(
129:                 'url' => Ansel::getUrlFor('view', $view_params, true),
130:                 'title' => $this->_view->gallery->get('name'));
131: 
132:             try {
133:                 $url = new Horde_Url($registry->bookmarks->getAddUrl($api_params));
134:                 $html .= '<li>' . $url->link(array('class' => 'widget')) . Horde::img('trean.png') . ' ' . _("Add to bookmarks") . '</a></li>';
135:             } catch (Horde_Exception $e) {}
136:         }
137: 
138:         /* Download as ZIP link */
139:         if (!empty($conf['gallery']['downloadzip']) &&
140:             $this->_view->gallery->canDownload() &&
141:             $count &&
142:             $this->_view->gallery->hasFeature('zipdownload')) {
143: 
144:             $zip_params = array_merge(array('actionID' => 'downloadzip'), $date);
145:             $html .= '<li>' . $galleryurl->copy()->add($zip_params)->link(array('class' => 'widget')) . Horde::img('mime/compressed.png') . ' ' .  _("Download as zip file") . '</a></li>';
146:         }
147: 
148:         /* Image upload, subgalleries, captions etc... */
149:         if ($this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
150:             /* Properties */
151:             $html .= '<li>' . $galleryurl->copy()->add(array('actionID' => 'modify', 'url' => $selfurl))->link(array('class' => 'widget')) . Horde::img('edit.png') . ' ' . _("Change properties") . '</a></li>';
152:             if ($count) {
153:                 /* Captions */
154:                 if ($this->_view->gallery->hasFeature('image_captions')) {
155:                     $params = array_merge(array('gallery' => $id), $date);
156:                     $html .= '<li>' . Horde::url('gallery/captions.php')->add($params)->link(array('class' => 'widget')) . Horde::img('text.png') . ' ' . _("Set captions") . ' ' . '</a></li>';
157:                 }
158: 
159:                 /* Sort */
160:                 if ($this->_view->gallery->hasFeature('sort_images')) {
161:                     $sorturl = Horde::url('gallery/sort.php')->add(array_merge(array('gallery' => $id), $date));
162:                     $html .= '<li>' . $sorturl->copy()->add('actionId' , 'getOrder')->link(array('class' => 'widget')) . Horde::img('arrow_switch.png') . ' ' . _("Sort photos") . '</a></li>';
163:                 }
164: 
165:                 /* Regenerate Thumbnails */
166:                 $html .= '<li>' . $galleryurl->copy()->add(array('actionID' => 'generateThumbs'))->link(array('class' => 'widget')) . Horde::img('reload.png') . ' ' . _("Reset all thumbnails") . '</a></li>';
167: 
168:                 /* Regenerate all views  */
169:                 $html .= '<li>' . $galleryurl->copy()->add(array('actionID' => 'deleteCache'))->link(array('class' => 'widget')) . Horde::img('reload.png') . ' ' . _("Regenerate all photo views") . '</a></li>';
170: 
171:                 /* Find faces */
172:                 if ($conf['faces']['driver'] && $this->_view->gallery->hasFeature('faces')) {
173:                     $html .= '<li>' . Horde::url('faces/gallery.php')->add(
174:                         array_merge($date,
175:                                     array('gallery' => $id, 'page' => (!empty($this->_view->_params['page']) ? $this->_view->_params['page'] : 0))))
176:                         ->link(array('class' => 'widget')) . Horde::img('user.png') . ' ' . _("Find faces") . '</a></li>';
177:                 }
178: 
179:             } /* end if ($count) {} */
180: 
181:             if ($this->_view->gallery->hasFeature('stacks')) {
182:                 $html .= '<li>' . $galleryurl->copy()->add(array('actionID' => 'generateDefault', 'url' => $selfurl))->link(array('class' => 'widget')) . Horde::img('reload.png') . ' ' . _("Reset default photo") . '</a></li>';
183:             }
184:         }
185: 
186:         if ($GLOBALS['registry']->getAuth() &&
187:             $this->_view->gallery->get('owner') == $GLOBALS['registry']->getAuth()) {
188:              $url = new Horde_Url('#');
189:              $html .= '<li>' . $url->link(array('class' => 'popup widget', 'onclick' => Horde::popupJs(Horde::url('perms.php'), array('params' => array('cid' => $this->_view->gallery->id), 'urlencode' => true)) . 'return false;')) . Horde::img('perms.png') . ' ' . _("Set permissions") . '</a></li>';
190:         } elseif (!empty($conf['report_content']['driver']) &&
191:             (($conf['report_content']['allow'] == 'authenticated' &&
192:             $registry->isAuthenticated()) ||
193:                    $conf['report_content']['allow'] == 'all')) {
194: 
195:             $reporturl = Horde::url('report.php')->add('gallery', $id);
196:             $html .= '<li>' . $reporturl->link(array('class' => 'widget')) . _("Report") . '</a></li>';
197:         }
198: 
199:         if ($this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) {
200:             $html .= '<li>' . $galleryurl->copy()->add('actionID', 'empty')->link(array('class' => 'widget')) . Horde::img('delete.png') . ' ' . _("Delete All Photos") . '</a></li>';
201:             $html .= '<li>' . $galleryurl->copy()->add('actionID', 'delete')->link(array('class' => 'widget')) . Horde::img('delete.png', 'horde') . ' ' . _("Delete Entire Gallery") . '</a></li>';
202:         }
203:         $html .= '</ul></div>';
204: 
205:         return $html;
206:     }
207: }
208: 
API documentation generated by ApiGen