当前位置: 首页>>代码示例>>PHP>>正文


PHP Ansel::getDateParameter方法代码示例

本文整理汇总了PHP中Ansel::getDateParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Ansel::getDateParameter方法的具体用法?PHP Ansel::getDateParameter怎么用?PHP Ansel::getDateParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ansel的用法示例。


在下文中一共展示了Ansel::getDateParameter方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __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();
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:57,代码来源:Gallery.php

示例2: array

    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
    exit;
}
try {
    $gallery = $injector->getInstance('Ansel_Storage')->getGallery($galleryId);
} catch (Ansel_Excception $e) {
    $notification->push(_("There was an error accessing the gallery."), 'horde.error');
    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
    exit;
}
if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
    $notification->push(_("Access denied editing this gallery."), 'horde.error');
    Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
}
$style = $gallery->getStyle();
$date = Ansel::getDateParameter();
$gallery->setDate($date);
switch (Horde_Util::getFormData('action')) {
    case 'Sort':
        parse_str(Horde_Util::getPost('order'), $order);
        $order = $order['order'];
        foreach ($order as $pos => $id) {
            $gallery->setImageOrder($id, $pos);
        }
        $notification->push(_("Gallery sorted."), 'horde.success');
        $style = $gallery->getStyle();
        Ansel::getUrlFor('view', array_merge(array('view' => 'Gallery', 'gallery' => $galleryId, 'slug' => $gallery->get('slug')), $date), true)->redirect();
        exit;
    case 'Reset':
        // Reset the sort order by date.
        $images = $injector->getInstance('Ansel_Storage')->listImages(array('gallery_id' => $galleryId, 'sort' => 'image_original_date'));
开发者ID:jubinpatel,项目名称:horde,代码行数:31,代码来源:sort.php

示例3: _getGallery

 /**
  * Todo
  *
  * @param integer $galleryId  The gallery id
  * @param string $slug        The gallery slug
  *
  * @return Ansel_Gallery  The requested Ansel_Gallery object
  * @throws Horde_Exception
  * @throws InvalidArgumentException
  *
  */
 protected function _getGallery($galleryId = null, $slug = '')
 {
     if (is_null($galleryId) && empty($slug)) {
         $galleryId = !empty($this->_params['gallery_id']) ? $this->_params['gallery_id'] : null;
         $slug = !empty($this->_params['gallery_slug']) ? $this->_params['gallery_slug'] : null;
     }
     if (empty($galleryId) && empty($slug)) {
         throw new Ansel_Exception(_("No gallery specified"));
     }
     // If we have a slug, use it.
     try {
         if (!empty($slug)) {
             $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGalleryBySlug($slug);
         } else {
             $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($galleryId);
         }
     } catch (Ansel_Exception $e) {
         throw new Horde_Exception_NotFound($e->getmessage());
     }
     if (!$gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::READ)) {
         throw new Horde_Exception_PermissionDenied(_("Access denied to this gallery."));
     }
     /* Set any date info we might have */
     if (!empty($this->_params['year'])) {
         $date = Ansel::getDateParameter(array('year' => $this->_params['year'], 'month' => $this->_params['month'], 'day' => $this->_params['day']));
     } else {
         $date = array();
     }
     $gallery->setDate($date);
     return $gallery;
 }
开发者ID:raz0rsdge,项目名称:horde,代码行数:42,代码来源:Base.php

示例4: editActions

 /**
  * Check for, and handle, image editing actions.
  *
  * @param string $actionID  The action identifier.
  *
  * @return boolean  True if an action was handled, otherwise false.
  * @throws Ansel_Exception
  */
 public static function editActions($actionID)
 {
     global $notification, $page_output, $registry;
     $ansel_storage = $GLOBALS['injector']->getInstance('Ansel_Storage');
     $gallery_id = Horde_Util::getFormData('gallery');
     $image_id = Horde_Util::getFormData('image');
     $date = Ansel::getDateParameter();
     $page = Horde_Util::getFormData('page', 0);
     $watermark_font = Horde_Util::getFormData('font');
     $watermark_halign = Horde_Util::getFormData('whalign');
     $watermark_valign = Horde_Util::getFormData('wvalign');
     $watermark = Horde_Util::getFormData('watermark', $GLOBALS['prefs']->getValue('watermark_text'));
     // Get the gallery object and style information.
     try {
         $gallery = $ansel_storage->getGallery($gallery_id);
     } catch (Ansel_Exception $e) {
         $notification->push(sprintf(_("Gallery %s not found."), $gallery_id), 'horde.error');
         Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
         exit;
     }
     switch ($actionID) {
         case 'modify':
             try {
                 $image = $ansel_storage->getImage($image_id);
                 $ret = Horde_Util::getFormData('ret', 'gallery');
             } catch (Ansel_Exception $e) {
                 $notification->push(_("Photo not found."), 'horde.error');
                 Ansel::getUrlFor('view', array('view' => 'List'), true)->redirect();
                 exit;
             }
             $title = sprintf(_("Edit properties :: %s"), $image->filename);
             // Set up the form object.
             $vars = Horde_Variables::getDefaultVariables();
             if ($ret == 'gallery') {
                 $vars->set('actionID', 'saveclose');
             } else {
                 $vars->set('actionID', 'savecloseimage');
             }
             $form = new Ansel_Form_Image($vars, $title);
             $renderer = new Horde_Form_Renderer();
             // Set up the gallery attributes.
             $vars->set('image_default', $image->id == $gallery->get('default'));
             $vars->set('image_desc', $image->caption);
             $vars->set('image_tags', implode(', ', $image->getTags()));
             $vars->set('image_originalDate', $image->originalDate);
             $vars->set('image_uploaded', $image->uploaded);
             $page_output->header(array('title' => $title));
             $form->renderActive($renderer, $vars, Horde::url('image.php'), 'post', 'multipart/form-data');
             $page_output->footer();
             exit;
         case 'savecloseimage':
         case 'saveclose':
         case 'save':
             $title = _("Save Photo");
             if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
                 $notification->push(_("Access denied saving photo to this gallery."), 'horde.error');
                 Ansel::getUrlFor('view', array_merge(array('gallery' => $gallery_id, 'slug' => $gallery->get('slug'), 'view' => 'Gallery', 'page' => $page), $date), true)->redirect();
                 exit;
             }
             // Validate the form object.
             $vars = Horde_Variables::getDefaultVariables();
             $vars->set('actionID', 'save');
             $renderer = new Horde_Form_Renderer();
             $form = new Ansel_Form_Image($vars, _("Edit a photo"));
             // Update existing image.
             if ($form->validate($vars)) {
                 $form->getInfo($vars, $info);
                 // Replacing photo
                 if (!empty($info['file0']['file'])) {
                     try {
                         $GLOBALS['browser']->wasFileUploaded('file0');
                         if (filesize($info['file0']['file'])) {
                             $data = file_get_contents($info['file0']['file']);
                             if (getimagesize($info['file0']['file']) === false) {
                                 $notification->push(_("The file you uploaded does not appear to be a valid photo."), 'horde.error');
                                 unset($data);
                             }
                         }
                     } catch (Horde_Browser_Exception $e) {
                     }
                 }
                 $image = $ansel_storage->getImage($image_id);
                 $image->caption = $vars->get('image_desc');
                 $image->setTags(explode(',', $vars->get('image_tags')));
                 $newDate = new Horde_Date($vars->get('image_originalDate'));
                 $image->originalDate = (int) $newDate->timestamp();
                 if (!empty($data)) {
                     try {
                         $image->replace($data);
                     } catch (Ansel_Exception $e) {
                         $notification->push(_("There was an error replacing the photo."), 'horde.error');
                     }
//.........这里部分代码省略.........
开发者ID:raz0rsdge,项目名称:horde,代码行数:101,代码来源:ActionHandler.php

示例5: __construct

 /**
  * Const'r
  *
  * @param array  Parameters for the view.
  * @throws Ansel_Exception
  */
 public function __construct(array $params = array())
 {
     parent::__construct($params);
     // Get the Ansel_Image
     $this->resource = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($params['image_id']);
     // Get the Ansel_Gallery
     $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));
         $url = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => empty($params['slug']) ? '' : $params['slug'], 'page' => empty($params['page']) ? 0 : $params['page'], 'view' => 'Image', 'image' => $this->resource->id), $date), true);
         $params = array('gallery' => $this->gallery->id, 'url' => $url);
         Horde::url('disclamer.php')->add($params)->setRaw(true)->redirect();
         exit;
     }
     // Check password
     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));
         $url = Ansel::getUrlFor('view', array_merge(array('gallery' => $this->gallery->id, 'slug' => empty($params['slug']) ? '' : $params['slug'], 'page' => empty($params['page']) ? 0 : $params['page'], 'view' => 'Image', 'image' => $this->resource->id), $date), true);
         $params = array('gallery' => $this->gallery->id, 'url' => $url);
         Horde::url('protect.php')->add($params)->setRaw(true)->redirect();
         exit;
     }
     // Any script files we may need if not calling via the api
     if (empty($this->_params['api'])) {
         $GLOBALS['page_output']->addScriptFile('scriptaculous/effects.js', 'horde');
         $GLOBALS['page_output']->addScriptFile('stripe.js', 'horde');
     }
     $this->_includeViewSpecificScripts();
 }
开发者ID:horde,项目名称:horde,代码行数:42,代码来源:Image.php

示例6: array

    Ansel::getUrlFor('default_view', array())->redirect();
    exit;
}
try {
    $gallery = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($gallery_id);
} catch (Ansel_Exception $e) {
    $notification->push($e->getMessage(), 'horde.error');
    Ansel::getUrlFor('view', array('gallery' => $gallery_id))->redirect();
    exit;
}
if (!$gallery->hasPermission($registry->getAuth(), Horde_Perms::EDIT)) {
    $notification->push(_("Access denied editing this gallery."), 'horde.error');
    Ansel::getUrlFor('view', array('gallery' => $gallery_id))->redirect();
    exit;
}
$gallery->setDate(Ansel::getDateParameter());
$page = Horde_Util::getFormData('page', 0);
$perpage = min($prefs->getValue('tilesperpage'), $conf['thumbnail']['perpage']);
$images = $gallery->getImages($page * $perpage, $perpage);
$reloadimage = Horde::img('reload.png');
$customimage = Horde::img('layout.png');
$customurl = Horde::url('faces/custom.php')->add('page', $page);
$face = $injector->getInstance('Ansel_Faces');
$autogenerate = $face->canAutogenerate();
$vars = Horde_Variables::getDefaultVariables();
$pager = new Horde_Core_Ui_Pager('page', $vars, array('num' => $gallery->countImages(), 'url' => 'faces/gallery.php', 'perpage' => $perpage));
$pager->preserve('gallery', $gallery_id);
$title = sprintf(_("Searching for faces in %s"), Ansel::getUrlFor('view', array('gallery' => $gallery_id, 'view' => 'Gallery'))->link() . $gallery->get('name') . '</a>');
$page_output->addScriptFile('stripe.js', 'horde');
$page_output->addScriptFile('popup.js', 'horde');
$page_output->header(array('title' => $title));
开发者ID:raz0rsdge,项目名称:horde,代码行数:31,代码来源:gallery.php

示例7: _getPagerUrl

 /**
  * Return the current pagerurl.
  *
  * @return Horde_Url  The url
  */
 protected function _getPagerUrl()
 {
     $date_params = Ansel::getDateParameter(array('year' => !empty($this->view->year) ? $this->view->year : 0, 'month' => !empty($this->view->month) ? $this->view->month : 0, 'day' => !empty($this->view->day) ? $this->view->day : 0));
     if (!empty($this->view->gallery_view_url)) {
         $pagerurl = new Horde_Url(str_replace(array('%g', '%s'), array($this->galleryId, $this->gallerySlug), urldecode($this->view->gallery_view_url)));
         $pagerurl->add($date_params)->setRaw(true);
     } else {
         // Build the pager url. Add the needed variables directly to the
         // url instead of passing it as a preserved variable to the pager
         // since the logic to build the URL is already in getUrlFor()
         $pager_params = array_merge(array('gallery' => $this->galleryId, 'view' => 'Gallery', 'slug' => $this->view->gallery->get('slug')), $date_params);
         $pagerurl = Ansel::getUrlfor('view', $pager_params, true);
     }
     return $pagerurl;
 }
开发者ID:horde,项目名称:horde,代码行数:20,代码来源:Base.php

示例8: html

    /**
     * Get the HTML representing this view.
     *
     * @return string The HTML
     */
    public function html()
    {
        global $conf, $prefs, $registry;
        // Initialize the Horde_View instance.
        $view = $this->_getHordeView();
        // Get JSON data for view
        if ($this->mode == Ansel_GalleryMode_Base::MODE_NORMAL) {
            $json = Ansel_View_Base::json($this->view->gallery, array('full' => !empty($this->view->api), 'perpage' => $this->perpage));
        } else {
            if (!empty($this->date['day']) && $this->numTiles) {
                $json = Ansel_View_Base::json($this->view->gallery, array('full' => !empty($this->view->api), 'perpage' => $this->perpage));
            } else {
                $json = '[]';
            }
        }
        $date_params = Ansel::getDateParameter(array('year' => !empty($this->view->year) ? $this->view->year : 0, 'month' => !empty($this->view->month) ? $this->view->month : 0, 'day' => !empty($this->view->day) ? $this->view->day : 0));
        $pagerurl = $this->_getPagerUrl();
        $graphics_dir = Horde::url(Horde_Themes::img(), true, -1);
        $image_text = _("Photo");
        $of = _("of");
        $flipped = array_flip($date_params);
        if (count($flipped) == 1 && !empty($flipped[0])) {
            $gallery_url = $pagerurl . '?';
        } else {
            $gallery_url = $pagerurl . '&';
        }
        $js = array();
        $js[] = <<<EOT
        LightboxOptions = {
            gallery_json: {$json},
            fileLoadingImage: '{$graphics_dir}/lightbox/loading.gif',
            fileBottomNavCloseImage: '{$graphics_dir}/lightbox/closelabel.gif',
            overlayOpacity: 0.8,   // controls transparency of shadow overlay
            animate: true,         // toggles resizing animations
            resizeSpeed: 7,        // controls the speed of the image resizing animations (1=slowest and 10=fastest)
            borderSize: 10,        // if you adjust the padding in the CSS, you will need to update this variable

            // Used to write: Image # of #.
            labelImage: '{$image_text}',
            labelOf: '{$of}',
            //URL to return to when the lightbox closes
            returnURL: '{$gallery_url}',
            startPage: '{$view->page}'
        };
        document.lb = new Lightbox(LightboxOptions); if (window.location.hash.length) document.lb.start(window.location.hash.substring(1));
EOT;
        $GLOBALS['page_output']->addInlineScript($js, true);
        // Output js/css here if we are calling via the api
        if ($this->view->api) {
            Horde::startBuffer();
            global $page_output;
            $page_output->addThemeStylesheet('lightbox.css');
            $page_output->includeStylesheetFiles(array('nobase' => true), true);
            foreach (array('prototype.js', 'accesskeys.js', 'scriptaculous/effects.js') as $val) {
                $tmp = new Horde_Script_File_JsDir($val, 'horde');
                echo $tmp->tag_full;
            }
            $tmp = new Horde_Script_File_JsDir('lightbox.js');
            echo $tmp->tag_full;
            $page_output->outputInlineScript();
            $html = Horde::endBuffer();
            return $html . $view->render('gallery');
        }
        return $view->render('gallery');
    }
开发者ID:jubinpatel,项目名称:horde,代码行数:70,代码来源:GalleryLightbox.php

示例9: downloadImagesAsZip

 /**
  * Downloads all requested images as a zip file.  Assumes all permissions
  * have been checked on the requested resource.  Can request either a
  * single gallery of images, OR an array of individual image ids.
  *
  * @param Ansel_Gallery $gallery  The galleries to download
  * @param array $images           The images to download
  */
 public static function downloadImagesAsZip($gallery = null, $images = array())
 {
     global $session;
     if (empty($GLOBALS['conf']['gallery']['downloadzip'])) {
         $GLOBALS['notification']->push(_("Downloading zip files is not enabled. Talk to your server administrator."));
         Horde::url('view.php?view=List', true)->redirect();
         exit;
     }
     // Requested a gallery
     if (!is_null($gallery)) {
         // We can name the zip file with the slug if we have it
         $slug = $gallery->get('slug');
         // Set the date in case we are viewing in date mode
         $gallery->setDate(Ansel::getDateParameter());
         $images = $gallery->listImages();
     }
     // At this point, we should always have a list of images
     if (!count($images)) {
         $notification->push(sprintf(_("There are no photos in %s to download."), $gallery->get('name')), 'horde.message');
         Horde::url('view.php?view=List', true)->redirect();
         exit;
     }
     // Try to close off the current session to avoid locking it while the
     // gallery is downloading.
     $session->close();
     if (!is_null($gallery)) {
         // Check full photo permissions
         if ($gallery->canDownload()) {
             $view = 'full';
         } else {
             $view = 'screen';
         }
     }
     $zipfiles = array();
     foreach ($images as $id) {
         $image = $GLOBALS['injector']->getInstance('Ansel_Storage')->getImage($id);
         // If we didn't select an entire gallery, check the download
         // size for each image.
         if (!isset($view)) {
             $g = $GLOBALS['injector']->getInstance('Ansel_Storage')->getGallery($image->gallery);
             $v = $g->canDownload() ? 'full' : 'screen';
         } else {
             $v = $view;
         }
         $zipfiles[] = array('data' => $image->raw($v), 'name' => $image->filename);
     }
     $zip = Horde_Compress::factory('zip');
     $body = $zip->compress($zipfiles);
     if (!empty($gallery)) {
         $filename = (!empty($slug) ? $slug : $gallery->id) . '.zip';
     } else {
         $filename = 'Ansel.zip';
     }
     $GLOBALS['browser']->downloadHeaders($filename, 'application/zip', false, strlen($body));
     echo $body;
     exit;
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:65,代码来源:Ansel.php


注:本文中的Ansel::getDateParameter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。