function imageNameByNode($contentObjectAttribute, $mainNode, $language = false) { if ($language === false) { if (is_object($contentObjectAttribute)) { $language = $contentObjectAttribute->attribute('language_code'); } else { $language = $contentObjectAttribute['language_code']; } } $objectName = $mainNode->getName($language); if (!$objectName) { $objectName = $this->attribute('alternative_text'); if (!$objectName) { $objectName = ezpI18n::tr('kernel/classes/datatypes', 'image', 'Default image name'); } } $objectName = eZImageAliasHandler::normalizeImageName($objectName); return $objectName; }
if ( $parts[0] != '' ) { $filePath = $parts[0]; //if html5 parameters is set, get image_alias path if($html == 'html') { $file = $dataMap['file']; $imageHandler = new eZImageAliasHandler( $file ); $alias = $imageHandler->imageAlias( 'fmc' ); $filePath = $alias["full_path"]; } //html value for fmc if($html == 'fmc') { $file = $dataMap['file']; $imageHandler = new eZImageAliasHandler( $file ); $alias = $imageHandler->imageAlias( 'fmc' ); $filePath = $alias["full_path"]; } $fileHandler = eZClusterFileHandler::instance($filePath); $extension = substr($filePath, strripos($filePath, '.') + 1); if ( $fileHandler->fileExists($filePath) ) { $image = true; } } } } else {
function deleteStoredObjectAttribute($contentObjectAttribute, $version = null) { if ($version === null) { eZImageAliasHandler::removeAllAliases($contentObjectAttribute); } else { $imageHandler = $contentObjectAttribute->attribute('content'); if ($imageHandler) { $imageHandler->removeAliases($contentObjectAttribute); } } }
$db = eZDB::instance(); $db->begin(); $imageManager = eZImageManager::factory(); $contentObjectAttributes = eZPersistentObject::fetchObjectList(eZContentObjectAttribute::definition(), null, array('data_type_string' => 'ezimage')); $script->resetIteration(count($contentObjectAttributes)); foreach ($contentObjectAttributes as $contentObjectAttribute) { $success = false; $xmlString = $contentObjectAttribute->attribute('data_text'); if ($xmlString != '') { $dom = new DOMDocument('1.0', 'UTF-8'); $success = $dom->loadXML($xmlString); unset($dom); } if (!$success) { // upgrade from old image system to the one introduced in eZ Publish 3.3 $imageAliasHandler = new eZImageAliasHandler($contentObjectAttribute); $attributeID = $contentObjectAttribute->attribute('id'); $attributeVersion = $contentObjectAttribute->attribute('version'); $objectID = $contentObjectAttribute->attribute('contentobject_id'); $imageRows = $db->arrayQuery("SELECT * FROM ezimage\n WHERE contentobject_attribute_id={$attributeID} AND\n version={$attributeVersion}"); $doc = new DOMDocument('1.0', 'utf-8'); $imageNode = $doc->createElement('ezimage'); $doc->appendChild($imageNode); $isValid = false; $fileName = false; $suffix = false; $baseName = false; $dirPath = false; $filePath = false; $originalFileName = false; $mimeType = false;
public static function createAlias($contentObjectId, $attributeIdentifier, $aliasName) { $contentObject = eZContentObject::fetch($contentObjectId); if (!is_object($contentObject)) { throw new Exception("This is not an object id [" . $contentObjectId . "]"); } $dataMap = $contentObject->DataMap(); if (!isset($dataMap[$attributeIdentifier])) { throw new Exception("This is not an attribute identifer [" . $attributeIdentifier . "] on content class '" . $contentObject->ClassName . "'"); } $imgAttribute = $dataMap[$attributeIdentifier]; $imageAliasHandler = new eZImageAliasHandler($imgAttribute); $result = $imageAliasHandler->imageAlias($aliasName); return "Command executed successfully \n"; }
/** * Initializes image handler for the given application and applies selection rules * (internal) fetches the good eZContentObjectAttribute containing the expected image and its image alias handler * * @return void * @throws Exception */ public function initImage() { if ( !isset($this->_imageAttribute) ) { $this->_imageAttribute = $this->fetchImageAttribute(); if ( $this->_imageAttribute !== true ) { $handler = new eZImageAliasHandler($this->_imageAttribute); $this->_aliasHandler = $handler->imageAlias($this->_aliasName); } else if ( $this->_isLocalImage ) { $filePath = self::$_localImagePaths[$this->_localImage]; $mime = eZMimeType::findByURL($filePath); $this->_aliasHandler = array( 'url' => $filePath, 'filesize' => filesize($filePath), 'mime_type' => $mime['name'], ); } else throw new Exception('Image Attribute has no valid case'); } }
/** * @dataProvider providerForTestImageNameByNodeObjectFalse */ public function testImageNameByNodeObjectFalse($longName, $expects) { ezpINIHelper::setINISetting('site.ini', 'URLTranslator', 'TransformationGroup', 'urlalias_iri'); $handler = new eZImageAliasHandler(null); $language = "fre-FR"; $mainNodeMock = $this->getMockBuilder('eZContentObjectTreeNode')->disableOriginalConstructor()->getMock(); $mainNodeMock->expects($this->any())->method('getName')->will($this->returnValue($longName)); $name = $handler->imageNameByNode(null, $mainNodeMock, $language); $this->assertEquals($expects, $name); ezpINIHelper::setINISetting('site.ini', 'URLTranslator', 'TransformationGroup', 'urlalias'); }