embedCode() public static method

Generate the JS necessary to embed a gallery / images into another external site.
public static embedCode ( array $options ) : string
$options array The options to build the view.
return string The javascript code
示例#1
0
 public function html()
 {
     global $registry;
     $view = $GLOBALS['injector']->createInstance('Horde_View');
     $view->addTemplatePath(ANSEL_TEMPLATES . '/widgets');
     $view->owner = $this->_view->gallery->get('owner');
     $view->userfeedurl = Ansel::getUrlFor('rss_user', array('owner' => $view->owner));
     $view->slug = $this->_view->gallery->get('slug');
     $view->galleryname = $this->_view->gallery->get('name');
     $view->galleryfeedurl = Ansel::getUrlFor('rss_gallery', array('gallery' => $this->_view->gallery->id, 'slug' => $view->slug));
     $view->title = _("Links");
     /* Embed html */
     if (empty($this->_view->_params['image_id'])) {
         /* Gallery view */
         $params = array('count' => 10);
         if (!empty($slug)) {
             $params['gallery_slug'] = $slug;
         } else {
             $params['gallery_id'] = $this->_view->gallery->id;
         }
     } else {
         // This is an image view
         $params = array('thumbsize' => 'screen', 'images' => $this->_view->_params['image_id'], 'count' => 10);
     }
     $view->embed = Ansel::embedCode($params);
     return $view->render('links');
 }
示例#2
0
文件: Gallery.php 项目: horde/horde
 /**
  */
 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>';
 }