private function getTemplateDataFromCache($templateData) { $templateProxy = org_glizy_ObjectFactory::createObject('org.glizycms.template.models.proxy.TemplateProxy'); // $templateProxy->invalidateCache(); $cache = $templateProxy->getTemplateCache(); $cssFileName = __Paths::get('CACHE') . md5($this->getClassName() . '_' . $templateData->__id) . '.css'; $self = $this; $templateData = $cache->get($cssFileName, array(), function () use($self, $templateData, $cssFileName) { $newTemplateData = new StdClass(); $newTemplateData->footerLogo = ''; $self->updateTemplateData($templateData); $self->compileCss($templateData, $cssFileName); $templateData->footerLogo = @json_decode($templateData->footerLogo); if ($templateData->footerLogo && $templateData->footerLogo->id) { $image = org_glizy_helpers_Media::getImageById($templateData->footerLogo->id); if ($templateData->footerLogoLink) { $image = __Link::formatLink($templateData->footerLogoLink, $templateData->footerLogoTitle, $image); } $newTemplateData->footerLogo = $image; } $newTemplateData->css = $templateData->css; return $newTemplateData; }); return $templateData; }
function _render_html() { if ($this->_content['mediaId'] > 0) { $linkTitle = $this->getAttribute('linkTitle'); $linkTitle = str_replace('#title#', $this->_content['title'], $linkTitle); $linkTitle = str_replace('#size#', org_glizy_helpers_String::formatFileSize($this->media->size), $linkTitle); $originalFileName = $this->media->originalFileName; $part = explode('.', $originalFileName); $type = ''; if (count($part) > 1) { $type = strtoupper($part[count($part) - 1]); } $linkTitle = str_replace('#format#', $type, $linkTitle); $this->_content['linkTitle'] = $linkTitle; $this->_content['__url__'] = org_glizy_helpers_Media::getFileUrlById($this->media->id, $this->getAttribute('directUrl')); $this->_content['__html__'] = org_glizy_helpers_Link::makeSimpleLink($this->_content['title'], $this->_content['__url__'], $linkTitle, $this->getAttribute('cssClass'), $this->getAttribute('rel')); } }
function renderCell(&$ar) { $ar->__image = ''; foreach ($ar->getValuesAsArray() as $value) { if (is_string($value) && preg_match('/getImage.php\\?id=(\\d+)/', $value, $m)) { $id = $m[1]; $ar->__image = org_glizy_helpers_Media::getResizedImageById($id, true, __Config::get('movio.thumb.entityList.width'), __Config::get('movio.thumb.entityList.height'), __Config::get('movio.thumb.entityList.crop')); break; } } if ($ar->__image == '') { $ar->__image = '<img src="' . __Config::get('movio.noImage.src') . '" width="' . __Config::get('movio.thumb.entityList.width') . '" height="' . __Config::get('movio.thumb.entityList.height') . '"/>'; } // TODO: verificare perché viene letto dalla request if (!__Request::get('visualization')) { $ar->visualization = 'list'; } else { $ar->visualization = __Request::get('visualization'); } }
function process_ajax() { $c = $this->getRootComponent(); $c->process(); $content = $this->stripIdFromContent(parent::getContent()); $timeline = array('date' => array(), 'type' => 'default', 'headline' => $content['title'], 'text' => $content['subtitle'], 'startDate' => $this->formatDate($content['startDate'])); $num = count($content['timelineDef']); for ($i = 0; $i < $num; $i++) { $temp = array('headline' => '', 'text' => '', 'asset' => array('media' => '', 'caption' => '', 'credit' => '')); if ($content['timelineDef'][$i]->startDate) { $temp['startDate'] = $this->formatDate($content['timelineDef'][$i]->startDate); } if ($content['timelineDef'][$i]->endDate) { $temp['endDate'] = $this->formatDate($content['timelineDef'][$i]->endDate); } if ($content['timelineDef'][$i]->headline) { $temp['headline'] = $content['timelineDef'][$i]->headline; } if ($content['timelineDef'][$i]->text) { $temp['text'] = $content['timelineDef'][$i]->text; } if ($content['timelineDef'][$i]->mediaExternal) { $temp['asset']['media'] = $content['timelineDef'][$i]->mediaExternal; } else { if ($content['timelineDef'][$i]->media['mediaId'] > 0) { $temp['asset']['media'] = GLZ_HOST . '/' . org_glizy_helpers_Media::getResizedImageUrlById($content['timelineDef'][$i]->media['mediaId'], false, __Config::get('IMAGE_WIDTH'), __Config::get('IMAGE_HEIGHT')); $temp['asset']['thumbnail'] = GLZ_HOST . '/' . org_glizy_helpers_Media::getResizedImageUrlById($content['timelineDef'][$i]->media['mediaId'], false, __Config::get('THUMB_WIDTH'), __Config::get('THUMB_HEIGHT')); } } if ($content['timelineDef'][$i]->mediaCaption) { $temp['asset']['caption'] = $content['timelineDef'][$i]->mediaCaption; } $timeline['date'][] = $temp; } return array('timeline' => $timeline); }
private function renderTemplateHeader($view, $templateData) { $siteProp = unserialize(org_glizy_Registry::get(__Config::get('REGISTRY_SITE_PROP') . $view->_application->getLanguage(), '')); $view->addOutputCode($siteProp['title'], 'title1'); $view->addOutputCode($siteProp['subtitle'], 'title2'); /* $view->addOutputCode(str_replace('../getImage.php', 'getImage.php', $templateData->title1), 'title1'); $view->addOutputCode(str_replace('../getImage.php', 'getImage.php', $templateData->title2), 'title2'); */ $view->addOutputCode(str_replace('../getImage.php', 'getImage.php', $templateData->title3), 'title3'); $view->addOutputCode(str_replace('../getImage.php', 'getImage.php', $templateData->title4), 'title4'); $templateData->footerLogo = @json_decode($templateData->footerLogo); if ($templateData->footerLogo && $templateData->footerLogo->id) { $image = org_glizy_helpers_Media::getImageById($templateData->footerLogo->id); if ($templateData->footerLogoLink) { $image = __Link::formatLink($templateData->footerLogoLink, $templateData->footerLogoTitle, $image); } $view->addOutputCode($image, 'logoFooter'); } $view->addOutputCode(org_glizy_helpers_CSS::CSScode($templateData->customCss), 'head'); }
private function addMediaById($mediaId) { $media = org_glizycms_mediaArchive_MediaManager::getMediaById($mediaId); if ($media == null) { return null; } if ($media->type == 'VIDEO') { return GLZ_HOST . '/' . org_glizy_helpers_Media::getFileUrlById($media->id); } else { $this->medias[$media->id] = $media->fileName; return 'media/' . $media->fileName; } }
public function fixTemplateData(&$templateData, &$newTemplateData) { $templateData->footerLogo = @json_decode($templateData->footerLogo); if ($templateData->footerLogo && $templateData->footerLogo->id) { $image = org_glizy_helpers_Media::getImageById($templateData->footerLogo->id); if ($templateData->footerLogoLink) { $image = __Link::formatLink($templateData->footerLogoLink, $templateData->footerLogoTitle, $image); } $newTemplateData->footerLogo = $image; } }
function _render_html() { if ($this->_content['mediaId'] > 0) { $attributes = $this->_content; if (!is_null($this->getAttribute('width')) && !is_null($this->getAttribute('height'))) { if ($this->getAttribute('processThumbnail') != 'false') { if ($this->getAttribute('processThumbnail') == 'full') { $thumbnail = $this->media->getResizeImage($this->getAttribute('width'), $this->getAttribute('height'), $this->getAttribute('crop'), $this->getAttribute('cropOffset')); } else { $thumbnail = $this->media->getThumbnail($this->getAttribute('width'), $this->getAttribute('height'), $this->getAttribute('crop'), $this->getAttribute('cropOffset')); } $attributes['src'] = $thumbnail['fileName']; $attributes['width'] = $thumbnail['width']; $attributes['height'] = $thumbnail['height']; $this->_content['src'] = $thumbnail['fileName']; $this->_content['width'] = $thumbnail['width']; $this->_content['height'] = $thumbnail['height']; } else { $attributes['src'] = org_glizy_helpers_Media::getImageUrlById($this->_content['mediaId'], $this->getAttribute('width'), $this->getAttribute('height'), $this->getAttribute('crop')); $this->_content['src'] = $attributes['src']; } } $useZoom = $attributes['zoom']; unset($attributes['description']); unset($attributes['mediaId']); unset($attributes['zoom']); unset($attributes['size']); unset($attributes['mediaType']); unset($attributes['originalSrc']); unset($attributes['__media__']); $this->_content['__html__'] = '<img ' . $this->_renderAttributes($attributes) . '/>'; if ($this->getAttribute('zoom')) { if ($useZoom && $this->getAttribute('superZoom')) { $this->_application->addZoomJsCode(); $this->_content['__html__'] .= '<span class="superzoom js-glizySuperZoom" data-mediaid="' . $this->media->id . '" data-mediawatermark="' . ($this->media->watermark ? '1' : '0') . '">' . $this->getAttribute('superZoomLabel') . '</span>'; } $this->_application->addLightboxJsCode(); $attributes = array(); $attributes['title'] = $this->_content['title']; if ($this->media->type == 'IMAGE') { $attributes['class'] = 'js-lightbox-image'; $attributes['href'] = org_glizycms_helpers_Media::getImageUrlById($this->media->id, __Config::get('IMG_WIDTH_ZOOM'), __Config::get('IMG_HEIGHT_ZOOM')); } else { $attributes['class'] = 'js-lightbox-inline'; $attributes['href'] = org_glizycms_helpers_Media::getFileUrlById($this->media->id); } $attributes['data-type'] = strtolower($this->media->type); $attributes['rel'] = $this->getAttribute('group'); $this->_content['__html__'] = org_glizy_helpers_Html::renderTag('a', $attributes, true, $this->_content['__html__']); } } else { $this->_content['__html__'] = ''; } }
function mediaAbsoluteUrl($item, $field) { $json = $item->{$field}; if (preg_match('/{"id":(\\d+)/', $json, $m)) { $media = json_decode($json); $item->{$field . 'Title'} = $media->title; $m = org_glizycms_mediaArchive_MediaManager::getMediaById($media->id); if ($m->type == 'VIDEO') { $item->{$field . 'Url'} = GLZ_HOST . '/' . org_glizy_helpers_Media::getFileUrlById($media->id, true); } else { $item->{$field . 'Url'} = GLZ_HOST . '/' . org_glizy_helpers_Media::getFileUrlById($media->id); } } else { $item->{$field . 'Title'} = ''; $item->{$field . 'Url'} = ''; } unset($item->{$field}); }
function addMedia($key, $media) { if ($media != '') { $result = new StdClass(); $media = json_decode($media); $m = org_glizycms_mediaArchive_MediaManager::getMediaById($media->id); if ($m == null) { return null; } $result->type = $m->type; $result->title = $media->title; $media->type = $m->type; if ($result->type == 'VIDEO') { $result->url = GLZ_HOST . '/' . org_glizy_helpers_Media::getFileUrlById($media->id, true); } else { $result->fileName = $media->fileName; $this->medias[$media->id] = $media->fileName; } if ($key) { $this->json[$key][$media->id] = $result; } } return $result; }