本文整理汇总了PHP中eZContentObjectAttribute::contentClassAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectAttribute::contentClassAttribute方法的具体用法?PHP eZContentObjectAttribute::contentClassAttribute怎么用?PHP eZContentObjectAttribute::contentClassAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectAttribute
的用法示例。
在下文中一共展示了eZContentObjectAttribute::contentClassAttribute方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateObjectAttribute
/**
* Validates the data structure and returns true if it is valid for this datatype
*
* @param eZContentObjectAttribute $contentObjectAttribute
* @param string $idString
* @param string $keywordString
* @param string $parentString
* @param string $localeString
*
* @return bool
*/
private function validateObjectAttribute($contentObjectAttribute, $idString, $keywordString, $parentString, $localeString)
{
$classAttribute = $contentObjectAttribute->contentClassAttribute();
// we cannot use empty() here as there can be cases where $parentString or $idString can be "0",
// which evaluates to false with empty(), which is wrong for our use case
if (strlen($keywordString) == 0 && strlen($parentString) == 0 && strlen($idString) == 0 && strlen($localeString) == 0) {
if ($contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/eztags/datatypes', 'At least one tag is required to be added.'));
return eZInputValidator::STATE_INVALID;
}
} else {
if (strlen($keywordString) == 0 || strlen($parentString) == 0 || strlen($idString) == 0 || strlen($localeString) == 0) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/eztags/datatypes', 'Attribute contains invalid data.'));
return eZInputValidator::STATE_INVALID;
} else {
$idArray = explode('|#', $idString);
$keywordArray = explode('|#', $keywordString);
$parentArray = explode('|#', $parentString);
$localeArray = explode('|#', $localeString);
if (count($keywordArray) != count($idArray) || count($parentArray) != count($idArray) || count($localeArray) != count($idArray)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/eztags/datatypes', 'Attribute contains invalid data.'));
return eZInputValidator::STATE_INVALID;
}
$maxTags = (int) $classAttribute->attribute(self::MAX_TAGS_FIELD);
if ($maxTags > 0 && (count($idArray) > $maxTags || count($keywordArray) > $maxTags || count($parentArray) > $maxTags || count($localeArray) > $maxTags)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/eztags/datatypes', 'Up to %1 tags are allowed to be added.', null, array('%1' => $maxTags)));
return eZInputValidator::STATE_INVALID;
}
}
}
return eZInputValidator::STATE_ACCEPTED;
}
示例2: validateObjectAttributeHTTPInput
/**
* Validate post data, these are then used by
* {@link eZGmapLocationType::fetchObjectAttributeHTTPInput()}
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
*/
function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
{
$latitude = '';
$longitude = '';
$classAttribute = $contentObjectAttribute->contentClassAttribute();
if ( $http->hasPostVariable( $base . '_data_gmaplocation_latitude_' . $contentObjectAttribute->attribute( 'id' ) ) &&
$http->hasPostVariable( $base . '_data_gmaplocation_longitude_' . $contentObjectAttribute->attribute( 'id' ) ) )
{
$latitude = $http->postVariable( $base . '_data_gmaplocation_latitude_' . $contentObjectAttribute->attribute( 'id' ) );
$longitude = $http->postVariable( $base . '_data_gmaplocation_longitude_' . $contentObjectAttribute->attribute( 'id' ) );
}
if ( $latitude === '' || $longitude === '' )
{
if ( !$classAttribute->attribute( 'is_information_collector' ) && $contentObjectAttribute->validateIsRequired() )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( 'extension/ezgmaplocation/datatype',
'Missing Latitude/Longitude input.' ) );
return eZInputValidator::STATE_INVALID;
}
}
else if ( !is_numeric( $latitude ) || !is_numeric( $longitude ) )
{
$contentObjectAttribute->setValidationError( ezpI18n::tr( 'extension/ezgmaplocation/datatype',
'Invalid Latitude/Longitude input.' ) );
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
}
示例3: validateObjectAttributeHTTPInput
/**
* Validates the input and returns the validity status code
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
*
* @return int
*/
function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
/** @var eZContentClassAttribute $classAttribute */
$classAttribute = $contentObjectAttribute->contentClassAttribute();
if ($http->hasPostVariable($base . self::OIB_VARIABLE . $contentObjectAttribute->attribute("id"))) {
$data = trim($http->postVariable($base . self::OIB_VARIABLE . $contentObjectAttribute->attribute("id")));
if (empty($data)) {
if (!$classAttribute->attribute("is_information_collector") && $contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr("kernel/classes/datatypes", "Input required."));
return eZInputValidator::STATE_INVALID;
}
} else {
if (!$this->validateOib($data)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr("extension/ngoib/datatypes", "Personal identification number is not valid."));
return eZInputValidator::STATE_INVALID;
}
}
} else {
if (!$classAttribute->attribute("is_information_collector") && $contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr("kernel/classes/datatypes", "Input required."));
return eZInputValidator::STATE_INVALID;
}
}
return eZInputValidator::STATE_ACCEPTED;
}
示例4: getPermissionArray
/**
* Returns the array with permission info for linking tags to current content object attribute
*
* @return array
*/
private function getPermissionArray()
{
$permissionArray = array('can_add' => false, 'subtree_limit' => $this->Attribute->contentClassAttribute()->attribute(eZTagsType::SUBTREE_LIMIT_FIELD), 'allowed_locations' => array(), 'allowed_locations_tags' => false);
$userLimitations = eZTagsTemplateFunctions::getSimplifiedUserAccess('tags', 'add');
if ($userLimitations['accessWord'] == 'no') {
return $permissionArray;
}
$userLimitations = isset($userLimitations['simplifiedLimitations']['Tag']) ? $userLimitations['simplifiedLimitations']['Tag'] : array();
$limitTag = eZTagsObject::fetchWithMainTranslation($permissionArray['subtree_limit']);
if (empty($userLimitations)) {
if ($permissionArray['subtree_limit'] == 0 || $limitTag instanceof eZTagsObject) {
$permissionArray['allowed_locations'] = array($permissionArray['subtree_limit']);
if ($limitTag instanceof eZTagsObject) {
$permissionArray['allowed_locations_tags'] = array($limitTag);
}
}
} else {
if ($permissionArray['subtree_limit'] == 0) {
$permissionArray['allowed_locations_tags'] = array();
/** @var eZTagsObject[] $userLimitations */
$userLimitations = eZTagsObject::fetchList(array('id' => array($userLimitations)), null, null, true);
if (is_array($userLimitations) && !empty($userLimitations)) {
foreach ($userLimitations as $limitation) {
$permissionArray['allowed_locations'][] = $limitation->attribute('id');
$permissionArray['allowed_locations_tags'][] = $limitation;
}
}
} else {
if ($limitTag instanceof eZTagsObject) {
/** @var eZTagsObject[] $userLimitations */
$userLimitations = eZTagsObject::fetchList(array('id' => array($userLimitations)), null, null, true);
if (is_array($userLimitations) && !empty($userLimitations)) {
$pathString = $limitTag->attribute('path_string');
foreach ($userLimitations as $limitation) {
if (strpos($pathString, '/' . $limitation->attribute('id') . '/') !== false) {
$permissionArray['allowed_locations'] = array($permissionArray['subtree_limit']);
$permissionArray['allowed_locations_tags'] = array($limitTag);
break;
}
}
}
}
}
}
if (!empty($permissionArray['allowed_locations'])) {
$permissionArray['can_add'] = true;
}
return $permissionArray;
}
示例5: validateObjectAttributeHTTPInput
/**
* Validates input on content object level
* Checks if entered color code is a valid color code
* @param eZHTTPTool $http
* @param string $base POST variable name prefix (Always "ContentObjectAttribute")
* @param eZContentObjectAttribute $contentObjectAttribute
* @return eZInputValidator::STATE_ACCEPTED|eZInputValidator::STATE_INVALID|eZInputValidator::STATE_INTERMEDIATE
*/
public function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
$classAttribute = $contentObjectAttribute->contentClassAttribute();
if ($http->hasPostVariable($base . self::CONTENT_FIELD_VARIABLE . $contentObjectAttribute->attribute("id"))) {
$data = $http->postVariable($base . self::CONTENT_FIELD_VARIABLE . $contentObjectAttribute->attribute("id"));
$data = str_replace(" ", "", $data);
$pattern = '/^#[a-f0-9]{6}$/i';
if ($data == "") {
return eZInputValidator::STATE_ACCEPTED;
} elseif (strlen($data) > 7 || preg_match($pattern, $data, $matches) == 0) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Invalid input'));
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
}
return eZInputValidator::STATE_ACCEPTED;
}
示例6: validateObjectAttributeHTTPInput
/**
* Validates the input and returns true if the input was valid for this datatype
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
* @return bool
*/
function validateObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
$classAttribute = $contentObjectAttribute->contentClassAttribute();
if ($http->hasPostVariable($base . '_eztags_data_text_' . $contentObjectAttribute->attribute('id')) && $http->hasPostVariable($base . '_eztags_data_text2_' . $contentObjectAttribute->attribute('id')) && $http->hasPostVariable($base . '_eztags_data_text3_' . $contentObjectAttribute->attribute('id'))) {
$data = trim($http->postVariable($base . '_eztags_data_text_' . $contentObjectAttribute->attribute('id')));
$data2 = trim($http->postVariable($base . '_eztags_data_text2_' . $contentObjectAttribute->attribute('id')));
$data3 = trim($http->postVariable($base . '_eztags_data_text3_' . $contentObjectAttribute->attribute('id')));
if (strlen($data) == 0 && strlen($data2) == 0 && strlen($data3) == 0) {
if ($contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
return eZInputValidator::STATE_INVALID;
}
} else {
if (!(strlen($data) > 0 && strlen($data2) > 0 && strlen($data3) > 0)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
return eZInputValidator::STATE_INVALID;
} else {
$dataArray = explode('|#', $data);
$data2Array = explode('|#', $data2);
$data3Array = explode('|#', $data3);
if (count($data2Array) != count($dataArray) || count($data3Array) != count($dataArray)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
return eZInputValidator::STATE_INVALID;
}
$maxTags = (int) $classAttribute->attribute(self::MAX_TAGS_FIELD);
if ($maxTags > 0 && (count($dataArray) > $maxTags || count($data2Array) > $maxTags || count($data3Array) > $maxTags)) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
return eZInputValidator::STATE_INVALID;
}
}
}
} else {
if ($contentObjectAttribute->validateIsRequired()) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('kernel/classes/datatypes', 'Input required.'));
return eZInputValidator::STATE_INVALID;
}
}
return eZInputValidator::STATE_ACCEPTED;
}
示例7: initializeObjectAttribute
/**
* Initializes object attribute before displaying edit template
* Can be useful to define default values. Default values can be defined in class attributes
*
* @param eZContentObjectAttribute $contentObjectAttribute Object attribute for the new version
* @param int $currentVersion Version number. NULL if this is the first version
* @param eZContentObjectAttribute $originalContentObjectAttribute Object attribute of the previous version
* @see eZDataType::initializeObjectAttribute()
*/
public function initializeObjectAttribute($contentObjectAttribute, $currentVersion, $originalContentObjectAttribute)
{
// Sets default values on first version
if ($currentVersion === null) {
$contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
$contentObjectAttribute->setAttribute('data_int', $contentClassAttribute->attribute(self::CLASSATTRIBUTE_COMMENTS_ACTIVATED_DEFAULT_FIELD));
}
}
示例8: initializeObjectAttribute
/**
* Initialize contentobject attribute content
*
* @param eZContentObjectAttribute $contentObjectAttribute
* @param integer $currentVersion
* @param eZContentObjectAttribute $originalContentObjectAttribute
*/
function initializeObjectAttribute($contentObjectAttribute, $currentVersion, $originalContentObjectAttribute)
{
if ($currentVersion != false) {
$contentObjectID = $contentObjectAttribute->attribute('contentobject_id');
$originalContentObjectID = $originalContentObjectAttribute->attribute('contentobject_id');
if ($contentObjectID != $originalContentObjectID) {
$page = $originalContentObjectAttribute->content();
$clonedPage = clone $page;
$contentObjectAttribute->setContent($clonedPage);
$contentObjectAttribute->store();
} else {
$dataText = $originalContentObjectAttribute->attribute('data_text');
$contentObjectAttribute->setAttribute('data_text', $dataText);
}
} else {
$contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
$defaultLayout = $contentClassAttribute->attribute("data_text1");
$zoneINI = eZINI::instance('zone.ini');
$page = new eZPage();
$zones = array();
if ($defaultLayout !== '') {
if ($zoneINI->hasVariable($defaultLayout, 'Zones')) {
$zones = $zoneINI->variable($defaultLayout, 'Zones');
}
$page->setAttribute('zone_layout', $defaultLayout);
foreach ($zones as $zoneIdentifier) {
$newZone = $page->addZone(new eZPageZone());
$newZone->setAttribute('id', md5(mt_rand() . microtime() . $page->getZoneCount()));
$newZone->setAttribute('zone_identifier', $zoneIdentifier);
$newZone->setAttribute('action', 'add');
}
} else {
$allowedZones = array();
if ($zoneINI->hasGroup('General') && $zoneINI->hasVariable('General', 'AllowedTypes')) {
$allowedZones = $zoneINI->variable('General', 'AllowedTypes');
}
$class = eZContentClass::fetch($contentClassAttribute->attribute('contentclass_id'));
foreach ($allowedZones as $allowedZone) {
$availableForClasses = array();
if ($zoneINI->hasVariable($allowedZone, 'AvailableForClasses')) {
$availableForClasses = $zoneINI->variable($allowedZone, 'AvailableForClasses');
}
if (in_array($class->attribute('identifier'), $availableForClasses)) {
if ($zoneINI->hasVariable($allowedZone, 'Zones')) {
$zones = $zoneINI->variable($allowedZone, 'Zones');
}
$page->setAttribute('zone_layout', $allowedZone);
foreach ($zones as $zoneIdentifier) {
$newZone = $page->addZone(new eZPageZone());
$newZone->setAttribute('id', md5(mt_rand() . microtime() . $page->getZoneCount()));
$newZone->setAttribute('zone_identifier', $zoneIdentifier);
$newZone->setAttribute('action', 'add');
}
break;
} else {
continue;
}
}
}
$contentObjectAttribute->setContent($page);
}
}
示例9: store
/**
* Stores the tags to database
*
* @param eZContentObjectAttribute $attribute
*/
function store($attribute)
{
if (!($attribute instanceof eZContentObjectAttribute && is_numeric($attribute->attribute('id')))) {
return;
}
$attributeID = $attribute->attribute('id');
$attributeVersion = $attribute->attribute('version');
$objectID = $attribute->attribute('contentobject_id');
$db = eZDB::instance();
$currentTime = time();
//get existing tags for object attribute
$existingTagIDs = array();
$existingTags = $db->arrayQuery("SELECT DISTINCT keyword_id FROM eztags_attribute_link WHERE objectattribute_id = {$attributeID} AND objectattribute_version = {$attributeVersion}");
if (is_array($existingTags)) {
foreach ($existingTags as $t) {
$existingTagIDs[] = (int) $t['keyword_id'];
}
}
//get tags to delete from object attribute
$tagsToDelete = array();
$tempIDArray = array();
// if for some reason already existing tags are added with ID = 0 with fromString
// check to see if they really exist, so we don't delete them by mistake
foreach (array_keys($this->IDArray) as $key) {
if ($this->IDArray[$key] == 0) {
$existing = eZTagsObject::fetchList(array('keyword' => array('like', trim($this->KeywordArray[$key])), 'parent_id' => $this->ParentArray[$key]));
if (is_array($existing) && !empty($existing)) {
$tempIDArray[] = $existing[0]->attribute('id');
}
} else {
$tempIDArray[] = $this->IDArray[$key];
}
}
foreach ($existingTagIDs as $tid) {
if (!in_array($tid, $tempIDArray)) {
$tagsToDelete[] = $tid;
}
}
//and delete them
if (!empty($tagsToDelete)) {
$dbString = $db->generateSQLINStatement($tagsToDelete, 'keyword_id', false, true, 'int');
$db->query("DELETE FROM eztags_attribute_link WHERE {$dbString} AND eztags_attribute_link.objectattribute_id = {$attributeID} AND eztags_attribute_link.objectattribute_version = {$attributeVersion}");
}
//get tags that are new to the object attribute
$newTags = array();
$tagsToLink = array();
foreach (array_keys($this->IDArray) as $key) {
if (!in_array($this->IDArray[$key], $existingTagIDs)) {
if ($this->IDArray[$key] == 0) {
// We won't allow adding tags to the database that already exist, but instead, we link to the existing tags
$existing = eZTagsObject::fetchList(array('keyword' => array('like', trim($this->KeywordArray[$key])), 'parent_id' => $this->ParentArray[$key]));
if (is_array($existing) && !empty($existing)) {
if (!in_array($existing[0]->attribute('id'), $existingTagIDs)) {
$tagsToLink[] = $existing[0]->attribute('id');
}
} else {
$newTags[] = array('id' => $this->IDArray[$key], 'keyword' => $this->KeywordArray[$key], 'parent_id' => $this->ParentArray[$key]);
}
} else {
$tagsToLink[] = $this->IDArray[$key];
}
}
}
//we need to check if user really has access to tags/add, taking into account policy and subtree limits
$attributeSubTreeLimit = $attribute->contentClassAttribute()->attribute(eZTagsType::SUBTREE_LIMIT_FIELD);
$userLimitations = eZTagsTemplateFunctions::getSimplifiedUserAccess('tags', 'add');
if ($userLimitations['accessWord'] != 'no' && !empty($newTags)) {
//first we need to fetch all locations user has access to
$userLimitations = isset($userLimitations['simplifiedLimitations']['Tag']) ? $userLimitations['simplifiedLimitations']['Tag'] : array();
$allowedLocations = self::getAllowedLocations($attributeSubTreeLimit, $userLimitations);
foreach ($newTags as $t) {
//and then for each tag check if user can save in one of the allowed locations
$parentTag = eZTagsObject::fetch($t['parent_id']);
$pathString = $parentTag instanceof eZTagsObject ? $parentTag->attribute('path_string') : '/';
$depth = $parentTag instanceof eZTagsObject ? (int) $parentTag->attribute('depth') + 1 : 1;
if (self::canSave($pathString, $allowedLocations)) {
$db->query("INSERT INTO eztags ( parent_id, main_tag_id, keyword, depth, path_string, modified, remote_id ) VALUES ( " . $t['parent_id'] . ", 0, '" . $db->escapeString(trim($t['keyword'])) . "', {$depth}, '{$pathString}', 0, '" . eZTagsObject::generateRemoteID() . "' )");
$tagID = (int) $db->lastSerialID('eztags', 'id');
$db->query("UPDATE eztags SET path_string = CONCAT(path_string, CAST({$tagID} AS CHAR), '/') WHERE id = {$tagID}");
$pathArray = explode('/', trim($pathString, '/'));
array_push($pathArray, $tagID);
$db->query("UPDATE eztags SET modified = {$currentTime} WHERE " . $db->generateSQLINStatement($pathArray, 'id', false, true, 'int'));
$tagsToLink[] = $tagID;
if (class_exists('ezpEvent', false)) {
ezpEvent::getInstance()->filter('tag/add', array('tag' => eZTagsObject::fetch($tagID), 'parentTag' => $parentTag));
}
}
}
}
//link tags to objects taking into account subtree limit
if (!empty($tagsToLink)) {
$dbString = $db->generateSQLINStatement($tagsToLink, 'id', false, true, 'int');
$tagsToLink = $db->arrayQuery("SELECT id, path_string FROM eztags WHERE {$dbString}");
if (is_array($tagsToLink) && !empty($tagsToLink)) {
foreach ($tagsToLink as $t) {
//.........这里部分代码省略.........
示例10: initializeObjectAttribute
/**
* Initialize contentobject attribute content
*
* @param eZContentObjectAttribute $contentObjectAttribute
* @param integer $currentVersion
* @param eZContentObjectAttribute $originalContentObjectAttribute
*/
function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
{
if ( $currentVersion != false )
{
$contentObjectID = $contentObjectAttribute->attribute( 'contentobject_id' );
$originalContentObjectID = $originalContentObjectAttribute->attribute( 'contentobject_id' );
$languageMask = $contentObjectAttribute->attribute( 'language_id' ) & ~1;
$originalLanguageMask = $originalContentObjectAttribute->attribute( 'language_id' ) & ~1;
// Case when content object was copied or when new translation has been added to the existing one
if ( ( $contentObjectID != $originalContentObjectID )
|| ( ( $contentObjectID == $originalContentObjectID )
&& ( $languageMask != $originalLanguageMask )
&& ( $contentObjectAttribute->attribute( 'can_translate' ) ) ) )
{
$page = $originalContentObjectAttribute->content();
$clonedPage = clone $page;
$contentObjectAttribute->setContent( $clonedPage );
$contentObjectAttribute->store();
}
else
{
$dataText = $originalContentObjectAttribute->attribute( 'data_text' );
$contentObjectAttribute->setAttribute( 'data_text', $dataText );
}
}
else
{
$contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
$defaultLayout = $contentClassAttribute->attribute( self::DEFAULT_ZONE_LAYOUT_FIELD );
$zoneINI = eZINI::instance( 'zone.ini' );
$page = new eZPage();
$zones = array();
if ( $defaultLayout !== '' )
{
if ( $zoneINI->hasVariable( $defaultLayout, 'Zones' ) )
$zones = $zoneINI->variable( $defaultLayout, 'Zones' );
$page->setAttribute( 'zone_layout', $defaultLayout );
foreach ( $zones as $zoneIdentifier )
{
$newZone = $page->addZone( new eZPageZone() );
$newZone->setAttribute( 'id', md5( mt_rand() . microtime() . $page->getZoneCount() ) );
$newZone->setAttribute( 'zone_identifier', $zoneIdentifier );
$newZone->setAttribute( 'action', 'add' );
}
}
else
{
$allowedZones = array();
if ( $zoneINI->hasGroup( 'General' ) && $zoneINI->hasVariable( 'General', 'AllowedTypes' ) )
$allowedZones = $zoneINI->variable( 'General', 'AllowedTypes' );
$class = eZContentClass::fetch( $contentClassAttribute->attribute( 'contentclass_id' ) );
foreach ( $allowedZones as $allowedZone )
{
$availableForClasses = array();
if ( $zoneINI->hasVariable( $allowedZone, 'AvailableForClasses' ) )
$availableForClasses = $zoneINI->variable( $allowedZone, 'AvailableForClasses' );
if ( in_array( $class->attribute( 'identifier' ), $availableForClasses ) )
{
if ( $zoneINI->hasVariable( $allowedZone, 'Zones' ) )
$zones = $zoneINI->variable( $allowedZone, 'Zones' );
$page->setAttribute( 'zone_layout', $allowedZone );
foreach ( $zones as $zoneIdentifier )
{
$newZone = $page->addZone( new eZPageZone() );
$newZone->setAttribute( 'id', md5( mt_rand() . microtime() . $page->getZoneCount() ) );
$newZone->setAttribute( 'zone_identifier', $zoneIdentifier );
$newZone->setAttribute( 'action', 'add' );
}
break;
}
else
continue;
}
}
$contentObjectAttribute->setContent( $page );
}
}
示例11: validateAttributeHTTPInput
/**
* Validates content object attribute HTTP input
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
* @param bool $isInformationCollection
*
* @return int
*/
protected function validateAttributeHTTPInput($http, $base, $contentObjectAttribute, $isInformationCollection = false)
{
/** @var eZContentClassAttribute $classAttribute */
$classAttribute = $contentObjectAttribute->contentClassAttribute();
$classContent = $classAttribute->content();
$infoCollectionCheck = $isInformationCollection == $classAttribute->attribute('is_information_collector');
$isRequired = $contentObjectAttribute->validateIsRequired();
$selectionName = join('_', array($base, 'sckenhancedselection_selection', $contentObjectAttribute->attribute('id')));
if ($http->hasPostVariable($selectionName)) {
$selection = $http->postVariable($selectionName);
if ($infoCollectionCheck) {
switch (true) {
case $isRequired === true && count($selection) == 0:
case $isRequired === true && count($selection) == 1 && empty($selection[0]):
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/enhancedselection2/datatypes', 'This is a required field.'));
return eZInputValidator::STATE_INVALID;
}
}
} else {
if ($infoCollectionCheck && $isRequired && $classContent['is_multiselect'] == 1) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/enhancedselection2/datatypes', 'This is a required field.'));
} else {
if ($infoCollectionCheck && $isRequired) {
$contentObjectAttribute->setValidationError(ezpI18n::tr('extension/enhancedselection2/datatypes', 'No POST variable. Please check your configuration.'));
} else {
return eZInputValidator::STATE_ACCEPTED;
}
}
return eZInputValidator::STATE_INVALID;
}
return eZInputValidator::STATE_ACCEPTED;
}