Example #1
0
 /**
  * Regression test for issue #18613 :
  * Empty ezcontentlanguage_cache.php not being regenerated.
  * This cache file should always exist, but if for some reason it's empty (lost sync with cluster for instance),
  * it should be at least properly regenerated
  *
  * @link http://issues.ez.no/18613
  * @group issue18613
  */
 public function testFetchListWithBlankCacheFile()
 {
     // First simulate a problem generating the language cache file (make it blank)
     $cachePath = eZSys::cacheDirectory() . '/ezcontentlanguage_cache.php';
     $clusterFileHandler = eZClusterFileHandler::instance($cachePath);
     $clusterFileHandler->storeContents('', 'content', 'php');
     unset($GLOBALS['eZContentLanguageList']);
     // Language list should never be empty
     self::assertNotEmpty(eZContentLanguage::fetchList());
     // Remove the test language cache file
     $clusterFileHandler->delete();
     $clusterFileHandler->purge();
 }
 /**
  *	@desc		settings local use in your site
  *	@author 	David LE RICHE <*****@*****.**>
  *	@param		array $fileTranslationList => translation's file list
  *	@return		void
  *	@copyright	2012
  *	@version 	1.1
  */
 public function setFileListById($fileTranslationList)
 {
     $languageListe = eZContentLanguage::fetchList();
     $localeOverride = eZINI::instance('owtranslate.ini')->variable('LocaleOverride', 'locale');
     foreach ($languageListe as $language) {
         $this->languageList[$language->ID] = array('locale' => array_key_exists($language->Locale, $localeOverride) ? $localeOverride[$language->Locale] : $language->Locale, 'name' => $language->Name);
     }
     foreach ($fileTranslationList as $fileKey => $file) {
         foreach ($this->languageList as $key => $language) {
             if (substr($fileKey, 0, 6) == substr($language['locale'], 0, 6)) {
                 $this->fileList[$key] = $file;
             }
         }
     }
 }
 function createSqlParts($params)
 {
     $sqlJoins = '';
     if (isset($params['locales'])) {
         $language_mask = 0;
         $locales = eZContentLanguage::fetchList();
         foreach ($locales as $locale) {
             if (in_array($locale->attribute('locale'), $params['locales'])) {
                 $language_mask |= $locale->attribute('id');
             }
         }
         if ($language_mask) {
             $sqlJoins = " ezcontentobject.language_mask & {$language_mask} AND ";
         }
     }
     return array('tables' => '', 'joins' => $sqlJoins, 'columns' => '');
 }
 function attribute($attr)
 {
     switch ($attr) {
         case 'sections':
             $sections = eZSection::fetchList(false);
             foreach ($sections as $key => $section) {
                 $sections[$key]['Name'] = $section['name'];
                 $sections[$key]['value'] = $section['id'];
             }
             return $sections;
             break;
         case 'languages':
             return eZContentLanguage::fetchList();
             break;
     }
     return eZWorkflowEventType::attribute($attr);
 }
Example #5
0
                return $Module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' );
            }
        }
        else
        {
            return $Module->handleError( eZError::KERNEL_ACCESS_DENIED, 'kernel' );
        }
        $obj->cleanupInternalDrafts();
    }
    else
    {
        // No version so we investigate further.
        $obj->cleanupInternalDrafts();

        // Check number of languages
        $languages = eZContentLanguage::fetchList();
        // If there is only one language we choose it for the user and goes to version choice screen.
        if ( count( $languages ) == 1 )
        {
            $firstLanguage = array_shift( $languages );
            return $Module->redirectToView( 'edit', array( $ObjectID, 'f', $firstLanguage->attribute( 'locale' ) ) );
        }

        $canCreateLanguageList = $obj->attribute( 'can_create_languages' );
        $canEditLanguageList = $obj->attribute( 'can_edit_languages' );
        if ( count( $canCreateLanguageList ) == 0 && count( $canEditLanguageList ) == 1 )
        {
            $firstLanguage = array_shift( $canEditLanguageList );
            return $Module->redirectToView( 'edit', array( $ObjectID, 'f', $firstLanguage->attribute( 'locale' ) ) );
        }
 /**
  *
  * @return array an array of eZContentObjectStateLanguage objects, representing all possible
  *         translations of this content object state
  */
 public function allTranslations()
 {
     if (!is_array($this->AllTranslations)) {
         $allTranslations = array();
         foreach ($this->translations() as $translation) {
             $languageID = $translation->attribute('language_id') & ~1;
             $allTranslations[$languageID] = $translation;
         }
         $languages = eZContentLanguage::fetchList();
         foreach ($languages as $language) {
             $languageID = $language->attribute('id');
             if (!array_key_exists($languageID, $allTranslations)) {
                 $row = array('language_id' => $languageID);
                 if (isset($this->ID)) {
                     $row['contentobject_state_id'] = $this->ID;
                 }
                 $allTranslations[$languageID] = new eZContentObjectStateLanguage($row);
             }
         }
         ksort($allTranslations);
         // array_values is needed here to reset keys, otherwise eZHTTPPersistence::fetch() won't work
         $this->AllTranslations = array_values($allTranslations);
     }
     return $this->AllTranslations;
 }
/**
 * File containing the elevate view of the ezfind module.
 *
 * @package eZFind
 */

require_once( "kernel/common/template.php" );

$module = $Params['Module'];
$http = eZHTTPTool::instance();
$tpl = templateInit();
$feedback = array();
$wildcard = eZFindElevateConfiguration::WILDCARD;
$viewParameters = array();
$availableTranslations = eZContentLanguage::fetchList();
$thisUrl = '/ezfind/elevate';

// Elevation was triggered from the javascript menu ( content structure menu OR subitems menu )
if ( $http->hasPostVariable( 'ObjectIDFromMenu' ) and is_numeric( $http->postVariable( 'ObjectIDFromMenu' ) ) )
{
    $elevatedObject = eZContentObject::fetch( $http->postVariable( 'ObjectIDFromMenu' ) );

    $tpl->setVariable( 'back_from_browse', true );
    $tpl->setVariable( 'elevatedObject', $elevatedObject );
    $tpl->setVariable( 'elevateSearchQuery', '' );
}

// back from browse
else if (
    $http->hasPostVariable( 'BrowseActionName' ) and
 /**
  * \return The bitmap mask containing all languages, i. e. the sum of the IDs of all languages. (The 0-th bit is set.)
  */
 static function maskForRealLanguages()
 {
     if (!isset($GLOBALS['eZContentLanguageMask'])) {
         eZContentLanguage::fetchList(true);
     }
     return $GLOBALS['eZContentLanguageMask'];
 }
    /**
     * Returns an array with locale objects, these objects represents the languages the content objects are
     * allowed to be translated into.
     *
     * The setting ContentSettings/TranslationList in site.ini determines the array.
     *
     * @return eZLocale[]
     */
    static function translationList()
    {
        $translationList = array();
        $languageList = eZContentLanguage::fetchList();

        foreach ( $languageList as $language )
        {
            $translationList[] = $language->localeObject();
        }

        return $translationList;
    }
 function attribute($attr)
 {
     switch ($attr) {
         case 'sections':
             $sections = eZSection::fetchList(false);
             foreach ($sections as $key => $section) {
                 $sections[$key]['Name'] = $section['name'];
                 $sections[$key]['value'] = $section['id'];
             }
             return $sections;
             break;
         case 'languages':
             return eZContentLanguage::fetchList();
             break;
         case 'usergroups':
             $groups = eZPersistentObject::fetchObjectList(eZContentObject::definition(), array('id', 'name'), array('contentclass_id' => 3, 'status' => eZContentObject::STATUS_PUBLISHED), null, null, false);
             foreach ($groups as $key => $group) {
                 $groups[$key]['Name'] = $group['name'];
                 $groups[$key]['value'] = $group['id'];
             }
             return $groups;
             break;
         case 'contentclass_list':
             $classes = eZContentClass::fetchList(eZContentClass::VERSION_STATUS_DEFINED, true, false, array('name' => 'asc'));
             $classList = array();
             for ($i = 0; $i < count($classes); $i++) {
                 $classList[$i]['Name'] = $classes[$i]->attribute('name');
                 $classList[$i]['value'] = $classes[$i]->attribute('id');
             }
             return $classList;
             break;
         case 'workflow_list':
             $workflows = eZWorkflow::fetchList();
             $workflowList = array();
             for ($i = 0; $i < count($workflows); $i++) {
                 $workflowList[$i]['Name'] = $workflows[$i]->attribute('name');
                 $workflowList[$i]['value'] = $workflows[$i]->attribute('id');
             }
             return $workflowList;
             break;
     }
     return eZWorkflowEventType::attribute($attr);
 }
Example #11
0
    /**
     * Removes object $contentObject from the search database.
     *
     * @param eZContentObject $contentObject the content object to remove
     * @param bool $commit Whether to commit after removing the object
     * @return bool True if the operation succeed.
     */
    function removeObject( $contentObject, $commit = null )
    {
        /*
         * @since eZFind 2.2: allow delayed commits if explicitely set as configuration setting and
         * the parameter $commit it is not set
         * Default behaviour is as before
         */
        if ( !isset( $commit ) && ( $this->FindINI->variable( 'IndexOptions', 'DisableDeleteCommits' ) === 'true' ) )
        {
            $commit = false;
        }
        elseif ( !isset( $commit ) )
        {
            $commit = true;
        }

        // 1: remove the assciated "elevate" configuration
        eZFindElevateConfiguration::purge( '', $contentObject->attribute( 'id' ) );
        //eZFindElevateConfiguration::synchronizeWithSolr();
        $this->pushElevateConfiguration();

        // @todo Remove if accepted. Optimize is bad on runtime.
        $optimize = false;
        if ( $commit && ( $this->FindINI->variable( 'IndexOptions', 'OptimizeOnCommit' ) === 'enabled' ) )
        {
            $optimize = true;
        }

        // 2: create a delete array with all the required infos, groupable by language
        $languages = eZContentLanguage::fetchList();
        foreach ( $languages as $language )
        {
            $languageCode = $language->attribute( 'locale' );
            $docs[$languageCode] = $this->guid( $contentObject, $languageCode );
        }
        if ( $this->UseMultiLanguageCores === true )
        {
            foreach ( $docs as $languageCode => $doc )
            {
                $this->SolrLanguageShards[$languageCode]->deleteDocs( array( $doc ), false, $commit, $optimize );
            }
        }
        else
        {
            return $this->Solr->deleteDocs( $docs, false, $commit, $optimize );
        }
    }
 /**
  *	@desc		Generate xml file for all locale on your site with all translation found
  *	@author 	David LE RICHE <*****@*****.**>
  *	@return		bool
  *	@copyright	2012
  *	@version 	1.1
  */
 public function generateXML()
 {
     $this->languageList = eZContentLanguage::fetchList();
     $directoryMainExtension = eZINI::instance('owtranslate.ini')->variable('MainExtension', 'directory');
     $baseDirectory = eZExtension::baseDirectory() . '/' . $directoryMainExtension . '/translations';
     $this->createLocaleDirIfNotExist($baseDirectory);
     $localeOverride = eZINI::instance('owtranslate.ini')->variable('LocaleOverride', 'locale');
     // verification file translation exist
     foreach ($this->languageList as $language) {
         $locale = array_key_exists($language->Locale, $localeOverride) ? $localeOverride[$language->Locale] : $language->Locale;
         if (file_exists($baseDirectory . '/' . $locale . '/translation.ts')) {
             $saveXml = $this->addTranslationIfNotExist($baseDirectory . '/' . $locale . '/translation.ts');
         } else {
             $saveXml = $this->addTranslationFile($baseDirectory . '/' . $locale . '/translation.ts');
         }
     }
     return $saveXml;
 }