本文整理汇总了PHP中eZContentLanguage::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentLanguage::fetch方法的具体用法?PHP eZContentLanguage::fetch怎么用?PHP eZContentLanguage::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentLanguage
的用法示例。
在下文中一共展示了eZContentLanguage::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addUrlALias
/**
* Code taken from content/urlalias module
*/
static function addUrlALias($node, $aliasText, $languageId, $aliasRedirects = false, $parentIsRoot = false)
{
$infoCode = 'no-errors';
$language = eZContentLanguage::fetch($languageId);
if (!$language) {
$infoCode = "error-invalid-language";
$infoData['language'] = $languageCode;
} else {
$parentID = 0;
$linkID = 0;
$filter = new eZURLAliasQuery();
$filter->actions = array('eznode:' . $node->attribute('node_id'));
$filter->type = 'name';
$filter->limit = false;
$existingElements = $filter->fetchAll();
// TODO: add error handling when $existingElements is empty
if (count($existingElements) > 0) {
$parentID = (int) $existingElements[0]->attribute('parent');
$linkID = (int) $existingElements[0]->attribute('id');
}
if ($parentIsRoot) {
$parentID = 0;
// Start from the top
}
$mask = $language->attribute('id');
$obj = $node->object();
$alwaysMask = $obj->attribute('language_mask') & 1;
$mask |= $alwaysMask;
$origAliasText = $aliasText;
$result = eZURLAliasML::storePath($aliasText, 'eznode:' . $node->attribute('node_id'), $language, $linkID, $alwaysMask, $parentID, true, false, false, $aliasRedirects);
if ($result['status'] === eZURLAliasML::LINK_ALREADY_TAKEN) {
$lastElements = eZURLAliasML::fetchByPath($result['path']);
if (count($lastElements) > 0) {
$lastElement = $lastElements[0];
$infoCode = "feedback-alias-exists";
$infoData['new_alias'] = $aliasText;
$infoData['url'] = $lastElement->attribute('path');
$infoData['action_url'] = $lastElement->actionURL();
//$aliasText = $origAliasText;
}
} else {
if ($result['status'] === true) {
$aliasText = $result['path'];
if (strcmp($aliasText, $origAliasText) != 0) {
$infoCode = "feedback-alias-cleanup";
$infoData['orig_alias'] = $origAliasText;
$infoData['new_alias'] = $aliasText;
} else {
$infoData['new_alias'] = $aliasText;
}
if ($infoCode == 'no-errors') {
$infoCode = "feedback-alias-created";
}
//$aliasText = false;
}
}
}
return array('infoCode' => $infoCode, 'infoData' => $infoData);
}
示例2: execute
public function execute($process, $event)
{
$processParameters = $process->attribute('parameter_list');
$object = eZContentObject::fetch($processParameters['object_id']);
$node = $object->mainNode();
$href = '/push/node/' . $node->attribute('node_id');
$version = eZContentObjectVersion::fetchVersion($processParameters['version'], $processParameters['object_id']);
if ($version instanceof eZContentObjectVersion) {
$language = eZContentLanguage::fetch($version->attribute('initial_language_id'));
if ($language instanceof eZContentLanguage) {
$href .= '/' . $language->attribute('locale');
}
}
eZURI::transformURI($href, false, 'full');
$http = eZHTTPTool::instance();
$http->setSessionVariable('RedirectURIAfterPublish', $href);
return eZWorkflowType::STATUS_ACCEPTED;
}
示例3: checkPermission
function checkPermission($comment)
{
// check permission
$contentObject = $comment->contentObject();
$contentNode = $contentObject->mainNode();
$languageID = $comment->attribute('language_id');
$languageCode = eZContentLanguage::fetch($languageID)->attribute('locale');
$canDeleteResult = ezcomPermission::hasAccessToFunction('delete', $contentObject, $languageCode, $comment, null, $contentNode);
$objectAttributes = $contentObject->fetchDataMap(false, $languageCode);
$objectAttribute = null;
foreach ($objectAttributes as $attribute) {
if ($attribute->attribute('data_type_string') === 'ezcomcomments') {
$objectAttribute = $attribute;
break;
}
}
$commentContent = $objectAttribute->content();
if (!$canDeleteResult['result'] || !$commentContent['show_comments']) {
return ezpI18n::tr('ezcomments/comment/delete', 'You don\'t have' . ' access to delete comment' . ' or the comment is hidden!');
} else {
return true;
}
}
示例4: metaData
/**
* Returns the meta data used for storing search indices
*
* @param eZContentObjectAttribute $attribute
*
* @return string
*/
public function metaData($attribute)
{
/** @var $eZTags eZTags */
$eZTags = $attribute->content();
if (!$eZTags instanceof eZTags) {
return '';
}
$indexSynonyms = eZINI::instance('eztags.ini')->variable('SearchSettings', 'IndexSynonyms') === 'enabled';
$keywords = array();
$tags = $eZTags->attribute('tags');
/** @var eZTagsObject $tag */
foreach ($tags as $tag) {
if (!$indexSynonyms && $tag->isSynonym()) {
$tag = $tag->getMainTag();
}
if ($tag instanceof eZTagsObject) {
$keyword = $tag->getKeyword($attribute->attribute('language_code'));
if (!$keyword) {
//fall back to main language
/** @var eZContentLanguage $mainLanguage */
$mainLanguage = eZContentLanguage::fetch($tag->attribute('main_language_id'));
if ($mainLanguage instanceof eZContentLanguage) {
$keyword = $tag->getKeyword($mainLanguage->attribute('locale'));
}
}
if ($keyword) {
$keywords[] = $keyword;
}
}
}
return implode(', ', array_unique($keywords));
}
示例5: array
if ($module->isCurrentAction('RemoveTranslation')) {
if (!$module->hasActionParameter('LanguageID')) {
return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
}
$languageIDArray = $module->actionParameter('LanguageID');
if ($module->hasActionParameter('ConfirmRemoval') && $module->actionParameter('ConfirmRemoval')) {
if (eZOperationHandler::operationIsAvailable('content_removetranslation')) {
$operationResult = eZOperationHandler::execute('content', 'removetranslation', array('object_id' => $objectID, 'language_id_list' => $languageIDArray, 'node_id' => $nodeID));
} else {
eZContentOperationCollection::removeTranslation($objectID, $languageIDArray);
}
return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
}
$languages = array();
foreach ($languageIDArray as $languageID) {
$language = eZContentLanguage::fetch($languageID);
if ($language) {
$languages[] = $language;
}
}
if (!$languages) {
return $module->redirectToView('view', array($viewMode, $nodeID, $languageCode));
}
$tpl = eZTemplate::factory();
$tpl->setVariable('object_id', $objectID);
$tpl->setVariable('object', $object);
$tpl->setVariable('node_id', $nodeID);
$tpl->setVariable('language_code', $languageCode);
$tpl->setVariable('languages', $languages);
$tpl->setVariable('view_mode', $viewMode);
$Result = array();
示例6: decodeLanguageMask
/**
* Decodes $langMask into all languages it comprises and whether or not
* the language mask signifies always available or not.
*
* The constituent languages are returned as an array of language ids. If
* the second parameter, $returnLanguageLocale is set to TRUE, locale-codes
* are used instead of language ids.
*
* @param int $langMask
* @param boolean $returnLanguageLocale
* @return array
*/
public static function decodeLanguageMask($langMask, $returnLanguageLocale = false)
{
$maxNumberOfLanguges = self::maxCount();
$maxInteger = pow(2, $maxNumberOfLanguges);
$list = array();
// Applying this bit-logic on negative numbers, or numbers out of bounds
// will have unexpected results.
if ($langMask < 0 or $langMask > $maxInteger or $langMask == 1) {
// We use the default language if the situation above occurs
$defaultLanguage = eZContentLanguage::topPriorityLanguage();
$langMask = $defaultLanguage->attribute('id');
}
$alwaysAvailable = $langMask % 2;
$mask = $langMask & ~1;
// Calculating which translations are present in the current version
for ($i = 1; $i < $maxNumberOfLanguges; ++$i) {
$newMask = 1 << $i;
if (($newMask & $mask) > 0) {
if ($returnLanguageLocale) {
$list[] = eZContentLanguage::fetch($newMask)->attribute('locale');
} else {
$list[] = $newMask;
}
}
}
return array('always_available' => $alwaysAvailable, 'language_list' => $list);
}
示例7: language
/**
* return the eZ Publish content language associated with this content object state group language
*
* @return eZContentLanguage
*/
public function language()
{
return eZContentLanguage::fetch( $this->LanguageID & ~1 );
}
示例8: removeTranslation
/**
* Removes a translation from the current object
*
* @param int $languageID
* @return bool
*/
function removeTranslation( $languageID )
{
$language = eZContentLanguage::fetch( $languageID );
if ( !$language )
{
return false;
}
// check permissions for editing
if ( !$this->checkAccess( 'edit', false, false, false, $languageID ) )
{
return false;
}
// check if it is not the initial language
$objectInitialLanguageID = $this->attribute( 'initial_language_id' );
if ( $objectInitialLanguageID == $languageID )
{
return false;
}
// change language_mask of the object
$languageMask = (int) $this->attribute( 'language_mask' );
$languageMask = (int) $languageMask & ~ (int) $languageID;
$this->setAttribute( 'language_mask', $languageMask );
$db = eZDB::instance();
$db->begin();
$this->store();
$objectID = $this->ID;
// If the current version has initial_language_id $languageID, change it to the initial_language_id of the object.
$currentVersion = $this->currentVersion();
if ( $currentVersion->attribute( 'initial_language_id' ) == $languageID )
{
$currentVersion->setAttribute( 'initial_language_id', $objectInitialLanguageID );
$currentVersion->store();
}
// Remove all versions which had the language as its initial ID. Because of previous checks, it is sure we will not remove the published version.
$versionsToRemove = $this->versions( true, array( 'conditions' => array( 'initial_language_id' => $languageID ) ) );
foreach ( $versionsToRemove as $version )
{
$version->removeThis();
}
$altLanguageID = $languageID++;
// Remove all attributes in the language
$attributes = $db->arrayQuery( "SELECT * FROM ezcontentobject_attribute
WHERE contentobject_id='$objectID'
AND ( language_id='$languageID' OR language_id='$altLanguageID' )" );
foreach ( $attributes as $attribute )
{
$attributeObject = new eZContentObjectAttribute( $attribute );
$attributeObject->remove( $attributeObject->attribute( 'id' ), $attributeObject->attribute( 'version' ) );
unset( $attributeObject );
}
// Remove all names in the language
$db->query( "DELETE FROM ezcontentobject_name
WHERE contentobject_id='$objectID'
AND ( language_id='$languageID' OR language_id='$altLanguageID' )" );
// Update masks of the objects
$mask = eZContentLanguage::maskForRealLanguages() - (int) $languageID;
if ( $db->databaseName() == 'oracle' )
{
$db->query( "UPDATE ezcontentobject_version SET language_mask = bitand( language_mask, $mask )
WHERE contentobject_id='$objectID'" );
}
else
{
$db->query( "UPDATE ezcontentobject_version SET language_mask = language_mask & $mask
WHERE contentobject_id='$objectID'" );
}
$urlElementfilter = new eZURLAliasQuery();
$urlElementfilter->type = 'name';
// We want all languages present here, so we are turning off
// language filtering
$urlElementfilter->languages = false;
$urlElementfilter->limit = false;
$nodes = $this->assignedNodes();
foreach ( $nodes as $node )
{
$parent = null;
$textMD5 = null;
//.........这里部分代码省略.........
示例9: defaultLanguage
/**
*
* @return int the numerical ID of the default language
*/
public function defaultLanguage()
{
return eZContentLanguage::fetch($this->DefaultLanguageID);
}
示例10: array
return;
}
if (!is_numeric($commentID)) {
eZDebug::writeError('The parameter comment id is not a number.', 'ezcomments');
return;
}
$comment = ezcomComment::fetch($commentID);
if (is_null($comment)) {
eZDebug::writeError('The comment doesn\'t exist.', 'ezcomments');
return;
}
//check the permission
$contentObject = $comment->contentObject();
$contentNode = $contentObject->mainNode();
$languageID = $comment->attribute('language_id');
$languageCode = eZContentLanguage::fetch($languageID)->attribute('locale');
$canEdit = false;
$canEditResult = ezcomPermission::hasAccessToFunction('edit', $contentObject, $languageCode, $comment, null, $contentNode);
$canEdit = $canEditResult['result'];
$tpl->setVariable('can_edit', $canEdit);
if (!$canEdit) {
$Result['path'] = array(array('url' => false, 'text' => ezpI18n::tr('ezcomments/comment/edit', 'Edit comment')));
$Result['content'] = $tpl->fetch('design:comment/edit.tpl');
return $Result;
}
$contentID = $comment->attribute('contentobject_id');
// get if notification is enabled and notification value
$ini = eZINI::instance('ezcomments.ini');
$formSettings = $ini->variable('FormSettings', 'AvailableFields');
$notificationEnabled = in_array('notificationField', $formSettings);
$emailEnabled = in_array('email', $formSettings);
示例11: language
/**
* return the eZ Publish content language associated with this content object state group language
*
* @return eZContentLanguage
*/
public function language()
{
return eZContentLanguage::fetch($this->RealLanguageID);
}
示例12: initialLanguage
function initialLanguage()
{
return eZContentLanguage::fetch( $this->InitialLanguageID );
}
示例13: processTag
/**
* Extracts data to be indexed from the tag
*
* @param eZTagsObject $tag
* @param array $tagIDs
* @param array $keywords
* @param bool $indexParentTags
* @param bool $includeSynonyms
*/
private function processTag(eZTagsObject $tag, array &$tagIDs, array &$keywords, $indexParentTags = false, $includeSynonyms = false)
{
if (!$this->indexSynonyms && $tag->isSynonym()) {
$tag = $tag->getMainTag();
}
//get keyword in content's locale
$keyword = $tag->getKeyword($this->ContentObjectAttribute->attribute('language_code'));
if (!$keyword) {
//fall back to main language
/** @var eZContentLanguage $mainLanguage */
$mainLanguage = eZContentLanguage::fetch($tag->attribute('main_language_id'));
if ($mainLanguage instanceof eZContentLanguage) {
$keyword = $tag->getKeyword($mainLanguage->attribute('locale'));
}
}
if ($keyword) {
$tagIDs[] = (int) $tag->attribute('id');
$keywords[] = $keyword;
}
if ($indexParentTags) {
$parentTags = $tag->getPath(true);
foreach ($parentTags as $parentTag) {
if ($parentTag instanceof eZTagsObject) {
$this->processTag($parentTag, $tagIDs, $keywords);
}
}
}
if ($this->indexSynonyms && $includeSynonyms) {
foreach ($tag->getSynonyms() as $synonym) {
if ($synonym instanceof eZTagsObject) {
$this->processTag($synonym, $tagIDs, $keywords);
}
}
}
}
示例14: eZDateTime
$now = new eZDateTime();
$currentTime = $now->toTime()->timeStamp();
$ezcommentsINI = eZINI::instance('ezcomments.ini');
$sendingNumber = $ezcommentsINI->variable('NotificationSettings', 'NotificationNumberPerExecuation');
$mailContentType = $ezcommentsINI->variable('NotificationSettings', 'MailContentType');
$mailFrom = $ezcommentsINI->variable('NotificationSettings', 'MailFrom');
$contentObjectIDList = $db->arrayQuery('SELECT DISTINCT contentobject_id, language_id' . ' FROM ezcomment_notification ' . 'WHERE status=1' . ' AND send_time < ' . $currentTime, array('offset' => 0, 'limit' => $sendingNumber));
$notificationCount = 0;
$mailCount = 0;
foreach ($contentObjectIDList as $contentObjectArray) {
$contentObjectID = $contentObjectArray['contentobject_id'];
$contentLanguage = $contentObjectArray['language_id'];
$notifications = $db->arrayQuery('SELECT * FROM ezcomment_notification ' . 'WHERE contentobject_id = ' . $contentObjectID);
// fetch content object
$contentObject = eZContentObject::fetch($contentObjectID, true);
$contentLanguageLocale = eZContentLanguage::fetch($contentLanguage)->attribute('locale');
$contentObject->setCurrentLanguage($contentLanguageLocale);
if (is_null($contentObject)) {
$cli->output("Content doesn't exist, delete the notification. Content ID:" . $contentObjectID);
$db->query('DELETE FROM ezcomment_notification WHERE contentobject_id=' . $contentObjectID);
continue;
}
// fetch subscribers
$subscriptionList = $db->arrayQuery("SELECT subscriber_id FROM ezcomment_subscription" . " WHERE enabled = 1" . " AND content_id = {$contentObjectID}" . " AND language_id = {$contentLanguage}");
$subscriberList = array();
foreach ($subscriptionList as $subscription) {
$subscriberList[] = ezcomSubscriber::fetch($subscription['subscriber_id']);
}
//fetch comment list
$commentList = array();
foreach ($notifications as $notification) {
示例15: getLanguage
function getLanguage()
{
return eZContentLanguage::fetch($this->LangMask);
}