/** * This file is part of the GLIZY framework. * Copyright (c) 2005-2012 Daniele Ugoletti <*****@*****.**> * * For the full copyright and license information, please view the COPYRIGHT.txt * file that was distributed with this source code. */ function getImage($applicationPath, $corePath = '') { require_once $corePath . 'core/core.inc.php'; org_glizy_Paths::init($applicationPath, $corePath); org_glizy_Config::init(); $id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : NULL; $w = isset($_REQUEST['w']) ? intval($_REQUEST['w']) : NULL; $h = isset($_REQUEST['h']) ? intval($_REQUEST['h']) : NULL; $force = isset($_REQUEST['f']) ? $_REQUEST['f'] == 'true' || $_REQUEST['f'] == '1' : false; $crop = isset($_REQUEST['c']) ? $_REQUEST['c'] == 'true' || $_REQUEST['c'] == '1' : false; if (is_null($id)) { exit; } glz_import('org.glizycms.mediaArchive.MediaManager'); $media = org_glizycms_mediaArchive_MediaManager::getMediaById($id); if ($media->type != 'IMAGE') { exit; } if (!is_null($w) && !is_null($h)) { //resize the image $mediaInfo = $media->getResizeImage($w, $h, $crop, 0, $force); } else { // get the full image $mediaInfo = $media->getImageInfo(); } $ext = array(IMG_GIF => '.gif', IMG_JPG => '.jpeg', IMG_PNG => '.png', IMG_WBMP => '.wbmp'); header("location: " . GLZ_HOST . '/' . $mediaInfo['fileName']); }
public function publish() { $exportPath = __Paths::get('CACHE') . 'export/'; $mediaPath = $exportPath . 'media/'; $zipPath = __Paths::get('BASE') . 'export/' . 'mobileContents.zip'; org_glizy_helpers_Files::deleteDirectory($exportPath); @unlink($zipPath); @mkdir($exportPath); @mkdir($mediaPath); $exportService = org_glizy_ObjectFactory::createObject('movio.modules.publishApp.service.ExportService'); $exportService->export(); $medias = $exportService->getMedias(); foreach ($medias as $id => $fileName) { $media = org_glizycms_mediaArchive_MediaManager::getMediaById($id); copy($media->getFileName(), $mediaPath . $fileName); } $dbHost = __Config::get('DB_HOST'); $dbUser = __Config::get('DB_USER'); $dbPass = __Config::get('DB_PSW'); $dbName = __Config::get('DB_NAME'); $tableName = __Config::get('movio.modules.publishApp.mobileContentsTable'); $sqliteDb = $exportPath . __Config::get('movio.modules.publishApp.sqliteDbName'); $mysql2SqliteService = org_glizy_ObjectFactory::createObject('movio.modules.publishApp.service.Mysql2SqliteService'); $mysql2SqliteService->convert($dbHost, $dbUser, $dbPass, $dbName, $tableName, $sqliteDb); $this->createZip($exportPath, $zipPath); org_glizy_Registry::set('movio/modules/publishApp/lastUpdate', time()); }
public function renderCell(&$ar) { $media = org_glizycms_mediaArchive_MediaManager::getMediaByRecord($ar); $sizes = method_exists($media, 'getOriginalSizes') ? $media->getOriginalSizes() : array('width' => 0, 'height' => 0); $thumbnail = $media->getThumbnail(__Config::get('THUMB_WIDTH'), __Config::get('THUMB_HEIGHT'), __Config::get('ADM_THUMBNAIL_CROP'), __Config::get('ADM_THUMBNAIL_CROPPOS')); $ar->thumb_filename = $thumbnail['fileName']; $ar->thumb_w = $thumbnail['width']; $ar->thumb_h = $thumbnail['height']; $ar->media_w = $sizes['width']; $ar->media_h = $sizes['height']; if ($ar->media_title == '') { $ar->media_title = $ar->media_originalFileName; } if (!$ar->media_date) { $ar->media_date = ''; } if (!$ar->media_copyright) { $ar->media_copyright = ''; } if (!$ar->media_description) { $ar->media_description = ''; } $ar->__jsonMedia = org_glizycms_Glizycms::getMediaArchiveBridge()->getJsonFromAr($ar); $application = $this->application; $user = $application->_user; $ar->__url__ = $user->acl($application->getPageId(), 'edit') ? __Routing::makeUrl('actionsMVC', array('action' => 'edit', 'id' => $ar->media_id)) : false; $ar->__urlDelete__ = $user->acl($application->getPageId(), 'delete') ? __Routing::makeUrl('actionsMVC', array('action' => 'delete', 'id' => $ar->media_id)) : false; $ar->__urlDownload__ = org_glizycms_helpers_Media::getFileUrlById($ar->media_id); $ar->__urlPreview__ = org_glizycms_helpers_Media::getImageUrlById($ar->media_id, 800, 600); }
public static function getFileUrlById($id, $direct = false) { if ($direct) { $media =& org_glizycms_mediaArchive_MediaManager::getMediaById($id); return is_null($media) ? '' : $media->getFileName(false); } else { return org_glizycms_Glizycms::getMediaArchiveBridge()->getMediaById($id); } }
function renderCell($key, $value, $row) { $application =& org_glizy_ObjectValues::get('org.glizy', 'application'); $media = org_glizycms_mediaArchive_MediaManager::getMediaByValues($row); $sizes = method_exists($media, 'getOriginalSizes') ? $media->getOriginalSizes() : array('width' => 0, 'height' => 0); // $scale = strpos( $application->getPageId(), 'picker' ) !== false ? 2 : 1; // vavr_dump(__Config::get('THUMB_WIDTH')); $scale = 1; $thumbnail = $media->getThumbnail(__Config::get('THUMB_WIDTH') / $scale, __Config::get('THUMB_HEIGHT') / $scale, __Config::get('ADM_THUMBNAIL_CROP'), __Config::get('ADM_THUMBNAIL_CROPPOS')); $title = !empty($media->title) ? $media->title : $media->fileName; return '<img src="' . $thumbnail['fileName'] . '" width="' . $thumbnail['width'] . '" height="' . $thumbnail['height'] . '" alt="' . $title . '" title="' . $title . '" data-id="' . $media->id . '" data-filename="' . $media->fileName . '" data-width="' . $sizes['width'] . '" data-height="' . $sizes['height'] . '" style="cursor: pointer;" />'; }
function execute($mediaPath, $languageId, $languageCode, $menuIdArray, $title, $subtitle, $creditPageId, $isExhibitionActive) { if ($this->user->isLogged()) { $mobileContentsTable = __Config::get('movio.modules.publishApp.mobileContentsTable'); org_glizy_dataAccessDoctrine_DataAccess::truncateTable($mobileContentsTable); $mobileFulltextTable = __Config::get('movio.modules.publishApp.mobileFulltextTable'); org_glizy_dataAccessDoctrine_DataAccess::truncateTable($mobileFulltextTable); $exportService = org_glizy_ObjectFactory::createObject('movio.modules.publishApp.service.ExportService'); $exportService->export($languageId, $languageCode, $menuIdArray, $title, $subtitle, $creditPageId, $isExhibitionActive); $medias = $exportService->getMedias(); foreach ($medias as $id => $fileName) { $media = org_glizycms_mediaArchive_MediaManager::getMediaById($id); @copy($media->getFileName(), $mediaPath . $fileName); } return $exportService->getGraphs(); } }
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}); }
private function addLogoAndCustomCss(&$templateData, $css) { $templateData->headerLogo = @json_decode($templateData->headerLogo); if ($templateData->headerLogo) { $image = org_glizycms_mediaArchive_MediaManager::getMediaById($templateData->headerLogo->id); $fileName = $image->getFileName(); $sizes = $image->getOriginalSizes(); $templateData->customCss .= <<<EOD header .site-logo { background: url("../{$fileName}") no-repeat ; width: {$sizes['width']}px; height: {$sizes['height']}px; } EOD; } $css .= PHP_EOL . $templateData->customCss; return $css; }
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; } }
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : NULL; $w = isset($_REQUEST['w']) ? intval($_REQUEST['w']) : NULL; $h = isset($_REQUEST['h']) ? intval($_REQUEST['h']) : NULL; $force = isset($_REQUEST['f']) ? $_REQUEST['f'] == 'true' || $_REQUEST['f'] == '1' : false; $crop = isset($_REQUEST['c']) ? $_REQUEST['c'] == 'true' || $_REQUEST['c'] == '1' : false; $useThumbnail = isset($_REQUEST['t']) ? $_REQUEST['t'] == 'true' || $_REQUEST['t'] == '1' : false; $cropOffset = isset($_REQUEST['co']) ? $_REQUEST['co'] : 0; if (is_null($id)) { exit; } glz_import('org.glizycms.mediaArchive.MediaManager'); $media = org_glizycms_mediaArchive_MediaManager::getMediaById($id); if ($useThumbnail && !empty($media->ar->media_thumbFileName)) { $media->ar->media_fileName = $media->ar->media_thumbFileName; $media->ar->media_type = 'IMAGE'; $media = org_glizycms_mediaArchive_MediaManager::getMediaByRecord($media->ar); } if (!is_null($w) && !is_null($h)) { //resize the image if ($media->type != 'IMAGE') { $iconFile = $media->getIconFileName(); header('location: ' . $iconFile); } $mediaInfo = $media->getResizeImage($w, $h, $crop, $cropOffset, $force); } else { // get the full image $mediaInfo = $media->getImageInfo(); } $gmdate_mod = gmdate("D, d M Y H:i:s", filemtime($mediaInfo['fileName'])); if (!strstr($gmdate_mod, "GMT")) { $gmdate_mod .= " GMT";
protected function addLogoCss(&$templateData, $css) { $templateData->headerLogo = @json_decode($templateData->headerLogo); if ($templateData->headerLogo) { $image = org_glizycms_mediaArchive_MediaManager::getMediaById($templateData->headerLogo->id); $fileName = $image->getFileName(); $templateData->customCss .= <<<EOD header .site-logo { background: url("../{$fileName}") no-repeat ; } EOD; } return $css; }
function getThumbnail($width, $height, $crop = false, $cropOffset = 0) { $iconPath = $this->getIconFileName(); // controlla se c'è un'anteprima associata if (!empty($this->ar->media_thumbFileName)) { // TODO: da implementare meglio in modo che i metodi di resize // non siano in Image ma comuni a tutti i media $this->ar->media_fileName = $this->ar->media_thumbFileName; $this->ar->media_type = 'IMAGE'; $media = org_glizycms_mediaArchive_MediaManager::getMediaByRecord($this->ar); return $media->getThumbnail($width, $height); } list($originalWidth, $originalHeight, $imagetypes) = getImageSize($iconPath); return array('fileName' => $iconPath, 'width' => $originalWidth, 'height' => $originalHeight); }
public function render() { if (is_object($this->_content) && $this->_content->image && $this->_content->hotspots) { $media = org_glizycms_mediaArchive_MediaManager::getMediaById($this->_content->image); $speakingUrlManager = $this->_application->retrieveProxy('org.glizycms.speakingUrl.Manager'); if (is_object($media)) { $id = $this->getId(); $imageInfo = $media->getImageInfo(); $width = $imageInfo['width']; $height = $imageInfo['height']; $attributes = array(); $attributes['src'] = $media->getFileName(true); $attributes['width'] = $imageInfo['width']; $attributes['height'] = $imageInfo['height']; $attributes['alt'] = $media->title; $attributes['title'] = $media->title; $image = '<img ' . $this->_renderAttributes($attributes) . ' />'; $hotspots = ''; foreach ($this->_content->hotspots as $h) { $attributes = array(); $attributes['id'] = $id . '-' . $h->id; $attributes['class'] = 'movio-hotspot' . ($h->form == 'circle' ? '-circle' : ''); $attributes['style'] = 'display: block; top: ' . $h->top . 'px; left: ' . $h->left . 'px; height: ' . $h->height . 'px; width: ' . $h->width . 'px;'; if ($h->description) { $attributes['data-tooltip'] = glz_encodeOutput($h->description); } $link = ''; if ($h->type = 'linkEx' && $h->src) { $link = __Link::formatLink($h->src); } else { if ($h->type = 'link' && $h->srcInt) { $link = __Link::formatInternalLink($speakingUrlManager->makeUrl($h->srcInt)); } } if ($link) { $link = str_replace('<a ', '<a style="text-indent: -9999px; height: ' . $h->height . 'px; width: ' . $h->width . 'px; display: block;"', $link); } // <a target="_blank" style="height: 148px; width: 186px; display: block;" href="www.google.com" class="hotspot-circle"></a> $hotspots .= '<div ' . $this->_renderAttributes($attributes) . '>' . $link . '</div>'; } $css = trim('movio-hotspotContainer ' . $this->getAttribute('cssClass')); $output = <<<EOD <div id="{$id}" class="{$css}"> {$image} <div class="movio-imageHotspot-scale"> {$hotspots} </div> </div> <script src="static/jquery/jquery-transform/jquery.transform2d.js"></script> <script> jQuery( function(){ \$('div.movio-hotspotContainer').find('div[data-tooltip!=""]').qtip({ content: { attr: 'data-tooltip' }, position: { my: 'bottom left', at: 'bottom left', target: 'mouse' }, style: { classes: 'qtip-bootstrap' } }); var img = \$('div.movio-hotspotContainer img').first(); var scale = img.width() / parseInt(img.attr('width')); \$('.movio-imageHotspot-scale').css('transform', 'scale('+scale+','+scale+')'); }); </script> EOD; $this->addOutputCode($output); $this->addOutputCode(org_glizy_helpers_JS::linkStaticJSfile('jquery/jquery.qtip/jquery.qtip.min.js'), 'head'); $this->addOutputCode(org_glizy_helpers_CSS::linkStaticCSSfile('jquery/jquery.qtip/jquery.qtip.min.css'), 'head'); } } }
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; }
function attachMedia() { $this->_content = array(); $this->_content['mediaUrl'] = $this->mediaUrl; $this->_content['alt'] = $this->mediaUrl; $this->_content['title'] = $this->mediaUrl; $this->_content['class'] = $this->getAttribute('cssClass'); $this->_content['style'] = ""; if (is_string($this->mediaUrl) && strpos($this->mediaUrl, 'http://') === false && strpos($this->mediaUrl, 'https://') === false) { $this->media =& org_glizycms_mediaArchive_MediaManager::getEmptyMediaByType('IMAGE'); $this->media->fileName = $this->getAttribute('path') . '/' . $this->mediaUrl; $this->imageInfo = $this->media->getImageInfo(); $this->_content['src'] = $this->media->getFileName($this->getAttribute('checkIfExists')); $this->_content['width'] = $this->imageInfo['width']; $this->_content['height'] = $this->imageInfo['height']; } else { $this->_content['src'] = $this->mediaUrl; $this->_content['width'] = ""; $this->_content['height'] = ""; } }
function attachMedia($mediaId) { $this->media =& org_glizycms_mediaArchive_MediaManager::getMediaById($mediaId); if (is_object($this->media)) { if ($this->getAttribute('imageInfo') && !$this->_application->isAdmin()) { $this->imageInfo = $this->media->getImageInfo(); $width = $this->imageInfo['width']; $height = $this->imageInfo['height']; } else { $width = ''; $height = ''; } $this->_content = array(); $this->_content['mediaId'] = $this->media->id; $this->_content['src'] = $this->media->getFileName($this->getAttribute('checkIfExists')); $this->_content['originalSrc'] = $this->_content['src']; $this->_content['alt'] = $this->media->title; $this->_content['title'] = $this->media->title; $this->_content['description'] = $this->media->description; $this->_content['zoom'] = $this->media->zoom; $this->_content['class'] = $this->getAttribute('cssClass'); $this->_content['style'] = ""; $this->_content['onclick'] = ""; $this->_content['width'] = $width; $this->_content['height'] = $height; $this->_content['size'] = $this->media->size; $this->_content['mediaType'] = $this->media->type; /* if ($this->getAttribute('zoom')==true) { $this->_content['onclick'] = 'Glizy.previewImage(\''.$this->media->id.'\');'; $this->_content['style'] = 'cursor: pointer'; } */ } }
/** * @param $ext * * @return int|string */ static function getMediaTypeFromExtension($ext) { $ext = strtolower($ext); $fileTypes = org_glizycms_mediaArchive_MediaManager::getMediaTypeInfo(); $fileType = 'OTHER'; foreach ($fileTypes as $k => $v) { if (in_array($ext, $v['extension'])) { $fileType = $k; break; } } return $fileType; }
private function imageSrc($url) { if (strpos($url, 'getImage.php') !== false) { $url = str_replace(array('getImage.php?', '&'), array('', '&'), $url); $chunks = explode('&', $url); $image = array(); foreach ($chunks as $key => $chunk) { list($k, $v) = explode('=', $chunk); $image[$k] = $v; } // controllo if (!isset($image['id'])) { return ""; } $media = org_glizycms_mediaArchive_MediaManager::getMediaById($image['id']); if (isset($image['w']) && isset($image['h'])) { $mediaInfo = $media->getResizeImage($image['w'], $image['h']); } else { $mediaInfo = $media->getImageInfo(); } return "<img src=\"" . $mediaInfo['fileName']; } }
$id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : NULL; $w = isset($_REQUEST['w']) ? intval($_REQUEST['w']) : 0; if (is_null($id)) { exit; } if (!defined('GLZ_LOADED')) { require_once 'core/core.inc.php'; org_glizy_Paths::init('application', ''); org_glizy_Config::init(); if (file_exists(org_glizy_Paths::get('APPLICATION_STARTUP'))) { // if the startup folder is defined all files are included glz_require_once_dir(org_glizy_Paths::get('APPLICATION_STARTUP')); } org_glizy_ObjectValues::set('org.glizy', 'languageId', 1); } $zoomFile = __Paths::get('CACHE') . '/zoom_' . $id . '_' . $w . '.xml'; if (!file_exists($zoomFile)) { glz_import('org.glizycms.mediaArchive.MediaManager'); set_time_limit(0); $media = org_glizycms_mediaArchive_MediaManager::getMediaById($id); if (preg_match('/\\.tif$/', $media->fileName)) { $mediaInfo = $media->getResizeImage(2000, 2000); $media->fileName = $mediaInfo['fileName']; } set_include_path(implode(PATH_SEPARATOR, array(realpath('application/libs/openzoom/'), get_include_path()))); require 'Oz/Deepzoom/ImageCreator.php'; $converter = new Oz_Deepzoom_ImageCreator(254, 1, "jpg", 0.8); $converter->create(realpath($media->getFileName()), $zoomFile); } echo json_encode(true);
public function saveMedia($data, $action = self::MOVE_TO_CMS, $createRecordIfFileNotExists = false) { $filePath = $data->__filePath; $filePathThumb = property_exists($data, '__filePathThumb') ? $data->__filePathThumb : ''; // controlla che il file esista if (!file_exists($filePath)) { if ($createRecordIfFileNotExists) { return $this->createMediaRecord($data); } else { return array('errors' => array('Il file ' . $filePath . ' non esiste')); } } $originalFileName = $data->__originalFileName; $fileSize = filesize($filePath); $fileExtension = strtolower(pathinfo($data->__originalFileName, PATHINFO_EXTENSION)); $fileType = org_glizycms_mediaArchive_MediaManager::getMediaTypeFromExtension($fileExtension); $saveExifData = __Config::get('glizycms.mediaArchive.exifEnabled') && $fileType == 'IMAGE'; if ($saveExifData) { $exif = @exif_read_data($filePath); } if ($action != self::NONE) { $r = $this->copyFileInArchive($action, $filePath, $originalFileName, $fileType); if (!$r['status']) { return $r; } $data->media_fileName = $r['destName']; $fileDestinationPath = $r['destPath']; if ($filePathThumb) { $r = $this->copyFileInArchive($action, $filePathThumb, 'thumb_' . $originalFileName, $fileType); if (!$r['status']) { return $r; } $filePathThumb = $r['destName']; } /* $file_destname = md5(time()) . "_" . $originalFileName; $destinationFolder = org_glizy_Paths::get('APPLICATION_MEDIA_ARCHIVE').ucfirst(strtolower($fileType)); $fileDestinationPath = $destinationFolder.'/'.$file_destname; $data->media_fileName = $file_destname; // verifica che la cartella di destinazione sia scrivibile if (!is_writeable($destinationFolder)) { return array('errors' => array('Rendere scrivibile la cartella '.$destinationFolder)); } if ($action == self::MOVE_TO_CMS) { rename($filePath, $fileDestinationPath); } else if ($action == self::COPY_TO_CMS) { copy($filePath, $fileDestinationPath); } */ } else { $fileDestinationPath = $filePath; } $media = org_glizy_ObjectFactory::createModel('org.glizycms.models.Media'); $media->media_originalFileName = $originalFileName; $media->media_thumbFileName = $filePathThumb; $media->media_size = $fileSize; $media->media_type = $fileType; $media->media_FK_user_id = org_glizy_ObjectValues::get('org.glizy', 'userId'); $media->media_creationDate = new org_glizy_types_DateTime(); $media->media_modificationDate = new org_glizy_types_DateTime(); $media->media_download = 0; $media->media_md5 = md5_file($fileDestinationPath); if ($fileExtension == 'tif' || $fileExtension == 'tiff') { $media->media_watermark = 1; $media->media_allowDownload = 0; } else { $media->media_allowDownload = 1; $media->media_watermark = 0; } foreach ($data as $k => $v) { // remove the system values if (strpos($k, '__') === 0 || !$media->fieldExists($k)) { continue; } $media->{$k} = $v; } if ($saveExifData) { if ($exif['COMPUTED']['Copyright'] && empty($ar->media_copyright)) { $ar->media_copyright = $exif['COMPUTED']['Copyright']; } } $mediaId = $media->save(); if ($saveExifData) { $exifService = org_glizy_ObjectFactory::createObject('org.glizycms.mediaArchive.services.ExifService'); $exifService->saveExifData($mediaId, $exif); } return $mediaId; }
function attachMedia($mediaId) { $this->media =& org_glizycms_mediaArchive_MediaManager::getMediaById($mediaId); if (is_object($this->media)) { $this->_content['mediaId'] = $this->media->id; $this->_content['src'] = $this->media->getFileName(); $this->_content['title'] = $this->media->title; $this->_content['size'] = $this->media->size; $this->_content['mediaType'] = $this->media->type; } }