Esempio n. 1
0
 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";
 }
Esempio n. 2
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
    {
        exitError('Not an image object given');
    /**
     * 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');
        }
    }