Overview

Packages

  • Ansel
  • None

Classes

  • Ansel_Application
  • Ansel_Block_Cloud
  • Ansel_Block_Gallery
  • Ansel_Block_MyGalleries
  • Ansel_Block_RandomPhoto
  • Ansel_Block_RecentComments
  • Ansel_Block_RecentFaces
  • Ansel_Block_Recentlyadded
  • Ansel_Block_RecentlyAddedGeodata
  • Ansel_Config
  • Ansel_Form_Watermark
  • Overview
  • Package
  • Class
  • Tree
 1: <?php
 2: /**
 3:  * Display a random photo in a block.
 4:  *
 5:  * Copyright 2003-2007 Duck <duck@obla.net>
 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  Duck <Duck@obla.net>
11:  * @author  Ben Chavet <ben@horde.org>
12:  */
13: class Ansel_Block_RandomPhoto extends Horde_Core_Block
14: {
15:     /**
16:      */
17:     public $updateable = true;
18: 
19:     /**
20:      */
21:     public function __construct($app, $params = array())
22:     {
23:         parent::__construct($app, $params);
24: 
25:         $this->_name = _("Random photo");
26:     }
27: 
28:     /**
29:      */
30:     protected function _content()
31:     {
32:         $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRandomGallery();
33:         if (!$gallery) {
34:             return _("There are no photo galleries available.");
35:         }
36:         $imagelist = $gallery->listImages(rand(0, $gallery->countImages() - 1), 1);
37:         if (empty($imagelist)) {
38:             return '';
39:         }
40:         $imageId = $imagelist[0];
41:         $viewurl = Ansel::getUrlFor('view', array('gallery' => $gallery->id,
42:                                                   'slug' => $gallery->get('slug'),
43:                                                   'image' => $imageId,
44:                                                   'view' => 'Image'), true);
45: 
46:         if ($gallery->isOldEnough() && !$gallery->hasPasswd()) {
47:             $img = '<img src="' . Ansel::getImageUrl($imageId, 'thumb', true, Ansel::getStyleDefinition('ansel_default')) . '" alt="[random photo]" />';
48:         } else {
49:             $img = Horde::img('thumb-error.png');
50:         }
51: 
52:         return $viewurl->link(array('title' => _("View Photo"))) . $img . '</a>';
53:     }
54: 
55: }
56: 
API documentation generated by ApiGen