Esempio n. 1
0
 /**
  * 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');
 }
Esempio n. 2
0
 /**
  * Helper function to build the list of tags
  *
  * @return string  The HTML representing the tag list.
  */
 protected function _getTagHTML()
 {
     global $registry;
     // Clear the tag cache?
     if (Horde_Util::getFormData('havesearch', 0) == 0) {
         $tag_browser = new Ansel_TagBrowser($GLOBALS['injector']->getInstance('Ansel_Tagger'));
         $tag_browser->clearSearch();
     }
     $tagger = $GLOBALS['injector']->getInstance('Ansel_Tagger');
     $hasEdit = $this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT);
     $owner = $this->_view->gallery->get('owner');
     $tags = $tagger->getTags((int) $this->_view->resource->id, $this->_resourceType);
     if (count($tags)) {
         $tags = $tagger->getTagInfo(array_keys($tags), 500, $this->_resourceType);
     }
     if ($this->_resourceType != 'image') {
         $removeLink = Horde::url('gallery.php')->add(array('actionID' => 'removeTags', 'gallery' => $this->_view->gallery->id));
     } else {
         $removeLink = Horde::url('image.php')->add(array('actionID' => 'removeTags', 'gallery' => $this->_view->gallery->id, 'image' => $this->_view->resource->id));
     }
     $links = Ansel::getTagLinks($tags, 'add', $owner);
     $html = '<ul class="horde-tags">';
     foreach ($tags as $taginfo) {
         $tag_id = $taginfo['tag_id'];
         $html .= '<li>' . $links[$tag_id]->link(array('title' => sprintf(ngettext("%d photo", "%d photos", $taginfo['count']), $taginfo['count']))) . htmlspecialchars($taginfo['tag_name']) . '</a>' . ($hasEdit ? '<a href="' . strval($removeLink) . '" onclick="return AnselTagActions.remove(' . $tag_id . ');"> ' . Horde::img('delete-small.png', _("Remove Tag")) . '</a>' : '') . '</li>';
     }
     $html .= '</ul>';
     return $html;
 }
Esempio n. 3
0
<?php

/**
 * Copyright 2001-2016 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.
 */
require_once __DIR__ . '/lib/Application.php';
Horde_Registry::appInit('ansel');
$layout = new Horde_Core_Block_Layout_View($injector->getInstance('Horde_Core_Factory_BlockCollection')->create(array('ansel'), 'myansel_layout')->getLayout(), Horde::url('browse_edit.php'), Horde::url('browse.php', true));
$layout_html = $layout->toHtml();
$tag_browser = new Ansel_TagBrowser($injector->getInstance('Ansel_Tagger'));
$tag_browser->clearSearch();
Ansel::initJSVariables();
$page_output->header(array('title' => _("Photo Galleries")));
$notification->notify(array('listeners' => 'status'));
include ANSEL_TEMPLATES . '/browse/new.inc';
echo $layout_html;
$page_output->footer();