| // +--------------------------------------------------------------------+ // // $Id$ // // +X2C includes require_once 'BIFE/Widget.php'; // ~X2C require_once 'BIFE/Link.php'; require_once 'Image/Transform.php'; // +X2C Class 20 :Thumbs /** * Photo album widget. [TODO: Make a better explanation] * * @package BIFE_Album * @access public */ class BIFE_Album_Thumbs extends BIFE_Widget { // ~X2C // +X2C Operation 22 /** * Constructor. * * @param array $attrs Attributes. * * @return void * @access public */ function BIFE_Album_Thumbs($attrs) // ~X2C { $this->__construct($attrs); } // -X2C // +X2C Operation 57 /** * Constructor. * * @param array $attrs Attributes. * * @return void * @access public */ function __construct($attrs) // ~X2C { // TODO - get defaults from an INI file. $defaults = array( 'DIR' => '.', 'RECURSIVE' => true, 'THUMBSFORMAT' => 'jpeg', 'THUMBSDIR' => '.thumbs', 'EXTENSIONS' => 'png,jpg,jpeg,PNG,JPG,JPEG', 'MAXROWS' => 0, 'COLUMNS' => 4, 'LINK' => 'photo.xbf', ); $attrs = array_merge($defaults, $attrs); $attrs['EXTENSIONS'] = explode(',', $attrs['EXTENSIONS']); parent::__construct($attrs); } // -X2C // +X2C Operation 23 /** * Renders the widget. * * @param HTML_Template_HIT &$template Template to use to render the widget. * * @return string * @access public */ function render(&$template) // ~X2C { $template->pushGroup('album'); $list = $this->getList(BIFE_Link::getFsPath() . $this->attrs['DIR'], $this->attrs['EXTENSIONS'], $this->attrs['THUMBSFORMAT'], $this->attrs['THUMBSDIR']); $tot = count($list); $rows = ceil($tot / $this->attrs['COLUMNS']); for ($row = 0; $row < $rows; $row++) { for ($col = 0; $col < $this->attrs['COLUMNS']; $col++) { $cur = $row * $this->attrs['COLUMNS'] + $col; if ($photo = @$list[$cur]) { if (is_null($photo['THUMB'])) { $photo['THUMB'] = $this->makeThumb( BIFE_Link::getFsPath() . $photo['FILE'], $this->attrs['THUMBSFORMAT'], $this->attrs['THUMBSDIR']); } $photo['THUMB'] = BIFE_Link::getWebPath() . $this->attrs['DIR'] . '/' . $photo['THUMB']; $photo['URL'] = BIFE_Link::getURL( array( 'URL' => $this->attrs['LINK'], 'DATA-BIFE_ALBUM_FILE' => BIFE_Link::getWebPath() . $this->attrs['DIR'] . '/' . $photo['FILE'], ) ); $cell = $template->parse('item', $photo); } else { $cell = $template->parse('empty'); } $template->parseBuffered('cell', 'CONTENTS', $cell); } $template->parseBuffered('row', 'CONTENTS', $template->popBuffer('cell')); } $out = $template->parse('body', array( 'DESC' => $this->getDescription(), 'CONTENTS' => $template->popBuffer('row'))); $template->popGroup(); return $out; } // -X2C // +X2C Operation 95 /** * Gets a list of photos with their descriptions and thumbnails. Returns an array of associative arrays with this keys: