/**
     * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
     * @return array for further processing
     */

    public static function getAttributeData ( eZContentObjectAttribute $contentObjectAttribute )
    {
        $dataTypeIdentifier = $contentObjectAttribute->attribute( 'data_type_string' );
        $contentClassAttribute = eZContentClassAttribute::fetch( $contentObjectAttribute->attribute( 'contentclassattribute_id' ) );
        $attributeHandler =  $dataTypeIdentifier . 'SolrStorage';
        // prefill the array with generic metadata first
        $target = array (
            'data_type_identifier' => $dataTypeIdentifier,
            'version_format' => self::STORAGE_VERSION_FORMAT,
            'attribute_identifier' => $contentClassAttribute->attribute( 'identifier' ),
            'has_content' => $contentObjectAttribute->hasContent(),

            );
        if ( class_exists( $attributeHandler ) )
        {
            $attributeContent = call_user_func( array( $attributeHandler, 'getAttributeContent' ),
                     $contentObjectAttribute, $contentClassAttribute );
            return array_merge( $target, $attributeContent, array( 'content_method' => self::CONTENT_METHOD_CUSTOM_HANDLER ) );

        }
        else
        {
            $target = array_merge( $target, array(
                'content_method' => self::CONTENT_METHOD_TOSTRING,
                'content' => $contentObjectAttribute->toString(),
                'has_rendered_content' => false,
                'rendered' => null
                ));
            return $target;
        }
    }
Ejemplo n.º 2
0
 /**
  * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
  * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
  * @return array
  */
 public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
 {
     $url = eZURL::fetch( $contentObjectAttribute->attribute( 'data_int' ) );
     return array(
         'content' => array(
             'url' => ( $url instanceof eZURL ) ? $url->attribute( 'url' ) : null,
             'text' => $contentObjectAttribute->attribute( 'data_text' ),
         ),
         'has_rendered_content' => false,
         'rendered' => null,
     );
 }
Ejemplo n.º 3
0
    /**
     * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
     * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
     * @return array
     */
    public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
    {
        $content = $contentObjectAttribute->attribute( 'content' );
        $multioptionArray = array(
            'name' => $content->attribute( 'name' ),
        );

        foreach ( $content->attribute( 'multioption_list' ) as $option )
        {
            $optionArray = array(
                'name' => $option['name'],
                'default_option_id' => $option['default_option_id']
            );
            foreach ( $option['optionlist'] as $value )
            {
                $optionArray['optionlist'][] = array(
                    'value' => $value['value'],
                    'additional_price' => $value['additional_price']
                );
            }
            $multioptionArray['multioption_list'][] = $optionArray;
        }

        return array(
            'content' => $multioptionArray,
            'has_rendered_content' => false,
            'rendered' => null,
        );
    }
    /**
     * Creates the eZContentObject from the uploaded file
     *
     * @param eZHTTPFile $file
     * @param eZContentObjectTreeNode $location
     * @param string $name
     * @return eZContentObject
     * @throw InvalidArgumentException if the parent location does not exists
     * @throw RuntimeException if the object can not be created
     */
    public function createObject( $file, $parentNodeId, $name = '' )
    {
        $result = array();
        $parentNode = eZContentObjectTreeNode::fetch( $parentNodeId );
        if ( !$parentNode instanceof eZContentObjectTreeNode )
        {
            throw new InvalidArgumentException(
                ezpI18n::tr(
                    'extension/ezjscore/ajaxuploader', 'Location not found.'
                )
            );
        }

        $upload = new eZContentUpload();
        $r = $upload->handleLocalFile(
            $result, $file, $parentNodeId, null, $name,
            $this->attribute->attribute( 'language_code' )
        );
        if ( !$r || !$result['contentobject'] instanceof eZContentObject )
        {
            throw new RuntimeException(
                ezpI18n::tr(
                    'extension/ezjscore/ajaxuploader',
                    'Unable to create the content object to add to the relation: %detail',
                    null, array( '%detail', $result['errors'][0]['description'] )
                )
            );
        }
        return $result['contentobject'];
    }
 /**
  * (called for each obj attribute)
  */
 public function checkObjectAttribute(array $contentObjectAttribute)
 {
     // we adopt the ez api instead of acting on raw data
     $contentObjectAttribute = new eZContentObjectAttribute($contentObjectAttribute);
     $binaryFile = $contentObjectAttribute->attribute('content');
     $warnings = array();
     // do not check attributes which do not even contain images
     if ($binaryFile) {
         // get path to original file
         $filePath = $binaryFile->attribute('filepath');
         // check if it is on fs (remember, images are clusterized)
         $file = eZClusterFileHandler::instance($filePath);
         if (!$file->exists()) {
             $warnings[] = "Binary file not found: {$filePath}" . $this->postfixErrorMsg($contentObjectAttribute);
         } else {
             // if it is, check its size as well
             if ($this->maxSize > 0) {
                 $maxSize = $this->maxSize * 1024 * 1024;
                 if ($file->size() > $maxSize) {
                     $warnings[] = "Binary file larger than {$maxSize} bytes : " . $file->size() . $this->postfixErrorMsg($contentObjectAttribute);
                 }
             }
         }
     } else {
         if (!$this->nullable) {
             $warnings[] = "Attribute is null and it should not be" . $this->postfixErrorMsg($contentObjectAttribute);
         }
     }
     return $warnings;
 }
    /**
     * (non-PHPdoc)
     * @see extension/sqliimport/classes/content/diffhandlers/ISQLIDiffHandler::contentIsModified()
     */
    public static function contentIsModified( $data, eZContentObjectAttribute $attribute )
    {
        $isModified = false;

        if ($attribute->attribute( 'content' ))
        {
            $originalFilename   = $attribute->attribute( 'content' )->attribute( 'original_filename' );
            $newFilename        = basename( (string)$data );

            if( $newFilename != $originalFilename )
                $isModified = true;

            return $isModified;
        }

        return true;
    }
 /**
  * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
  * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
  * @return array
  */
 public static function getAttributeContent(eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute)
 {
     $authorList = array();
     foreach ($contentObjectAttribute->attribute('content')->attribute('author_list') as $author) {
         $authorList[] = array('id' => $author['id'], 'name' => $author['name'], 'email' => $author['email']);
     }
     return array('content' => $authorList, 'has_rendered_content' => false, 'rendered' => null);
 }
Ejemplo n.º 8
0
 /**
  * (called for each obj attribute)
  */
 public function checkObjectAttribute(array $contentObjectAttribute)
 {
     // we adopt the ez api instead of acting on raw data
     $contentObjectAttribute = new eZContentObjectAttribute($contentObjectAttribute);
     // for ezuser datatype, the user is always created even if attribute is set to nullable...
     $warnings = array();
     $userid = $contentObjectAttribute->attribute('contentobject_id');
     $user = $contentObjectAttribute->attribute('content');
     if (!$user) {
         $warnings[] = "No ezuser {$userid} found" . $this->postfixErrorMsg($contentObjectAttribute);
     }
     $settings = eZUserSetting::fetch($userid);
     if (!$settings) {
         $warnings[] = "No settings found for user {$userid}" . $this->postfixErrorMsg($contentObjectAttribute);
     }
     return $warnings;
 }
 /**
  * Initializes the object attribute with some data.
  * @param eZContentObjectAttribute $objectAttribute
  * @param int $currentVersion
  * @param eZContentObjectAttribute $originalContentObjectAttribute
  */
 function initializeObjectAttribute($objectAttribute, $currentVersion, $originalContentObjectAttribute)
 {
     if (NULL === $currentVersion) {
         $data = '';
     } else {
         $data = $originalContentObjectAttribute->attribute("data_text");
     }
     $objectAttribute->setAttribute("data_text", $data);
 }
Ejemplo n.º 10
0
 /**
  * Regression test for issue #14983
  * Linked to #17781
  *
  * @link http://issues.ez.no/14983
  * @link http://issues.ez.no/17781
  * @group issue14983
  * @group issue17781
  */
 public function testIssue14983()
 {
     $files = eZImageFile::fetchForContentObjectAttribute($this->fileAttribute->attribute("id"), true);
     self::assertInternalType("array", $files);
     $file = $files[0];
     unset($files);
     // Read stored path, move to trash, and read stored path again
     self::assertInstanceOf('eZImageFile', $file);
     $oldFile = $file;
     $this->imageObject->object->removeThis();
     $this->imageObject->refresh();
     $files = eZImageFile::fetchForContentObjectAttribute($this->fileAttribute->attribute("id"), true);
     self::assertInternalType("array", $files);
     $file = $files[0];
     unset($files);
     self::assertInstanceOf('eZImageFile', $file);
     self::assertTrue(strpos($file->attribute("filepath"), '/trashed') !== false, "The stored file should be renamed when trashed");
 }
Ejemplo n.º 11
0
 /**
  * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
  * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
  * @return array
  */
 public static function getAttributeContent(eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute)
 {
     $content = $contentObjectAttribute->attribute('content');
     $optionArray = array('name' => $content->attribute('name'));
     foreach ($content->attribute('option_list') as $value) {
         $optionArray['option_list'][] = array('id' => $value['id'], 'value' => $value['value'], 'additional_price' => $value['additional_price'], 'is_default' => $value['is_default']);
     }
     return array('content' => $optionArray, 'has_rendered_content' => false, 'rendered' => null);
 }
 /**
  * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
  * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
  * @return array
  */
 public static function getAttributeContent(eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute)
 {
     $objectAttributeContent = $contentObjectAttribute->attribute('content');
     $objectIDList = array();
     foreach ($objectAttributeContent['relation_list'] as $objectInfo) {
         $objectIDList[] = $objectInfo['contentobject_id'];
     }
     return array('content' => $objectIDList, 'has_rendered_content' => false, 'rendered' => null);
 }
Ejemplo n.º 13
0
 /**
  * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
  * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
  * @return array
  */
 public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
 {
     $dateTime = new DateTime( '@' . $contentObjectAttribute->attribute( 'data_int' ) );
     return array(
         'content' => $dateTime->format( 'c' ),
         'has_rendered_content' => false,
         'rendered' => null,
     );
 }
Ejemplo n.º 14
0
 /**
  * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
  * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
  * @return json encoded string for further processing
  * required first level elements 'method', 'version_format', 'data_type_identifier', 'content'
  * optional first level element is 'rendered' which should store (template) rendered xhtml snippets
  */
 public static function getAttributeContent(eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute)
 {
     $dataTypeIdentifier = $contentObjectAttribute->attribute('data_type_string');
     $attributeID = $contentObjectAttribute->attribute("id");
     $version = $contentObjectAttribute->attribute("version");
     if (!$contentObjectAttribute->hasContent()) {
         $content = null;
     } else {
         $binaryFile = eZBinaryFile::fetch($attributeID, $version);
         $content = $binaryFile->storedFileInfo();
     }
     // This is not really the place, but for now initiate the safeguarding of the file itself here
     $archiveFileHandler = ezpFileArchiveFactory::getFileArchiveHandler('filesystem');
     // todo: insert check if handler is really returned and of the right class before calling the archive action
     // maybe use the attribute id as prefix as well, may be useful for bookkeeping/recovery and potentially easier restore as well
     $archiveResult = $archiveFileHandler->archiveFile($content['filepath'], array($content['filepath']), $attributeID, 'ezbinaryfile');
     $target = array('content' => $content, 'has_rendered_content' => false, 'rendered' => null, 'archived' => true, 'archive' => $archiveResult);
     return $target;
 }
 /**
  *
  * http://maps.googleapis.com/maps/api/staticmap?zoom=13&size=600x300&maptype=roadmap&markers=color:blue|{first_set( $attribute.content.latitude, '0.0')},{first_set( $attribute.content.longitude, '0.0')}
  * @param array $parameters
  * @param eZContentObjectAttribute $attribute
  * @return string
  */
 public static function gmapStaticImage(array $parameters, eZContentObjectAttribute $attribute, $extraCacheFileNameStrings = array())
 {
     $cacheParameters = array(serialize($parameters));
     $cacheFile = $attribute->attribute('id') . implode('-', $extraCacheFileNameStrings) . '-' . md5(implode('-', $cacheParameters)) . '.cache';
     $extraPath = eZDir::filenamePath($attribute->attribute('id'));
     $cacheDir = eZDir::path(array(eZSys::cacheDirectory(), 'gmap_static', $extraPath));
     // cacenllo altri file con il medesimo attributo
     $fileList = array();
     $deleteItems = eZDir::recursiveList($cacheDir, $cacheDir, $fileList);
     foreach ($fileList as $file) {
         if ($file['type'] == 'file' && $file['name'] !== $cacheFile) {
             unlink($file['path'] . '/' . $file['name']);
         }
     }
     $cachePath = eZDir::path(array($cacheDir, $cacheFile));
     $args = compact('parameters', 'attribute');
     $cacheFile = eZClusterFileHandler::instance($cachePath);
     $result = $cacheFile->processCache(array('OCOperatorsCollectionsTools', 'gmapStaticImageRetrieve'), array('OCOperatorsCollectionsTools', 'gmapStaticImageGenerate'), null, null, $args);
     return $result;
 }
 /**
  * (called for each obj attribute)
  */
 public function checkObjectAttribute(array $contentObjectAttribute)
 {
     if ($this->nullable) {
         return array();
     }
     $contentObjectAttribute = new eZContentObjectAttribute($contentObjectAttribute);
     if (!$contentObjectAttribute->attribute('has_content')) {
         return array("Attribute is null and it should not be" . $this->postfixErrorMsg($contentObjectAttribute));
     }
     return array();
 }
Ejemplo n.º 17
0
 /**
  * (called for each obj attribute)
  */
 public function checkObjectAttribute(array $contentObjectAttribute)
 {
     // we adopt the ez api instead of acting on raw data
     $contentObjectAttribute = new eZContentObjectAttribute($contentObjectAttribute);
     $value = $contentObjectAttribute->attribute('content');
     // do not check attributes which do not even contain images
     if ($contentObjectAttribute->attribute('has_content')) {
         if ($this->min !== null && $value < $this->min) {
             return array("Integer smaller than {$this->min}: {$value}" . $this->postfixErrorMsg($contentObjectAttribute));
         }
         if ($this->max !== null && $value > $this->max) {
             return array("Integer bigger than {$this->max}: {$value}" . $this->postfixErrorMsg($contentObjectAttribute));
         }
     } else {
         if (!$this->nullable) {
             return array("Attribute is null and it should not be" . $this->postfixErrorMsg($contentObjectAttribute));
         }
     }
     return array();
 }
 /**
  * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
  * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
  * @return json encoded string for further processing
  * required first level elements 'method', 'version_format', 'data_type_identifier', 'content'
  * optional first level element is 'rendered' which should store (template) rendered xhtml snippets
  */
 public static function getAttributeContent(eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute)
 {
     $dataTypeIdentifier = $contentObjectAttribute->attribute('data_type_string');
     $attributeContents = $contentObjectAttribute->content();
     $doc = new DOMDocument('1.0');
     $doc->loadXML($attributeContents->attribute('xml_data'));
     $xpath = new DOMXPath($doc);
     $content = $doc->saveXML($xpath->query('/*')->item(0));
     $target = array('content' => $content, 'has_rendered_content' => $contentObjectAttribute->hasContent(), 'rendered' => $attributeContents->attribute('output')->attribute('output_text'));
     return $target;
 }
Ejemplo n.º 19
0
 /**
  * Gets the instance of Open Graph attribute handler for the attribute
  *
  * @param eZContentObjectAttribute $objectAttribute
  *
  * @return ngOpenGraphBase
  */
 static function getInstance(eZContentObjectAttribute $objectAttribute)
 {
     $datatypeString = $objectAttribute->attribute('data_type_string');
     $dataTypeHandlers = self::$ogIni->variable('OpenGraph', 'DataTypeHandlers');
     if (array_key_exists($datatypeString, $dataTypeHandlers)) {
         if (class_exists($dataTypeHandlers[$datatypeString])) {
             return new $dataTypeHandlers[$datatypeString]($objectAttribute);
         }
     }
     return new ngOpenGraphBase($objectAttribute);
 }
 protected static function validateConfirmation(eZHTTPTool $http, $base, eZContentObjectAttribute $attribute, $isCollection = false)
 {
     $field = $attributeName = $base . '_attributeconfirmation_' . $attribute->attribute('id');
     $value = $http->postVariable($field, null);
     if (empty($value)) {
         if ((bool) $attribute->attribute('is_required')) {
             $attribute->setValidationError(ezpI18n::tr('extension/attributeconfirmation', 'Input required.'));
             return eZInputValidator::STATE_INVALID;
         } else {
             return eZInputValidator::STATE_ACCEPTED;
         }
     }
     $attributeToConfirm = $attribute->attribute('contentclass_attribute')->attribute(self::FIELD_ATTRIBUTE);
     $attributeToConfirmValue = null;
     $version = $attribute->attribute('object_version');
     $dataMap = $version->attribute('data_map');
     if ($isCollection) {
         if (isset($dataMap[$attributeToConfirm])) {
             $attributeID = $dataMap[$attributeToConfirm]->attribute('id');
             $fields = array_keys($_POST);
             foreach ($fields as $field) {
                 if (preg_match('/^' . $base . '.*' . $attributeID . '$/i', $field) === 1) {
                     $attributeToConfirmValue = $http->postVariable($field, null);
                     break;
                 }
             }
         }
     } else {
         if (isset($dataMap[$attributeToConfirm])) {
             $attributeToConfirmValue = $dataMap[$attributeToConfirm]->attribute('content');
         }
     }
     if (empty($attributeToConfirmValue)) {
         return eZInputValidator::STATE_ACCEPTED;
     }
     if ($attributeToConfirmValue != $value) {
         $attribute->setValidationError(ezpI18n::tr('extension/attributeconfirmation', 'Input does not match.'));
         return eZInputValidator::STATE_INVALID;
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
 /**
  * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
  * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
  * @return array
  */
 public static function getAttributeContent(eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute)
 {
     $selectedOptionsList = array_fill_keys($contentObjectAttribute->content(), true);
     $availableOptionsArray = $contentObjectAttribute->attribute('class_content');
     $finalAvailableOptions = array();
     foreach ($availableOptionsArray['options'] as $availableOption) {
         if (isset($selectedOptionsList[$availableOption['id']])) {
             $finalAvailableOptions[] = array('name' => $availableOption['name'], 'id' => $availableOption['id']);
         }
     }
     return array('content' => $finalAvailableOptions, 'has_rendered_content' => false, 'rendered' => null);
 }
Ejemplo n.º 22
0
 /**
  * (called for each obj attribute)
  */
 public function checkObjectAttribute(array $contentObjectAttribute)
 {
     // we adopt the ez api instead of acting on raw data
     $contentObjectAttribute = new eZContentObjectAttribute($contentObjectAttribute);
     // do not check attributes which do not even contain images
     if ($contentObjectAttribute->attribute('has_content')) {
         if ($this->maxLen > 0) {
             /// @todo check that this is the appropriate way of counting length of db data
             $textCodec = eZTextCodec::instance(false);
             $stringLength = $textCodec->strlen($contentObjectAttribute->attribute('content'));
             if ($stringLength > $this->maxLen) {
                 return array("String longer than {$this->maxLen} chars: {$stringLength}" . $this->postfixErrorMsg($contentObjectAttribute));
             }
         }
     } else {
         if (!$this->nullable) {
             return array("Attribute is null and it should not be" . $this->postfixErrorMsg($contentObjectAttribute));
         }
     }
     return array();
 }
 /**
  * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
  * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
  * @return array
  */
 public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
 {
     $user = eZUser::fetch( $contentObjectAttribute->attribute( "contentobject_id" ) );
     return array(
         'content' => array(
             'id' => $user->attribute( 'id' ),
             'login' => $user->attribute( 'login' ),
             'email' => $user->attribute( 'email' ),
         ),
         'has_rendered_content' => false,
         'rendered' => null,
     );
 }
    /**
     * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
     * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
     * @return array
     */
    public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
    {
        $category =  $contentObjectAttribute->attribute( 'content' );

        return array(
            'content' => array(
                'name' => $category ? $category->attribute( 'name' ) : null,
                'id' => $category ? $category->attribute( 'id' ) : null,
            ),
            'has_rendered_content' => false,
            'rendered' => null,
        );
    }
function normalizeValue($newValue, $currentValue, eZContentObjectAttribute $attribute)
{
    switch ($attribute->attribute('data_type_string')) {
        case 'eztime':
            $parts = explode(':', $newValue);
            if (count($parts) == 2) {
                $parts[] = '00';
                //seconds
                $newValue = implode(':', $parts);
            }
    }
    return $newValue;
}
    /**
     * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
     * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
     * @return array
     */
    public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
    {
        $price = $contentObjectAttribute->attribute( 'content' );

        return array(
            'content' => array(
                'price' => $price->attribute( 'price' ),
                'selected_vat_type' => $price->attribute( 'selected_vat_type' )->attribute( 'id' ),
                'is_vat_included' => (bool)$price->attribute( 'is_vat_included' ),
            ),
            'has_rendered_content' => false,
            'rendered' => null,
        );
    }
Ejemplo n.º 27
0
    /**
     * @param eZContentObjectAttribute $contentObjectAttribute the attribute to serialize
     * @param eZContentClassAttribute $contentClassAttribute the content class of the attribute to serialize
     * @return array
     */
    public static function getAttributeContent( eZContentObjectAttribute $contentObjectAttribute, eZContentClassAttribute $contentClassAttribute )
    {
        $option = $contentObjectAttribute->attribute( 'content' );

        return array(
            'content' => array(
                'name' => $option->attribute( 'name' ),
                'start_value' => $option->attribute( 'start_value' ),
                'stop_value' => $option->attribute( 'stop_value' ),
                'step_value' => $option->attribute( 'step_value' ),
            ),
            'has_rendered_content' => false,
            'rendered' => null,
        );
    }
Ejemplo n.º 28
0
 /**
  * (called for each obj attribute)
  */
 public function checkObjectAttribute(array $contentObjectAttribute)
 {
     // we adopt the ez api instead of acting on raw data
     $contentObjectAttribute = new eZContentObjectAttribute($contentObjectAttribute);
     $handler = $contentObjectAttribute->attribute('content');
     $warnings = array();
     // do not check attributes which do not even contain images
     if ($handler->attribute('is_valid')) {
         // get path to original file
         $original = $handler->attribute('original');
         $filePath = $original['full_path'];
         // check if it is on fs (remember, images are clusterized)
         $file = eZClusterFileHandler::instance($filePath);
         if (!$file->exists()) {
             $warnings[] = array("Image file not found: {$filePath}" . $this->postfixErrorMsg($contentObjectAttribute));
         } else {
             // if it is, check its size as well
             if ($this->maxSize > 0) {
                 $maxSize = $this->maxSize * 1024 * 1024;
                 if ($file->size() > $maxSize) {
                     $warnings[] = "Image bigger than {$maxSize} bytes : " . $file->size() . $this->postfixErrorMsg($contentObjectAttribute);
                 }
             }
         }
         // check if it is in custom table in db
         $image = eZImageFile::fetchByFilepath($contentObjectAttribute->attribute('id'), $filePath, false);
         if (!$image) {
             $warnings[] = "Image not found in ezimagefile table: {$filePath}" . $this->postfixErrorMsg($contentObjectAttribute);
         }
     } else {
         if (!$this->nullable) {
             $warnings[] = "Attribute is null and it should not be" . $this->postfixErrorMsg($contentObjectAttribute);
         }
         // q: are these old images possibly tied to older versions of the content ?
         /*$db = eZDB::instance();
           $count = $db->arrayQuery('select count(*) as leftovers from ezimagefile where contentobject_attribute_id='.$contentObjectAttribute->attribute('id'));
           if($count[0]['leftovers'])
           {
               $warnings[] = "Leftovers in ezimageattribute table" . $this->postfixErrorMsg( $contentObjectAttribute );
           }*/
     }
     return $warnings;
 }
Ejemplo n.º 29
0
 /**
  * Iterates over images referenced in data_text, and adds eZImageFile references
  * @param eZContentObjectAttribute $objectAttribute
  */
 function postStore($objectAttribute)
 {
     $objectAttributeId = $objectAttribute->attribute("id");
     if (($doc = simplexml_load_string($objectAttribute->attribute("data_text"))) === false) {
         return;
     }
     // Creates ezimagefile entries
     foreach ($doc->xpath("//*/@url") as $url) {
         $url = (string) $url;
         if ($url === "") {
             continue;
         }
         eZImageFile::appendFilepath($objectAttributeId, $url, true);
     }
 }
 /**
  * Delete map location data when attribute (version) is removed
  *
  * @param eZContentObjectAttribute $contentObjectAttribute
  * @param int|null $version (Optional, deletes all versions if null)
  */
 function deleteStoredObjectAttribute( $contentObjectAttribute, $version = null )
 {
 	eZGmapLocation::removeById( $contentObjectAttribute->attribute('id'), $version );
 }