本文整理汇总了PHP中Ansel::getStyleDefinition方法的典型用法代码示例。如果您正苦于以下问题:PHP Ansel::getStyleDefinition方法的具体用法?PHP Ansel::getStyleDefinition怎么用?PHP Ansel::getStyleDefinition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ansel
的用法示例。
在下文中一共展示了Ansel::getStyleDefinition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _content
/**
*/
protected function _content()
{
$GLOBALS['page_output']->addScriptFile('block.js');
/* Get the top level galleries */
try {
$galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('perm' => Horde_Perms::EDIT, 'attributes' => $GLOBALS['registry']->getAuth(), 'all_levels' => false, 'count' => empty($this->_params['limit']) ? 0 : $this->_params['limit'], 'sort_by' => 'last_modified', 'direction' => Ansel::SORT_DESCENDING));
} catch (Ansel_Exception $e) {
return $e->getMessage();
}
$header = array(_("Gallery Name"), _("Last Modified"), _("Photo Count"));
$html = <<<HEADER
<table class="linedRow" cellspacing="0" style="width:100%">
<thead><tr class="item nowrap">
<th class="item leftAlign">{$header['0']}</th>
<th class="item leftAlign">{$header['1']}</th>
<th class="item leftAlign">{$header['2']}</th>
</tr></thead>
<tbody>
HEADER;
foreach ($galleries as $gallery) {
$url = Ansel::getUrlFor('view', array('view' => 'Gallery', 'slug' => $gallery->get('slug'), 'gallery' => $gallery->id), true);
$html .= '<tr><td>' . $url->link(array('onmouseout' => '$("ansel_preview").hide();$("ansel_preview").update("");', 'onmouseover' => 'Ansel.previewImage(event, ' . $gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')) . ');')) . htmlspecialchars($gallery->get('name')) . '</a></td><td>' . strftime($GLOBALS['prefs']->getValue('date_format'), $gallery->get('last_modified')) . '</td><td>' . (int) $gallery->countImages(true) . '</td></tr>';
}
$html .= '</tbody></table>';
return $html;
}
示例2: _getOtherGalleries
/**
* Build the HTML for the other galleries widget content.
*
* @param Horde_View $view The view object.
*/
protected function _getOtherGalleries(&$view)
{
$owner = $this->_view->gallery->get('owner');
// Set up the tree
$tree = $GLOBALS['injector']->getInstance('Horde_Core_Factory_Tree')->create('otherAnselGalleries_' . md5($owner), 'Javascript', array('class' => 'anselWidgets'));
try {
$galleries = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('attributes' => $owner));
} catch (Ansel_Exception $e) {
Horde::log($e, 'ERR');
return;
}
foreach ($galleries as $gallery) {
$parents = $gallery->get('parents');
if (empty($parents)) {
$parent = null;
} else {
$parents = explode(':', $parents);
$parent = array_pop($parents);
}
$img = (string) Ansel::getImageUrl($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')), 'mini', true);
$link = Ansel::getUrlFor('view', array('gallery' => $gallery->id, 'slug' => $gallery->get('slug'), 'view' => 'Gallery'), true);
$tree->addNode(array('id' => $gallery->id, 'parent' => $parent, 'label' => $gallery->get('name'), 'expanded' => $gallery->id == $this->_view->gallery->id, 'params' => array('icon' => $img, 'url' => $link)));
}
Horde::startBuffer();
$tree->sort('label');
$tree->renderTree();
$view->tree = Horde::endBuffer();
$GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('Ansel_Ajax_Imple_ToggleOtherGalleries', array('id' => 'othergalleries-toggle'));
}
示例3: __construct
/**
* Const'r
*
* @see Ansel_View_Base::__construct
*/
public function __construct(array $params = array())
{
parent::__construct($params);
if (!empty($params['gallery_slug'])) {
$this->gallery = $this->_getGallery(null, $params['gallery_slug']);
} elseif (!empty($params['gallery_id'])) {
$this->gallery = $this->_getGallery($params['gallery_id']);
} else {
$this->gallery = $this->_getGallery();
}
// Check user age
if (!$this->gallery->isOldEnough()) {
if (!empty($params['api'])) {
throw new Ansel_Exception('Locked galleries are not viewable via the api.');
}
$date = Ansel::getDateParameter(array('year' => isset($this->_params['year']) ? $this->_params['year'] : 0, 'month' => isset($this->_params['month']) ? $this->_params['month'] : 0, 'day' => isset($this->_params['day']) ? $this->_params['day'] : 0));
$galleryurl = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => empty($params['slug']) ? '' : $params['slug'], 'page' => empty($params['page']) ? 0 : $params['page'], 'view' => 'Gallery'), $date), true);
$params = array('gallery' => $this->gallery->id, 'url' => $galleryurl);
Horde::url('disclamer.php')->add($params)->setRaw(true)->redirect();
exit;
}
if ($this->gallery->hasPasswd()) {
if (!empty($params['api'])) {
throw new Ansel_Exception(_("Locked galleries are not viewable via the api."));
}
$date = Ansel::getDateParameter(array('year' => isset($this->_params['year']) ? $this->_params['year'] : 0, 'month' => isset($this->_params['month']) ? $this->_params['month'] : 0, 'day' => isset($this->_params['day']) ? $this->_params['day'] : 0));
$galleryurl = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => empty($params['slug']) ? '' : $params['slug'], 'page' => empty($params['page']) ? 0 : $params['page'], 'view' => 'Gallery'), $date), true);
$params = array('gallery' => $this->gallery->id, 'url' => $galleryurl);
Horde::url('protect.php')->add($params)->setRaw(true)->redirect();
exit;
}
if (!$this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
throw new Horde_Exception_PermissionDenied();
}
// Since this is a gallery view, the resource is the gallery.
$this->resource = $this->gallery;
// Do we have an explicit style set? If not, use the gallery's
if (!empty($this->_params['style'])) {
$style = Ansel::getStyleDefinition($this->_params['style']);
} else {
$style = $this->gallery->getStyle();
}
if (!empty($this->_params['gallery_view'])) {
$renderer = $this->_params['gallery_view'];
} else {
$renderer = !empty($style->gallery_view) ? $style->gallery_view : 'Gallery';
}
// Load the helper
$classname = 'Ansel_View_GalleryRenderer_' . basename($renderer);
$this->_renderer = new $classname($this);
$this->_renderer->init();
}
示例4: _content
/**
*/
protected function _content()
{
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRandomGallery();
if (!$gallery) {
return _("There are no photo galleries available.");
}
$imagelist = $gallery->listImages(rand(0, $gallery->countImages() - 1), 1);
if (empty($imagelist)) {
return '';
}
$imageId = $imagelist[0];
$viewurl = Ansel::getUrlFor('view', array('gallery' => $gallery->id, 'slug' => $gallery->get('slug'), 'image' => $imageId, 'view' => 'Image'), true);
if ($gallery->isOldEnough() && !$gallery->hasPasswd()) {
$img = '<img src="' . Ansel::getImageUrl($imageId, 'thumb', true, Ansel::getStyleDefinition('ansel_default')) . '" alt="[random photo]" />';
} else {
$img = Horde::img('thumb-error.png');
}
return $viewurl->link(array('title' => _("View Photo"))) . $img . '</a>';
}
示例5: _content
/**
*/
protected function _content()
{
try {
$gallery = $this->_getGallery();
} catch (Ansel_Exception $e) {
return $e->getMessage();
}
$params = array('gallery_id' => $gallery->id, 'count' => $this->_params['perpage']);
if (!empty($this->_params['use_lightbox'])) {
$params['lightbox'] = true;
}
$html = Ansel::embedCode($params);
// Be nice to people with <noscript>
$viewurl = Ansel::getUrlFor('view', array('view' => 'Gallery', 'gallery' => $gallery->id, 'slug' => $gallery->get('slug')), true);
$html .= '<noscript>';
$html .= $viewurl->link(array('title' => sprintf(_("View %s"), $gallery->get('name'))));
if ($iid = $gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')) && $gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
$html .= '<img src="' . Ansel::getImageUrl($gallery->getKeyImage(Ansel::getStyleDefinition('ansel_default')), 'thumb', true) . '" alt="' . htmlspecialchars($gallery->get('name')) . '" />';
} else {
$html .= Horde::img('thumb-error.png');
}
return $html . '</a></noscript>';
}
示例6: html
/**
* Return the HTML representing this view.
*
* @return string The HTML.
*
*/
public function html()
{
global $conf, $prefs, $registry;
$vars = Horde_Variables::getDefaultVariables();
if (!empty($this->_params['page'])) {
$vars->add('page', $this->_params['page']);
}
if (!empty($this->_params['pager_url'])) {
$this->_pagerurl = $this->_params['pager_url'];
$override = true;
} else {
$override = false;
$this->_pagerurl = Ansel::getUrlFor('view', array('owner' => $this->_owner, 'special' => $this->_special, 'groupby' => $this->_view->groupby, 'view' => 'List'));
}
$p_params = array('num' => $this->_view->numGalleries, 'url' => $this->_pagerurl, 'perpage' => $this->_view->gPerPage);
if ($override) {
$p_params['url_callback'] = null;
}
$this->_pager = new Horde_Core_Ui_Pager('page', $vars, $p_params);
$preserve = array('sort_dir' => $this->_view->sortDir);
if (!empty($this->_view->sortBy)) {
$preserve['sort'] = $this->_view->sortBy;
}
$this->_pager->preserve($preserve);
if ($this->_view->numGalleries) {
$min = $this->_page * $this->_view->gPerPage;
$max = $min + $this->_view->gPerPage;
if ($max > $this->_view->numGalleries) {
$max = $this->_view->numGalleries - $min;
}
$this->_view->start = $min + 1;
$this->_view->end = min($this->_view->numGalleries, $min + $this->_view->gPerPage);
if ($this->_owner) {
$this->_view->refresh_link = Ansel::getUrlFor('view', array('groupby' => $this->_view->groupby, 'owner' => $this->_owner, 'page' => $this->_page, 'view' => 'List'));
} else {
$this->_view->refresh_link = Ansel::getUrlFor('view', array('view' => 'List', 'groupby' => $this->_view->groupby, 'page' => $this->_page));
}
// Get top-level / default gallery style.
if (empty($this->_params['style'])) {
$style = Ansel::getStyleDefinition($prefs->getValue('default_gallerystyle'));
} else {
$style = Ansel::getStyleDefinition($this->_params['style']);
}
// Final touches.
if (empty($this->_params['api'])) {
$this->_view->breadcrumbs = Ansel::getBreadcrumbs();
$this->_view->groupbyUrl = strval(Ansel::getUrlFor('group', array('actionID' => 'groupby', 'groupby' => 'owner')));
}
$this->_view->pager = $this->_pager->render();
$this->_view->style = $style;
$this->_view->tilesperrow = $prefs->getValue('tilesperrow');
$this->_view->cellwidth = round(100 / $this->_view->tilesperrow);
$this->_view->params = $this->_params;
$GLOBALS['page_output']->addScriptFile('views/common.js');
return $this->_view->render('list');
}
return ' ';
}
示例7: html
/**
* Get the HTML representing this view.
*
* @return string The HTML
*/
public function html()
{
global $conf, $prefs;
$view = $GLOBALS['injector']->getInstance('Horde_View');
$view->addTemplatePath(ANSEL_TEMPLATES . '/view');
$view->perPage = $this->_perPage;
// Ansel Storage
$ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
// Get the slice of galleries/images to view on this page.
try {
$view->results = $this->_browser->getSlice($this->_page, $this->_perPage);
} catch (Ansel_Exception $e) {
Horde::log($e->getMessage(), 'ERR');
return _("An error has occured retrieving the image. Details have been logged.");
}
$view->total = $this->_browser->count();
$view->total = $view->total['galleries'] + $view->total['images'];
// The number of resources to display on this page.
$view->numimages = count($view->results);
$view->tilesperrow = $prefs->getValue('tilesperrow');
$view->cellwidth = round(100 / $view->tilesperrow);
// Get any related tags to display.
if ($conf['tags']['relatedtags']) {
$view->rtags = $this->_browser->getRelatedTags();
$view->taglinks = Ansel::getTagLinks($view->rtags, 'add');
}
$vars = Horde_Variables::getDefaultVariables();
$option_move = $option_copy = $ansel_storage->countGalleries($GLOBALS['registry']->getAuth(), array('perm' => Horde_Perms::EDIT));
$this->_pagestart = $this->_page * $this->_perPage + 1;
$this->_pageend = min($this->_pagestart + $view->numimages - 1, $this->_pagestart + $this->_perPage - 1);
$view->pageStart = $this->_pageStart;
$view->pageEnd = $this->_pageEnd;
$view->owner = $this->_owner;
$view->tagTrail = $this->_browser->getTagTrail();
$view->title = $this->getTitle();
$view->params = $this->_params;
$view->style = Ansel::getStyleDefinition($GLOBALS['prefs']->getValue('default_gallerystyle'));
$viewurl = Horde::url('view.php')->add(array('view' => 'Results', 'actionID' => 'add'));
$view->pager = new Horde_Core_Ui_Pager('page', $vars, array('num' => $view->total, 'url' => $viewurl, 'perpage' => $this->_perPage));
$GLOBALS['page_output']->addScriptFile('views/common.js');
$GLOBALS['page_output']->addScriptFile('views/gallery.js');
return $view->render('results');
}
示例8: Horde_Exception_PermissionDenied
<?php
/**
* Copyright 2003-2015 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Chuck Hagenbuch <chuck@horde.org>
*/
require_once __DIR__ . '/../lib/Application.php';
Horde_Registry::appInit('ansel');
$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage(Horde_Util::getFormData('image'));
$gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery);
if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::READ)) {
throw new Horde_Exception_PermissionDenied(_("Access denied viewing this photo."));
}
/* Sendfile support. Lighttpd < 1.5 only understands the X-LIGHTTPD-send-file header */
if ($conf['vfs']['src'] == 'sendfile') {
/* Need to ensure the file exists */
try {
$image->createView('screen', Ansel::getStyleDefinition('ansel_default'), $GLOBALS['prefs']->getValue('watermark_auto') ? $GLOBALS['prefs']->getValue('watermark_text', '') : '');
} catch (Ansel_Exception $e) {
Horde::log($result, 'ERR');
exit;
}
$filename = $injector->getInstance('Horde_Core_Factory_Vfs')->create('images')->readFile($image->getVFSPath('screen'), $image->getVFSName('screen'));
Ansel::doSendfile($filename, $image->getType('screen'));
exit;
}
$image->display('screen');
示例9: catch
<?php
/**
* Copyright 2007-2015 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (GPL). If you
* did not receive this file, see http://www.horde.org/licenses/gpl.
*
* @author Michael Rubinsky <mrubinsk@horde.org>
*/
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('ansel');
$imageId = Horde_Util::getFormData('image');
try {
$image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($imageId);
$gal = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery(abs($image->gallery));
$img = Ansel::getImageUrl($imageId, 'thumb', false, Ansel::getStyleDefinition('ansel_default'));
} catch (Ansel_Exception $e) {
Horde::log($e->getMessage(), 'ERR');
exit;
} catch (Horde_Exception_NotFound $e) {
Horde::log($e->getMessage(), 'ERR');
exit;
}
if ($gal->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::SHOW) && !$gal->hasPasswd() && $gal->isOldEnough()) {
echo '<img src="' . $img . '" alt="' . htmlspecialchars($image->filename) . '">';
} else {
echo '';
}
示例10: _prepare
/**
* Build variables needed to output the html. Extracted to this method so
* child classes can use this as well.
*/
protected function _prepare()
{
global $conf;
$this->_page = isset($this->_params['page']) ? $this->_params['page'] : 0;
$this->_slug = $this->gallery->get('slug');
$this->_date = $this->gallery->getDate();
$this->_style = empty($this->_params['style']) ? $this->gallery->getStyle() : Ansel::getStyleDefinition($this->_params['style']);
// Make sure the screen view is loaded and get the geometry
try {
$this->_geometry = $this->resource->getDimensions('screen');
} catch (Ansel_Exception $e) {
Horde::log($e, 'ERR');
$this->_geometry = $GLOBALS['conf']['screen'];
}
// Get the image lists
$this->_imageList = $this->gallery->listImages();
$this->_revList = array_flip($this->_imageList);
// Not needed when being called via api
if (empty($this->_params['api'])) {
// Build the various urls
$imageActionUrl = Horde::url('image.php')->add(array_merge(array('gallery' => $this->gallery->id, 'image' => $this->resource->id, 'page' => $this->_page), $this->_date));
if ($this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
$this->_urls['prop_popup'] = Horde::popupJs($imageActionUrl, array('urlencode' => true, 'height' => 360, 'width' => 500, 'params' => array('actionID' => 'modify', 'ret' => 'image', 'gallery' => $this->gallery->id, 'image' => $this->resource->id, 'page' => $this->_page)));
$this->_urls['edit'] = $imageActionUrl->copy()->add('actionID', 'editimage');
}
if ($this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::DELETE)) {
$this->_urls['delete'] = $imageActionUrl->copy()->add('actionID', 'delete');
}
if (!empty($conf['ecard']['enable'])) {
$this->_urls['ecard'] = Horde::url('img/ecard.php')->add(array_merge(array('gallery' => $this->gallery->id, 'image' => $this->resource->id), $this->_date));
}
if ($this->gallery->canDownload()) {
$this->_urls['download'] = Horde::url('img/download.php', true)->add('image', $this->resource->id);
}
if ((!$GLOBALS['registry']->getAuth() || $this->gallery->get('owner') != $GLOBALS['registry']->getAuth()) && !empty($GLOBALS['conf']['report_content']['driver']) && ($conf['report_content']['allow'] == 'authenticated' && $GLOBALS['registry']->isAuthenticated() || $conf['report_content']['allow'] == 'all')) {
$this->_urls['report'] = Horde::url('report.php')->add(array('gallery' => $this->gallery->id, 'image' => $this->resource->id));
}
}
// Check for an explicit gallery view url to use
if (!empty($this->_params['gallery_view_url'])) {
$this->_urls['gallery'] = new Horde_Url(str_replace(array('%g', '%s'), array($this->gallery->id, $this->_slug), urldecode($this->_params['gallery_view_url'])));
$this->_urls['gallery']->add($this->_date);
} else {
$this->_urls['gallery'] = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => $this->_slug, 'page' => $this->_page, 'view' => 'Gallery'), $this->_date), true);
}
// Get the image src url
$this->_urls['imgsrc'] = Ansel::getImageUrl($this->resource->id, 'screen', true, $this->_style);
// A self url. Can't use Horde::selfUrl() since that would ignore
// pretty urls.
$this->_urls['self'] = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => $this->_slug, 'image' => $this->resource->id, 'view' => 'Image', 'page' => $this->_page), $this->_date));
}
示例11: html
/**
* Build the javascript that will render the view.
*
* @return string A string containing valid javascript.
*/
public function html()
{
// Required
$node = $this->_params['container'];
if (empty($node)) {
return '';
}
// Optional
$gallery_slug = !empty($this->_params['gallery_slug']) ? $this->_params['gallery_slug'] : '';
$gallery_id = !empty($this->_params['gallery_id']) ? $this->_params['gallery_id'] : null;
$start = isset($this->_params['start']) ? $this->_params['start'] : 0;
$count = isset($this->_params['count']) ? $this->_params['count'] : 0;
$perpage = isset($this->_params['perpage']) ? $this->_params['perpage'] : 0;
$thumbsize = !empty($this->_params['thumbsize']) ? $this->_params['thumbsize'] : 'mini';
if ($thumbsize != 'mini' && $thumbsize != 'thumb' && $thumbsize != 'screen') {
$thumbsize = 'mini';
}
$thumbtype = !empty($this->_params['thumbtype']) ? $this->_params['thumbtype'] : 'squarethumb';
// Do we have a gallery, imagelist or user?
$images = !empty($this->_params['images']) ? $this->_params['images'] : array();
if (!empty($images)) {
// Images are filtered for age and password protected galleries
// in the ::getImageJson() call since they could all be from different
// galleries.
$images = explode(':', $images);
} elseif (!empty($this->_params['user'])) {
// User's most recent images.
$galleries = array();
$gs = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('attributes' => $this->_params['user']));
foreach ($gs as $gallery) {
$galleries[] = $gallery->id;
}
$images = array();
$is = $GLOBALS['injector']->getInstance('Ansel_Storage')->getRecentImages($galleries, $count);
foreach ($is as $i) {
$images[] = $i->id;
}
} else {
try {
$this->gallery = $this->_getGallery($gallery_id, $gallery_slug);
} catch (Exception $e) {
Horde::log($e, 'ERR');
exit;
}
// We don't allow age restricted or password locked galleries to be
// viewed via the mini embedded view since it shows *all* the images
if (!$this->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ) || !$this->gallery->isOldEnough() || $this->gallery->hasPasswd()) {
return '';
}
}
if (empty($images)) {
$images = $json = self::json($this->gallery, array('full' => true, 'from' => $start, 'count' => $count, 'image_view' => $thumbsize, 'view_links' => true, 'generator' => $thumbtype));
$json_full = self::json($this->gallery, array('full' => true, 'from' => $start, 'count' => $count, 'view_links' => true));
} else {
if ($thumbsize == 'thumb') {
$style = Ansel::getStyleDefinition('ansel_default');
$style->thumbstyle = $thumbtype;
} else {
$style = null;
}
$json = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImageJson($images, $style, true, $thumbsize, true);
$json_full = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImageJson($images, $style, true, 'screen', true);
}
global $page_output;
$page_output->addThemeStylesheet('embed.css');
/* Some paths */
$js_path = $GLOBALS['registry']->get('jsuri', 'horde');
$pturl = Horde::url($js_path . '/prototype.js', true);
$hjsurl = Horde::url($js_path . '/tooltips.js', true);
$ansel_js_path = $GLOBALS['registry']->get('jsuri', 'ansel');
$jsurl = Horde::url($ansel_js_path . '/embed.js', true);
$hideLinks = (bool) (!empty($this->_params['hidelinks']));
/* Lightbox specific URLs */
if (!empty($this->_params['lightbox'])) {
$effectsurl = Horde::url($js_path . '/scriptaculous/effects.js', true);
$lbjsurl = Horde::url($ansel_js_path . '/lightbox.js', true);
$page_output->addThemeStylesheet('lightbox.css');
}
Horde::startBuffer();
$page_output->includeStylesheetFiles(array('nobase' => true), true);
$css = Horde::endBuffer();
/* Start building the javascript */
$html = <<<EOT
//<![CDATA[
// Old fashioned way to play nice with Safari 2 (Adding script inline with the
// DOM won't work). Need two seperate files output here since the incldued
// files don't seem to be parsed until after the entire page is loaded, so we
// can't include prototype on the same page it's needed.
if (typeof anseljson == 'undefined') {
if (typeof Prototype == 'undefined') {
document.write('<script type="text/javascript" src="{$pturl}"></script>');
}
if (typeof Horde_ToolTips == 'undefined') {
document.write('<script type="text/javascript" src="{$hjsurl}"></script>');
//.........这里部分代码省略.........
示例12: array
<?php
global $prefs, $registry;
$ansel_webroot = $registry->get('webroot');
$horde_webroot = $registry->get('webroot', 'horde');
$style = Ansel::getStyleDefinition('ansel_mobile');
/* Variables used in core javascript files. */
$code['conf'] = array('SESSION_ID' => SID, 'thumbWidth' => $style->width ? $style->width : 75, 'thumbHeight' => $style->height ? $style->height : 75, 'user' => $GLOBALS['registry']->convertUsername($GLOBALS['registry']->getAuth(), false), 'name' => $registry->get('name'));
// List of top level galleries
$gallerylist = $GLOBALS['injector']->getInstance('Ansel_Storage')->listGalleries(array('all_levels' => false, 'attributes' => $registry->getAuth()));
$galleries = array();
foreach ($gallerylist as $gallery) {
$galleries[] = $gallery->toJson();
}
$code['conf']['galleries'] = $galleries;
/* Gettext strings used in core javascript files. */
$code['text'] = array('ajax_error' => _("Error when communicating with the server."));
echo $GLOBALS['page_output']->addInlineJsVars(array('var Ansel' => $code), array('top' => true));
示例13: getImageJson
/**
* Retrieve json data for an arbitrary list of image ids, not necessarily
* from the same gallery.
*
* @param array $images An array of image ids
* @param Ansel_Style $style A gallery style to force if requesting
* pretty thumbs.
* @param boolean $full Generate full urls
* @param string $image_view Which image view to use? screen, thumb etc..
* @param boolean $view_links Include links to the image view
*
* @return string The json data
*/
public function getImageJson(array $images, Ansel_Style $style = null, $full = false, $image_view = 'mini', $view_links = false)
{
$galleries = array();
if (is_null($style)) {
$style = Ansel::getStyleDefinition('ansel_default');
}
$json = array();
foreach ($images as $id) {
$image = $this->getImage($id);
$gallery_id = abs($image->gallery);
if (empty($galleries[$gallery_id])) {
$galleries[$gallery_id]['gallery'] = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id);
}
// Any authentication that needs to take place for any of the
// images included here MUST have already taken place or the
// image will not be incldued in the output.
if (!isset($galleries[$gallery_id]['perm'])) {
$galleries[$gallery_id]['perm'] = $galleries[$gallery_id]['gallery']->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ) && $galleries[$gallery_id]['gallery']->isOldEnough() && !$galleries[$gallery_id]['gallery']->hasPasswd();
}
if ($galleries[$gallery_id]['perm']) {
$data = array((string) Ansel::getImageUrl($image->id, $image_view, $full, $style), htmlspecialchars($image->filename), $GLOBALS['injector']->getInstance('Horde_Core_Factory_TextFilter')->filter($image->caption, 'text2html', array('parselevel' => Horde_Text_Filter_Text2html::MICRO_LINKURL)), $image->id, 0);
if ($view_links) {
$data[] = (string) Ansel::getUrlFor('view', array('gallery' => $image->gallery, 'image' => $image->id, 'view' => 'Image', 'slug' => $galleries[$gallery_id]['gallery']->get('slug')), $full);
$data[] = (string) Ansel::getUrlFor('view', array('gallery' => $image->gallery, 'slug' => $galleries[$gallery_id]['gallery']->get('slug'), 'view' => 'Gallery'), $full);
}
$json[] = $data;
}
}
return Horde_Serialize::serialize($json, Horde_Serialize::JSON);
}
示例14: _thumbStyles
/**
* Get a list of available, currently usable thumbnail styles.
*
* @return array An array of Classnames => titles
*/
protected function _thumbStyles()
{
// Iterate all available thumbstyles:
$dir = ANSEL_BASE . '/lib/ImageGenerator';
$files = scandir($dir);
$thumbs = array();
foreach ($files as $file) {
if (substr($file, -9) == 'Thumb.php') {
try {
$generator = Ansel_ImageGenerator::factory(substr($file, 0, -4), array('style' => Ansel::getStyleDefinition('ansel_default')));
$thumbs[substr($file, 0, -4)] = $generator->title;
} catch (Ansel_Exception $e) {
}
}
}
return $thumbs;
}
示例15: init
/**
* Initialize the renderer. This *must* be called before any attempt is made
* to display or otherwise interact with the renderer.
*
*/
public function init()
{
global $prefs, $conf, $registry, $page_output;
$this->galleryId = $this->view->gallery->id;
$this->gallerySlug = $this->view->gallery->get('slug');
$this->page = $this->view->page;
// Number perpage from prefs or config
if ($this->view->tilesperpage) {
$this->perpage = $this->view->tilesperpage;
} else {
$this->perpage = min($prefs->getValue('tilesperpage'), $conf['thumbnail']['perpage']);
}
$this->pagestart = $this->page * $this->perpage + 1;
// Fetch the children
$this->fetchChildren($this->view->force_grouping);
// Do we have an explicit style set from the API?
// If not, use the gallery's
if (!empty($this->view->style)) {
$this->style = Ansel::getStyleDefinition($this->view->style);
} else {
$this->style = $this->view->gallery->getStyle();
}
// Include any widgets
if (!empty($this->style->widgets) && !$this->view->api) {
// Special case widgets - these are built in
if (array_key_exists('Actions', $this->style->widgets)) {
// Don't show action widget if no actions
if ($registry->getAuth() || !empty($conf['report_content']['driver']) && ($conf['report_content']['allow'] == 'authenticated' && $registry->isAuthenticated() || $conf['report_content']['allow'] == 'all')) {
$this->view->addWidget(Ansel_Widget::factory('Actions'));
}
unset($this->style->widgets['Actions']);
}
// Gallery widgets always receive an array of image ids for
// the current page.
$ids = $this->getChildImageIds();
foreach ($this->style->widgets as $wname => $wparams) {
$wparams = array_merge($wparams, array('images' => $ids));
$this->view->addWidget(Ansel_Widget::factory($wname, $wparams));
}
}
if (empty($this->view->api)) {
$page_output->addScriptFile('views/common.js');
$page_output->addScriptFile('views/gallery.js');
$page_output->addScriptFile('popup.js', 'horde');
$strings = array('delete_conf' => _("Are you sure you want to delete the selected photos?"), 'choose_gallery_move' => _("You must choose a gallery to move photos to."), 'choose_images' => _("You must first choose photos."));
$urls = array('image_date' => strval(Horde::url('edit_dates.php')->add(array('gallery' => $this->galleryId))));
$js = array('Ansel = window.Ansel || {};', 'Ansel.galleryview_strings = ' . Horde_Serialize::serialize($strings, Horde_Serialize::JSON), 'Ansel.galleryview_urls = ' . Horde_Serialize::serialize($urls, Horde_Serialize::JSON), 'Ansel.has_edit = ' . $this->view->gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT) ? 1 : 0, 'Ansel.has_delete = ' . $this->view->gallery->hasPermission($registry->getAuth(), Horde_Perms::DELETE) ? 1 : 0);
$page_output->addInlineScript($js, true);
}
// Perform any initialization of the subclasses.
$this->_init();
}