/*!
Adds all the new image alias structures in \a $imageAliasList to the content object attribute.
341758
function addImageAliases( $imageAliasList )
    {
        $domTree = $this->domTree();
        foreach ( $imageAliasList as $imageAliasName => $imageAlias )
        {
            if ( $imageAlias['is_new'] )
            {
                $this->addImageAliasToXML( $domTree, $imageAlias );
                $this->setAliasAttribute( $imageAliasName, 'is_new', false );
            }
        }
        $attr = false;
        $this->storeDOMTree( $domTree, true, $attr );
    }
1110063
function aliasList( $checkValidity = true )
    {
        if ( $checkValidity && isset( $this->ContentObjectAttributeData['DataTypeCustom']['alias_list'] ) )
        {
            return $this->ContentObjectAttributeData['DataTypeCustom']['alias_list'];
        }

        eZDebug::accumulatorStart('imageparse', 'XML', 'Image XML parsing' );

        $domTree = new DOMDocument( '1.0', 'utf-8' );

        $xmlString = $this->ContentObjectAttributeData['data_text'];

        $success = false;
        if ( $xmlString != '' )
        {
            $success = $domTree->loadXML( $xmlString );
        }

        if ( !$success )
        {
            $this->generateXMLData();
            $xmlString = $this->ContentObjectAttributeData['data_text'];
            $success = $domTree->loadXML( $xmlString );
        }

        $this->ContentObjectAttributeData['DataTypeCustom']['dom_tree'] = $domTree;
        $imageNodeArray = $domTree->getElementsByTagName( "ezimage" );

        $aliasList = array();

        // I think this is a bug in the plain package or related to the bug I filed
        // about the image datatype serialization
        // http://ez.no/bugs/view/8821 ezpm Error: (eZFileHandler::copy) Unable to open source file in read mode
        if ( $imageNodeArray->length == 0 )
        {
            return $aliasList;
        }

        $imageNode = $imageNodeArray->item( 0 );

        $imageInfoNodeArray = $imageNode->getElementsByTagName( "information" );
        $imageVariationNodeArray = $imageNode->getElementsByTagName( "alias" );
        $imageOriginalArray = $imageNode->getElementsByTagName( "original" );

        $aliasEntry = array();

        $alternativeText = $imageNode->getAttribute( 'alternative_text' );
        $originalFilename = $imageNode->getAttribute( 'original_filename' );
        $basename = $imageNode->getAttribute( 'basename' );
        $displayText = $this->displayText( $alternativeText );

        $originalData = array( 'attribute_id' => '',
                               'attribute_version' => '',
                               'attribute_language' => '' );
        if ( $imageOriginalArray->length > 0 )
        {
            $imageOriginalNode = $imageOriginalArray->item( 0 );
            $originalData = array( 'attribute_id' => $imageOriginalNode->getAttribute( 'attribute_id' ),
                                   'attribute_version' => $imageOriginalNode->getAttribute( 'attribute_version' ),
                                   'attribute_language' => $imageOriginalNode->getAttribute( 'attribute_language' ) );
        }
        if ( strlen( $originalData['attribute_id'] ) == 0 ||
             strlen( $originalData['attribute_version'] ) == 0 ||
             strlen( $originalData['attribute_language'] ) == 0 )
        {
            $originalData = array( 'attribute_id' => $this->ContentObjectAttributeData['id'],
                                   'attribute_version' => $this->ContentObjectAttributeData['version'],
                                   'attribute_language' => $this->ContentObjectAttributeData['language_code'] );
        }
        $this->setOriginalAttributeData( $originalData );

        $aliasEntry['name'] = 'original';
        $aliasEntry['width'] = $imageNode->getAttribute( 'width' );
        $aliasEntry['height'] = $imageNode->getAttribute( 'height' );
        $aliasEntry['mime_type'] = $imageNode->getAttribute( 'mime_type' );
        $aliasEntry['filename'] = $imageNode->getAttribute( 'filename' );
        $aliasEntry['suffix'] = $imageNode->getAttribute( 'suffix' );
        $aliasEntry['dirpath'] = $imageNode->getAttribute( 'dirpath' );
        $aliasEntry['basename'] = $basename;
        $aliasEntry['alternative_text'] = $alternativeText;
        $aliasEntry['text'] = $displayText;
        $aliasEntry['original_filename'] = $originalFilename;
        $aliasEntry['url'] = $imageNode->getAttribute( 'url' );
        $aliasEntry['alias_key'] = $imageNode->getAttribute( 'alias_key' );
        $aliasEntry['timestamp'] = $imageNode->getAttribute( 'timestamp' );
        $aliasEntry['full_path'] = $aliasEntry['url'];
        $aliasEntry['is_valid'] = $imageNode->getAttribute( 'is_valid' );
        $aliasEntry['is_new'] = false;
        $aliasEntry['filesize'] = false;

        if ( $aliasEntry['url'] )
        {
            $aliasFile = eZClusterFileHandler::instance( $aliasEntry['url'] );

            if ( $aliasFile->exists() )
                $aliasEntry['filesize'] = $aliasFile->size();
        }

        $imageInformation = false;
        if ( $imageInfoNodeArray->length > 0 )
        {
            $imageInfoNode = $imageInfoNodeArray->item( 0 );
            $imageInformation = $this->parseInformationNode( $imageInfoNode );
        }
        $aliasEntry['info'] = $imageInformation;

        $serialNumber = $imageNode->getAttribute( 'serial_number' );
        if ( $serialNumber )
        {
            $this->setImageSerialNumber( $serialNumber );
        }

        $aliasList['original'] = $aliasEntry;

        if ( $imageVariationNodeArray->length > 0 )
        {
            $imageManager = eZImageManager::factory();
            foreach ( $imageVariationNodeArray as $imageVariation )
            {
                $aliasEntry = array();
                $aliasEntry['name'] = $imageVariation->getAttribute( 'name' );
                $aliasEntry['width'] = $imageVariation->getAttribute( 'width' );
                $aliasEntry['height'] = $imageVariation->getAttribute( 'height' );
                $aliasEntry['mime_type'] = $imageVariation->getAttribute( 'mime_type' );
                $aliasEntry['filename'] = $imageVariation->getAttribute( 'filename' );
                $aliasEntry['suffix'] = $imageVariation->getAttribute( 'suffix' );
                $aliasEntry['dirpath'] = $imageVariation->getAttribute( 'dirpath' );
                $aliasEntry['alias_key'] = $imageVariation->getAttribute( 'alias_key' );
                $aliasEntry['timestamp'] = $imageVariation->getAttribute( 'timestamp' );
                $aliasEntry['is_valid'] = $imageVariation->getAttribute( 'is_valid' );
                $aliasEntry['url'] = $imageVariation->getAttribute( 'url' );
                $aliasEntry['basename'] = $basename;
                $aliasEntry['alternative_text'] = $alternativeText;
                $aliasEntry['text'] = $displayText;
                $aliasEntry['original_filename'] = $originalFilename;
                $aliasEntry['full_path'] = $aliasEntry['url'];
                $aliasEntry['is_new'] = false;
                $aliasEntry['info'] = $imageInformation;

                if ( $aliasEntry['url'] )
                {
                    $aliasFile = eZClusterFileHandler::instance( $aliasEntry['url'] );

                    if ( $aliasFile->exists() )
                        $aliasEntry['filesize'] = $aliasFile->size();
                }

                if ( $imageManager->isImageAliasValid( $aliasEntry ) || !$checkValidity )
                {
                    $aliasList[$aliasEntry['name']] = $aliasEntry;
                }
            }
        }
        if ( $checkValidity )
            $this->setAliasList( $aliasList );
        eZDebug::accumulatorStop( 'imageparse' );
        return $aliasList;
    }
1095168
public function updateCollectionAliasExternal($cName, $cLink, $newWindow = 0)
    {
        if ($this->cPointerExternalLink != '') {
            $db = Database::connection();
            $this->markModified();
            if ($newWindow) {
                $newWindow = 1;
            } else {
                $newWindow = 0;
            }
            $db->executeQuery('update CollectionVersions set cvName = ? where cID = ?', array($cName, $this->cID));
            $db->executeQuery('update Pages set cPointerExternalLink = ?, cPointerExternalLinkNewWindow = ? where cID = ?', array($cLink, $newWindow, $this->cID));
        }
    }
425749
private function addAliases()
    {
        if (!$aliases = $this->container->getAliases()) {
            if ($this->container->isFrozen()) {
                return "\n        \$this->aliases = array();\n";
            } else {
                return '';
            }
        }

        $code = "        \$this->aliases = array(\n";
        ksort($aliases);
        foreach ($aliases as $alias => $id) {
            $id = (string) $id;
            while (isset($aliases[$id])) {
                $id = (string) $aliases[$id];
            }
            $code .= '            '.$this->export($alias).' => '.$this->export($id).",\n";
        }

        return $code."        );\n";
    }
1078680
static function imageCopy( $imageObject, $destinationGeometry, $sourceGeometry,
                               $sourceMimeData, $destinationMimeData )
    {
        $destinationWidth = $destinationGeometry['width'];
        $destinationHeight = $destinationGeometry['height'];

        $temporaryImageObject = eZImageGDHandler::imageCreate( $destinationWidth, $destinationHeight, eZImageGDHandler::isImageTrueColor( $imageObject, $sourceMimeData ) );
        ImageCopy( $temporaryImageObject, $imageObject,
                   $destinationGeometry['x'], $destinationGeometry['y'],
                   $sourceGeometry['x'], $sourceGeometry['y'], $sourceGeometry['width'], $sourceGeometry['height'] );
        return $temporaryImageObject;
    }
508075
function addImageToCells(imageId, range) {
    const model = {
      type: 'image',
      imageId,
      range,
    };
    this._media.push(new Image(this, model));
  }
156283
protected function addOpacityFilter()
    {
        $opacity = Utils::fixPNGOpacity($this->opacity);

        if ($opacity >= 0 && $opacity < 127) {
            imagealphablending($this->resource, false);
            imagefilter($this->resource, IMG_FILTER_COLORIZE, 0, 0, 0, $opacity);
        }
    }
397943
final protected void common_addAlias(Object key, Object[] aliasArray) {
        ValidateUtility.objectNotNull(key, "key", aliasArray, "aliasArray");
        cache.addAlias(
                       key,
                       aliasArray,
                       cache.shouldPull(this.sharingPolicy, key),
                       true);
    }
1063044
function mergeLayer( $image, $layerData, $lastLayerData )
    {
        $position = $image->calculatePosition( $layerData['parameters'], $this->width(), $this->height() );
        $x = $position['x'];
        $y = $position['y'];
        $imageObject = $this->imageObject();
        if ( $lastLayerData === null )
        {
            $destinationImageObject = $image->imageObjectInternal( false );
            if ( $destinationImageObject === null )
            {
                $isTrueColor = $this->isTruecolor();
                $image->cloneImage( $this->imageObject(), $this->width(), $this->height(),
                                    $isTrueColor );
            }
            else
            {
                $image->mergeImage( $destinationImageObject, $imageObject,
                                    $x, $y,
                                    $this->width(), $this->height(), 0, 0,
                                    $image->getTransparencyPercent( $layerData['parameters'] ) );
            }
        }
        else
        {
            $destinationImageObject = $image->imageObjectInternal();
            $image->mergeImage( $destinationImageObject, $imageObject,
                                $x, $y,
                                $this->width(), $this->height(), 0, 0,
                                $image->getTransparencyPercent( $layerData['parameters'] ) );
        }
    }
1282207
static function updateUrlObjectLinks( $contentObjectAttribute, $urlIDArray )
    {
        $objectAttributeID = $contentObjectAttribute->attribute( 'id' );
        $objectAttributeVersion = $contentObjectAttribute->attribute('version');

        // Ensure links that have been removed from the attribute version are removed from the object link table
        $linkObjectLinkList = eZURLObjectLink::fetchLinkObjectList( $objectAttributeID, $objectAttributeVersion );
        foreach ( $linkObjectLinkList as $linkObjectLink ) {
            if ( !in_array( $linkObjectLink->attribute( 'url_id' ), $urlIDArray ) ) {
                $linkObjectLink->remove();
            }
        }

        // Ensure links that have been added to the attribute version are added to the object link table
        foreach( $urlIDArray as $urlID )
        {
            $linkObjectLink = eZURLObjectLink::fetch( $urlID, $objectAttributeID, $objectAttributeVersion );
            if ( $linkObjectLink == null )
            {
                $linkObjectLink = eZURLObjectLink::create( $urlID, $objectAttributeID, $objectAttributeVersion );
                $linkObjectLink->store();
            }
        }
    }
1124950
public function addAliases(array $aliases): void
    {
        foreach ($aliases as $alias) {
            $this->aliases[] = '\\('.$alias;
        }
        $this->aliases = \array_unique($this->aliases);
    }
168839
public function addImage($location, $caption = null, $geoLocation = null, $title = null, $license = null)
    {
        $image = $location instanceof ImageTag ? $location : new ImageTag($location, $caption, $geoLocation, $title, $license);

        $this->images[] = $image;
    }
209788
function buildXml()
    {
        $this->checkConnector();
        $this->checkRequest();

        if (!$this->_currentFolder->checkAcl(CKFINDER_CONNECTOR_ACL_FILE_VIEW)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED);
        }

        $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig();

        if (!isset($_GET["fileName"])) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_NAME);
        }

        $fileName = CKFinder_Connector_Utils_FileSystem::convertToFilesystemEncoding($_GET["fileName"]);

        if (!CKFinder_Connector_Utils_FileSystem::checkFileName($fileName) || $resourceTypeInfo->checkIsHiddenFile($fileName)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
        }

        if (!$resourceTypeInfo->checkExtension($fileName, false)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST);
        }

        $filePath = CKFinder_Connector_Utils_FileSystem::combinePaths($this->_currentFolder->getServerPath(), $fileName);

        if (!file_exists($filePath) || !is_file($filePath)) {
            $this->_errorHandler->throwError(CKFINDER_CONNECTOR_ERROR_FILE_NOT_FOUND);
        }

        list($width, $height) = getimagesize($filePath);
        $oNode = new Ckfinder_Connector_Utils_XmlNode("ImageInfo");
        $oNode->addAttribute("width", $width);
        $oNode->addAttribute("height", $height);
        $this->_connectorNode->addChild($oNode);
    }
489492
function setOriginalAttributeData( $originalData )
    {
        $this->ContentObjectAttributeData['DataTypeCustom']['original_data'] = $originalData;

        $domTree = $this->domTree();
        $imageOriginalArray = $domTree->getElementsByTagName( "original" );
        if ( $imageOriginalArray->length > 0 )
        {
            $imageOriginalNode = $imageOriginalArray->item( 0 );
            $this->createOriginalAttributeXMLData( $imageOriginalNode, $originalData );
        }
    }
778297
protected function addAliases($loader, $aliases)
    {
        foreach ($aliases as $alias => $path) {
            if (is_array($path)) {
                $this->addAliases($loader, $path);
            } elseif (is_string($path) && is_dir($path)) {
                $loader->addPath($path, substr($alias, 1));
            }
        }
    }
148074
function initializeFromHTTPFile( $httpFile, $imageAltText = false )
    {
        $this->increaseImageSerialNumber();

        $mimeData = eZMimeType::findByFileContents( $httpFile->attribute( 'filename' ) );
        if ( !$mimeData['is_valid'] )
        {
            $mimeData = eZMimeType::findByName( $httpFile->attribute( 'mime_type' ) );
            if ( !$mimeData['is_valid'] )
            {
                $mimeData = eZMimeType::findByURL( $httpFile->attribute( 'original_filename' ) );
            }
        }
        $this->removeAliases();
        $this->setOriginalAttributeDataValues( $this->ContentObjectAttributeData['id'],
                                               $this->ContentObjectAttributeData['version'],
                                               $this->ContentObjectAttributeData['language_code'] );
        $contentVersion = eZContentObjectVersion::fetchVersion( $this->ContentObjectAttributeData['version'],
                                                                $this->ContentObjectAttributeData['contentobject_id'] );
        $objectName = $this->imageName( $this->ContentObjectAttributeData, $contentVersion );
        $objectPathString = $this->imagePath( $this->ContentObjectAttributeData, $contentVersion, true );

        eZMimeType::changeBaseName( $mimeData, $objectName );
        eZMimeType::changeDirectoryPath( $mimeData, $objectPathString );

        $httpFile->store( false, false, $mimeData );

        $originalFilename = $httpFile->attribute( 'original_filename' );
        return $this->initialize( $mimeData, $originalFilename, $imageAltText );
    }
810693
function cloneImage( $imageObject, $width, $height, $useTruecolor = null )
    {
        if ( $this->ImageObject !== null and
             $this->ImageObjectRef !== null )
        {
            $this->destroy();
        }
        $this->ImageObject = eZImageInterface::createImage( $width, $height, $useTruecolor );
        $this->IsTrueColor = $useTruecolor;
        $this->ImageObjectRef = eZImageInterface::registerImage( $this->ImageObject );
        ImageCopy( $this->ImageObject, $imageObject, 0, 0, 0, 0, $width, $height );
    }