function modifyData(&$data, $params, $modelParams) { $rootUri = JURI::root(true) . '/'; $keepSize = AriUtils2::getParam($modelParams, 'keepSize', false); $target = AriUtils2::getParam($modelParams, 'target'); if ($target == '_self') $target = null; $group = $params['_default']['groupName']; if (empty($group)) $group = uniqid('asexy_'); $modal = AriUtils2::parseValueBySample($params['_default']['modal'], false); $captionTemplate = AriUtils2::getParam($modelParams, 'caption', '{$Title}'); $needParseTemplate = strpos($captionTemplate, '{$') !== false; foreach ($data as $key => $value) { $dataItem =& $data[$key]; $img = $dataItem['image']; $title = $needParseTemplate ? AriSimpleTemplate::parse($captionTemplate, $dataItem, true) : $captionTemplate; $aAttrs = array('href' => $rootUri . $img . ($modal ? '?modal=1' : ''), 'rel' => 'sexylightbox[' . $group . ']', 'title' => $title); if ($target) $aAttrs['target'] = $target; if ($keepSize) { $size = @getimagesize(JPATH_ROOT . DS . $img); if (!empty($size) && count($size) > 1) { $aAttrs['href'] .= $modal ? '&' : '?'; $aAttrs['href'] .= 'width=' . $size[0] . '&height=' . $size[1]; } } $imgAttrs = array('src' => $rootUri . $dataItem['thumb'], 'border' => '0', 'alt' => str_replace('"', '&qout;', AriUtils2::getParam($dataItem, 'Title', ''))); if ($dataItem['w']) $imgAttrs['width'] = $dataItem['w']; if ($dataItem['h']) $imgAttrs['height'] = $dataItem['h']; if (!empty($dataItem['Link'])) $imgAttrs['longdesc'] = $dataItem['Link']; $dataItem['sexyimage'] = sprintf('<a%1$s><img%2$s/></a>', AriHtmlHelper::getAttrStr($aAttrs), AriHtmlHelper::getAttrStr($imgAttrs)); } }
function applyFilters($value, $filterStr) { $filters = explode('|', $filterStr); if (empty($filters)) return $value; foreach ($filters as $filter) { if (empty($filter)) continue; $filterInfo = explode(':', $filter); $filterName = $filterInfo[0]; array_shift($filterInfo); $value = AriSimpleTemplate::applyFilter($filterName, $value, $filterInfo); } return $value; }
function getData($picasaData, $modelParams, $params) { $data = array(); if (empty($picasaData)) return $data; $group = $params['_default']['groupName']; if (empty($group)) $group = uniqid('asexy_'); $modal = AriUtils2::parseValueBySample($params['_default']['modal'], false); $keepSize = AriUtils2::getParam($modelParams, 'keepSize', false); $captionTemplate = AriUtils2::getParam($modelParams, 'caption', '{$Title}'); $needParseTemplate = strpos($captionTemplate, '{$') !== false; foreach ($picasaData as $key => $value) { $dataItem = $value; $dataItem['Title'] = AriUtils2::getParam($dataItem, 'summary', ''); $title = $needParseTemplate ? AriSimpleTemplate::parse($captionTemplate, $dataItem, true) : $captionTemplate; $img = $dataItem['image']; $thumb = $dataItem['thumb']; $aAttrs = array('href' => $img['url'] . ($modal ? '?modal=1' : ''), 'rel' => 'sexylightbox[' . $group . ']', 'title' => $title); $imgAttrs = array('src' => $thumb['url'], 'border' => '0', 'alt' => $dataItem['Title'], 'width' => $thumb['w'], 'height' => $thumb['h']); if ($keepSize) { $aAttrs['href'] .= $modal ? '&' : '?'; $aAttrs['href'] .= 'width=' . $img['w'] . '&height=' . $img['h']; } $dataItem['sexyimage'] = sprintf('<a%1$s><img%2$s/></a>', AriHtmlHelper::getAttrStr($aAttrs), AriHtmlHelper::getAttrStr($imgAttrs)); $data[$key] = $dataItem; } return $data; }
function _register() { AriSimpleTemplate::registerFilter($this->getFilterName(), $this->getClassName()); }
function render($data) { if (!is_array($data) || count($data) == 0) return $this->_emptyTemplate->getContent(); $rowTemplate = $this->_rowTemplate->getContent(); $cellTemplate = $this->_cellTemplate->getContent(); $emptyCellTemplate = $this->_emptyCellTemplate->getContent(); $content = $this->_headerTemplate->getContent(); $columnPerRow = $this->_rowTemplate->getColumnCount(); $itemIndex = 0; $rowIndex = 0; $columns = ''; foreach ($data as $dataItem) { $columns .= AriSimpleTemplate::parse($cellTemplate, array('data' => $dataItem), true); ++$itemIndex; if ($itemIndex && ($itemIndex % $columnPerRow == 0)) { $content .= AriSimpleTemplate::parse( str_replace('#{cellTemplate}', $columns, $rowTemplate), array('rowClass' => $this->_rowTemplate->getRowClass($rowIndex))); $columns = ''; ++$rowIndex; } } if ($itemIndex % $columnPerRow != 0) { $columns .= str_repeat($emptyCellTemplate, $columnPerRow - ($itemIndex % $columnPerRow)); $content .= AriSimpleTemplate::parse( str_replace('#{cellTemplate}', $columns, $rowTemplate), array('rowClass' => $this->_rowTemplate->getRowClass($rowIndex))); } $content .= $this->_footerTemplate->getContent(); return $content; }
function getData($flickrData, $modelParams, $params) { $data = array('photos' => array(), 'photosets' => array()); if (empty($flickrData)) return $data; $group = $params['_default']['groupName']; if (empty($group)) $group = uniqid('asexy_'); $modal = AriUtils2::parseValueBySample($params['_default']['modal'], false); $captionTemplate = AriUtils2::getParam($modelParams, 'caption', '{$Title}'); $needParseTemplate = strpos($captionTemplate, '{$') !== false; $photos = AriUtils2::getParam($flickrData, 'photos', $flickrData); foreach ($photos as $key => $value) { $dataItem = $value; $title = $needParseTemplate ? AriSimpleTemplate::parse($captionTemplate, $dataItem, true) : $captionTemplate; $aAttrs = array('href' => $dataItem['imgUrl'] . ($modal ? '?modal=1' : ''), 'rel' => 'sexylightbox[' . $group . ']', 'title' => $title); $imgAttrs = array('src' => $dataItem['thumbUrl'], 'border' => '0', 'alt' => $dataItem['Title']); $dataItem['thumb'] = $dataItem['thumbUrl']; $dataItem['sexyimage'] = sprintf('<a%1$s><img%2$s/></a>', AriHtmlHelper::getAttrStr($aAttrs), AriHtmlHelper::getAttrStr($imgAttrs)); $data['photos'][$key] = $dataItem; } $data['photosets'] = AriUtils2::getParam($flickrData, 'photosets', array()); return $data; }
function getData($params) { $data = array(); $prefix = $this->_prefix; $descrFile = $params['descrFile']; $thumbPath = $params['thumbPath']; $cacheDir = $this->_cacheDir; $cacheUri = $cacheDir; if (strpos($cacheUri, JPATH_ROOT . DS) === 0) $cacheUri = substr($cacheUri, strlen(JPATH_ROOT . DS)); $cacheUri = str_replace(DS, '/', $cacheUri); $folders = $params['folders']; $thumbWidth = $params['thumbWidth']; $thumbHeight = $params['thumbHeight']; $sortBy = $params['sortBy']; $sortDir = $params['sortDir']; $thumbType = $params['thumbType']; $thumbTypeParams = $params['thumbTypeParams']; $thumbBehavior = $thumbType == 'resize' ? AriUtils::getParam($thumbTypeParams, 'behavior') : null; $emptyTitle = $params['emptyTitle']; $needProcessEmptyTitle = ($emptyTitle && strpos($emptyTitle, '{$') !== false); foreach ($folders as $folder) { $descriptions = $this->getDescriptions($descrFile, $folder); $files = $this->getImageFiles($folder, $params['fileFilter']); $inCSV = false; $folderData = array(); foreach ($files as $file) { $dataItem = null; $fileUri = str_replace(DS, '/', $file); $filePath = JPATH_ROOT . DS . $file; $baseFileName = basename($file); $thumbImagePath = $thumbPath ? JPATH_ROOT . DS . $folder . DS . str_replace('{$fileName}', $baseFileName, $thumbPath) : null; if ($thumbImagePath && file_exists($thumbImagePath) && is_readable($thumbImagePath)) { $thumbSize = getimagesize($thumbImagePath); $dataItem = array( 'image' => $fileUri, 'thumb' => str_replace(DS, '/', $folder . DS . str_replace('{$fileName}', $baseFileName, $thumbPath)), 'w' => $thumbSize[0], 'h' => $thumbSize[1] ); } else { $thumbSize = AriImageHelper::getThumbnailDimension($filePath, $thumbWidth, $thumbHeight, $thumbBehavior); $dataItem = array( 'image' => $fileUri, 'thumb' => $fileUri, 'w' => $thumbSize['w'], 'h' => $thumbSize['h'] ); if ($thumbSize['w'] && $thumbSize['h']) { $thumbFile = AriImageHelper::generateThumbnailFileName($prefix, $filePath, $thumbSize['w'], $thumbSize['h'], $thumbType); if (@file_exists($cacheDir . DS . $thumbFile)) $dataItem['thumb'] = $cacheUri . '/' . $thumbFile; } } if (isset($descriptions[$baseFileName])) { $dataItem = array_merge($descriptions[$baseFileName], $dataItem); $inCSV = true; } if ($emptyTitle && empty($dataItem['Title'])) { $title = $emptyTitle; if ($needProcessEmptyTitle) { $pathInfo = pathinfo($baseFileName); $title = AriSimpleTemplate::parse( $title, array( 'fileName' => $baseFileName, 'baseFileName' => basename($baseFileName, '.' . $pathInfo['extension']) ) ); } $dataItem['Title'] = $title; } $key = $this->getDataItemKey($filePath, $baseFileName, $sortBy, $inCSV); if (empty($key)) $folderData[$baseFileName] = $dataItem; else $folderData[$key] = $dataItem; } if (count($folderData) == 0) continue ; if ($inCSV && $sortBy == 'csv') { $tempData = array(); foreach ($descriptions as $fileName => $value) { if (!isset($folderData[$fileName])) continue ; $tempData[] = $folderData[$fileName]; unset($folderData[$fileName]); } if ($sortDir == 'desc') $tempData = array_reverse($tempData); $folderData = array_values($folderData); $folderData = array_merge($tempData, array_values($folderData)); } else if ($sortBy != 'filename' && $sortBy != 'modified') { $folderData = array_values($folderData); } $data = array_merge($data, $folderData); } if ($sortBy && $sortBy != 'random' && $sortBy != 'csv') { if ($sortDir == 'asc') ksort($data); else krsort($data); } return $data; }