/**
  * 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);
 }
Example #2
0
 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;
 }
Example #3
0
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;
    }
}
Example #4
0
 /**
  * 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));
 }
Example #5
0
 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();
 /**
  * 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);
 }
 /**
  * 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 );
 }
    /**
     * 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;

            $urlElementfilter->actions = array( 'eznode:' . $node->attribute( 'node_id' ) );
            $urlElementfilter->prepare();
            $urlElements = $urlElementfilter->fetchAll();

            foreach ($urlElements as $url )
            {
                if ( $url->attribute( 'lang_mask' ) === (int)$languageID or
                     $url->attribute( 'lang_mask') === (int)$altLanguageID )
                {
                    $parent = $url->attribute( 'parent');
                    $textMD5 = $url->attribute( 'text_md5' );
                    break;
                }
            }

            if ( $parent !== null and $textMD5 !== null )
                eZURLAliasML::removeSingleEntry( $parent, $textMD5, $language );
        }
        $db->commit();

        return true;
    }
 /**
  *
  * @return int the numerical ID of the default language
  */
 public function defaultLanguage()
 {
     return eZContentLanguage::fetch($this->DefaultLanguageID);
 }
Example #10
0
    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);
 /**
  * return the eZ Publish content language associated with this content object state group language
  *
  * @return eZContentLanguage
  */
 public function language()
 {
     return eZContentLanguage::fetch($this->RealLanguageID);
 }
Example #12
0
 function initialLanguage()
 {
     return eZContentLanguage::fetch( $this->InitialLanguageID );
 }
 /**
  * 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);
             }
         }
     }
 }
$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) {
 function getLanguage()
 {
     return eZContentLanguage::fetch($this->LangMask);
 }
 /**
  * Updates an existing content object.
  *
  * This function works like createAndPublishObject
  *
  * Here is an example
  * <code>
  *
  * <?php
  * $contentObjectID = 1;
  * $contentObject = eZContentObject::fetch( $contentObjectID );
  *
  * if( $contentObject instanceof eZContentObject )
  * {
  *     $xmlDeclaration = '<?xml version="1.0" encoding="utf-8"?>
  *                         <section xmlns:image="http://ez.no/namespaces/ezpublish3/image/"
  *                                  xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"
  *                                  xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">';
  *
  *     $now = $now = date( 'Y/m/d H:i:s', time() );
  *     $xmlDeclaration = '<?xml version="1.0" encoding="utf-8"?>
  *                     <section xmlns:image="http://ez.no/namespaces/ezpublish3/image/"
  *                                 xmlns:xhtml="http://ez.no/namespaces/ezpublish3/xhtml/"
  *                                 xmlns:custom="http://ez.no/namespaces/ezpublish3/custom/">';
  *
  *     $attributeList = array( 'name'              => 'Name ' . $now,
  *                             'short_name'        => 'Short name ' . $now,
  *                             'short_description' => $xmlDeclaration . '<paragraph>Short description '. $now . '</paragraph></section>',
  *                             'description'       => $xmlDeclaration . '<paragraph>Description '. $now . '</paragraph></section>',
  *                             'show_children'     => false);
  *
  *     $params = array();
  *     $params['attributes'] = $attributeList;
  *     // $params['remote_id'] = $now;
  *     // $params['section_id'] = 3;
  *     // $params['language']  = 'ger-DE';
  *
  *     $result = eZContentFunctions::updateAndPublishObject( $contentObject, $params );
  *
  *     if( $result )
  *         print( 'Update OK' );
  *     else
  *         print( 'Failed' );
  * }
  * ?>
  * </code>
  * @param eZContentObject an eZContentObject object
  * @param array an array with the attributes to update
  * @static
  * @return bool true if the object has been successfully updated, false otherwise
  */
 public static function updateAndPublishObject(eZContentObject $object, array $params)
 {
     if (!array_key_exists('attributes', $params) and !is_array($params['attributes']) and count($params['attributes']) > 0) {
         eZDebug::writeError('No attributes specified for object' . $object->attribute('id'), __METHOD__);
         return false;
     }
     $storageDir = '';
     $languageCode = false;
     $mustStore = false;
     if (array_key_exists('remote_id', $params)) {
         $object->setAttribute('remote_id', $params['remote_id']);
         $mustStore = true;
     }
     if (array_key_exists('section_id', $params)) {
         $object->setAttribute('section_id', $params['section_id']);
         $mustStore = true;
     }
     if ($mustStore) {
         $object->store();
     }
     if (array_key_exists('storage_dir', $params)) {
         $storageDir = $params['storage_dir'];
     }
     if (array_key_exists('language', $params) and $params['language'] != false) {
         $languageCode = $params['language'];
     } else {
         $initialLanguageID = $object->attribute('initial_language_id');
         $language = eZContentLanguage::fetch($initialLanguageID);
         $languageCode = $language->attribute('locale');
     }
     $db = eZDB::instance();
     $db->begin();
     $newVersion = $object->createNewVersion(false, true, $languageCode);
     if (!$newVersion instanceof eZContentObjectVersion) {
         eZDebug::writeError('Unable to create a new version for object ' . $object->attribute('id'), __METHOD__);
         $db->rollback();
         return false;
     }
     $newVersion->setAttribute('modified', time());
     $newVersion->store();
     $attributeList = $newVersion->attribute('contentobject_attributes');
     $attributesData = $params['attributes'];
     foreach ($attributeList as $attribute) {
         $attributeIdentifier = $attribute->attribute('contentclass_attribute_identifier');
         if (array_key_exists($attributeIdentifier, $attributesData)) {
             $dataString = $attributesData[$attributeIdentifier];
             switch ($datatypeString = $attribute->attribute('data_type_string')) {
                 case 'ezimage':
                 case 'ezbinaryfile':
                 case 'ezmedia':
                     $dataString = $storageDir . $dataString;
                     break;
                 default:
             }
             $attribute->fromString($dataString);
             $attribute->store();
         }
     }
     $db->commit();
     $operationResult = eZOperationHandler::execute('content', 'publish', array('object_id' => $newVersion->attribute('contentobject_id'), 'version' => $newVersion->attribute('version')));
     if ($operationResult['status'] == eZModuleOperationInfo::STATUS_CONTINUE) {
         return true;
     }
     return false;
 }
Example #17
0
 function removeTranslation($languageID)
 {
     $language = eZContentLanguage::fetch($languageID);
     if (!$language) {
         return false;
     }
     // check if it is not the initial language
     $classInitialLanguageID = $this->attribute('initial_language_id');
     if ($classInitialLanguageID == $languageID) {
         return false;
     }
     $db = eZDB::instance();
     $db->begin();
     $classID = $this->attribute('id');
     $languageID = $language->attribute('id');
     // change language_mask of the object
     $languageMask = (int) $this->attribute('language_mask');
     $languageMask = (int) $languageMask & ~(int) $languageID;
     $this->setAttribute('language_mask', $languageMask);
     // Remove all names in the language
     $db->query("DELETE FROM ezcontentclass_name\n                     WHERE contentclass_id='{$classID}'\n                       AND language_id='{$languageID}'");
     $languageLocale = $language->attribute('locale');
     $this->NameList->removeName($languageLocale);
     $this->DescriptionList->removeName($languageLocale);
     $this->store();
     // Remove names for attributes in the language
     $attributes = $this->fetchAttributes();
     foreach ($attributes as $attribute) {
         $attribute->removeTranslation($languageLocale);
         $attribute->store();
     }
     $db->commit();
     return true;
 }
            $tpl->setVariable('is_edit', $Module->isCurrentAction('Edit'));
            $Result['content'] = $tpl->fetch('design:content/translationnew.tpl');
            $Result['path'] = array(array('text' => ezpI18n::tr('kernel/content', 'Translation'), 'url' => false), array('text' => 'New', 'url' => false));
            return;
        }
    }
}
if ($Module->isCurrentAction('Remove')) {
    $seletedIDList = $Module->actionParameter('SelectedTranslationList');
    $db = eZDB::instance();
    $db->begin();
    foreach ($seletedIDList as $translationID) {
        eZContentLanguage::removeLanguage($translationID);
    }
    $db->commit();
    ezpEvent::getInstance()->notify('content/translations/cache', array($seletedIDList));
}
if ($Params['TranslationID']) {
    $translation = eZContentLanguage::fetch($Params['TranslationID']);
    if (!$translation) {
        return $Module->handleError(eZError::KERNEL_NOT_AVAILABLE, 'kernel');
    }
    $tpl->setVariable('translation', $translation);
    $Result['content'] = $tpl->fetch('design:content/translationview.tpl');
    $Result['path'] = array(array('text' => ezpI18n::tr('kernel/content', 'Content translations'), 'url' => 'content/translations'), array('text' => $translation->attribute('name'), 'url' => false));
    return;
}
$availableTranslations = eZContentLanguage::fetchList();
$tpl->setVariable('available_translations', $availableTranslations);
$Result['content'] = $tpl->fetch('design:content/translations.tpl');
$Result['path'] = array(array('text' => ezpI18n::tr('kernel/content', 'Languages'), 'url' => false));
 /**
  * Updates an contentobject's initial language
  *
  * @param int $objectID
  * @param int $newInitialLanguageID
  *
  * @return array An array with operation status, always true
  */
 public static function updateInitialLanguage($objectID, $newInitialLanguageID)
 {
     $object = eZContentObject::fetch($objectID);
     $language = eZContentLanguage::fetch($newInitialLanguageID);
     if ($language and !$language->attribute('disabled')) {
         $object->setAttribute('initial_language_id', $newInitialLanguageID);
         $objectName = $object->name(false, $language->attribute('locale'));
         $object->setAttribute('name', $objectName);
         $object->store();
         if ($object->isAlwaysAvailable()) {
             $object->setAlwaysAvailableLanguageID($newInitialLanguageID);
         }
         $nodes = $object->assignedNodes();
         foreach ($nodes as $node) {
             $node->updateSubTreePath();
         }
     }
     eZContentCacheManager::clearContentCacheIfNeeded($objectID);
     return array('status' => true);
 }
Example #20
0
 /**
  * Returns translation of the tag for provided language ID
  *
  * @param int $languageID
  *
  * @return eZTagsKeyword
  */
 public function translationByLanguageID($languageID)
 {
     /** @var eZContentLanguage $language */
     $language = eZContentLanguage::fetch($languageID);
     if ($language instanceof eZContentLanguage) {
         return $this->translationByLocale($language->attribute('locale'));
     }
     return false;
 }