本文整理汇总了PHP中eZContentObjectAttribute::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectAttribute::fetch方法的具体用法?PHP eZContentObjectAttribute::fetch怎么用?PHP eZContentObjectAttribute::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectAttribute
的用法示例。
在下文中一共展示了eZContentObjectAttribute::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Constructor
*
* @param int $attributeId
* @param int $version
*
* @throw InvalidArgumentException if the attribute cannot be loaded
*/
public function __construct($attributeId, $version)
{
$this->attribute = eZContentObjectAttribute::fetch($attributeId, $version);
if (!$this->attribute instanceof eZContentObjectAttribute) {
throw new InvalidArgumentException(ezpI18n::tr('extension/ezjscore/ajaxuploader', 'Provided attribute id and version number are invalid.'));
}
}
示例2: __construct
/**
* Constructor
*/
public function __construct()
{
$http = eZHTTPTool::instance();
// @todo change hasVariable to hasPostVariable
if (!$http->hasVariable('key') || !$http->hasVariable('image_id') || !$http->hasVariable('image_version') || !$http->hasVariable('history_version')) {
// @todo manage errors
return;
}
$this->key = $http->variable('key');
$this->image_id = $http->variable('image_id');
$this->image_version = $http->variable('image_version');
$this->history_version = $http->variable('history_version');
// retieve the attribute image
$this->original_image = eZContentObjectAttribute::fetch($this->image_id, $this->image_version)->attribute('content');
if ($this->original_image === null) {
// @todo manage error (the image_id does not match any existing image)
return;
}
// we could store the images in var/xxx/cache/public
$this->working_folder = eZSys::cacheDirectory() . "/public/ezie/" . $this->key;
$this->image_path = $this->working_folder . "/" . $this->history_version . "-" . $this->original_image->attributeFromOriginal('filename');
// check if file exists (that will mean the data sent is correct)
$absolute_image_path = eZSys::rootDir() . "/" . $this->image_path;
$handler = eZClusterFileHandler::instance();
if (!$handler->fileExists($this->image_path)) {
// @todo manage error
return;
}
$this->prepare_region();
}
示例3: rate
/**
* Rate content object attribute id
*
* @param array $args ( 0 => contentobjectattribute_id, 1 => contentobject_version, 2 => rating )
* @return array
*/
public static function rate($args)
{
$ret = array('id' => 0, 'rated' => false, 'already_rated' => false, 'stats' => false);
if (isset($args[0])) {
$ret['id'] = $args[0];
}
if (!isset($args[2]) || !is_numeric($args[0]) || !is_numeric($args[1]) || !is_numeric($args[2]) || $args[2] > 5 || $args[2] < 1) {
return $ret;
}
// Provide extra session protection on 4.1 (not possible on 4.0) by expecting user
// to have an existing session (new session = mostlikely a spammer / hacker trying to manipulate rating)
if (class_exists('eZSession') && eZSession::userHasSessionCookie() !== true) {
return $ret;
}
// Return if parameters are not valid attribute id + version numbers
$contentobjectAttribute = eZContentObjectAttribute::fetch($ret['id'], $args[1]);
if (!$contentobjectAttribute instanceof eZContentObjectAttribute) {
return $ret;
}
// Return if attribute is not a rating attribute
if ($contentobjectAttribute->attribute('data_type_string') !== ezsrRatingType::DATA_TYPE_STRING) {
return $ret;
}
// Return if rating has been disabled on current attribute
if ($contentobjectAttribute->attribute('data_int')) {
return $ret;
}
// Return if user does not have access to object
$contentobject = $contentobjectAttribute->attribute('object');
if (!$contentobject instanceof eZContentObject || !$contentobject->attribute('can_read')) {
return $ret;
}
$rateDataObj = ezsrRatingDataObject::create(array('contentobject_id' => $contentobjectAttribute->attribute('contentobject_id'), 'contentobject_attribute_id' => $ret['id'], 'rating' => $args[2]));
$proiorRating = $rateDataObj->userHasRated(true);
if ($proiorRating === true) {
$ret['already_rated'] = true;
} else {
if ($proiorRating instanceof ezsrRatingDataObject) {
$rateDataObj = $proiorRating;
$rateDataObj->setAttribute('rating', $args[2]);
$ret['already_rated'] = true;
$proiorRating = false;
// just to reuse code bellow
}
}
if (!$proiorRating) {
$rateDataObj->store();
$avgRateObj = $rateDataObj->getAverageRating();
$avgRateObj->updateFromRatingData();
$avgRateObj->store();
eZContentCacheManager::clearContentCacheIfNeeded($rateDataObj->attribute('contentobject_id'));
$ret['rated'] = true;
$ret['stats'] = array('rating_count' => $avgRateObj->attribute('rating_count'), 'rating_average' => $avgRateObj->attribute('rating_average'), 'rounded_average' => $avgRateObj->attribute('rounded_average'));
}
return $ret;
}
示例4: updateblockorder
/**
* Update blocks order based on AJAX data send after D&D operation is finished
*
* @param mixed $args
* @return array
*/
public static function updateblockorder($args)
{
$http = eZHTTPTool::instance();
$contentObjectAttributeID = (int) $http->postVariable('contentobject_attribute_id', 0);
$version = (int) $http->postVariable('version', 0);
$zoneID = $http->postVariable('zone', '');
$blockOrder = $http->postVariable('block_order', array());
$contentObjectAttribute = eZContentObjectAttribute::fetch($contentObjectAttributeID, $version);
if (!$contentObjectAttribute instanceof eZContentObjectAttribute) {
return array();
}
$contentObject = $contentObjectAttribute->attribute('object');
if (!$contentObject->attribute('can_edit')) {
return array();
}
// checking that the version is a draft and belongs to the current user
$contentVersion = $contentObjectAttribute->attribute('object_version');
if ($contentVersion->attribute('status') != eZContentObjectVersion::STATUS_DRAFT && $contentVersion->attribute('status') != eZContentObjectVersion::STATUS_INTERNAL_DRAFT) {
return array();
}
if ($contentVersion->attribute('creator_id') != eZUser::currentUserID()) {
return array();
}
$sortArray = array();
foreach ($blockOrder as $blockID) {
$idArray = explode('_', $blockID);
if (isset($idArray[1])) {
$sortArray[] = $idArray[1];
}
}
if ($contentObjectAttribute) {
$page = $contentObjectAttribute->content();
}
if ($page) {
$zone = $page->getZone($zoneID);
}
if ($zone) {
$zone->sortBlocks($sortArray);
}
$contentObjectAttribute->setContent($page);
$contentObjectAttribute->store();
return array();
}
示例5: attribute_edit
public static function attribute_edit()
{
$http = eZHTTPTool::instance();
$objectId = $http->postVariable('objectId', 0);
$attributeId = $http->postVariable('attributeId', 0);
$version = $http->postVariable('version', 0);
$content = $http->postVariable('content', '');
$object = eZContentObject::fetch($objectId);
if ($object instanceof eZContentObject && $object->attribute('can_edit')) {
$attribute = eZContentObjectAttribute::fetch($attributeId, $version);
if ($attribute instanceof eZContentObjectAttribute && $attribute->attribute('contentobject_id') == $objectId) {
$params['attributes'] = array($attribute->attribute('contentclass_attribute_identifier') => $content);
eZContentFunctions::updateAndPublishObject($object, $params);
$object = eZContentObject::fetch($objectId);
return $object->attribute('name');
}
}
throw new Exception("Error");
}
示例6: updateblockorder
/**
* Update blocks order based on AJAX data send after D&D operation is finished
*
* @param mixed $args
* @return array
*/
public static function updateblockorder($args)
{
$http = eZHTTPTool::instance();
if ($http->hasPostVariable('contentobject_attribute_id')) {
$contentObjectAttributeID = $http->postVariable('contentobject_attribute_id');
}
if ($http->hasPostVariable('version')) {
$version = $http->postVariable('version');
}
if ($http->hasPostVariable('zone')) {
$zoneID = $http->postVariable('zone');
}
if ($http->hasPostVariable('block_order')) {
$blockOrder = $http->postVariable('block_order');
}
$contentObjectAttribute = eZContentObjectAttribute::fetch($contentObjectAttributeID, $version);
$sortArray = array();
foreach ($blockOrder as $blockID) {
$idArray = explode('_', $blockID);
if (isset($idArray[1])) {
$sortArray[] = $idArray[1];
}
}
if ($contentObjectAttribute) {
$page = $contentObjectAttribute->content();
}
if ($page) {
$zone = $page->getZone($zoneID);
}
if ($zone) {
$zone->sortBlocks($sortArray);
}
$contentObjectAttribute->setContent($page);
$contentObjectAttribute->store();
return array();
}
示例7: clearCacheForObjectLink
static function clearCacheForObjectLink($urlID)
{
$urlObjectLinkList = eZPersistentObject::fetchObjectList(eZURLObjectLink::definition(), null, array('url_id' => $urlID), null, null, true);
foreach ($urlObjectLinkList as $urlObjectLink) {
$objectAttributeID = $urlObjectLink->attribute('contentobject_attribute_id');
$objectAttributeVersion = $urlObjectLink->attribute('contentobject_attribute_version');
$objectAttribute = eZContentObjectAttribute::fetch($objectAttributeID, $objectAttributeVersion);
if ($objectAttribute) {
$objectID = $objectAttribute->attribute('contentobject_id');
$objectVersion = $objectAttribute->attribute('version');
eZContentCacheManager::clearContentCacheIfNeeded($objectID, $objectVersion);
}
}
}
示例8: addToBasket
function addToBasket($objectID, $optionList, $quantity)
{
$object = eZContentObject::fetch($objectID);
$nodeID = $object->attribute('main_node_id');
$price = 0.0;
$isVATIncluded = true;
$attributes = $object->contentObjectAttributes();
$priceFound = false;
foreach ($attributes as $attribute) {
$dataType = $attribute->dataType();
if (eZShopFunctions::isProductDatatype($dataType->isA())) {
$priceObj = $attribute->content();
$price += $priceObj->attribute('price');
$priceFound = true;
}
}
if (!$priceFound) {
eZDebug::writeError('Attempted to add object without price to basket.');
return array('status' => eZModuleOperationInfo::STATUS_CANCELLED);
}
$currency = $priceObj->attribute('currency');
// Check for 'option sets' in option list.
// If found each 'option set' will be added as a separate product purchase.
$hasOptionSet = false;
foreach (array_keys($optionList) as $optionKey) {
if (substr($optionKey, 0, 4) == 'set_') {
$returnStatus = eZShopOperationCollection::addToBasket($objectID, $optionList[$optionKey]);
// If adding one 'option set' fails we should stop immediately
if ($returnStatus['status'] == eZModuleOperationInfo::STATUS_CANCELLED) {
return $returnStatus;
}
$hasOptionSet = true;
}
}
if ($hasOptionSet) {
return $returnStatus;
}
$unvalidatedAttributes = array();
foreach ($attributes as $attribute) {
$dataType = $attribute->dataType();
if ($dataType->isAddToBasketValidationRequired()) {
$errors = array();
if ($attribute->validateAddToBasket($optionList[$attribute->attribute('id')], $errors) !== eZInputValidator::STATE_ACCEPTED) {
$description = $errors;
$contentClassAttribute = $attribute->contentClassAttribute();
$attributeName = $contentClassAttribute->attribute('name');
$unvalidatedAttributes[] = array("name" => $attributeName, "description" => $description);
}
}
}
if (count($unvalidatedAttributes) > 0) {
return array('status' => eZModuleOperationInfo::STATUS_CANCELLED, 'reason' => 'validation', 'error_data' => $unvalidatedAttributes);
}
$basket = eZBasket::currentBasket();
/* Check if the item with the same options is not already in the basket: */
$itemID = false;
$collection = $basket->attribute('productcollection');
if (!$collection) {
eZDebug::writeError('Unable to find product collection.');
return array('status' => eZModuleOperationInfo::STATUS_CANCELLED);
} else {
$collection->setAttribute('currency_code', $currency);
$collection->store();
$count = 0;
/* Calculate number of options passed via the HTTP variable: */
foreach (array_keys($optionList) as $key) {
if (is_array($optionList[$key])) {
$count += count($optionList[$key]);
} else {
$count++;
}
}
$collectionItems = $collection->itemList(false);
foreach ($collectionItems as $item) {
/* For all items in the basket which have the same object_id: */
if ($item['contentobject_id'] == $objectID) {
$options = eZProductCollectionItemOption::fetchList($item['id'], false);
/* If the number of option for this item is not the same as in the HTTP variable: */
if (count($options) != $count) {
break;
}
$theSame = true;
foreach ($options as $option) {
/* If any option differs, go away: */
if (is_array($optionList[$option['object_attribute_id']]) && !in_array($option['option_item_id'], $optionList[$option['object_attribute_id']]) || !is_array($optionList[$option['object_attribute_id']]) && $option['option_item_id'] != $optionList[$option['object_attribute_id']]) {
$theSame = false;
break;
}
}
if ($theSame) {
$itemID = $item['id'];
break;
}
}
}
if ($itemID) {
/* If found in the basket, just increment number of that items: */
$item = eZProductCollectionItem::fetch($itemID);
$item->setAttribute('item_count', $quantity + $item->attribute('item_count'));
$item->store();
//.........这里部分代码省略.........
示例9: storeDOMTree
function storeDOMTree($domTree, $storeAttribute, $contentObjectAttributeRef)
{
if (!$domTree) {
return false;
}
$this->ContentObjectAttributeData['DataTypeCustom']['dom_tree'] = $domTree;
$this->ContentObjectAttributeData['DataTypeCustom']['is_storage_required'] = false;
$xmlString = $domTree->saveXML();
$this->ContentObjectAttributeData['data_text'] = $xmlString;
if ($storeAttribute) {
if (is_object($contentObjectAttributeRef)) {
$contentObjectAttribute = $contentObjectAttributeRef;
} else {
$contentObjectAttribute = eZContentObjectAttribute::fetch($this->ContentObjectAttributeData['id'], $this->ContentObjectAttributeData['version']);
}
if (is_object($contentObjectAttribute)) {
$contentObjectAttribute->setAttribute('data_text', $xmlString);
$contentObjectAttribute->storeData();
} else {
eZDebug::writeError("Invalid objectAttribute: id = " . $this->ContentObjectAttributeData['id'] . " version = " . $this->ContentObjectAttributeData['version'], __METHOD__);
}
}
return true;
}
示例10: unset
$classAttribute->store();
$classAttribute->setAttribute('data_int1', 0);
$classAttribute->setAttribute('data_text1', '');
$classAttribute->store();
unset($classAttribute);
}
} else {
$cli->output('No class attributes to update!');
}
$IDs = $db->arrayQuery("SELECT id, version\n FROM ezcontentobject_attribute\n WHERE data_type_string = 'ezenhancedselection'");
$cli->output();
$cli->output($cli->stylize('bold', 'Updating object attributes'));
if (is_array($IDs) and count($IDs) > 0) {
foreach ($IDs as $id) {
$cli->output('Updating object attribute: id - ' . $id['id'] . ' & version - ' . $id['version']);
$objectAttribute = eZContentObjectAttribute::fetch($id['id'], $id['version']);
$textString = $objectAttribute->attribute('data_text');
$textArray = explode('***', $textString);
$objectAttribute->setAttribute('data_type_string', 'sckenhancedselection');
$objectAttribute->DataTypeString = 'sckenhancedselection';
$objectAttribute->setAttribute('data_text', serialize($textArray));
$objectAttribute->store();
$objectAttribute->updateSortKey();
$object = $objectAttribute->attribute('object');
$class = $object->attribute('content_class');
// Reset the name
$object->setName($class->contentObjectName($object));
// Update the nodes
$nodes = $object->attribute('assigned_nodes');
foreach ($nodes as $node) {
eZContentOperationCollection::publishNode($node->attribute('parent_node_id'), $object->attribute('id'), $object->attribute('current_version'), $object->attribute('main_node_id'));
示例11: contentObjectAttribute
function contentObjectAttribute()
{
$contentObject = $this->contentObject();
return eZContentObjectAttribute::fetch( $this->attribute( 'contentobject_attribute_id' ), $contentObject->attribute( 'current_version' ) );
}
示例12: eZIEImagePreAction
* File containing the ezie no save & quit menu item handler
*
* @copyright Copyright (C) eZ Systems AS.
* @license For full copyright and license information view LICENSE file distributed with this source code.
* @version //autogentag//
* @package ezie
*/
$prepare_action = new eZIEImagePreAction();
$imageId = $prepare_action->getImageId();
$imageVersion = $prepare_action->getImageVersion();
$imageAttribute = eZContentObjectAttribute::fetch($imageId, $imageVersion);
// Save the class attribute
$imageHandler = $prepare_action->getImageHandler();
$imageHandler->initializeFromFile($prepare_action->getImagePath(), $imageHandler->attribute('alternative_text'), $imageHandler->attribute('original_filename'));
// TODO: what's $contentobjectattribute (ask jerome) ?
$imageHandler->store($imageAttribute);
// remove view cache if needed
eZContentCacheManager::clearObjectViewCacheIfNeeded($imageAttribute->attribute('contentobject_id'));
// delete all the images in working directory
// delete working directory
$working_folder = eZDir::dirpath($prepare_action->getImagePath());
// deletes the working folder recursively
eZDir::recursiveDelete($working_folder);
// new attribute
$imageAttribute = eZContentObjectAttribute::fetch($imageId, $imageVersion);
// @todo Use proper JSON, but this will do for now.
$tpl = eZTemplate::factory();
$tpl->setVariable('ezie_ajax_response', true);
$tpl->setVariable('attribute', $imageAttribute);
echo $tpl->fetch("design:content/datatype/edit/ezimage.tpl");
eZExecution::cleanExit();
示例13: publish
function publish($contentObjectID, $contentObjectVersion)
{
// fetch object
$object = eZContentObject::fetch($contentObjectID);
// get content class object
$contentClass = $object->attribute('content_class');
if ($contentClass->attribute('identifier') == 'file' || $contentClass->attribute('identifier') == 'nettopp') {
$contentObjectAttributes = $object->contentObjectAttributes();
$loopLenght = count($contentObjectAttributes);
// Find image and file attribute
for ($i = 0; $i < $loopLenght; $i++) {
switch ($contentObjectAttributes[$i]->attribute('contentclass_attribute_identifier')) {
case 'image':
$image = $contentObjectAttributes[$i];
break;
case 'file':
$file = $contentObjectAttributes[$i];
break;
}
}
if (!$file->hasContent()) {
return;
}
if (!is_object($image)) {
eZDebug::writeNotice("Image field was not found", "pdf2image");
return;
}
// Get previous version and check that file has changed
if ((int) $file->Version > 0 && $image->hasContent()) {
$previousFile = eZContentObjectAttribute::fetch($file->ID, $file->Version - 1, true);
if (is_object($previousFile) && $previousFile->hasContent()) {
if ($previousFile->content()->Filename == $file->content()->Filename) {
eZDebug::writeNotice("File hasn't changed", "pdf2image");
return;
}
}
}
// Check that file is PDF
if ($file->content()->MimeType != "application/pdf") {
eZDebug::writeNotice("File not application/pdf", "pdf2image");
return;
}
$source = $file->content()->filePath();
if (!file_exists($source) or !is_readable($source)) {
eZDebug::writeError("File not readable or doesn't exist", "pdf2image");
return;
}
$page = 0;
$width = 1000;
$height = 1000;
$target = eZSys::cacheDirectory() . "/" . md5(time() . 'pdf2image') . ".jpg";
// Run conversion and redirect error to stdin
$cmd = "convert " . "-density 200 " . eZSys::escapeShellArgument($source . "[" . $page . "]") . " " . "-colorspace rgb " . "-resize " . eZSys::escapeShellArgument($width . "x" . $height) . " " . eZSys::escapeShellArgument($target) . " 2>&1";
eZDebug::writeNotice("Converting '" . $cmd . "'", "pdf2image");
$out = shell_exec($cmd);
// If we got a message somthing went wrong
if ($out) {
eZDebug::writeError("Conversion return error message '" . $out . "'", "pdf2image");
// but it doesn't necessarily mean that it failed
if (!is_readable($target)) {
return;
}
}
// Add imagefile to image handler and save
$imageContent = $image->content();
$imageContent->initializeFromFile($target, $object->Name);
if ($imageContent->isStorageRequired()) {
$imageContent->store($image);
}
unlink($target);
}
}
示例14: switch
<?php
$return = true;
$attributeId = (int) $_REQUEST['attribute_id'];
$versionId = (int) $_REQUEST['version_id'];
$content = $_REQUEST['data'];
if ($attributeId && $versionId) {
$attribute = eZContentObjectAttribute::fetch($attributeId, $versionId);
switch ($attribute->attribute('data_type_string')) {
case 'ezxmltext':
if (eZOEXMLInput::browserSupportsDHTMLType() === 'Trident') {
$content = str_replace("\t", '', $content);
}
$parser = new eZOEInputParser();
$document = $parser->process($content);
// Remove last empty paragraph (added in the output part)
$parent = $document->documentElement;
$lastChild = $parent->lastChild;
while ($lastChild && $lastChild->nodeName !== 'paragraph') {
$parent = $lastChild;
$lastChild = $parent->lastChild;
}
if ($lastChild && $lastChild->nodeName === 'paragraph') {
$textChild = $lastChild->lastChild;
// $textChild->textContent == "�" : string(2) whitespace in Opera
if (!$textChild || $lastChild->childNodes->length == 1 && $textChild->nodeType == XML_TEXT_NODE && ($textChild->textContent == "�" || $textChild->textContent == ' ' || $textChild->textContent == '' || $textChild->textContent == ' ')) {
$parent->removeChild($lastChild);
}
}
$xmlString = eZXMLTextType::domString($document);
$attribute->setAttribute('data_text', $xmlString);
示例15: contentObjectAttribute
/**
* Return contentObjectAttribute.
*
* @return void
*/
public function contentObjectAttribute()
{
$object = $this->contentObject();
$version = $object->attribute('current_version');
return eZContentObjectAttribute::fetch($this->attribute('contentobjectattribute_id'), $version);
}