From: Michael J. Rubinsky Date: Sun, 2 Aug 2009 15:17:40 +0000 (-0400) Subject: Remove these Vimeo gallery objects. They were not meant to get committed X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=3868040a186553849e3738a5999f2f22ebde5d3e;p=horde.git Remove these Vimeo gallery objects. They were not meant to get committed yet. --- diff --git a/ansel/lib/GalleryMode/RemoteVimeo.php b/ansel/lib/GalleryMode/RemoteVimeo.php deleted file mode 100644 index 922283786..000000000 --- a/ansel/lib/GalleryMode/RemoteVimeo.php +++ /dev/null @@ -1,255 +0,0 @@ - - */ -class Ansel_GalleryMode_RemoteVimeo { - - var $_vimeo; - var $_thumbs; - - /** - * @var Ansel_Gallery - */ - var $_gallery; - var $_features = array(); - - /** - * Constructor - * - * @param Ansel_Gallery $gallery The gallery to bind to. - * - * @return Ansel_Gallery_ModeNormal - */ - function Ansel_GalleryMode_RemoteVimeo($gallery) - { - // Build a Horde_Service_Vimeo object - // It *requires* a http client object and can make use of a cache object, - $params = array('http_client' => new Horde_Http_Client(), - 'cache' => $GLOBALS['cache'], - 'cache_lifetime' => $GLOBALS['conf']['cache']['default_lifetime']); - - $this->_vimeo = Horde_Service_Vimeo::factory('Simple', $params); - $vimeo_id = 'user1015172'; //TODO: Get this from prefs? - $this->_thumbs = unserialize($this->_vimeo->user($vimeo_id)->clips()->run()); - $this->_gallery = $gallery; - } - - function init() - { - $remote_ids = array(); - - // Get the remote video_ids - foreach ($this->_thumbs as $thumb) { - $remote_ids[$thumb['clip_id']] = false; - } - - // Get localimage objects... - $images = $this->getImages(); - if (!is_a($images, 'PEAR_Error')) { - foreach ($images as $image) { - $caption = $image->caption; - if (in_array($caption, array_keys($remote_ids))) { - // We still have this video on Vimeo. - // AND we know that we will be checking for this locally - // later, so save the info now. - $remote_ids[$caption] = true; - } else { - // Remote no longer exists - delete the local thumbnail - $this->removeImage($image, false); - } - } - - // Now check the other direction - foreach($this->_thumbs as $thumb) { - if (!$remote_ids[$thumb['clip_id']]) { - // We didn't find a match in any of our local images earlier - // create one now. - $hc = new Horde_Http_Client(); - $response = $hc->get($thumb['thumbnail_large']); - - $image_id = $this->_gallery->addImage(array( - 'image_filename' => $thumb['title'], - 'image_caption' => $thumb['clip_id'], - 'data' => $response->getBody(), - 'image_type' => $response->getHeader('Content-Type') - )); - } - } - } - } - - function hasFeature($feature) - { - return in_array($feature, $this->_features); - } - - /** - * Get the children of this gallery. - * - * Should never be called with a RemoteVimeo gallery since we override - * fetchChildren() in Ansel_GalleryRenderer...but implement something - * sensible just in case that ever changes. - * - * @param integer $perm The permissions to limit to. - * @param integer $from The child to start at. - * @param integer $to The child to end with. - * - * @return A mixed array of Ansel_Gallery and Ansel_Image objects that are - * children of this gallery. - */ - function getGalleryChildren($perm = PERMS_SHOW, $from = 0, $to = 0) - { - if ($this->_gallery->data['attribute_images']) { - $images = $this->getImages($from, $to); - if (is_a($images, 'PEAR_Error')) { - Horde::logMessage($images->message, __FILE__, __LINE__, - PEAR_LOG_ERR); - $images = array(); - } - } else { - $images = array(); - } - - return $images; - } - - /** - * Get an array describing where this gallery is in a breadcrumb trail. - * - * @return An array of 'title' and 'navdata' hashes with the [0] element - * being the deepest part. - */ - function getGalleryCrumbData() - { - $trail = array(); - $text = htmlspecialchars($this->_gallery->get('name')); - $navdata = array('view' => 'Gallery', - 'gallery' => $this->_gallery->id, - 'slug' => $this->_gallery->get('slug')); - $trail[] = array('title' => $text, 'navdata' => $navdata); - $parent_list = array_reverse($this->_gallery->getParents()); - foreach ($parent_list as $p) { - $text = htmlspecialchars($p->get('name')); - $navdata = array('view' => 'Gallery', - 'gallery' => $p->id, - 'slug' => $p->get('slug')); - $trail[] = array('title' => $text, 'navdata' => $navdata); - } - - return $trail; - } - - function setDate($date = array()) - { - //noop - } - - function getDate() - { - return array(); - } - - /** - * Return the count this gallery's children - * - * @param integer $perm The permissions to require. - * @param boolean $galleries_only Only include galleries, no images. - * - * @return integer The count of this gallery's children. - */ - function countGalleryChildren($perm = PERMS_SHOW, $galleries_only = false) - { - return count($this->_thumbs); - } - - /** - * Lists a slice of the image ids in this gallery. - * - * @param integer $from The image to start listing. - * @param integer $count The numer of images to list. - * - * @return mixed An array of image_ids | PEAR_Error - */ - function listImages($from = 0, $count = 0) - { - return $GLOBALS['ansel_storage']->listImages($this->_gallery->id, $from, - $count); - } - - function moveImagesTo($images, $gallery) - { - return false; - } - - function removeImage($image, $isStack) - { - return false; - } - - /** - * Gets a slice of the images in this gallery. - * - * @param integer $from The image to start fetching. - * @param integer $count The numer of images to return. - * - * @param mixed An array of Ansel_Image objects | PEAR_Error - */ - function getImages($from = 0, $count = 0) - { - $this->_gallery->_shareOb->_db->setLimit($count, $from); - $images = $this->_gallery->_shareOb->_db->query('SELECT image_id, gallery_id, image_filename, image_type, image_caption, image_uploaded_date, image_sort FROM ansel_images WHERE gallery_id = ' . $this->_gallery->id . ' ORDER BY image_sort'); - if (is_a($images, 'PEAR_Error')) { - return $images; - } - - $objects = array(); - while ($image = $images->fetchRow(MDB2_FETCHMODE_ASSOC)) { - $image['image_filename'] = Horde_String::convertCharset($image['image_filename'], $GLOBALS['conf']['sql']['charset']); - $image['image_caption'] = Horde_String::convertCharset($image['image_caption'], $GLOBALS['conf']['sql']['charset']); - $objects[$image['image_id']] = new Ansel_Image($image); - $GLOBALS['ansel_storage']->images[(int)$image['image_id']] = &$objects[$image['image_id']]; - } - $images->free(); - - $ccounts = $GLOBALS['ansel_storage']->_getImageCommentCounts(array_keys($objects)); - if (!is_a($ccounts, 'PEAR_Error') && count($ccounts)) { - foreach ($objects as $key => $image) { - $objects[$key]->commentCount = (!empty($ccounts[$key]) ? $ccounts[$key] : 0); - } - } - return array_values($objects); - } - - /** - * Checks if the gallery has any subgallery - * - * @return boolean - */ - function hasSubGalleries() - { - return false; - } - - /** - * Returns the number of images in this gallery and, optionally, all - * sub-galleries. - * - * @param boolean $subgalleries Determines whether subgalleries should - * be counted or not. - * - * @return integer number of images in this gallery - */ - function countImages($subgalleries = false) - { - return count($this->_thumbs); - } - -} diff --git a/ansel/lib/View/GalleryRenderer/GalleryVimeo.php b/ansel/lib/View/GalleryRenderer/GalleryVimeo.php deleted file mode 100644 index bdeb551ed..000000000 --- a/ansel/lib/View/GalleryRenderer/GalleryVimeo.php +++ /dev/null @@ -1,192 +0,0 @@ - - * @package Ansel - */ -require_once ANSEL_BASE . '/lib/Views/GalleryRenderer.php'; - -class Ansel_View_GalleryRenderer_GalleryVimeo extends Ansel_View_GalleryRenderer { - /** - * - * @var Horde_Service_Vimeo object - */ - var $_vimeo; - var $_thumbs; - - /** - * Perform any tasks that should be performed before the view is rendered. - * - */ - function _init() - { - // Attach the script and CSS files here if we aren't being called via the api - if (empty($this->view->_params['api'])) { - Horde::addScriptFile('effects.js', 'horde', true); - Horde::addScriptFile('redbox.js', 'horde', true); - } - } - - /** - * Override the parent class' fetchChildren method so we can grab the video - * thumbnail information from Vimeo instead of from our local image storage. - * - * @param boolean $noauto Ignored in this class since we won't be doing any - * date browsing. Maybe another experiment? ;) - */ - function fetchChildren($noauto = true) - { - // Build a Horde_Service_Vimeo object - // It *requires* a http client object and can make use of a cache object, - // so let's take advantage of it. - $params = array('http_client' => new Horde_Http_Client(), - 'cache' => $GLOBALS['cache'], - 'cache_lifetime' => $GLOBALS['conf']['cache']['default_lifetime']); - - $this->_vimeo = Horde_Service_Vimeo::factory('Simple', $params); - - // The identifier for what we are requesting. - // If we are requesting a user's videos, this is the user's vimeo_id - // if we want to request a particular group, this would be the group_id - // etc... - // - // For this example, the id is hard coded here, but if I were to implement - // this on a live site I would add a new user pref to ansel for the - // user to enter his/her own vimeo_id and then grab the value from - // pref storage here. - $vimeo_id = 'user1015172'; //TODO: Get this from prefs? - - // This gets the data representing the videos. See the API docs for - // exactly what is returned, but for our purposes, we will be using: - // clip_id, url, caption, thumbnail_large etc... - $thumbs = unserialize($this->_vimeo->user($vimeo_id)->clips()->run()); - - // We fetch the information needed to embed each video now to make things - // easier for this example...the cache helps tremendously with load times - // after the first page is requested. - foreach ($thumbs as $thumb) { - $this->_json[$thumb['clip_id']] = $this->_vimeo->getEmbedJSON(array('url' => $thumb['url'], 'byline' => 'false', 'portrait' => 'false')); - $this->_thumbs[$thumb['clip_id']] = $thumb; - } - - // Vimeo's Simple API doesn't provide for paging - so we emulate it - // by only returning the video thumbnails that should appear on this - // current gallery page. Like stated above, the first load will take - // a bit of time depending on the number of videos the user has - but - // each subsequent page will load *much* faster as we don't have to - // contact Vimeo at all. - - // Total number of thumbnails in the gallery - $this->numTiles = count($thumbs); - - // The last one to display on this page - $this->pageend = min($this->numTiles, $this->pagestart + $this->perpage - 1); - - - $this->children = $this->view->gallery->getGalleryChildren( - PERMS_SHOW, - $this->page * $this->perpage, - $this->perpage, - !empty($this->view->_params['force_grouping'])); - } - - /** - * Get the HTML representing this view. - * - * Responsible for building the HTML for the view. It's stripped down - * somewhat from the other styles...sets up the variables needed for the - * template we put in ansel/templates/view - though there is really no - * reason we *have* to have a template file there if we can generate the - * entire HTML here, or load a template from this directory or....? - * - * @return string The HTML - */ - function _html() - { - global $conf, $prefs, $registry; - - // Deal with getting the correct gallery owner string, get any - // parameters we are interested in from the view - $galleryOwner = $this->view->gallery->get('owner'); - $id = $this->view->gallery->getOwner(); - $owner = $id->getValue('fullname'); - if (!$owner) { - $owner = $galleryOwner; - } - $vars = Horde_Variables::getDefaultVariables(); - if (!empty($this->view->_params['page'])) { - $vars->add('page', $this->view->_params['page']); - $page = $this->view->_params['page']; - } else { - $page = 0; - } - - // Build the proper pager urls - if (!empty($this->view->_params['gallery_view_url'])) { - $pagerurl = str_replace(array('%g', '%s'), array($this->galleryId, $this->gallerySlug), urldecode($this->view->_params['gallery_view_url'])); - } 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('gallery' => $this->galleryId, - 'view' => 'Gallery', - 'slug' => $this->view->gallery->get('slug')); - $pagerurl = Ansel::getUrlfor('view', $pager_params, true); - } - if (!empty($this->view->_params['urlCallback'])) { - $callback = $this->view->_params['urlCallback']; - } else { - $callback = null; - } - $params = array('num' => $this->numTiles, - 'url' => $pagerurl, - 'perpage' => $this->perpage, - 'url_callback' => $callback); - - $pager = new Horde_UI_Pager('page', $vars, $params); - - /* Start buffering */ - ob_start(); - - /* Output js/css here if we are calling via the api */ - if (!empty($this->view->_params['api'])) { - $includes = new Horde_Script_Files(); - $includes->disableAutoloadHordeJS(); - $includes->_add('redbox.js', 'horde', true, true); - $includes->includeFiles(); - } - - /* Needed in the template files */ - $tilesperrow = $prefs->getValue('tilesperrow'); - $cellwidth = round(100 / $tilesperrow); - $count = 0; - - include ANSEL_TEMPLATES . '/view/galleryvimeo.inc'; - return ob_get_clean(); - } - - function getTile($image, $video, $cnt) - { - $imgOnClick = 'return showVideo(' . $cnt . ');'; - $tile = '
' - . Horde::link($video->url, $video->title, '', '', $imgOnClick, $video->title) - . '' . ''; - $tile .= '
'; - $tile .= '
' . $video->caption . '
'; - - return $tile; - } - -} diff --git a/ansel/templates/view/galleryvimeo.inc b/ansel/templates/view/galleryvimeo.inc deleted file mode 100644 index ed30277dd..000000000 --- a/ansel/templates/view/galleryvimeo.inc +++ /dev/null @@ -1,62 +0,0 @@ - -
- numTiles ? '' . ($this->numTiles > $this->perpage ? sprintf(_("%d to %d of %d Items"), $this->pagestart, $this->pageend, $this->numTiles) : sprintf(ngettext("%d Item", "%d Items", $this->numTiles), $this->numTiles)) . '' : '') . Ansel::getBreadCrumbs(); ?> -
-view->gallery->get('desc')): ?> - - - - - - - -
;"> - numTiles): ?> -
- - - - - children as $child) { - echo ''; - if (!(++$count % $tilesperrow)) { - echo ''; - } - } - while ($count % $tilesperrow) { - echo ''; - $count++; - }?> - - -
render() ?>
' - . $this->getTile($child, new Horde_Support_Array($this->_thumbs[$child->caption]), $cnt++) . '
 
render() ?>
- -
- view->_params['api'])):?> - view->renderWidgets(); ?> - -
-view->countWidgets()): ?> - -