当前位置: 首页>>代码示例>>PHP>>正文


PHP eZContentClassAttribute类代码示例

本文整理汇总了PHP中eZContentClassAttribute的典型用法代码示例。如果您正苦于以下问题:PHP eZContentClassAttribute类的具体用法?PHP eZContentClassAttribute怎么用?PHP eZContentClassAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了eZContentClassAttribute类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getFieldName

 public static function getFieldName(eZContentClassAttribute $classAttribute, $subAttribute = null, $context = 'search')
 {
     switch ($classAttribute->attribute('data_type_string')) {
         case 'ezinteger':
             return parent::generateAttributeFieldName($classAttribute, self::getClassAttributeType($classAttribute, null, $context));
             break;
         default:
             break;
     }
 }
开发者ID:OpencontentCoop,项目名称:ocsearchtools,代码行数:10,代码来源:ocsolrdocumentfieldinteger.php

示例2: validateStringHTTPInput

 /**
  * Validates $data with the constraints defined on the class attribute
  *
  * @param $data
  * @param eZContentObjectAttribute $contentObjectAttribute
  * @param eZContentClassAttribute $classAttribute
  *
  * @return int
  */
 function validateStringHTTPInput($data, $contentObjectAttribute, $classAttribute)
 {
     $maxLen = $classAttribute->attribute(self::MAX_LEN_FIELD);
     $textCodec = eZTextCodec::instance(false);
     if ($textCodec->strlen($data) > $maxLen and $maxLen > 0) {
         $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The input text is too long. The maximum number of characters allowed is %1.'), $maxLen);
         return eZInputValidator::STATE_INVALID;
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:19,代码来源:ezstringtype.php

示例3: getFieldName

	public static function getFieldName( eZContentClassAttribute $classAttribute, $subAttribute = null )
    {
        $contentClassAttributeIdentifier = $classAttribute->attribute( 'identifier' );
        if ( $subAttribute != null )
        {
            $suffix = self::getPostFix( $contentClassAttributeIdentifier );
            return 'attr_'.$contentClassAttributeIdentifier.'_'.$subAttribute.$suffix;
        }
        return self::generateAttributeFieldName( $classAttribute, self::getClassAttributeType( $classAttribute ) );
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:10,代码来源:ezfsolrdocumentfieldsolrmetadata.php

示例4: testGetFieldName

 /**
  * test for getFieldName()
  */
 public function testGetFieldName()
 {
     $providerArray = array();
     $ezcca1 = new eZContentClassAttribute(array('identifier' => 'title', 'data_type_string' => 'ezstring'));
     $expected1 = ezfSolrDocumentFieldBase::ATTR_FIELD_PREFIX . 'title_t';
     $providerArray[] = array($expected1, $ezcca1, null);
     // Testing the default subattribute
     $ezcca2 = new eZContentClassAttribute(array('identifier' => 'dummy', 'data_type_string' => 'dummy_example'));
     $expected2 = ezfSolrDocumentFieldBase::ATTR_FIELD_PREFIX . 'dummy_t';
     $providerArray[] = array($expected2, $ezcca2, null);
     //Testing the class/attribute/subattribute syntax, with the secondary subattribute of
     //  the 'dummy' datatype
     $ezcca3 = $ezcca2;
     $expected3 = ezfSolrDocumentFieldBase::SUBATTR_FIELD_PREFIX . 'dummy-subattribute1_i';
     $options3 = 'subattribute1';
     $providerArray[] = array($expected3, $ezcca3, $options3);
     //Testing the class/attribute/subattribute syntax, with the default subattribute of
     //  the 'dummy' datatype
     $ezcca5 = $ezcca2;
     $expected5 = ezfSolrDocumentFieldBase::ATTR_FIELD_PREFIX . 'dummy_t';
     $options5 = 'subattribute2';
     $providerArray[] = array($expected5, $ezcca5, $options5);
     //Testing the class/attribute/subattribute syntax for ezobjectrelation attributes
     $time4 = time();
     $image4 = new ezpObject("image", 2);
     $image4->name = __METHOD__ . $time4;
     $image4->caption = __METHOD__ . $time4;
     $imageId4 = $image4->publish();
     $srcObjId4 = 123456;
     $ezcca4 = new eZContentClassAttribute(array('id' => $time4, 'identifier' => 'image', 'data_type_string' => 'ezobjectrelation', 'data_int' => $imageId4));
     $ezcca4->store();
     //Create entry in ezcontentobject_link
     $q4 = "INSERT INTO ezcontentobject_link VALUES( {$ezcca4->attribute('id')}, {$srcObjId4}, 1, 123456, 0, 8, {$imageId4} );";
     eZDB::instance()->query($q4);
     $expected4 = ezfSolrDocumentFieldBase::SUBATTR_FIELD_PREFIX . 'image-name_t';
     $options4 = 'name';
     $providerArray[] = array($expected4, $ezcca4, $options4);
     // Testing the class/attribute/subattribute syntax for ezobjectrelation attributes, with a subattribute of
     // a different type than the default Solr type :
     $ezcca5 = $ezcca4;
     $expected5 = ezfSolrDocumentFieldBase::SUBATTR_FIELD_PREFIX . 'image-caption_t';
     $options5 = 'caption';
     $providerArray[] = array($expected5, $ezcca5, $options5);
     // perform actual testing
     foreach ($providerArray as $input) {
         $expected = $input[0];
         $contentClassAttribute = $input[1];
         $options = $input[2];
         self::assertEquals($expected, ezfSolrDocumentFieldBase::getFieldName($contentClassAttribute, $options));
     }
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:54,代码来源:ezfsolrdocumentfieldbase_test.php

示例5: getFieldName

 public static function getFieldName(eZContentClassAttribute $classAttribute, $subAttribute = null, $context = 'search')
 {
     switch ($classAttribute->attribute('data_type_string')) {
         case 'ezmatrix':
             if ($subAttribute and $subAttribute !== '') {
                 // A subattribute was passed
                 return parent::generateSubattributeFieldName($classAttribute, $subAttribute, self::DEFAULT_SUBATTRIBUTE_TYPE);
             } else {
                 // return the default field name here.
                 return parent::generateAttributeFieldName($classAttribute, self::getClassAttributeType($classAttribute, null, $context));
             }
             break;
     }
     return null;
 }
开发者ID:OpencontentCoop,项目名称:ocsearchtools,代码行数:15,代码来源:ocsolrdocumentfieldmatrix.php

示例6: getAttributeData

    /**
     * @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;
        }
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:36,代码来源:ezfsolrstorage.php

示例7: buildFetch

 public function buildFetch()
 {
     $filters = array();
     foreach ($this->requestFields as $key => $value) {
         if (strpos($key, OCClassSearchFormAttributeField::NAME_PREFIX) !== false) {
             $contentClassAttributeID = str_replace(OCClassSearchFormAttributeField::NAME_PREFIX, '', $key);
             $contentClassAttribute = eZContentClassAttribute::fetch($contentClassAttributeID);
             if ($contentClassAttribute instanceof eZContentClassAttribute) {
                 $field = OCClassSearchFormAttributeField::instance($contentClassAttribute);
                 $field->buildFetch($this, $key, $value, $filters);
                 $this->isFetch = true;
             }
         } elseif (in_array($key, OCFacetNavgationHelper::$allowedUserParamters)) {
             if (!empty($value)) {
                 $this->currentParameters[$key] = $value;
                 $this->isFetch = true;
             }
         } elseif ($key == 'class_id') {
             $this->currentParameters[$key] = $value;
             $this->addFetchField(array('name' => ezpI18n::tr('extension/ezfind/facets', 'Content type'), 'value' => eZContentClass::fetch($value)->attribute('name'), 'remove_view_parameters' => $this->getViewParametersString(array($key))));
             $this->isFetch = true;
         } elseif ($key == 'publish_date') {
             $publishedField = new OCClassSearchFormPublishedField($this->requestFields['class_id']);
             $publishedField->buildFetch($this, $value, $filters);
             $this->isFetch = true;
         } elseif ($key == 'query') {
             $queryField = new OCClassSearchFormQueryField();
             $queryField->buildFetch($this, $value);
             $this->searchText = $queryField->queryText();
             $this->isFetch = true;
         }
     }
     $this->currentParameters['filter'] = $filters;
     return $this->currentParameters;
 }
开发者ID:OpencontentCoop,项目名称:ocsearchtools,代码行数:35,代码来源:occlasssearchformfetcher.php

示例8: testAttributeIsTranslatable

 /**
  * #15898: Cannot translate a user content object
  * Make sure datatype translation flag is honored.
  *
  * @link http://issues.ez.no/15898
  */
 public function testAttributeIsTranslatable()
 {
     $stringAttribute = eZContentClassAttribute::create(0, 'ezstring');
     $this->assertEquals(1, $stringAttribute->attribute('can_translate'), 'ezstring class attribute should have been translatable by default');
     $stringAttribute = eZContentClassAttribute::create(0, 'ezuser');
     $this->assertEquals(0, $stringAttribute->attribute('can_translate'), 'ezuser class attribute should NOT have been translatable by default');
 }
开发者ID:nfrp,项目名称:ezpublish,代码行数:13,代码来源:ezcontentclassattribute_test.php

示例9: validateClassAttributeHTTPInput

 function validateClassAttributeHTTPInput($http, $base, $classAttribute)
 {
     //checking if the recaptcha key is set up if recaptcha is enabled
     $ini = eZINI::instance('ezcomments.ini');
     $fields = $ini->variable('FormSettings', 'AvailableFields');
     if (in_array('recaptcha', $fields)) {
         $publicKey = $ini->variable('RecaptchaSetting', 'PublicKey');
         $privateKey = $ini->variable('RecaptchaSetting', 'PrivateKey');
         if ($publicKey === '' || $privateKey === '') {
             eZDebug::writeNotice('reCAPTCHA key is not set up. For help please visit http://projects.ez.no/ezcomments', __METHOD__);
         }
     }
     if ($http->hasPostVariable('StoreButton') || $http->hasPostVariable('ApplyButton')) {
         // find the class and count how many Comments dattype
         $cond = array('contentclass_id' => $classAttribute->attribute('contentclass_id'), 'version' => eZContentClass::VERSION_STATUS_TEMPORARY, 'data_type_string' => $classAttribute->attribute('data_type_string'));
         $classAttributeList = eZContentClassAttribute::fetchFilteredList($cond);
         // if there is more than 1 comment attribute, return it as INVALID
         if (!is_null($classAttributeList) && count($classAttributeList) > 1) {
             if ($classAttributeList[0]->attribute('id') == $classAttribute->attribute('id')) {
                 eZDebug::writeNotice('There are more than 1 comment attribute in the class.', __METHOD__);
                 return eZInputValidator::STATE_INVALID;
             }
         }
     }
     return eZInputValidator::STATE_ACCEPTED;
 }
开发者ID:jordanmanning,项目名称:ezpublish,代码行数:26,代码来源:ezcomcommentstype.php

示例10: classAttributeName

 function classAttributeName()
 {
     if ($this->ClassAttributeName === null) {
         $contentClassAttribute = eZContentClassAttribute::fetch($this->attribute('contentclass_attribute_id'));
         $this->ClassAttributeName = $contentClassAttribute->attribute('name');
     }
     return $this->ClassAttributeName;
 }
开发者ID:legende91,项目名称:ez,代码行数:8,代码来源:ezwaituntildatevalue.php

示例11: validateIntegerHTTPInput

 /**
  * Validates $data with the constraints defined on the class attribute
  *
  * @param $data
  * @param eZContentObjectAttribute $contentObjectAttribute
  * @param eZContentClassAttribute $classAttribute
  *
  * @return int
  */
 function validateIntegerHTTPInput($data, $contentObjectAttribute, $classAttribute)
 {
     $min = $classAttribute->attribute(self::MIN_VALUE_FIELD);
     $max = $classAttribute->attribute(self::MAX_VALUE_FIELD);
     $input_state = $classAttribute->attribute(self::INPUT_STATE_FIELD);
     switch ($input_state) {
         case self::NO_MIN_MAX_VALUE:
             $this->IntegerValidator->setRange(false, false);
             $state = $this->IntegerValidator->validate($data);
             if ($state === eZInputValidator::STATE_INVALID || $state === eZInputValidator::STATE_INTERMEDIATE) {
                 $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The input is not a valid integer.'));
             } else {
                 return $state;
             }
             break;
         case self::HAS_MIN_VALUE:
             $this->IntegerValidator->setRange($min, false);
             $state = $this->IntegerValidator->validate($data);
             if ($state === eZInputValidator::STATE_ACCEPTED) {
                 return eZInputValidator::STATE_ACCEPTED;
             } else {
                 $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The number must be greater than %1'), $min);
             }
             break;
         case self::HAS_MAX_VALUE:
             $this->IntegerValidator->setRange(false, $max);
             $state = $this->IntegerValidator->validate($data);
             if ($state === 1) {
                 return eZInputValidator::STATE_ACCEPTED;
             } else {
                 $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The number must be less than %1'), $max);
             }
             break;
         case self::HAS_MIN_MAX_VALUE:
             $this->IntegerValidator->setRange($min, $max);
             $state = $this->IntegerValidator->validate($data);
             if ($state === 1) {
                 return eZInputValidator::STATE_ACCEPTED;
             } else {
                 $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The number is not within the required range %1 - %2'), $min, $max);
             }
             break;
     }
     return eZInputValidator::STATE_INVALID;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:54,代码来源:ezintegertype.php

示例12: validateFloatHTTPInput

 /**
  * Validates $data with the constraints defined on the class attribute
  *
  * @param $data
  * @param eZContentObjectAttribute $contentObjectAttribute
  * @param eZContentClassAttribute $classAttribute
  *
  * @return int
  */
 function validateFloatHTTPInput($data, $contentObjectAttribute, $classAttribute)
 {
     $min = $classAttribute->attribute(self::MIN_FIELD);
     $max = $classAttribute->attribute(self::MAX_FIELD);
     $inputState = $classAttribute->attribute(self::INPUT_STATE_FIELD);
     switch ($inputState) {
         case self::NO_MIN_MAX_VALUE:
             $state = $this->FloatValidator->validate($data);
             if ($state === eZInputValidator::STATE_ACCEPTED) {
                 return eZInputValidator::STATE_ACCEPTED;
             } else {
                 $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The given input is not a floating point number.'));
             }
             break;
         case self::HAS_MIN_VALUE:
             $this->FloatValidator->setRange($min, false);
             $state = $this->FloatValidator->validate($data);
             if ($state === eZInputValidator::STATE_ACCEPTED) {
                 return eZInputValidator::STATE_ACCEPTED;
             } else {
                 $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The input must be greater than %1'), $min);
             }
             break;
         case self::HAS_MAX_VALUE:
             $this->FloatValidator->setRange(false, $max);
             $state = $this->FloatValidator->validate($data);
             if ($state === eZInputValidator::STATE_ACCEPTED) {
                 return eZInputValidator::STATE_ACCEPTED;
             } else {
                 $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The input must be less than %1'), $max);
             }
             break;
         case self::HAS_MIN_MAX_VALUE:
             $this->FloatValidator->setRange($min, $max);
             $state = $this->FloatValidator->validate($data);
             if ($state === eZInputValidator::STATE_ACCEPTED) {
                 return eZInputValidator::STATE_ACCEPTED;
             } else {
                 $contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'The input is not in defined range %1 - %2'), $min, $max);
             }
             break;
     }
     return eZInputValidator::STATE_INVALID;
 }
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:53,代码来源:ezfloattype.php

示例13: add

 /**
  * Adds new content class attribute to initialized class.
  *
  * @param string $name
  * @param string $identifier
  * @param string $type
  * @return eZContentClassAttribute
  */
 public function add($name = 'Test attribute', $identifer = 'test_attribute', $type = 'ezstring')
 {
     $classAttribute = eZContentClassAttribute::create($this->id, $type, array(), $this->language);
     $classAttribute->setName($name, $this->language);
     $dataType = $classAttribute->dataType();
     $dataType->initializeClassAttribute($classAttribute);
     $classAttribute->setAttribute('identifier', $identifer);
     $classAttribute->store();
     return $classAttribute;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:18,代码来源:class.php

示例14: testMultipleCallsToCalculatedPrice

 /**
  * Test scenario for issue #13712: Multiprice datatype shows wrong price after multiple calls in template
  *
  * Test Outline
  * ------------
  * 1. Create a euro currency
  * 2. Create a VAT type of 10 %
  * 3. Create a content class with an attribute of the datatype ezmultiprice
  * 4. Create a content object of this content class and set a custom price ex. VAT with the VAT type of 10% that we created
  * 5. Subsequently retrieve the attribute 'inc_vat_price_list'
  *
  * @result: the returned eZMultiPriceData instances differ on each call, their values are increased each time with VAT
  * @expected: the returned eZMultiPriceData instances are equal
  * @link http://issues.ez.no/13712
  * @group issue_13712
  */
 public function testMultipleCallsToCalculatedPrice()
 {
     $currencyCode = 'EUR';
     // create currency
     $currencyParams = array('code' => $currencyCode, 'symbol' => false, 'locale' => 'eng-GB', 'custom_rate_value' => 0, 'rate_factor' => 1);
     $currency = eZCurrencyData::create($currencyCode, '€', 'eng-GB', 0, 0, 1);
     $currency->store();
     $currencyID = $currency->attribute('id');
     $this->assertInternalType('integer', $currencyID);
     // create VAT type
     $row = array('name' => 'Test', 'percentage' => 10.0);
     $vatType = new eZVatType($row);
     $vatType->store();
     $vatTypeID = $vatType->attribute('id');
     $this->assertInternalType('integer', $vatTypeID);
     $class = eZContentClass::create(false, array('name' => 'eZMultiPrice::testMultipleCallsToCalculatedPrice', 'identifier' => 'ezmultiprice_test'));
     $class->store();
     $classID = $class->attribute('id');
     $this->assertInternalType('integer', $classID);
     $attributes = $class->fetchAttributes();
     // add class attributes
     $newAttribute = eZContentClassAttribute::create($classID, 'ezmultiprice', array('name' => 'Test', 'identifier' => 'test'));
     $dataType = $newAttribute->dataType();
     $dataType->initializeClassAttribute($newAttribute);
     $newAttribute->setAttribute(eZMultiPriceType::DEFAULT_CURRENCY_CODE_FIELD, $currencyCode);
     $newAttribute->setAttribute(eZMultiPriceType::VAT_ID_FIELD, $vatTypeID);
     $newAttribute->store();
     $attributes[] = $newAttribute;
     $class->storeDefined($attributes);
     $contentObject = $class->instantiate();
     $version = $contentObject->currentVersion();
     $dataMap = $version->dataMap();
     $multiPrice = $dataMap['test']->content();
     $multiPrice->setAttribute('selected_vat_type', $vatTypeID);
     $multiPrice->setAttribute('is_vat_included', eZMultiPriceType::EXCLUDED_VAT);
     $multiPrice->setCustomPrice($currencyCode, 100);
     $multiPrice->updateAutoPriceList();
     $dataMap['test']->setContent($multiPrice);
     $dataMap['test']->setAttribute('data_text', $vatTypeID . ',' . eZMultiPriceType::EXCLUDED_VAT);
     $dataMap['test']->store();
     // test values
     $firstIncVatPriceList = $multiPrice->attribute('inc_vat_price_list');
     $this->assertArrayHasKey('EUR', $firstIncVatPriceList);
     $firstCallValue = $firstIncVatPriceList['EUR']->attribute('value');
     $secondIncVatPriceList = $multiPrice->attribute('inc_vat_price_list');
     $this->assertArrayHasKey('EUR', $secondIncVatPriceList);
     $secondCallValue = $secondIncVatPriceList['EUR']->attribute('value');
     $this->assertEquals($firstCallValue, $secondCallValue);
     $thirdIncVatPriceList = $multiPrice->attribute('inc_vat_price_list');
     $this->assertArrayHasKey('EUR', $thirdIncVatPriceList);
     $thirdCallValue = $thirdIncVatPriceList['EUR']->attribute('value');
     $this->assertEquals($firstCallValue, $thirdCallValue);
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:69,代码来源:ezmultipricetype_regression.php

示例15: fetchContentClassImageAttributes

 /**
  * Fetch content class attributes by dataTypestring
  *
  * @param array $imageDataTypeStrings array of image datatype strings. ie: array( 'ezimage' )
  * @return array Array of content class attributes, empty array if not
  * @static
  */
 static function fetchContentClassImageAttributes($imageDataTypeStrings = false)
 {
     $contentClassImageAttributes = array();
     if (!is_array($imageDataTypeStrings)) {
         // Default datatypes to create image alias variations
         $imageDataTypeStrings = eZINI::instance('bcimagealias.ini')->variable('BCImageAliasSettings', 'ImageDataTypeStringList');
     }
     foreach ($imageDataTypeStrings as $dataTypeString) {
         $contentClassImageAttributes = array_merge($contentClassImageAttributes, eZContentClassAttribute::fetchList(true, array('data_type' => $dataTypeString)));
     }
     return $contentClassImageAttributes;
 }
开发者ID:philandteds,项目名称:bcimagealias,代码行数:19,代码来源:bcimagealias.php


注:本文中的eZContentClassAttribute类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。