/*!
Returns eZLocale object by HTTP locale code $httpLocaleCode
966716
static function fetchByHttpLocaleCode( $httpLocaleCode )
    {
        $locales = self::localeList( true );
        foreach ( $locales as $locale )
        {
            if ( $locale->httpLocaleCode() == $httpLocaleCode )
                return $locale;
        }

        return false;
    }
993308
function guid( $contentObject, $languageCode = '' )
    {
        if ( !$contentObject instanceof eZContentObject )
            return md5( self::installationID() . '-' . $contentObject . '-' . $languageCode );

        return md5( self::installationID() . '-' . $contentObject->attribute( 'id' ) . '-' . $languageCode );
    }
1154555
@JSFProperty(deferredValueType="java.lang.Object")
    public Locale getLocale()
    {
        if (_locale != null)
        {
            return _locale;
        }
        FacesContext context = FacesContext.getCurrentInstance();
        return context.getViewRoot().getLocale();
    }
1311287
private void doGetLocales() throws PageException {
	Struct sct = new StructImpl(StructImpl.TYPE_LINKED);
	// Array arr=new ArrayImpl();
	String strLocale = getString("locale", "english (united kingdom)");
	Locale locale = LocaleFactory.getLocale(strLocale);
	pageContext.setVariable(getString("admin", action, "returnVariable"), sct);
	Map locales = LocaleFactory.getLocales();
	Iterator it = locales.keySet().iterator();

	String key;
	Locale l;
	while (it.hasNext()) {
	    key = (String) it.next();
	    l = (Locale) locales.get(key);
	    sct.setEL(l.toString(), l.getDisplayName(locale));
	    // arr.append(locale.getDisplayName());
	}
	// arr.sort("textnocase","asc");
    }
534783
function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
    {
        if ( $http->hasPostVariable( $base . '_ezkeyword_data_text_' . $contentObjectAttribute->attribute( 'id' ) ) )
        {
            $data = $http->postVariable( $base . '_ezkeyword_data_text_' . $contentObjectAttribute->attribute( 'id' ) );
            $keyword = new eZKeyword();
            $keyword->initializeKeyword( $data );
            $contentObjectAttribute->setContent( $keyword );
            return true;
        }
        return false;
    }
1147852
function getLocale (key) {
    var locale;

    if (key && key._locale && key._locale._abbr) {
        key = key._locale._abbr;
    }

    if (!key) {
        return globalLocale;
    }

    if (!isArray$2(key)) {
        //short-circuit everything else
        locale = loadLocale(key);
        if (locale) {
            return locale;
        }
        key = [key];
    }

    return chooseLocale(key);
}
597447
@Override
    public Enumeration<Locale> getLocales() {
        ServletRESTRequestImpl ret = castRequest();
        if (ret != null)
            return ret.getLocales();
        return null;
    }
379430
public static function languagesLocaleCodes()
    {
        static $list;

        if ($list === null) {
            $list = [];
            foreach (static::codes() as $localeCode) {
                if ($languageCode = static::languageCode($localeCode)) {
                    $list[$languageCode][] = $localeCode;
                }
            }
        }

        return $list;
    }
1146223
function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
    {
        if ( $http->hasPostVariable( $base . "_data_float_" . $contentObjectAttribute->attribute( "id" ) ) )
        {
            $data = $http->postVariable( $base . "_data_float_" . $contentObjectAttribute->attribute( "id" ) );
            $contentObjectAttribute->setHTTPValue( $data );

            $locale = eZLocale::instance();
            $data = $locale->internalNumber( $data );

            $data = str_replace(" ", "", $data);

            $contentObjectAttribute->setAttribute( "data_float", $data );
            return true;
        }
        return false;
    }
1232357
private function getLocaleCode($locale)
    {
        $locales = explode('_', strtolower($locale));
        $locale = array_pop($locales);

        if ('en' === $locale) {
            $locale = 'gb';
        }

        return $locale;
    }
804966
function fetchHTTPFile( $httpFileIdentifier, &$errors, &$file, &$mimeData )
    {
        $returnCode = eZHTTPFile::canFetch( $httpFileIdentifier, 0 );
        if ( $returnCode !== eZHTTPFile::UPLOADEDFILE_OK && $returnCode !== true )
        {
            switch ( $returnCode )
            {
                case eZHTTPFile::UPLOADEDFILE_DOES_NOT_EXIST:
                    $errors[] = array( 'description' => ezpI18n::tr( 'kernel/content/upload', 'A file is required for upload, no file were found.' ) );
                    break;
                case eZHTTPFile::UPLOADEDFILE_EXCEEDS_PHP_LIMIT:
                case eZHTTPFile::UPLOADEDFILE_EXCEEDS_MAX_SIZE:
                    $errors[] = array( 'description' => ezpI18n::tr( 'kernel/content/upload', 'The uploaded file size is above the maximum limit.' ) );
                    break;
                case eZHTTPFile::UPLOADEDFILE_MISSING_TMP_DIR:
                case eZHTTPFile::UPLOADEDFILE_CANT_WRITE:
                case eZHTTPFile::UPLOADEDFILE_UNKNOWN_ERROR:
                    $errors[] = array( 'description' => ezpI18n::tr( 'kernel/content/upload', 'A system error occured while writing the uploaded file.' ) );
                    break;
            }
            return false;
        }

        $file = eZHTTPFile::fetch( $httpFileIdentifier );
        if ( !( $file instanceof eZHTTPFile ) )
        {
            $errors[] = array( 'description' => ezpI18n::tr( 'kernel/content/upload',
                                                        'Expected a eZHTTPFile object but got nothing.' ) );
            return false;
        }

        $mimeData = eZMimeType::findByFileContents( $file->attribute( "original_filename" ) );

        return true;
    }
1263096
function translationList( $language = false, $asObject = true )
    {
        $db = eZDB::instance();

        $languageSQL = '';
        if ( $language !== false )
        {
            $language = $db->escapeString( $language );
            $languageSQL = "AND language_code!='$language'";
        }

        $query = "SELECT DISTINCT language_code
                  FROM ezcontentobject_attribute
                  WHERE contentobject_id='$this->ContentObjectID' AND version='$this->Version'
                  $languageSQL
                  ORDER BY language_code";

        $languageCodes = $db->arrayQuery( $query );

        $translations = array();
        if ( $asObject )
        {
            foreach ( $languageCodes as $languageCode )
            {
                $translations[] = new eZContentObjectTranslation( $this->ContentObjectID, $this->Version, $languageCode["language_code"] );
            }
        }
        else
        {
            foreach ( $languageCodes as $languageCode )
            {
                $translations[] = $languageCode["language_code"];
            }
        }

        return $translations;
    }
870735
public function ezodfFetchOONode( $getParams, $getOptions, $postParams, $postOptions )
    {
        $nodeID = $getParams['nodeID'];
        $languageCode = $getOptions['languageCode'];

        // Alex 2008/04/16 - Added format argument: 'odt' (default), 'doc'
        $format = $getOptions['format'];

        $node = eZContentObjectTreeNode::fetch( $nodeID, $languageCode );

        if ( !$node )
        {
            throw new Exception( 'Could not fetch node: ' . $nodeID );
        }

        $domDocument = new DOMDocument( '1.0', 'utf-8' );
        $ooElement = $domDocument->createElement( 'OONode' );

        // Add node information.
        $ooElement->appendChild( $this->createTreeNodeDOMElement( $domDocument, $node ) );

        // Add binary data element.
        // Alex 2008/04/16 - Added format argument: 'odt' (default), 'doc'
        switch ( $format )
        {
            case 'doc':
                $ooElement->appendChild( $this->createDocDOMElement( $domDocument, $node ) );
                break;

            case 'odt':
                $ooElement->appendChild( $this->createOODOMElement( $domDocument, $node ) );
                break;
        }

        return $ooElement;
    }
693324
public function getTranslations($localeCode)
    {
        $locale = $this->getLocaleByCode($localeCode);

        if (!$locale->hasPoFile()) {
            throw new Exception(sprintf(__("The project has never been scanned for %s.", 'strata'), $locale->getNativeLabel()));
        }

        return Translations::fromPoFile($locale->getPoFilePath());
    }
346324
public static function getTimezoneFromCode($sCode)
    {
        $aAbbreviations = \DateTimeZone::listAbbreviations();
        foreach ($aAbbreviations as $sTzCode => $aValues) {
            if (strtolower($sCode) == $sTzCode) {
                $aTimeZone = reset($aValues);
                return getFromArray('timezone_id', $aTimeZone, false);
            }
        }

        return false;
    }
676928
function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
    {
        $latitude = '';
        $longitude = '';
        $classAttribute = $contentObjectAttribute->contentClassAttribute();
    	if ( $http->hasPostVariable( $base . '_data_gmaplocation_latitude_' . $contentObjectAttribute->attribute( 'id' ) ) &&
             $http->hasPostVariable( $base . '_data_gmaplocation_longitude_' . $contentObjectAttribute->attribute( 'id' ) ) )
        {

            $latitude = $http->postVariable( $base . '_data_gmaplocation_latitude_' . $contentObjectAttribute->attribute( 'id' ) );
            $longitude = $http->postVariable( $base . '_data_gmaplocation_longitude_' . $contentObjectAttribute->attribute( 'id' ) );
        }

        if ( $latitude === '' || $longitude === '' )
        {
            if ( !$classAttribute->attribute( 'is_information_collector' ) && $contentObjectAttribute->validateIsRequired() )
            {
                $contentObjectAttribute->setValidationError( ezpI18n::tr( 'extension/ezgmaplocation/datatype',
                                                                     'Missing Latitude/Longitude input.' ) );
                return eZInputValidator::STATE_INVALID;
            }
        }
        else if ( !is_numeric( $latitude ) || !is_numeric( $longitude ) )
        {
            $contentObjectAttribute->setValidationError( ezpI18n::tr( 'extension/ezgmaplocation/datatype',
                                                                 'Invalid Latitude/Longitude input.' ) );
            return eZInputValidator::STATE_INVALID;
        }

        return eZInputValidator::STATE_ACCEPTED;
    }
250049
private function createLocale($localeCode)
    {
        /** @var LocaleInterface $locale */
        $locale = $this->localeFactory->createNew();
        $locale->setCode($localeCode);

        return $locale;
    }