本文整理汇总了PHP中eZContentObject::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObject::fetch方法的具体用法?PHP eZContentObject::fetch怎么用?PHP eZContentObject::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObject
的用法示例。
在下文中一共展示了eZContentObject::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: modifier
function modifier()
{
if ($this->Modifier === null) {
$this->Modifier = eZContentObject::fetch($this->ModifierID);
}
return $this->Modifier;
}
示例2: getNodeUrl
/**
* @param eZContentObjectTreeNode $node
* @return string
*/
public function getNodeUrl(&$node = null)
{
$token = $this->getToken();
$dataMap = $node->dataMap();
$mediaContentAttribute = $dataMap['media_content'];
$mediaContentAttributeContent = $mediaContentAttribute->content();
$linkObjectID = $mediaContentAttributeContent['relation_list'][0]['contentobject_id'];
$linkObject = eZContentObject::fetch( $linkObjectID );
$linkDatamap = $linkObject->dataMap();
$url = $linkDatamap['url']->content();
$queryStringPosition = strpos($url, '?');
$queryString = substr($url, $queryStringPosition + 1);
$url = substr($url, 0, $queryStringPosition);
$queryStringParts = array();
parse_str($queryString, $queryStringParts);
$queryStringParts[self::SESSION_ID_FIELD] = $token;
$queryString = http_build_query($queryStringParts);
$url .= '?' . $queryString;
return $url;
}
示例3: akismet_ContentActionHandler
function akismet_ContentActionHandler($module, $http, $objectID)
{
$object = eZContentObject::fetch($objectID);
$version = $object->attribute('current');
if ($http->hasPostVariable('AkismetSubmitSpam')) {
$user = eZUser::currentUser();
$accessResult = $user->hasAccessTo('akismet', 'submit');
if ($accessResult['accessWord'] === 'yes') {
$mainNode = $object->attribute('main_node');
$module->redirectTo($mainNode->attribute('url_alias'));
$akismetObject = new eZContentObjectAkismet();
$comment = $akismetObject->akismetInformationExtractor($version);
if ($comment) {
$akismet = new eZAkismet($comment);
if ($akismet) {
$feedback = $akismet->submitSpam();
$response[] = $feedback[1];
} else {
$response[] = ezi18n('extension/contactivity/akismet/submit', "An error has occured, unable to submit spam to Akismet.");
}
} else {
$response[] = ezi18n('extension/contactivity/akismet/submit', "An error has occured, unable to submit spam to Akismet.");
}
}
$mainNode = $object->attribute('main_node');
$module->redirectTo($mainNode->attribute('url_alias'));
return true;
}
}
示例4: runOperation
function runOperation(&$node)
{
$object = $node->attribute('object');
$object_id = $object->attribute('id');
$objectLocales = $object->attribute('available_languages');
// If the alternative locale does not exist for object, create it
if (!in_array($this->altLocale, $objectLocales)) {
// The only translation is in locate to be removed - create a version in another locale first.
echo "Copying the single translation in " . $this->remLocale . " to " . $this->altLocale . " so former could be removed.\n";
$newVersion = $object->createNewVersionIn($this->altLocale, $this->remLocale, false, true, eZContentObjectVersion::STATUS_DRAFT);
$publishResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $object_id, 'version' => $newVersion->attribute('version')));
eZContentObject::clearCache();
$object = eZContentObject::fetch($object_id);
}
// Change objects main language to alternative language, if its current main language is to be removed.
if ($object->attribute('initial_language_code') == $this->remLocale) {
eZContentObject::clearCache();
$object = eZContentObject::fetch($object_id);
echo "Switching initial language to {$this->altLocale} so that " . $this->remLocale . " could be removed.\n";
$updateResult = eZContentOperationCollection::updateInitialLanguage($object_id, $this->altLangID);
$object->store();
eZContentObject::clearCache();
$object = eZContentObject::fetch($object_id);
}
// Now it should be safe to remove translation.
return $object->removeTranslation($this->remLangID);
}
示例5: contentObject
/**
* get the contentobject of one comment
* @return eZContentObject
*/
public function contentObject()
{
if (isset($this->ContentObjectID) and $this->ContentObjectID) {
return eZContentObject::fetch($this->ContentObjectID);
}
return null;
}
示例6: solrMetaDataExists
private function solrMetaDataExists( $contentObjectID=0, $attributeIdentifier='', $subattr='' )
{
try
{
$contentObject = eZContentObject::fetch( $contentObjectID );
$dataMap = $contentObject->dataMap();
if ( array_key_exists( $attributeIdentifier, $dataMap ) )
{
$contentObjectAttribute = $dataMap[$attributeIdentifier];
$eZType = eZDataType::create( solrMetaDataType::DATA_TYPE_STRING );
$value = $eZType->getValue( $contentObjectAttribute->ID, $subattr );
return ( ! empty( $value ) );
}
else
{
eZDebug::writeError( 'Object '.$contentObjectID.' has no attribute '.$attributeIdentifier, 'solrMetaDataExists Error' );
}
return false;
}
catch ( Exception $e )
{
eZDebug::writeError( $e, 'solrMetaDataExists Exception' );
return false;
}
}
示例7: execute
public function execute($process, $event)
{
$params = $process->attribute('parameter_list');
$object_id = $params['object_id'];
$object = eZContentObject::fetch($object_id);
if (!is_object($object)) {
eZDebug::writeError("Unable to fetch object: '{$object_id}'", __METHOD__);
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
// current parent node(s)
$parentNodeIds = $object->attribute('parent_nodes');
$checkedObjs = array();
foreach ($parentNodeIds as $parentNodeId) {
//eZDebug::writeDebug( "Checking parent node: " . $parentNodeId, __METHOD__ );
$parentNode = eZContentObjectTreeNode::fetch($parentNodeId);
$parentObj = $parentNode->attribute('object');
if (!in_array($parentObj->attribute('id'), $checkedObjs)) {
//eZDebug::writeDebug( "Checking all nodes of parent obj: " . $parentObj->attribute( 'id' ), __METHOD__ );
foreach ($parentObj->attribute('assigned_nodes') as $node) {
if (!in_array($node->attribute('node_id'), $parentNodeIds)) {
//eZDebug::writeDebug( "Found a node which is not parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ );
// the current obj has no node which is children of the given node of one of its parent objects
$operationResult = eZOperationHandler::execute('content', 'addlocation', array('node_id' => $object->attribute('main_node_id'), 'object_id' => $object->attribute('id'), 'select_node_id_array' => array($node->attribute('node_id'))), null, true);
if ($operationResult == null || $operationResult['status'] != true) {
eZDebug::writeError("Unable to add new location to object: " . $object->attribute('id'), __METHOD__);
}
} else {
//eZDebug::writeDebug( "Found a node which is already parent of current obj: " . $node->attribute( 'node_id' ), __METHOD__ );
}
}
}
$checkedObjs[] = $parentObj->attribute('id');
}
return eZWorkflowType::STATUS_ACCEPTED;
}
示例8: execute
function execute($process, $event)
{
// get object being published
$parameters = $process->attribute('parameter_list');
$objectID = $parameters['object_id'];
eZDebug::writeDebug('Update object state for object: ' . $objectID);
$object = eZContentObject::fetch($objectID);
$state_before = $event->attribute('state_before');
$state_after = $event->attribute('state_after');
if ($object == null) {
eZDebug::writeError('Update object state failed for inexisting object: ' . $objectID, __METHOD__);
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
if ($state_before == null || $state_after == null) {
eZDebug::writeError('Update object state failed: badly configured states', __METHOD__);
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
$currentStateIDArray = $object->attribute('state_id_array');
if (in_array($state_before->attribute('id'), $currentStateIDArray)) {
$canAssignStateIDList = $object->attribute('allowed_assign_state_id_list');
if (!in_array($state_after->attribute('id'), $canAssignStateIDList)) {
eZDebug::writeWarning("Not enough rights to assign state to object {$objectID}: " . $state_after->attribute('id'), __METHOD__);
} else {
eZDebug::writeDebug('Changing object state from ' . $state_before->attribute('name') . ' to ' . $state_after->attribute('name'), __METHOD__);
if (eZOperationHandler::operationIsAvailable('content_updateobjectstate')) {
$operationResult = eZOperationHandler::execute('content', 'updateobjectstate', array('object_id' => $objectID, 'state_id_list' => array($state_after->attribute('id'))));
} else {
eZContentOperationCollection::updateObjectState($objectID, array($state_after->attribute('id')));
}
}
}
return eZWorkflowType::STATUS_ACCEPTED;
}
示例9: testIssue19174
/**
* Regression test for issue {@see #19174 http://issues.ez.no/19174}
*/
public function testIssue19174()
{
$bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
// add a secondary language
$locale = eZLocale::instance('fre-FR');
$translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
// create related objects
$relatedObjectsIds = array($this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation());
$xmlTextEn = "<embed href=\"ezobject://{$relatedObjectsIds[0]}\" /><link href=\"ezobject://{$relatedObjectsIds[1]}\">link</link>";
$xmlTextFr = "<embed href=\"ezobject://{$relatedObjectsIds[2]}\" /><link href=\"ezobject://{$relatedObjectsIds[3]}\">link</link>";
// Create an article in eng-GB, and embed related object one in the intro
$article = new ezpObject('article', 2, 14, 1, 'eng-GB');
$article->title = __METHOD__ . ' eng-GB';
$article->intro = $xmlTextEn;
$articleId = $article->publish();
// Workaround as setting folder->name directly doesn't produce the expected result
$article->addTranslation('fre-FR', array('title' => __METHOD__ . ' fre-FR', 'intro' => $xmlTextFr));
$relatedObjects = eZContentObject::fetch($articleId)->relatedObjects(false, false, 0, false, array('AllRelations' => eZContentObject::RELATION_LINK | eZContentObject::RELATION_EMBED));
self::assertEquals(4, count($relatedObjects));
$expectedRelations = array_flip($relatedObjectsIds);
foreach ($relatedObjects as $relatedObject) {
if (isset($expectedRelations[$relatedObject->ID])) {
unset($expectedRelations[$relatedObject->ID]);
}
}
self::assertEquals(0, count($expectedRelations));
$article->remove();
$translation->removeThis();
eZContentLanguage::setPrioritizedLanguages($bkpLanguages);
}
示例10: getDataMember
/**
* Returns part of the data for the attribute
*
* @param string $dataMember
*
* @return string
*/
public function getDataMember($dataMember)
{
if ($dataMember === 'related_images') {
$images = array();
$relations = $this->ContentObjectAttribute->attribute('content');
foreach ($relations['relation_list'] as $relation) {
$object = eZContentObject::fetch($relation['contentobject_id']);
if ($object instanceof eZContentObject) {
$dataMap = $object->attribute('data_map');
foreach ($dataMap as $attribute) {
/** @var eZContentObjectAttribute $attribute */
if ($attribute->attribute('data_type_string') !== eZImageType::DATA_TYPE_STRING) {
continue;
}
if ($attribute->hasContent()) {
$imageAliasHandler = $attribute->attribute('content');
$imageAlias = $imageAliasHandler->imageAlias('opengraph');
if ($imageAlias['is_valid'] == 1) {
$images[] = eZSys::serverURL() . '/' . $imageAlias['full_path'];
}
}
}
}
}
if (empty($images)) {
$images[] = eZSys::serverURL() . eZURLOperator::eZImage(null, 'opengraph_default_image.png', '');
}
return $images;
}
return $this->getData();
}
示例11: testUnauthorizedContentByObject
/**
* @group issue18073
* @link http://issues.ez.no/18073
*/
public function testUnauthorizedContentByObject()
{
$this->setExpectedException('ezpContentAccessDeniedException');
// Let's take content node #5 / object #4 (users) as unauthorized content for anonymous user
$unauthorizedObjectID = 4;
$content = ezpContent::fromObject(eZContentObject::fetch($unauthorizedObjectID));
}
示例12: testUpdateAndPublishObject
public function testUpdateAndPublishObject()
{
// create content object first
$object = new ezpObject("folder", 2);
$object->title = __FUNCTION__ . '::' . __LINE__ . '::' . time();
$object->publish();
$contentObjectID = $object->attribute('id');
if ($object instanceof eZContentObject) {
$now = date('Y/m/d H:i:s', time());
$sectionID = 3;
$remoteID = md5($now);
$attributeList = array('name' => 'name ' . $now, 'short_name' => 'short_name ' . $now, 'short_description' => 'short_description' . $now, 'description' => 'description' . $now, 'show_children' => false);
$params = array();
$params['attributes'] = $attributeList;
$params['remote_id'] = $remoteID;
$params['section_id'] = $sectionID;
$result = eZContentFunctions::updateAndPublishObject($object, $params);
$this->assertTrue($result);
$object = eZContentObject::fetch($contentObjectID);
$this->assertEquals($object->attribute('section_id'), $sectionID);
$this->assertEquals($object->attribute('remote_id'), $remoteID);
$dataMap = $object->dataMap();
$this->assertEquals($attributeList['name'], $dataMap['name']->content());
$this->assertEquals($attributeList['short_name'], $dataMap['short_name']->content());
$this->assertEquals($attributeList['short_description'], $dataMap['short_description']->content());
$this->assertEquals($attributeList['description'], $dataMap['description']->content());
$this->assertEquals($attributeList['show_children'], (bool) $dataMap['show_children']->content());
}
}
示例13: execute
function execute($process, $event)
{
$parameters = $process->attribute('parameter_list');
$object = eZContentObject::fetch($parameters['object_id']);
$versionID = $parameters['version'];
if (!$object) {
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
$version = $object->version($versionID);
if (!$version) {
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
$akismetObject = new eZContentObjectAkismet();
$comment = $akismetObject->akismetInformationExtractor($version);
if ($comment) {
$akismet = new eZAkismet($comment);
if ($akismet) {
$isSpam = $akismet->isCommentSpam();
eZDebug::writeDebug($comment);
eZDebug::writeDebug("this is spam: " . $isSpam);
} else {
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
if (!$isSpam) {
$response = $akismet->submitHam();
return eZWorkflowType::STATUS_ACCEPTED;
}
return eZWorkflowType::STATUS_REJECTED;
}
}
示例14: remove
static function remove($objectID, $removeSubtrees = true)
{
eZContentCacheManager::clearContentCacheIfNeeded($objectID);
$object = eZContentObject::fetch($objectID);
if (!is_object($object)) {
return false;
}
// TODO: Is content cache cleared for all objects in subtree ??
if ($removeSubtrees) {
$assignedNodes = $object->attribute('assigned_nodes');
if (count($assignedNodes) == 0) {
$object->purge();
eZContentObject::expireAllViewCache();
return true;
}
$assignedNodeIDArray = array();
foreach ($assignedNodes as $node) {
$assignedNodeIDArray[] = $node->attribute('node_id');
}
eZContentObjectTreeNode::removeSubtrees($assignedNodeIDArray, false);
} else {
$object->purge();
}
return true;
}
示例15: feZMetaData_ContentActionHandler
function feZMetaData_ContentActionHandler( &$module, &$http, &$objectID )
{
// Action when user clicks on the Add Button
if( $http->hasPostVariable( 'AddMetaDataButton' ) )
{
$link = 'fezmetadata/edit/0/(contentObjectID)/'.$objectID;
$link .= '/(metaDataName)/'.$_POST['metaDataName'];
$link .= '/(language)/'.$_POST['language'];
eZURI::transformURI( $link );
$http->redirect( $link );
}
// Action when user clicks on the Remove Button
if( $http->hasPostVariable( 'RemoveMetaDataButton' ) and $http->hasPostVariable( 'MetaDataIDSelection' ) )
{
$metaDataSelection = $http->postVariable( 'MetaDataIDSelection' );
foreach( $metaDataSelection as $metaData )
{
$metaDataObject = feZMetaData::fetch( $metaData );
$metaDataObject->remove();
}
eZContentCacheManager::clearContentCache( $objectID );
$ContentObject = eZContentObject::fetch( $objectID );
$ContentNodeID = $ContentObject->mainNodeID();
return $module->redirect( 'content', 'view', array( 'full', $ContentNodeID ) );
}
}