public static function makeList($rows)
 {
     if (!is_array($rows) || count($rows) == 0) {
         return array();
     }
     $list = array();
     $maxNumberOfLanguages = eZContentLanguage::maxCount();
     foreach ($rows as $row) {
         $row['always_available'] = $row['lang_mask'] % 2;
         $mask = $row['lang_mask'] & ~1;
         for ($i = 1; $i < $maxNumberOfLanguages; ++$i) {
             $newMask = 1 << $i;
             if (($newMask & $mask) > 0) {
                 $row['lang_mask'] = 1 << $i;
                 $list[] = $row;
             }
         }
     }
     $objectList = eZPersistentObject::handleRows($list, 'eZPathElement', true);
     return $objectList;
 }
    /**
     * 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 = eZContentLanguage::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
                    );
    }