Example #1
0
 /**
  * Creates the json object used for map rendering
  *     
  * @param array $results listings
  * @param mixed $fields  custom fields, required when using the GeoMaps module
  * @param mixed $options mapUI options to override globals when using GeoMaps module
  */
 function makeJsonObject(&$results, &$fields = array(), $options = array())
 {
     $www_base = array_shift(pathinfo(WWW_ROOT));
     // Required for thumbnail path
     $paths = array(S2Paths::get('jreviews', 'S2_VIEWS_OVERRIDES') . 'themes' . DS . $this->c->Config->template . DS . 'theme_images' . DS, S2Paths::get('jreviews', 'S2_VIEWS') . 'themes' . DS . $this->c->Config->template . DS . 'theme_images' . DS, S2Paths::get('jreviews', 'S2_VIEWS_OVERRIDES') . 'themes' . DS . 'default' . DS . 'theme_images' . DS, S2Paths::get('jreviews', 'S2_VIEWS') . 'themes' . DS . 'default' . DS . 'theme_images' . DS);
     $path = fileExistsInPath(array('name' => '', 'suffix' => '', 'ext' => ''), $paths);
     App::import('Helper', array('html', 'routes', 'custom_fields', 'thumbnail'));
     $Html = new HtmlHelper();
     $Routes = new RoutesHelper();
     $CustomFields = new CustomFieldsHelper();
     $Thumbnail = new ThumbnailHelper();
     $Thumbnail->app = 'jreviews';
     $Thumbnail->name = $this->c->name;
     $Thumbnail->action = $this->c->action;
     $Routes->Config = $CustomFields->Config = $Thumbnail->Config = $this->c->Config;
     $Routes->Access = $CustomFields->Access = $Thumbnail->Access = $this->c->Access;
     $Routes->Html = $CustomFields->Html = $Thumbnail->Html = $Html;
     $CustomFields->viewTheme = $Thumbnail->viewTheme =& $this->c->viewTheme;
     $CustomFields->viewSuffix =& $this->c->viewSuffix;
     // Check format of results because we may need to re-format and add fields for Geomaps module
     $first = current($results);
     if (!isset($first['Listing'])) {
         $results = $this->buildListingArray($results, $fields);
     }
     // PaidListings - remove unpaid info
     Configure::read('PaidListings') and PaidListingsComponent::processPaidData($results);
     $marker_icons = array();
     $infowindow_data = array();
     $i = 1;
     $map_counter = 0;
     $default_icon = $this->c->name == 'categories' ? 'numbered' : 'default';
     if (!empty($results)) {
         $infowindow_fields = str_replace(" ", "", Sanitize::getString($this->c->Config, 'geomaps.infowindow_fields'));
         $infowindow_fields = $infowindow_fields != '' ? explode(",", $infowindow_fields) : array();
         foreach ($results as $key => $result) {
             $results[$key] = $this->injectDistanceGroup($result);
             // Override global setting for map display in lists if at least one listing has map enabled
             // For it's listing type and has valid coordinates
             if ($this->c->name == 'categories' && isset($result['ListingType']) && Sanitize::getBool($result['ListingType']['config'], 'geomaps.enable_map_list', true)) {
                 if (isset($result['Geomaps']) && abs($result['Geomaps']['lat']) > 0 && abs($result['Geomaps']['lon']) > 0) {
                     $map_counter++;
                 }
             }
             // Add menu id if not already there
             if (!isset($result['Listing']['menu_id'])) {
                 $results[$key]['Listing']['menu_id'] = $this->c->Menu->getCategory(array('cat_id' => $result['Listing']['cat_id'], 'dir_id' => $result['Directory']['dir_id'], 'section_id' => isset($result['Listing']['section_id']) ? $result['Listing']['section_id'] : null, 'listing' => $result['Listing']['listing_id']));
             }
             $listing_index = ($this->c->page - 1) * $this->c->limit + $i++;
             // Process and add icon info
             $icon = isset($result['Geomaps']) ? json_decode($result['Geomaps']['icon'], true) : array();
             $results[$key]['Geomaps']['icon'] = '';
             $icon_name = $default_icon;
             if (!empty($icon)) {
                 $foundIcon = false;
                 // Check if custom field assigned
                 if ($icon['field'] != '' && substr($icon['field'], 0, 3) == 'jr_') {
                     if (isset($result['Field']['pairs'][$icon['field']]) && isset($result['Field']['pairs'][$icon['field']]['image'][0])) {
                         $icon_name = substr($result['Field']['pairs'][$icon['field']]['image'][0], 0, strpos($result['Field']['pairs'][$icon['field']]['image'][0], '.'));
                         $marker_icons[$icon_name] = $results[$key]['Geomaps']['icon'] = $result['Field']['pairs'][$icon['field']]['image'][0];
                         $foundIcon = true;
                     }
                 } elseif ($icon['cat'] != '' && !$foundIcon) {
                     $icon_name = substr($icon['cat'], 0, strpos($icon['cat'], '.'));
                     if ($icon_name != 'default') {
                         $marker_icons[$icon_name] = $results[$key]['Geomaps']['icon'] = $icon['cat'];
                     }
                 }
             }
             if (isset($result['Geomaps']) && $result['Geomaps']['lat'] != '' && $result['Geomaps']['lon'] != '' && $result['Geomaps']['lat'] != 0 && $result['Geomaps']['lon']) {
                 # Create infowindow JSON object
                 // start with standard fields
                 $infowindow = array('id' => $result['Listing']['listing_id'], 'url' => str_replace(array($www_base, '&'), array('', '&'), $Routes->content('', $results[$key], array('return_url' => true))), 'index' => $listing_index, 'title' => $result['Listing']['title'], 'image' => str_replace($www_base, '', $Thumbnail->thumb($result, 0, array('tn_mode' => $this->c->Config->list_thumb_mode, 'location' => 'list', 'dimensions' => array($this->c->Config->list_image_resize), 'return_src' => 1))), 'featured' => $result['Listing']['featured'], 'rating_scale' => $this->c->Config->rating_scale, 'user_rating' => $result['Review']['user_rating'], 'user_rating_count' => $result['Review']['user_rating_count'], 'editor_rating' => $result['Review']['editor_rating'], 'editor_rating_count' => $result['Review']['editor_rating_count'], 'lat' => (double) $result['Geomaps']['lat'], 'lon' => (double) $result['Geomaps']['lon'], 'icon' => $icon_name);
                 if (!empty($result['Field']['pairs'])) {
                     # Limit fields will included in the payload json object
                     $result['Field']['pairs'] = array_intersect_key($result['Field']['pairs'], array_flip($infowindow_fields));
                     foreach ($result['Field']['pairs'] as $name => $fieldArray) {
                         $infowindow['field'][$name] = $CustomFields->field($name, $result);
                     }
                 }
                 $infowindow_data['id' . $result['Listing']['listing_id']] = $infowindow;
             }
         }
     }
     $this->c->Config->{'geomaps.enable_map_list'} = $map_counter;
     $mapUI = array();
     $zoom = '';
     switch ($this->c->name) {
         case 'categories':
             $maptypes = Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_list', 'buttons');
             //buttons|menu|none
             $maptype_def = Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_def_list', 'G_NORMAL_MAP');
             $map = Sanitize::getBool($this->c->Config, 'geomaps.ui.map_list', 1);
             $hybrid = Sanitize::getBool($this->c->Config, 'geomaps.ui.hybrid_list', 1);
             $satellite = Sanitize::getBool($this->c->Config, 'geomaps.ui.satellite_list', 1);
             $terrain = Sanitize::getBool($this->c->Config, 'geomaps.ui.terrain_list', 1);
             $panzoom = Sanitize::getBool($this->c->Config, 'geomaps.ui.panzoom_list', 1);
             $scale = Sanitize::getBool($this->c->Config, 'geomaps.ui.scale_list', 0);
             $scrollwheel = Sanitize::getBool($this->c->Config, 'geomaps.ui.scrollwheel_list', 0);
             $doubleclick = Sanitize::getBool($this->c->Config, 'geomaps.ui.doubleclick_list', 1);
             $mapUI['title']['trim'] = Sanitize::getVar($this->c->Config, 'geomaps.ui.trimtitle_list', 0);
             $mapUI['title']['trimchars'] = Sanitize::getVar($this->c->Config, 'geomaps.ui.trimtitle_chars', 30);
             break;
         case 'com_content':
             $maptypes = Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_detail', 'buttons');
             //buttons|menu|none
             $maptype_def = Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_def_detail', 'G_NORMAL_MAP');
             $map = Sanitize::getBool($this->c->Config, 'geomaps.ui.map_detail', 1);
             $hybrid = Sanitize::getBool($this->c->Config, 'geomaps.ui.hybrid_detail', 1);
             $satellite = Sanitize::getBool($this->c->Config, 'geomaps.ui.satellite_detail', 1);
             $terrain = Sanitize::getBool($this->c->Config, 'geomaps.ui.terrain_detail', 1);
             $panzoom = Sanitize::getBool($this->c->Config, 'geomaps.ui.panzoom_detail', 1);
             $scale = Sanitize::getBool($this->c->Config, 'geomaps.ui.scale_detail', 0);
             $scrollwheel = Sanitize::getBool($this->c->Config, 'geomaps.ui.scrollwheel_detail', 0);
             $doubleclick = Sanitize::getBool($this->c->Config, 'geomaps.ui.doubleclick_detail', 1);
             $zoom = Sanitize::getInt($this->c->Config, 'geomaps.ui.zoom_detail', '');
             $mapUI['title']['trim'] = Sanitize::getVar($this->c->Config, 'geomaps.ui.trimtitle_detail', 0);
             $mapUI['title']['trimchars'] = Sanitize::getVar($this->c->Config, 'geomaps.ui.trimtitle_chars', 30);
             break;
         case 'module_geomaps':
             $maptypes = Sanitize::getString($options, 'ui_maptype', 2) == '2' ? Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_module', 'buttons') : Sanitize::getString($options, 'ui_maptype');
             //buttons|menu|none
             $maptype_def = Sanitize::getString($options, 'ui_maptype_def', 2) == '2' ? Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_def_module', 'G_NORMAL_MAP') : Sanitize::getString($options, 'ui_maptype_def', 'G_NORMAL_MAP');
             $map = Sanitize::getInt($options, 'ui_map', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.map_module', 1) : Sanitize::getBool($options, 'ui_map');
             $hybrid = Sanitize::getInt($options, 'ui_hybrid', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.hybrid_module', 1) : Sanitize::getBool($options, 'ui_hybrid');
             $satellite = Sanitize::getInt($options, 'ui_satellite', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.satellite_module', 1) : Sanitize::getBool($options, 'ui_satellite');
             $terrain = Sanitize::getInt($options, 'ui_terrain', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.terrain_module', 1) : Sanitize::getBool($options, 'ui_terrain');
             $panzoom = Sanitize::getInt($options, 'ui_panzoom', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.panzoom_module', 1) : Sanitize::getBool($options, 'ui_panzoom');
             $scale = Sanitize::getInt($options, 'ui_scale', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.scale_module', 0) : Sanitize::getBool($options, 'ui_scale');
             $scrollwheel = Sanitize::getInt($options, 'ui_scrollwheel', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.scrollwheel_module', 0) : Sanitize::getBool($options, 'ui_scrollwheel');
             $doubleclick = Sanitize::getInt($options, 'ui_doubleclick', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.doubleclick_module', 1) : Sanitize::getBool($options, 'ui_doubleclick');
             $mapUI['title']['trim'] = Sanitize::getInt($options, 'ui_trimtitle_module', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.trimtitle_module', 30) : Sanitize::getBool($options, 'ui_trimtitle_module');
             $mapUI['title']['trimchars'] = Sanitize::getInt($options, 'ui_trimtitle_chars', 2) == '2' ? Sanitize::getInt($this->c->Config, 'geomaps.ui.trimtitle_chars', 30) : Sanitize::getInt($options, 'ui_trimtitle_chars');
             if (Sanitize::getString($options, 'detail_view', 1)) {
                 $zoom = Sanitize::getInt($this->c->Config, 'geomaps.ui.zoom_detail', '');
             }
             break;
     }
     switch ($maptypes) {
         case 'buttons':
             $mapUI['controls']['maptypecontrol'] = true;
             $mapUI['controls']['menumaptypecontrol'] = false;
             break;
         case 'menu':
             $mapUI['controls']['maptypecontrol'] = false;
             $mapUI['controls']['menumaptypecontrol'] = true;
             break;
         default:
             $mapUI['controls']['maptypecontrol'] = false;
             $mapUI['controls']['menumaptypecontrol'] = false;
     }
     $mapUI['maptypes']['def'] = $maptype_def;
     $mapUI['maptypes']['map'] = $map;
     $mapUI['maptypes']['hybrid'] = $hybrid;
     $mapUI['maptypes']['satellite'] = $satellite;
     $mapUI['maptypes']['terrain'] = $terrain;
     if ($panzoom) {
         $mapUI['controls']['smallzoomcontrol3d'] = true;
         $mapUI['controls']['largemapcontrol3d'] = true;
     } else {
         $mapUI['controls']['smallzoomcontrol3d'] = false;
         $mapUI['controls']['largemapcontrol3d'] = false;
     }
     $mapUI['controls']['scalecontrol'] = $scale;
     $mapUI['zoom']['scrollwheel'] = $scrollwheel;
     $mapUI['zoom']['doubleclick'] = $doubleclick;
     $mapUI['zoom']['start'] = $zoom;
     $mapUI['anchor']['x'] = Sanitize::getVar($this->c->Config, 'geomaps.infowindow_x', 0);
     $mapUI['anchor']['y'] = Sanitize::getVar($this->c->Config, 'geomaps.infowindow_y', 0);
     unset($Html, $Routes, $CustomFields, $Thumbnail);
     return json_encode(array('count' => count($infowindow_data), 'mapUI' => $mapUI, 'infowindow' => Sanitize::getString($this->c->Config, 'geomaps.infowindow', '_google'), 'icons' => $this->processIcons($marker_icons), 'payload' => $infowindow_data));
 }
 /**
  * Return a HTML representation of the image gallery
  *
  * The new gallery disables the old perrow control, and automatically fit the gallery to the available space in the browser.
  */
 private function renderGallery()
 {
     wfProfileIn(__METHOD__);
     // do not render empty gallery
     if (empty($this->mFiles)) {
         wfProfileOut(__METHOD__);
         return '';
     }
     // Route to the mobile gallery or the new MediaGallery
     if (F::app()->checkSkin('wikiamobile')) {
         $html = $this->renderWikiaMobileMediaGroup();
         wfProfileOut(__METHOD__);
         return $html;
     } elseif ($this->canRenderMediaGallery()) {
         $html = $this->renderMediaGallery();
         // remove spaces from html produced by mustache template
         $html = trim(preg_replace('/\\n+/', ' ', $html));
         wfProfileOut(__METHOD__);
         return $html;
     }
     /** @var Skin|Linker $skin The skin object falls back to Linker methods via __call */
     $skin = RequestContext::getMain()->getSkin();
     $thumbSize = $this->mWidths;
     $orientation = $this->getParam('orientation');
     $ratio = WikiaPhotoGalleryHelper::getRatioFromOption($orientation);
     $crop = $this->mCrop;
     //calculate height of the biggest image
     $maxHeight = 0;
     $fileObjectsCache = array();
     $heights = array();
     $widths = array();
     $thumbParams = array();
     // loop through the images and get height of the tallest one
     foreach ($this->mFiles as $imageData) {
         $img = $this->getImage($imageData[0]);
         $fileObjectsCache[] = $img;
         if (!empty($img)) {
             // get thumbnail limited only by given width
             if ($img->width > $thumbSize) {
                 $imageHeight = round($img->height * ($thumbSize / $img->width));
                 $imageWidth = $thumbSize;
             } else {
                 $imageHeight = $img->height;
                 $imageWidth = $img->width;
             }
             $heights[] = $imageHeight;
             $widths[] = $imageWidth;
             if ($imageHeight > $maxHeight) {
                 $maxHeight = $imageHeight;
             }
         }
     }
     // calculate height based on gallery width
     $height = round($thumbSize / $ratio);
     if ($orientation == 'none') {
         $this->enableCropping($crop = false);
         // use the biggest height found
         if ($maxHeight > 0) {
             $height = $maxHeight;
         }
         // limit height (RT #59355)
         $height = min($height, $thumbSize);
         // recalculate dimensions (RT #59355)
         foreach ($this->mFiles as $index => $image) {
             if (!empty($heights[$index]) && !empty($widths[$index])) {
                 //fix #59355, min() added to let borders wrap images with smaller width
                 //fix #63886, round ( $tmpFloat ) != floor ( $tmpFloat ) added to check if thumbnail will be generated from proper width
                 $tmpFloat = $widths[$index] * $height / $heights[$index];
                 $widths[$index] = min($widths[$index], floor($tmpFloat));
                 $heights[$index] = min($height, $heights[$index]);
                 if (round($tmpFloat) != floor($tmpFloat)) {
                     $heights[$index]--;
                 }
             } else {
                 $widths[$index] = $thumbSize;
                 $heights[$index] = $height;
             }
         }
     }
     $useBuckets = $this->getParam('buckets');
     $useRowDivider = $this->getParam('rowdivider');
     $captionColor = $this->getParam('captiontextcolor');
     $borderColor = $this->getParam('bordercolor');
     $perRow = $this->mPerRow > 0 ? $this->mPerRow : 'dynamic';
     $position = $this->getParam('position');
     $captionsPosition = $this->getParam('captionposition', 'below');
     $captionsAlign = $this->getParam('captionalign');
     $captionsSize = $this->getParam('captionsize');
     $captionsColor = !empty($captionColor) ? $captionColor : null;
     $spacing = $this->getParam('spacing');
     $borderSize = $this->getParam('bordersize');
     $borderColor = !empty($borderColor) ? $borderColor : 'accent';
     $isTemplate = isset($this->mData['params']['source']) && $this->mData['params']['source'] == "template";
     $hash = $this->mData['hash'];
     $id = 'gallery-' . $this->mData['id'];
     $showAddButton = $this->mShowAddButton == true;
     $hideOverflow = $this->getParam('hideoverflow');
     if (in_array($borderColor, array('accent', 'color1'))) {
         $borderColorClass = " {$borderColor}";
     } else {
         $borderColorCSS = " border-color: {$borderColor};";
         if ($captionsPosition == 'within') {
             $captionsBackgroundColor = $borderColor;
         }
     }
     $html = Xml::openElement('div', array('id' => $id, 'hash' => $hash, 'class' => 'wikia-gallery' . ($isTemplate ? ' template' : null) . " wikia-gallery-caption-{$captionsPosition}" . " wikia-gallery-position-{$position}" . " wikia-gallery-spacing-{$spacing}" . " wikia-gallery-border-{$borderSize}" . " wikia-gallery-captions-{$captionsAlign}" . " wikia-gallery-caption-size-{$captionsSize}"));
     // render gallery caption (RT #59241)
     if ($this->mCaption !== false) {
         $html .= Xml::openElement('div', array('class' => 'wikia-gallery-caption')) . $this->mCaption . Xml::closeElement('div');
     }
     $itemWrapperWidth = $thumbSize;
     $thumbWrapperHeight = $height;
     //compensate image wrapper width depending on the border size
     switch ($borderSize) {
         case 'large':
             $itemWrapperWidth += 10;
             //5px * 2
             $thumbWrapperHeight += 10;
             break;
         case 'medium':
             $itemWrapperWidth += 4;
             //2px * 2
             $thumbWrapperHeight += 4;
             break;
         case 'small':
             $itemWrapperWidth += 2;
             //1px * 2
             $thumbWrapperHeight += 2;
             break;
     }
     //adding more width for the padding
     $outeritemWrapperWidth = $itemWrapperWidth + 20;
     $rowDividerCSS = '';
     if ($useRowDivider) {
         $rowDividerCSS = "height: " . ($thumbWrapperHeight + 100) . "px; padding: 30px 15px 20px 15px; margin: 0px; border-bottom: solid 1px #CCCCCC;";
     }
     if ($useBuckets) {
         $itemSpanStyle = "width:{$outeritemWrapperWidth}px; " . ($useRowDivider ? $rowDividerCSS : 'margin: 4px;');
         $itemDivStyle = "background-color: #f9f9f9; height:{$thumbWrapperHeight}px; text-align: center; border: solid 1px #CCCCCC; padding: " . ($outeritemWrapperWidth - $thumbWrapperHeight) / 2 . "px 5px;";
     } else {
         $itemSpanStyle = "width:{$itemWrapperWidth}px; {$rowDividerCSS}";
         $itemDivStyle = "height:{$thumbWrapperHeight}px;";
     }
     foreach ($this->mFiles as $index => $imageData) {
         if ($perRow != 'dynamic' && $index % $perRow == 0) {
             $html .= Xml::openElement('div', array('class' => 'wikia-gallery-row'));
         }
         $html .= Xml::openElement('div', array('class' => 'wikia-gallery-item', 'style' => $itemSpanStyle));
         $html .= Xml::openElement('div', array('class' => 'thumb', 'style' => $itemDivStyle));
         $image = array();
         // let's properly scale image (don't make it bigger than original size)
         /**
          * @var $imageTitle Title
          * @var $fileObject LocalFile
          */
         $imageTitle = $imageData[0];
         $fileObject = $fileObjectsCache[$index];
         $imageTitleText = $imageTitle->getText();
         $image['height'] = $height;
         $image['width'] = $thumbSize;
         $image['caption'] = $imageData[1];
         if (!is_object($fileObject) || $imageTitle->getNamespace() != NS_FILE) {
             $image['linkTitle'] = $image['titleText'] = $imageTitleText;
             $image['thumbnail'] = false;
             $image['link'] = Skin::makeSpecialUrl("Upload", array('wpDestFile' => $image['linkTitle']));
             $image['classes'] = 'image broken-image accent new';
         } else {
             $thumbParams = WikiaPhotoGalleryHelper::getThumbnailDimensions($fileObject, $thumbSize, $height, $crop);
             $image['thumbnail'] = $fileObject->createThumb($thumbParams['width'], $thumbParams['height']);
             $image['DBKey'] = $fileObject->getTitle()->getDBKey();
             $image['fileTitle'] = $fileObject->getTitle()->getText();
             $image['height'] = $orientation == 'none' ? $heights[$index] : min($thumbParams['height'], $height);
             $imgHeightCompensation = ($height - $image['height']) / 2;
             if ($imgHeightCompensation > 0) {
                 $image['heightCompensation'] = $imgHeightCompensation;
             }
             $image['width'] = min($widths[$index], $thumbSize);
             //Fix #59914, shared.css has auto-alignment rules
             /*$imgWidthCompensation = ($thumbSize - $image['width']) / 2;
             		if ($imgHeightCompensation > 0) $image['widthCompensation'] = $imgWidthCompensation;*/
             $image['link'] = $imageData[2];
             $linkAttribs = $this->parseLink($imageTitle->getLocalUrl(), $imageTitleText, $image['link']);
             $image['link'] = $linkAttribs['href'];
             $image['linkTitle'] = $linkAttribs['title'];
             $image['classes'] = $linkAttribs['class'];
             $image['bytes'] = $fileObject->getSize();
             if ($this->mParser && $fileObject->getHandler()) {
                 $fileObject->getHandler()->parserTransformHook($this->mParser, $fileObject);
             }
         }
         wfRunHooks('GalleryBeforeRenderImage', array(&$image));
         //see Image SEO project
         $wrapperId = preg_replace('/[^a-z0-9_]/i', '-', Sanitizer::escapeId($image['linkTitle']));
         $html .= Xml::openElement('div', array('class' => 'gallery-image-wrapper' . (!$useBuckets && !empty($borderColorClass) ? $borderColorClass : null), 'id' => $wrapperId, 'style' => 'position: relative;' . ($useBuckets ? " width: {$itemWrapperWidth}px; border-style: none;" : " height:{$image['height']}px; width:{$image['width']}px;") . (!empty($image['heightCompensation']) ? " top:{$image['heightCompensation']}px;" : null) . (!empty($borderColorCSS) ? $borderColorCSS : null)));
         $imgStyle = null;
         $isVideo = WikiaFileHelper::isFileTypeVideo($fileObject);
         # Fix 59913 - thumbnail goes as <img /> not as <a> background.
         if ($orientation != 'none') {
             # margin calculation for image positioning
             if ($thumbParams['height'] > $image['height']) {
                 $tempTopMargin = -1 * ($thumbParams['height'] - $image['height']) / 2;
             } else {
                 unset($tempTopMargin);
             }
             if ($thumbParams['width'] > $image['width']) {
                 $tempLeftMargin = -1 * ($thumbParams['width'] - $image['width']) / 2;
             } else {
                 unset($tempLeftMargin);
             }
             $imgStyle = (!empty($tempTopMargin) ? " margin-top:" . $tempTopMargin . "px;" : null) . (!empty($tempLeftMargin) ? " margin-left:" . $tempLeftMargin . "px;" : null);
             if ($isVideo) {
                 $image['classes'] .= ' force-lightbox';
             }
         }
         $linkAttribs = array('class' => empty($image['thumbnail']) ? 'image-no-lightbox' : $image['classes'], 'href' => $image['link'], 'title' => $image['linkTitle'] . (isset($image['bytes']) ? ' (' . $skin->formatSize($image['bytes']) . ')' : ""), 'style' => "height:{$image['height']}px; width:{$image['width']}px;");
         if (!empty($image['thumbnail'])) {
             if ($isVideo) {
                 $thumbHtml = '';
                 $duration = $fileObject->getMetadataDuration();
                 if (!empty($duration)) {
                     $duration = WikiaFileHelper::formatDuration($duration);
                     $thumbHtml .= '<span class="duration">' . $duration . '</span>';
                 }
                 $playButtonSize = ThumbnailHelper::getThumbnailSize($image['width']);
                 $thumbHtml .= $this->videoPlayButton;
                 $linkAttribs['class'] .= ' video video-thumbnail ' . $playButtonSize;
             } else {
                 $thumbHtml = '';
             }
             $imgAttribs = array('style' => (!empty($image['titleText']) ? " line-height:{$image['height']}px;" : null) . $imgStyle, 'src' => $image['thumbnail'] ? $image['thumbnail'] : null, 'title' => $image['linkTitle'] . (isset($image['bytes']) ? ' (' . $skin->formatSize($image['bytes']) . ')' : ""), 'class' => 'thumbimage', 'alt' => preg_replace('/\\.[^\\.]+$/', '', $image['linkTitle']));
             if ($isVideo) {
                 $imgAttribs['data-video-name'] = htmlspecialchars($image['fileTitle']);
                 $imgAttribs['data-video-key'] = urlencode(htmlspecialchars($image['DBKey']));
             } else {
                 $imgAttribs['data-image-name'] = htmlspecialchars($image['fileTitle']);
                 $imgAttribs['data-image-key'] = urlencode(htmlspecialchars($image['DBKey']));
             }
             if (!empty($image['data-caption'])) {
                 $imgAttribs['data-caption'] = $image['data-caption'];
             }
             if (isset($image['thumbnail-classes']) && isset($image['thumbnail-src']) && isset($image['thumbnail-onload'])) {
                 $thumbHtml .= '<noscript>' . Xml::openElement('img', $imgAttribs) . '</noscript>';
                 $imgAttribs['class'] .= ' ' . $image['thumbnail-classes'];
                 $imgAttribs['data-src'] = $imgAttribs['src'];
                 $imgAttribs['src'] = $image['thumbnail-src'];
                 $imgAttribs['onload'] = $image['thumbnail-onload'];
             }
             $thumbHtml .= Xml::openElement('img', $imgAttribs);
         } else {
             $thumbHtml = $image['linkTitle'];
         }
         $html .= Xml::openElement('a', $linkAttribs);
         $html .= $thumbHtml;
         $html .= Xml::closeElement('a');
         if ($captionsPosition == 'below') {
             $html .= Xml::closeElement('div');
             $html .= Xml::closeElement('div');
         }
         // Insert video titles here
         if ($isVideo) {
             $html .= '<div class="title">' . $imageTitleText . '</div>';
         }
         if (!empty($image['caption'])) {
             $html .= Xml::openElement('div', array('class' => 'lightbox-caption' . (!empty($borderColorClass) && $captionsPosition == 'within' ? $borderColorClass : null), 'style' => ($captionsPosition == 'below' ? "width:{$thumbSize}px;" : null) . (!empty($captionsColor) ? " color:{$captionsColor};" : null) . (!empty($captionsBackgroundColor) ? " background-color:{$captionsBackgroundColor}" : null) . ($useBuckets ? " margin-top: 0px;" : '') . (!empty($hideOverflow) ? " overflow: hidden" : null)));
             $html .= $image['caption'];
             $html .= Xml::closeElement('div');
         }
         if ($captionsPosition == 'within') {
             $html .= Xml::closeElement('div');
             $html .= Xml::closeElement('div');
         }
         $html .= Xml::closeElement('div');
         // /div.wikia-gallery-item
         if ($perRow != 'dynamic' && ($index % $perRow == $perRow - 1 || $index == count($this->mFiles) - 1)) {
             $html .= Xml::closeElement('div');
         }
     }
     // "Add image to this gallery" button (this button is shown by JS only in Monaco)
     if ($showAddButton) {
         if ($perRow == 'dynamic') {
             $html .= Xml::element('br');
         }
         // add button for Oasis
         $html .= Xml::openElement('a', array('class' => 'wikia-photogallery-add wikia-button noprint', 'style' => 'display: none'));
         $html .= Xml::element('img', array('src' => F::app()->wg->BlankImgUrl, 'class' => 'sprite photo', 'width' => 26, 'height' => 16));
         $html .= wfMessage('wikiaPhotoGallery-viewmode-addphoto')->inContentLanguage()->text();
         $html .= Xml::closeElement('a');
     }
     $html .= Xml::closeElement('div');
     wfProfileOut(__METHOD__);
     return $html;
 }
 /**
  * Render image tags for the MediaGallery. Please note it is the caller's responsibility
  * to ensure thumb is of the proper type. No error checking takes place here and there's
  * the opportunity to throw a fatal if the wrong data is passed in.
  * @requestParam MediaTransformOutput thumb
  * @requestParam array options This is here for consistency, it's not used yet
  */
 public function gallery()
 {
     $this->response->setVal('mediaType', 'image');
     // Use the image template
     $this->overrideTemplate('image');
     $thumb = $this->getVal('thumb');
     $this->response->setVal('linkHref', $thumb->file->getTitle()->getLinkURL());
     ThumbnailHelper::setImageAttribs($this, $thumb, ['fluid' => true]);
     ThumbnailHelper::setPictureTagInfo($this, $thumb);
 }
Example #4
0
 /**
  * Creates the json object used for map rendering
  *     
  * @param array $results listings
  * @param mixed $fields  custom fields, required when using the GeoMaps module
  * @param mixed $options mapUI options to override globals when using GeoMaps module
  */
 function makeJsonObject(&$results, &$fields = array(), $options = array())
 {
     $www_base = array_shift(pathinfo(WWW_ROOT));
     // Required for thumbnail path
     $paths = array(S2Paths::get('jreviews', 'S2_VIEWS_OVERRIDES') . 'themes' . DS . $this->c->Config->template . DS . 'theme_images' . DS, S2Paths::get('jreviews', 'S2_VIEWS') . 'themes' . DS . $this->c->Config->template . DS . 'theme_images' . DS, S2Paths::get('jreviews', 'S2_VIEWS_OVERRIDES') . 'themes' . DS . 'default' . DS . 'theme_images' . DS, S2Paths::get('jreviews', 'S2_VIEWS') . 'themes' . DS . 'default' . DS . 'theme_images' . DS);
     $path = fileExistsInPath(array('name' => '', 'suffix' => '', 'ext' => ''), $paths);
     App::import('Helper', array('html', 'routes', 'custom_fields', 'thumbnail'));
     $Html = new HtmlHelper();
     $Routes = new RoutesHelper();
     $CustomFields = new CustomFieldsHelper();
     $Thumbnail = new ThumbnailHelper();
     $Thumbnail->app = 'jreviews';
     $Thumbnail->name = $this->c->name;
     $Thumbnail->action = $this->c->action;
     $Routes->Config = $CustomFields->Config = $Thumbnail->Config = $this->c->Config;
     $Routes->Access = $CustomFields->Access = $Thumbnail->Access = $this->c->Access;
     $Routes->Html = $CustomFields->Html = $Thumbnail->Html = $Html;
     $CustomFields->viewTheme = $Thumbnail->viewTheme =& $this->c->viewTheme;
     $CustomFields->viewSuffix =& $this->c->viewSuffix;
     // Check format of results because we may need to re-format and add fields for Geomaps module
     $first = current($results);
     if (!isset($first['Listing'])) {
         $results = $this->buildListingArray($results, $fields);
     }
     // PaidListings - remove unpaid info
     Configure::read('PaidListings') and PaidListingsComponent::processPaidData($results);
     $marker_icons = array();
     $infowindow_data = array();
     $i = 1;
     $default_icon = $this->c->name == 'categories' ? 'numbered' : 'default';
     // make sure we only have the numeric part of the id from request when checking against listing ids
     $request_id = explode(':', JRequest::getVar('id'));
     $request_id = $request_id[0];
     if (!empty($results)) {
         foreach ($results as $key => $result) {
             $results[$key] = $this->injectDistanceGroup($result);
             // Add menu id if not already there
             if (!isset($result['Listing']['menu_id'])) {
                 $results[$key]['Listing']['menu_id'] = $this->c->Menu->getCategory($result['Listing']['cat_id'], $result['Listing']['section_id'], $result['Directory']['dir_id'], $result['Listing']['listing_id']);
             }
             // Added to support extra coordinates
             //$coords = $result["Field"]["groups"]["Location Info"]["Fields"]["jr_extracoords"]["value"][0];
             //$xtracoords = $CustomFields->field('jr_extracoords', $listing, false, false);
             if (isset($result["Field"]["groups"]["Location Info"]) && isset($result["Field"]["groups"]["Location Info"]["Fields"]["jr_extracoords"])) {
                 $coords = $result["Field"]["groups"]["Location Info"]["Fields"]["jr_extracoords"]["value"][0];
                 if ($coords) {
                     $coords = json_decode($coords);
                     $results[$key]["ExtraCoords"] = $coords;
                     if (JRequest::getString("option") != "com_content") {
                         $results[$key]["ExtraCoords"] = 0;
                     }
                     // HTGMOD
                 }
             } elseif (isset($result["Field"]["pairs"]["jr_extracoords"])) {
                 //detail page
                 $coords = $result["Field"]["pairs"]["jr_extracoords"]["value"][0];
                 if ($coords) {
                     $coords = json_decode($coords);
                     $results[$key]["ExtraCoords"] = $coords;
                     if ($results[$key]["Listing"]["listing_id"] != $request_id) {
                         // "if the current listing_id in the loop == the listing_id being viewed on the detail page...."
                         $results[$key]["ExtraCoords"] = 0;
                     }
                 }
             }
             $listing_index = ($this->c->page - 1) * $this->c->limit + $i++;
             // Process and add icon info
             $icon = isset($result['Geomaps']) ? json_decode($result['Geomaps']['icon'], true) : array();
             $results[$key]['Geomaps']['icon'] = '';
             $icon_name = $default_icon;
             if (!empty($icon)) {
                 $foundIcon = false;
                 // Check if custom field assigned
                 if ($icon['field'] != '' && substr($icon['field'], 0, 3) == 'jr_') {
                     if (isset($result['Field']['pairs'][$icon['field']]) && isset($result['Field']['pairs'][$icon['field']]['image'][0])) {
                         $icon_name = substr($result['Field']['pairs'][$icon['field']]['image'][0], 0, strpos($result['Field']['pairs'][$icon['field']]['image'][0], '.'));
                         $marker_icons[$icon_name] = $results[$key]['Geomaps']['icon'] = $result['Field']['pairs'][$icon['field']]['image'][0];
                         $foundIcon = true;
                     }
                 } elseif ($icon['cat'] != '' && !$foundIcon) {
                     $icon_name = substr($icon['cat'], 0, strpos($icon['cat'], '.'));
                     if ($icon_name != 'default') {
                         $marker_icons[$icon_name] = $results[$key]['Geomaps']['icon'] = $icon['cat'];
                     }
                 }
             }
             if (isset($result['Geomaps']) && $result['Geomaps']['lat'] != '' && $result['Geomaps']['lon'] != '' && $result['Geomaps']['lat'] != 0 && $result['Geomaps']['lon']) {
                 # Create infowindow JSON object
                 // start with standard fields
                 $infowindow = array('id' => $result['Listing']['listing_id'], 'url' => str_replace(array($www_base, '&amp;'), array('', '&'), $Routes->content('', $results[$key], array('return_url' => true))), 'index' => $listing_index, 'title' => $result['Listing']['title'], 'image' => str_replace($www_base, '', $Thumbnail->thumb($result, 0, 'scale', 'list', array($this->c->Config->list_image_resize), array('return_src' => 1))), 'featured' => $result['Listing']['featured'], 'rating_scale' => $this->c->Config->rating_scale, 'user_rating' => $result['Review']['user_rating'], 'user_rating_count' => $result['Review']['user_rating_count'], 'editor_rating' => $result['Review']['editor_rating'], 'editor_rating_count' => $result['Review']['editor_rating_count'], 'lat' => (double) $result['Geomaps']['lat'], 'lon' => (double) $result['Geomaps']['lon'], 'icon' => $icon_name);
                 // Added for Hooked
                 $infowindow['criteria_id'] = $result['Criteria']['criteria_id'];
                 if (isset($results[$key]["ExtraCoords"])) {
                     $infowindow['extracoords'] = $results[$key]["ExtraCoords"];
                 }
                 if (isset($results[$key]['Listing']['relations'])) {
                     $infowindow['relations'] = $results[$key]['Listing']['relations'];
                 }
                 if ($results[$key]['Listing']['section_id'] != 1) {
                     $infowindow['hascontent'] = 1;
                 } else {
                     if (isset($results[$key]['Listing']['summary']) && $results[$key]['Listing']['summary'] != '') {
                         $infowindow['hascontent'] = 1;
                     } else {
                         $infowindow['hascontent'] = 0;
                     }
                 }
                 if (!empty($result['Field']['pairs'])) {
                     foreach ($result['Field']['pairs'] as $name => $fieldArray) {
                         $infowindow['field'][$name] = $CustomFields->field($name, $result);
                     }
                 }
                 $infowindow_data['id' . $result['Listing']['listing_id']] = $infowindow;
             }
         }
     }
     $mapUI = array();
     $zoom = '';
     switch ($this->c->name) {
         case 'categories':
             $maptypes = Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_list', 'buttons');
             //buttons|menu|none
             $maptype_def = Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_def_list', 'G_NORMAL_MAP');
             $map = Sanitize::getBool($this->c->Config, 'geomaps.ui.map_list', 1);
             $hybrid = Sanitize::getBool($this->c->Config, 'geomaps.ui.hybrid_list', 1);
             $satellite = Sanitize::getBool($this->c->Config, 'geomaps.ui.satellite_list', 1);
             $terrain = Sanitize::getBool($this->c->Config, 'geomaps.ui.terrain_list', 1);
             $panzoom = Sanitize::getBool($this->c->Config, 'geomaps.ui.panzoom_list', 1);
             $scale = Sanitize::getBool($this->c->Config, 'geomaps.ui.scale_list', 0);
             $scrollwheel = Sanitize::getBool($this->c->Config, 'geomaps.ui.scrollwheel_list', 0);
             $doubleclick = Sanitize::getBool($this->c->Config, 'geomaps.ui.doubleclick_list', 1);
             $mapUI['title']['trim'] = Sanitize::getVar($this->c->Config, 'geomaps.ui.trimtitle_list', 0);
             $mapUI['title']['trimchars'] = Sanitize::getVar($this->c->Config, 'geomaps.ui.trimtitle_chars', 30);
             break;
         case 'com_content':
             $maptypes = Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_detail', 'buttons');
             //buttons|menu|none
             $maptype_def = Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_def_detail', 'G_NORMAL_MAP');
             $map = Sanitize::getBool($this->c->Config, 'geomaps.ui.map_detail', 1);
             $hybrid = Sanitize::getBool($this->c->Config, 'geomaps.ui.hybrid_detail', 1);
             $satellite = Sanitize::getBool($this->c->Config, 'geomaps.ui.satellite_detail', 1);
             $terrain = Sanitize::getBool($this->c->Config, 'geomaps.ui.terrain_detail', 1);
             $panzoom = Sanitize::getBool($this->c->Config, 'geomaps.ui.panzoom_detail', 1);
             $scale = Sanitize::getBool($this->c->Config, 'geomaps.ui.scale_detail', 0);
             $scrollwheel = Sanitize::getBool($this->c->Config, 'geomaps.ui.scrollwheel_detail', 0);
             $doubleclick = Sanitize::getBool($this->c->Config, 'geomaps.ui.doubleclick_detail', 1);
             $zoom = Sanitize::getInt($this->c->Config, 'geomaps.ui.zoom_detail', '');
             $mapUI['title']['trim'] = Sanitize::getVar($this->c->Config, 'geomaps.ui.trimtitle_detail', 0);
             $mapUI['title']['trimchars'] = Sanitize::getVar($this->c->Config, 'geomaps.ui.trimtitle_chars', 30);
             break;
         case 'module_geomaps':
             $maptypes = Sanitize::getString($options, 'ui_maptype', 2) == '2' ? Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_module', 'buttons') : Sanitize::getString($options, 'ui_maptype');
             //buttons|menu|none
             $maptype_def = Sanitize::getString($options, 'ui_maptype_def', 2) == '2' ? Sanitize::getString($this->c->Config, 'geomaps.ui.maptype_def_module', 'G_NORMAL_MAP') : Sanitize::getString($options, 'ui_maptype_def', 'G_NORMAL_MAP');
             $map = Sanitize::getInt($options, 'ui_map', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.map_module', 1) : Sanitize::getBool($options, 'ui_map');
             $hybrid = Sanitize::getInt($options, 'ui_hybrid', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.hybrid_module', 1) : Sanitize::getBool($options, 'ui_hybrid');
             $satellite = Sanitize::getInt($options, 'ui_satellite', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.satellite_module', 1) : Sanitize::getBool($options, 'ui_satellite');
             $terrain = Sanitize::getInt($options, 'ui_terrain', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.terrain_module', 1) : Sanitize::getBool($options, 'ui_terrain');
             $panzoom = Sanitize::getInt($options, 'ui_panzoom', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.panzoom_module', 1) : Sanitize::getBool($options, 'ui_panzoom');
             $scale = Sanitize::getInt($options, 'ui_scale', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.scale_module', 0) : Sanitize::getBool($options, 'ui_scale');
             $scrollwheel = Sanitize::getInt($options, 'ui_scrollwheel', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.scrollwheel_module', 0) : Sanitize::getBool($options, 'ui_scrollwheel');
             $doubleclick = Sanitize::getInt($options, 'ui_doubleclick', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.doubleclick_module', 1) : Sanitize::getBool($options, 'ui_doubleclick');
             $mapUI['title']['trim'] = Sanitize::getInt($options, 'ui_trimtitle_module', 2) == '2' ? Sanitize::getBool($this->c->Config, 'geomaps.ui.trimtitle_module', 30) : Sanitize::getBool($options, 'ui_trimtitle_module');
             $mapUI['title']['trimchars'] = Sanitize::getInt($options, 'ui_trimtitle_chars', 2) == '2' ? Sanitize::getInt($this->c->Config, 'geomaps.ui.trimtitle_chars', 30) : Sanitize::getInt($options, 'ui_trimtitle_chars');
             if (Sanitize::getString($options, 'detail_view', 1)) {
                 $zoom = Sanitize::getInt($this->c->Config, 'geomaps.ui.zoom_detail', '');
             }
             break;
     }
     switch ($maptypes) {
         case 'buttons':
             $mapUI['controls']['maptypecontrol'] = true;
             $mapUI['controls']['menumaptypecontrol'] = false;
             break;
         case 'menu':
             $mapUI['controls']['maptypecontrol'] = false;
             $mapUI['controls']['menumaptypecontrol'] = true;
             break;
         default:
             $mapUI['controls']['maptypecontrol'] = false;
             $mapUI['controls']['menumaptypecontrol'] = false;
     }
     $mapUI['maptypes']['def'] = $maptype_def;
     $mapUI['maptypes']['map'] = $map;
     $mapUI['maptypes']['hybrid'] = $hybrid;
     $mapUI['maptypes']['satellite'] = $satellite;
     $mapUI['maptypes']['terrain'] = $terrain;
     if ($panzoom) {
         $mapUI['controls']['smallzoomcontrol3d'] = true;
         $mapUI['controls']['largemapcontrol3d'] = true;
     } else {
         $mapUI['controls']['smallzoomcontrol3d'] = false;
         $mapUI['controls']['largemapcontrol3d'] = false;
     }
     $mapUI['controls']['scalecontrol'] = $scale;
     $mapUI['zoom']['scrollwheel'] = $scrollwheel;
     $mapUI['zoom']['doubleclick'] = $doubleclick;
     $mapUI['zoom']['start'] = $zoom;
     $mapUI['anchor']['x'] = Sanitize::getVar($this->c->Config, 'geomaps.infowindow_x', 0);
     $mapUI['anchor']['y'] = Sanitize::getVar($this->c->Config, 'geomaps.infowindow_y', 0);
     unset($Html, $Routes, $CustomFields, $Thumbnail);
     return json_encode(array('count' => count($infowindow_data), 'mapUI' => $mapUI, 'infowindow' => Sanitize::getString($this->c->Config, 'geomaps.infowindow', '_google'), 'icons' => $this->processIcons($marker_icons), 'payload' => $infowindow_data));
 }
 public function getHTML()
 {
     global $wgCategoryExhibitionMediaSectionRows;
     $cachedContent = $this->getFromCache();
     if (empty($cachedContent)) {
         // grabs data for videos and images
         $aTmpData = $this->fetchSectionItems(array(NS_FILE));
         // we wan't old videos
         if (is_array($aTmpData) && count($aTmpData) > 0) {
             $pages = Paginator::newFromArray($aTmpData, $wgCategoryExhibitionMediaSectionRows * 4);
             $pageData = $pages->getPage($this->paginatorPosition, true);
             $aData = array();
             foreach ($pageData as $item) {
                 $itemTitle = Title::newFromID($item['page_id']);
                 $forceHeight = '';
                 $forceWidth = '';
                 $isVideo = WikiaFileHelper::isFileTypeVideo($itemTitle);
                 // item is image
                 $image = wfFindFile($itemTitle);
                 $elementClass = 'lightbox';
                 if (!is_object($image) || $image->height == 0 || $image->width == 0) {
                     $imageSrc = '';
                 } else {
                     $proportions = $image->width / $image->height;
                     if ($proportions < 1) {
                         $calculatedWidth = floor($proportions * $this->thumbWidth);
                     } else {
                         $calculatedWidth = $this->thumbMedia;
                     }
                     $forceWidth = floor($calculatedWidth);
                     $forceHeight = floor($calculatedWidth / $proportions);
                     $imageServing = new ImageServing(array($item['page_id']), $calculatedWidth, array("w" => $image->width, "h" => $image->height));
                     $imageSrc = wfReplaceImageServer($image->getThumbUrl($imageServing->getCut($image->width, $image->height) . "-" . $image->getName()));
                     if ($isVideo) {
                         $videoSizeClass = ThumbnailHelper::getThumbnailSize($forceWidth);
                         $elementClass .= ' video video-thumbnail ' . $videoSizeClass;
                     }
                 }
                 $linkedFiles = $this->getLinkedFiles($itemTitle);
                 if (!empty($linkedFiles)) {
                     $linkText = $linkedFiles->getText();
                     $linkFullUrl = $linkedFiles->getFullURL();
                 } else {
                     $linkText = '';
                     $linkFullUrl = '';
                 }
                 // types casting for proper caching;
                 $aData[] = array('id' => $item['page_id'], 'title' => $itemTitle->getText(), 'key' => $itemTitle->getDBKey(), 'img' => (string) $imageSrc, 'url' => $itemTitle->getFullURL(), 'dimensions' => array('w' => (int) $forceWidth, 'h' => (int) $forceHeight), 'class' => $elementClass, 'data-ref' => $itemTitle->getPrefixedURL(), 'targetUrl' => $linkFullUrl, 'targetText' => $linkText, 'isVideo' => $isVideo);
             }
             $aContent = array('data' => $aData, 'category' => $this->categoryTitle->getText(), 'paginator' => $pages->getBarHTML($this->sUrl));
             $this->saveToCache($aContent);
         } else {
             return false;
         }
     } else {
         $aContent = $cachedContent;
     }
     if (!empty($aContent) && is_array($aContent)) {
         $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/");
         $oTmpl->set_vars($aContent);
         $oTmpl->set_vars(array('fromAjax' => $this->isFromAjax));
         if ($this->isFromAjax) {
             return array('page' => $oTmpl->render($this->templateName), 'paginator' => $oTmpl->mVars['paginator']);
         } else {
             return $oTmpl->render($this->templateName);
         }
     }
 }