本文整理匯總了PHP中eZContentClassAttribute::attribute方法的典型用法代碼示例。如果您正苦於以下問題:PHP eZContentClassAttribute::attribute方法的具體用法?PHP eZContentClassAttribute::attribute怎麽用?PHP eZContentClassAttribute::attribute使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類eZContentClassAttribute
的用法示例。
在下文中一共展示了eZContentClassAttribute::attribute方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getValues
/**
* @return array
*/
protected function getValues()
{
if ($this->values === null) {
$this->values = array();
if ($this->contentClassAttribute->attribute('data_type_string') == 'ezobjectrelationlist') {
//$field = ezfSolrDocumentFieldBase::generateSubattributeFieldName( $this->contentClassAttribute, 'name', 'string' );
//@todo errore nella definzione del nome del sottoattributo? verifaicare vedi anche in self::buildFetch
//$field = ezfSolrDocumentFieldBase::$DocumentFieldName->lookupSchemaName(
// ezfSolrDocumentFieldBase::SUBMETA_FIELD_PREFIX . $this->contentClassAttribute->attribute( 'identifier' ) . ezfSolrDocumentFieldBase::SUBATTR_FIELD_SEPARATOR . 'name',
// 'string');
$field = ezfSolrDocumentFieldBase::$DocumentFieldName->lookupSchemaName(ezfSolrDocumentFieldBase::SUBATTR_FIELD_PREFIX . $this->contentClassAttribute->attribute('identifier') . ezfSolrDocumentFieldBase::SUBATTR_FIELD_SEPARATOR . 'name' . ezfSolrDocumentFieldBase::SUBATTR_FIELD_SEPARATOR, 'string');
} else {
$field = ezfSolrDocumentFieldBase::generateAttributeFieldName($this->contentClassAttribute, 'string');
}
$facets = array('field' => $field, 'name' => $this->attributes['name'], 'limit' => 300, 'sort' => 'alpha');
$fetchParameters = array('SearchContentClassID' => array($this->contentClassAttribute->attribute('contentclass_id')), 'Facet' => array($facets));
$data = $this->client->fetchRemoteNavigationList($fetchParameters);
if (isset($data[$this->attributes['name']])) {
$this->values = $data[$this->attributes['name']];
// setto i valori attivi e inietto il conto nel nome
foreach ($this->values as $index => $value) {
$current = (array) $this->attributes['value'];
if (in_array($value['query'], $current)) {
$this->values[$index]['active'] = true;
}
$this->values[$index]['query'] = OCFacetNavgationHelper::encodeValue($this->values[$index]['query']);
if (isset($value['count']) && $value['count'] > 0) {
$this->values[$index]['name'] = $value['name'] . ' (' . $value['count'] . ')';
}
}
}
}
return $this->values;
}
示例2: getTypeForSubattribute
/**
* Identifies, based on the existing object relations, the type of the subattribute.
*
* @param eZContentClassAttribute $classAttribute
* @param $subAttribute
* @param $context
*
* @return bool|string
*/
protected static function getTypeForSubattribute(eZContentClassAttribute $classAttribute, $subAttribute, $context)
{
$q = "SELECT DISTINCT( ezcoa.data_type_string )\n FROM ezcontentobject_link AS ezcol,\n ezcontentobject_attribute AS ezcoa,\n ezcontentclass_attribute AS ezcca,\n ezcontentclass_attribute AS ezcca_target\n WHERE ezcol.contentclassattribute_id={$classAttribute->attribute('id')}\n AND ezcca_target.identifier='{$subAttribute}'\n AND ezcca.data_type_string='{$classAttribute->attribute('data_type_string')}'\n AND ezcca.id=ezcol.contentclassattribute_id\n AND ezcol.to_contentobject_id = ezcoa.contentobject_id\n AND ezcoa.contentclassattribute_id = ezcca_target.id;\n ";
$rows = eZDB::instance()->arrayQuery($q);
if (count($rows) == 0) {
return self::DEFAULT_SUBATTRIBUTE_TYPE;
}
if ($rows and count($rows) > 0) {
if (count($rows) > 1) {
$msg = "Multiple types were found for subattribute '{$subAttribute}' of class attribute #{$classAttribute->attribute('id')} [{$classAttribute->attribute('data_type_string')}]. This means that objects of different content classes were related through class attribute #{$classAttribute->attribute('id')} and had attributes named '{$subAttribute}' of different datatypes : \n" . print_r($rows, true) . " Picking the first one here : {$rows[0]['data_type_string']}";
eZDebug::writeWarning($msg, __METHOD__);
}
return ezfSolrDocumentFieldBase::getClassAttributeType(new eZContentClassAttribute($rows[0]), null, $context);
}
return false;
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
}
示例6: 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;
}
示例7: 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 ) );
}
示例8: 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));
}
}
示例9: 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;
}
示例10: instance
/**
* @param eZContentClassAttribute $attribute
*
* @return OCClassSearchFormAttributeField
*/
public static function instance(eZContentClassAttribute $attribute)
{
if (self::$fieldHandlers === null) {
self::$fieldHandlers = array();
if (eZINI::instance('ocsearchtools.ini')->hasVariable('ClassSearchFormHandlers', 'AttributeHandlers')) {
self::$fieldHandlers = eZINI::instance('ocsearchtools.ini')->variable('ClassSearchFormHandlers', 'AttributeHandlers');
}
}
if (!isset(self::$_instances[$attribute->attribute('id')])) {
if (isset(self::$fieldHandlers[$attribute->attribute('data_type_string')]) && class_exists(self::$fieldHandlers[$attribute->attribute('data_type_string')])) {
$className = self::$fieldHandlers[$attribute->attribute('data_type_string')];
} else {
$className = 'OCClassSearchFormAttributeField';
}
self::$_instances[$attribute->attribute('id')] = new $className($attribute);
}
return self::$_instances[$attribute->attribute('id')];
}
示例11: contentActionList
/**
* Return content action(s) which can be performed on object containing
* the current datatype. Return format is array of arrays with key 'name'
* and 'action'. 'action' can be mapped to url in datatype.ini
*
* @param eZContentClassAttribute $classAttribute
* @return array
*/
function contentActionList($classAttribute)
{
$actionList = array();
if ($classAttribute instanceof eZContentClassAttribute) {
if ($classAttribute->attribute('is_information_collector') == true) {
$actionList[] = array('name' => ezpI18n::tr('kernel/classes/datatypes', 'Send', 'Datatype information collector action'), 'action' => 'ActionCollectInformation');
}
} else {
eZDebug::writeError('$classAttribute isn\'t an object.', __METHOD__);
}
return $actionList;
}
示例12: serializeContentClassAttribute
/**
* Adds the necessary DOM structure to the attribute parameters
*
* @param eZContentClassAttribute $classAttribute
* @param DOMNode $attributeNode
* @param DOMNode $attributeParametersNode
*/
public function serializeContentClassAttribute($classAttribute, $attributeNode, $attributeParametersNode)
{
$dom = $attributeParametersNode->ownerDocument;
$subTreeLimit = (string) $classAttribute->attribute(self::SUBTREE_LIMIT_FIELD);
$domNode = $dom->createElement('subtree-limit');
$domNode->appendChild($dom->createTextNode($subTreeLimit));
$attributeParametersNode->appendChild($domNode);
$maxTags = (string) $classAttribute->attribute(self::MAX_TAGS_FIELD);
$domNode = $dom->createElement('max-tags');
$domNode->appendChild($dom->createTextNode($maxTags));
$attributeParametersNode->appendChild($domNode);
$showDropDown = (int) $classAttribute->attribute(self::SHOW_DROPDOWN_FIELD) > 0 ? 'true' : 'false';
$domNode = $dom->createElement('dropdown');
$domNode->appendChild($dom->createTextNode($showDropDown));
$attributeParametersNode->appendChild($domNode);
$hideRootTag = (int) $classAttribute->attribute(self::HIDE_ROOT_TAG_FIELD) > 0 ? 'true' : 'false';
$domNode = $dom->createElement('hide-root-tag');
$domNode->appendChild($dom->createTextNode($hideRootTag));
$attributeParametersNode->appendChild($domNode);
}
示例13: classAttributeContent
/**
* Returns the content for the class attribute
* Result is an associative array :
* - default_activated (bool)
* - comments_by_location (bool)
*
* @param eZContentClassAttribute $classAttribute
* @return array
* @see eZDataType::classAttributeContent()
*/
public function classAttributeContent($classAttribute)
{
return array('default_activated' => (bool) $classAttribute->attribute(self::CLASSATTRIBUTE_COMMENTS_ACTIVATED_DEFAULT_FIELD));
}
示例14: changeContentObjectAttributeDataTypeString
/**
* @param eZContentClassAttribute $localeAttribute
* @param string $newDataTypeString
*/
protected function changeContentObjectAttributeDataTypeString($localeAttribute, $newDataTypeString)
{
/** @var eZContentObjectAttribute[] $contentAttributes */
$contentAttributes = eZContentObjectAttribute::fetchSameClassAttributeIDList($localeAttribute->attribute('id'), true);
foreach ($contentAttributes as $attribute) {
$attribute->setAttribute('data_type_string', $newDataTypeString);
$attribute->store();
}
}
示例15: fetchClassAttributeHTTPInput
/**
* Fetches all variables inputed on content class level
* return true if fetching of class attributes are successfull, false if not
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentClassAttribute $classAttribute
* @return bool
*/
function fetchClassAttributeHTTPInput($http, $base, $classAttribute)
{
if ($http->hasPostVariable($base . '_ezpage_default_layout_' . $classAttribute->attribute('id'))) {
$defaultLayout = $http->postVariable($base . '_ezpage_default_layout_' . $classAttribute->attribute('id'));
$classAttribute->setAttribute('data_text1', $defaultLayout);
}
return true;
}