function convertFromLocaleCurrency($toCurrency, $value, $applyRounding = true)
 {
     $locale = eZLocale::instance();
     $fromCurrency = $locale->currencyShortName();
     $retValue = $this->convert($fromCurrency, $toCurrency, $value, $applyRounding);
     return $retValue;
 }
Ejemplo n.º 2
0
 function getMeta($keyword)
 {
     $locale = eZLocale::instance();
     $siteURL = $this->siteIni->variable('SiteSettings', 'SiteURL');
     $metaData = $this->siteIni->variable('SiteSettings', 'MetaDataArray');
     return array('title' => sprintf("%s - %s", $keyword, $this->siteIni->variable('SiteSettings', 'SiteName')), 'description' => sprintf('Items on %s related to %s', $siteURL, $keyword), 'language' => $locale->httpLocaleCode(), 'authorName' => $metaData['author'], 'authorMail' => $this->siteIni->variable('MailSettings', 'AdminEmail'), 'siteURL' => $siteURL);
 }
 function locale()
 {
     if ( $this->Locale !== null )
         return $this->Locale;
     $this->Locale = eZLocale::instance( $this->LanguageCode );
     return $this->Locale;
 }
 function __construct($identifier)
 {
     $locale = eZLocale::instance();
     $format = OCCalendarData::FULLDAY_IDENTIFIER_FORMAT;
     $this->identifier = $identifier;
     $dateTime = DateTime::createFromFormat($format, $identifier, OCCalendarData::timezone());
     if (!$dateTime instanceof DateTime) {
         throw new Exception("{$identifier} in format '{$format}' is not a valid DateTime");
     }
     $dateTime->setTime(0, 0, 0);
     $this->day = $dateTime->format('j');
     $this->shortDayName = $locale->shortDayName($dateTime->format('w'));
     $this->longDayName = $locale->longDayName($dateTime->format('w'));
     $this->month = $dateTime->format('n');
     $this->longMonthName = $locale->longMonthName($this->month);
     $this->shortMonthName = $locale->shortMonthName($this->month);
     $this->year = $dateTime->format('Y');
     $this->urlSuffix = "/(day)/{$this->day}/(month)/{$this->month}/(year)/{$this->year}";
     $this->dayStartDateTime = clone $dateTime;
     $this->dayStartDateTime->setTime(0, 0, 0);
     $this->dayStartTimestamp = $this->dayStartDateTime->format('U');
     $today = mktime(0, 0, 0, date('n'), date('j'), date('Y'));
     $tomorrow = mktime(0, 0, 0, date('n'), date('j') + 1, date('Y'));
     $this->isToday = $this->dayStartTimestamp == $today;
     $this->isTomorrow = $this->dayStartTimestamp == $tomorrow;
     $this->isInWeek = date('W', $this->dayStartTimestamp) == date('W', $today);
     $this->isInMonth = date('n', $this->dayStartTimestamp) == date('n', $today);
     $this->dayEndDateTime = clone $dateTime;
     $this->dayEndDateTime->setTime(23, 59, 59);
     $this->dayEndTimestamp = $this->dayEndDateTime->format('U');
     $this->container = array();
 }
 /**
  * Test for regression #13497:
  * attribute operator throws a PHP fatal error on a node without parent in a displayable language
  *
  * Situation:
  *  - siteaccess with one language (fre-FR) and ShowUntranslatedObjects disabled
  *  - parent content node in another language (eng-GB) with always available disabled
  *  - content node in the siteaccess' language (fre-FR)
  *  - fetch this fre-FR node from anywhere, and call attribute() on it
  *
  * Result:
  *  - Fatal error: Call to a member function attribute() on a non-object in
  *    kernel/classes/ezcontentobjecttreenode.php on line 4225
  *
  * Explanation: the error actually comes from the can_remove_location attribute
  **/
 public function testIssue13497()
 {
     // Create a folder in english only
     $folder = new ezpObject("folder", 2, 14, 1, 'eng-GB');
     $folder->setAlwaysAvailableLanguageID(false);
     $folder->name = "Parent for " . __FUNCTION__;
     $folder->publish();
     $locale = eZLocale::instance('fre-FR');
     $translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
     // Create an article in french only, as a subitem of the previously created folder
     $article = new ezpObject("article", $folder->attribute('main_node_id'), 14, 1, 'fre-FR');
     $article->title = "Object for " . __FUNCTION__;
     $article->short_description = "Description of test for " . __FUNCTION__;
     $article->publish();
     $articleNodeID = $article->attribute('main_node_id');
     // INi changes: set language to french only, untranslatedobjects disabled
     ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ContentObjectLocale', 'fre-FR');
     ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'SiteLanguageList', array('fre-FR'));
     ezpINIHelper::setINISetting('site.ini', 'RegionalSettings', 'ShowUntranslatedObjects', 'disabled');
     eZContentLanguage::expireCache();
     // This should crash
     eZContentObjectTreeNode::fetch($articleNodeID)->attribute('can_remove_location');
     ezpINIHelper::restoreINISettings();
     // re-expire cache for further tests
     eZContentLanguage::expireCache();
 }
 /**
  * Regression test for issue {@see #19174 http://issues.ez.no/19174}
  */
 public function testIssue19174()
 {
     $bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();
     // add a secondary language
     $locale = eZLocale::instance('fre-FR');
     $translation = eZContentLanguage::addLanguage($locale->localeCode(), $locale->internationalLanguageName());
     // create related objects
     $relatedObjectsIds = array($this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation(), $this->createObjectForRelation());
     $xmlTextEn = "<embed href=\"ezobject://{$relatedObjectsIds[0]}\" /><link href=\"ezobject://{$relatedObjectsIds[1]}\">link</link>";
     $xmlTextFr = "<embed href=\"ezobject://{$relatedObjectsIds[2]}\" /><link href=\"ezobject://{$relatedObjectsIds[3]}\">link</link>";
     // Create an article in eng-GB, and embed related object one in the intro
     $article = new ezpObject('article', 2, 14, 1, 'eng-GB');
     $article->title = __METHOD__ . ' eng-GB';
     $article->intro = $xmlTextEn;
     $articleId = $article->publish();
     // Workaround as setting folder->name directly doesn't produce the expected result
     $article->addTranslation('fre-FR', array('title' => __METHOD__ . ' fre-FR', 'intro' => $xmlTextFr));
     $relatedObjects = eZContentObject::fetch($articleId)->relatedObjects(false, false, 0, false, array('AllRelations' => eZContentObject::RELATION_LINK | eZContentObject::RELATION_EMBED));
     self::assertEquals(4, count($relatedObjects));
     $expectedRelations = array_flip($relatedObjectsIds);
     foreach ($relatedObjects as $relatedObject) {
         if (isset($expectedRelations[$relatedObject->ID])) {
             unset($expectedRelations[$relatedObject->ID]);
         }
     }
     self::assertEquals(0, count($expectedRelations));
     $article->remove();
     $translation->removeThis();
     eZContentLanguage::setPrioritizedLanguages($bkpLanguages);
 }
 function __construct($value)
 {
     if ($value instanceof eZCurrency) {
         $value = $value->value();
     }
     $this->Value = $value;
     $this->Locale = eZLocale::instance();
 }
Ejemplo n.º 8
0
    /**
     * @param bool $localeString
     * @return string
     */
    public static function countryISO3166Code( $localeString = false )
    {
        if ( $localeString === false )
        {
            $localeString = eZLocale::instance()->localeFullCode();
        }

        $isoCodes = self::isoCodes( $localeString );
        return $isoCodes[1];
    }
Ejemplo n.º 9
0
 /**
  * Creates a new date object with default locale, if $date is not supplied
  * the current date is used.
  *
  * @note this uses the current Timezone
  *
  * @param int $date
  */
 function __construct($date = false)
 {
     $dt = new DateTime();
     if ($date !== false) {
         $dt->setTimestamp($date);
     }
     $dt->setTime(0, 0, 0);
     $this->Date = $dt->getTimestamp();
     $this->Locale = eZLocale::instance();
     $this->IsValid = $date !== null;
 }
Ejemplo n.º 10
0
 /**
  * i18n
  * Provides all i18n strings for use by TinyMCE and other javascript dialogs.
  * 
  * @static
  * @param array $args
  * @param string $fileExtension
  * @return string returns json string with translation data
  */
 public static function i18n($args, $fileExtension)
 {
     $lang = '-en';
     $locale = eZLocale::instance();
     if ($args && $args[0]) {
         $lang = $args[0];
     }
     $i18nArray = array($lang => array('soextra' => array('font_size' => ezi18n('design/standard/soextra', "Font size"), 'font_class' => ezi18n('design/standard/soextra', "Font style"), 'class' => ezi18n('design/standard/soextra', "Element style"), 'remove_tag' => ezi18n('design/standard/soextra', 'Remove &quot;%tag&quot; tag', null, array('%tag' => '<tag>')), 'remove_tag_keep_contents' => ezi18n('design/standard/soextra', 'Remove &quot;%tag&quot; tag (keep contents)', null, array('%tag' => '<tag>')), 'cursor_before' => ezi18n('design/standard/soextra', 'Place cursor before &quot;%tag&quot;', null, array('%tag' => '<tag>')), 'cursor_after' => ezi18n('design/standard/soextra', 'Place cursor after &quot;%tag&quot;', null, array('%tag' => '<tag>')))));
     $i18nString = json_encode($i18nArray);
     return 'tinyMCE.addI18n( ' . $i18nString . ' );';
 }
Ejemplo n.º 11
0
 /**
  * Executes the operators
  *
  * @param eZTemplate $tpl
  * @param string $operatorName
  * @param array $operatorParameters
  * @param string $rootNamespace
  * @param string $currentNamespace
  * @param mixed $operatorValue
  * @param array $namedParameters
  */
 function modify(&$tpl, &$operatorName, &$operatorParameters, &$rootNamespace, &$currentNamespace, &$operatorValue, &$namedParameters)
 {
     switch ($operatorName) {
         case 'opengraph':
             $operatorValue = $this->generateOpenGraphTags($namedParameters['nodeid']);
             break;
         case 'language_code':
             $operatorValue = eZLocale::instance()->httpLocaleCode();
             break;
     }
 }
Ejemplo n.º 12
0
 /**
  * i18n
  * Provides all i18n strings for use by TinyMCE and other javascript dialogs.
  *
  * @param array $args
  * @param string $fileExtension
  * @return string returns json string with translation data
  */
 public static function i18n($args, $fileExtension)
 {
     $lang = '-en';
     $locale = eZLocale::instance();
     if ($args && $args[0]) {
         $lang = $args[0];
     }
     $i18nArray = array($lang => array('common' => array('edit_confirm' => ezpI18n::tr('design/standard/ezoe', "Do you want to use the WYSIWYG mode for this textarea?"), 'apply' => ezpI18n::tr('design/standard/ezoe', "Apply"), 'insert' => ezpI18n::tr('design/standard/ezoe', "Insert"), 'update' => ezpI18n::tr('design/standard/ezoe', "Update"), 'cancel' => ezpI18n::tr('design/standard/ezoe', "Cancel"), 'close' => ezpI18n::tr('design/standard/ezoe', "Close"), 'browse' => ezpI18n::tr('design/standard/ezoe', "Browse"), 'class_name' => ezpI18n::tr('design/standard/ezoe', "Class"), 'not_set' => ezpI18n::tr('design/standard/ezoe', "-- Not set --"), 'clipboard_msg' => ezpI18n::tr('design/standard/ezoe', "Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?"), 'clipboard_no_support' => ezpI18n::tr('design/standard/ezoe', "Currently not supported by your browser, use keyboard shortcuts instead."), 'popup_blocked' => ezpI18n::tr('design/standard/ezoe', "Sorry, but we have noticed that your popup-blocker has disabled a window that provides application functionality. You will need to disable popup blocking on this site in order to fully utilize this tool."), 'invalid_data' => ezpI18n::tr('design/standard/ezoe', "Error: Invalid values entered, these are marked in red."), 'more_colors' => ezpI18n::tr('design/standard/ezoe', "More colors")), 'validator_dlg' => array('required' => ezpI18n::tr('design/standard/ezoe/validator', '&quot;%label&quot; is required and must have a value', null, array('%label' => '<label>')), 'number' => ezpI18n::tr('design/standard/ezoe/validator', '&quot;%label&quot; must be a valid number', null, array('%label' => '<label>')), 'int' => ezpI18n::tr('design/standard/ezoe/validator', '&quot;%label&quot; must be a valid integer number', null, array('%label' => '<label>')), 'url' => ezpI18n::tr('design/standard/ezoe/validator', '&quot;%label&quot; must be a valid absolute url address', null, array('%label' => '<label>')), 'email' => ezpI18n::tr('design/standard/ezoe/validator', '&quot;%label&quot; must be a valid email address', null, array('%label' => '<label>')), 'size' => ezpI18n::tr('design/standard/ezoe/validator', '&quot;%label&quot; must be a valid css size/unit value', null, array('%label' => '<label>')), 'html_id' => ezpI18n::tr('design/standard/ezoe/validator', '&quot;%label&quot; must be a valid html element id', null, array('%label' => '<label>')), 'min' => ezpI18n::tr('design/standard/ezoe/validator', '&quot;%label&quot; must be higher then %min', null, array('%label' => '<label>', '%min' => '<min>')), 'max' => ezpI18n::tr('design/standard/ezoe/validator', '&quot;%label&quot; must be lower then %max', null, array('%label' => '<label>', '%max' => '<max>'))), 'contextmenu' => array('align' => ezpI18n::tr('design/standard/ezoe', "Alignment"), 'left' => ezpI18n::tr('design/standard/ezoe', "Left"), 'center' => ezpI18n::tr('design/standard/ezoe', "Center"), 'right' => ezpI18n::tr('design/standard/ezoe', "Right"), 'full' => ezpI18n::tr('design/standard/ezoe', "Full")), 'insertdatetime' => array('date_fmt' => ezpI18n::tr('design/standard/ezoe', "%Y-%m-%d"), 'time_fmt' => ezpI18n::tr('design/standard/ezoe', "%H:%M:%S"), 'insertdate_desc' => ezpI18n::tr('design/standard/ezoe', "Insert date"), 'inserttime_desc' => ezpI18n::tr('design/standard/ezoe', "Insert time"), 'months_long' => implode(',', $locale->LongMonthNames), 'months_short' => implode(',', $locale->ShortMonthNames), 'day_long' => implode(',', $locale->LongDayNames) . ',' . $locale->longDayName(0), 'day_short' => implode(',', $locale->ShortDayNames) . ',' . $locale->shortDayName(0)), 'print' => array('print_desc' => ezpI18n::tr('design/standard/ezoe', "Print")), 'preview' => array('preview_desc' => ezpI18n::tr('design/standard/ezoe', "Preview")), 'directionality' => array('ltr_desc' => ezpI18n::tr('design/standard/ezoe', "Direction left to right"), 'rtl_desc' => ezpI18n::tr('design/standard/ezoe', "Direction right to left")), 'save' => array('save_desc' => ezpI18n::tr('design/standard/ezoe', "Save"), 'cancel_desc' => ezpI18n::tr('design/standard/ezoe', "Cancel all changes")), 'nonbreaking' => array('nonbreaking_desc' => ezpI18n::tr('design/standard/ezoe', "Insert non-breaking space character")), 'iespell' => array('iespell_desc' => ezpI18n::tr('design/standard/ezoe', "Run spell checking"), 'download' => ezpI18n::tr('design/standard/ezoe', "ieSpell not detected. Do you want to install it now?")), 'advhr' => array('advhr_desc' => ezpI18n::tr('design/standard/ezoe', "Horizontale rule")), 'emotions' => array('emotions_desc' => ezpI18n::tr('design/standard/ezoe', "Emotions")), 'emotions_dlg' => array('title' => ezpI18n::tr('design/standard/ezoe', "Insert emotion"), 'desc' => ezpI18n::tr('design/standard/ezoe', "Emotions"), 'cool' => ezpI18n::tr('design/standard/ezoe', "Cool"), 'cry' => ezpI18n::tr('design/standard/ezoe', "Cry"), 'embarassed' => ezpI18n::tr('design/standard/ezoe', "Embarassed"), 'foot_in_mouth' => ezpI18n::tr('design/standard/ezoe', "Foot in mouth"), 'frown' => ezpI18n::tr('design/standard/ezoe', "Frown"), 'innocent' => ezpI18n::tr('design/standard/ezoe', "Innocent"), 'kiss' => ezpI18n::tr('design/standard/ezoe', "Kiss"), 'laughing' => ezpI18n::tr('design/standard/ezoe', "Laughing"), 'money_mouth' => ezpI18n::tr('design/standard/ezoe', "Money mouth"), 'sealed' => ezpI18n::tr('design/standard/ezoe', "Sealed"), 'smile' => ezpI18n::tr('design/standard/ezoe', "Smile"), 'surprised' => ezpI18n::tr('design/standard/ezoe', "Surprised"), 'tongue_out' => ezpI18n::tr('design/standard/ezoe', "Tongue out"), 'undecided' => ezpI18n::tr('design/standard/ezoe', "Undecided"), 'wink' => ezpI18n::tr('design/standard/ezoe', "Wink"), 'usage' => ezpI18n::tr('design/standard/ezoe', "Use left and right arrows to navigate."), 'yell' => ezpI18n::tr('design/standard/ezoe', "Yell")), 'searchreplace' => array('search_desc' => ezpI18n::tr('design/standard/ezoe', "Find"), 'replace_desc' => ezpI18n::tr('design/standard/ezoe', "Find/Replace")), 'paste' => array('paste_text_desc' => ezpI18n::tr('design/standard/ezoe', "Paste as Plain Text"), 'paste_word_desc' => ezpI18n::tr('design/standard/ezoe', "Paste from Word"), 'selectall_desc' => ezpI18n::tr('design/standard/ezoe', "Select All"), 'plaintext_mode_sticky' => ezpI18n::tr('design/standard/ezoe', "Paste is now in plain text mode. Click again to toggle back to regular paste mode. After you paste something you will be returned to regular paste mode."), 'plaintext_mode' => ezpI18n::tr('design/standard/ezoe', "Paste is now in plain text mode. Click again to toggle back to regular paste mode.")), 'paste_dlg' => array('text_title' => ezpI18n::tr('design/standard/ezoe', "Use CTRL+V on your keyboard to paste the text into the window."), 'text_linebreaks' => ezpI18n::tr('design/standard/ezoe', "Keep linebreaks"), 'word_title' => ezpI18n::tr('design/standard/ezoe', "Use CTRL+V on your keyboard to paste the text into the window.")), 'table' => array('desc' => ezpI18n::tr('design/standard/ezoe', "Inserts a new table"), 'row_before_desc' => ezpI18n::tr('design/standard/ezoe', "Insert row before"), 'row_after_desc' => ezpI18n::tr('design/standard/ezoe', "Insert row after"), 'delete_row_desc' => ezpI18n::tr('design/standard/ezoe', "Delete row"), 'col_before_desc' => ezpI18n::tr('design/standard/ezoe', "Insert column before"), 'col_after_desc' => ezpI18n::tr('design/standard/ezoe', "Insert column after"), 'delete_col_desc' => ezpI18n::tr('design/standard/ezoe', "Remove column"), 'split_cells_desc' => ezpI18n::tr('design/standard/ezoe', "Split merged table cells"), 'merge_cells_desc' => ezpI18n::tr('design/standard/ezoe', "Merge table cells"), 'row_desc' => ezpI18n::tr('design/standard/ezoe', "Table row properties"), 'cell_desc' => ezpI18n::tr('design/standard/ezoe', "Table cell properties"), 'props_desc' => ezpI18n::tr('design/standard/ezoe', "Table properties"), 'paste_row_before_desc' => ezpI18n::tr('design/standard/ezoe', "Paste table row before"), 'paste_row_after_desc' => ezpI18n::tr('design/standard/ezoe', "Paste table row after"), 'cut_row_desc' => ezpI18n::tr('design/standard/ezoe', "Cut table row"), 'copy_row_desc' => ezpI18n::tr('design/standard/ezoe', "Copy table row"), 'del' => ezpI18n::tr('design/standard/ezoe', "Delete table"), 'row' => ezpI18n::tr('design/standard/ezoe', "Row"), 'col' => ezpI18n::tr('design/standard/ezoe', "Column"), 'rows' => ezpI18n::tr('design/standard/ezoe', "Rows"), 'cols' => ezpI18n::tr('design/standard/ezoe', "Columns"), 'cell' => ezpI18n::tr('design/standard/ezoe', "Cell")), 'autosave' => array('unload_msg' => ezpI18n::tr('design/standard/ezoe', "The changes you made will be lost if you navigate away from this page.")), 'fullscreen' => array('desc' => ezpI18n::tr('design/standard/ezoe', "Toggle fullscreen mode")), 'media' => array('desc' => ezpI18n::tr('design/standard/ezoe', "Insert / edit embedded media"), 'edit' => ezpI18n::tr('design/standard/ezoe', "Edit embedded media")), 'fullpage' => array('desc' => ezpI18n::tr('design/standard/ezoe', "Document properties")), 'template' => array('desc' => ezpI18n::tr('design/standard/ezoe', "Insert predefined template content")), 'visualchars' => array('desc' => ezpI18n::tr('design/standard/ezoe', "Visual control characters on/off.")), 'spellchecker' => array('desc' => ezpI18n::tr('design/standard/ezoe', "Toggle spellchecker"), 'menu' => ezpI18n::tr('design/standard/ezoe', "Spellchecker settings"), 'ignore_word' => ezpI18n::tr('design/standard/ezoe', "Ignore word"), 'ignore_words' => ezpI18n::tr('design/standard/ezoe', "Ignore all"), 'langs' => ezpI18n::tr('design/standard/ezoe', "Languages"), 'wait' => ezpI18n::tr('design/standard/ezoe', "Please wait..."), 'sug' => ezpI18n::tr('design/standard/ezoe', "Suggestions"), 'no_sug' => ezpI18n::tr('design/standard/ezoe', "No suggestions"), 'no_mpell' => ezpI18n::tr('design/standard/ezoe', "No misspellings found.")), 'pagebreak' => array('desc' => ezpI18n::tr('design/standard/ezoe', "Insert page break.")), 'advanced' => array('style_select' => ezpI18n::tr('design/standard/ezoe', "Styles"), 'block' => ezpI18n::tr('design/standard/ezoe', "Format"), 'paragraph' => ezpI18n::tr('design/standard/ezoe', "Paragraph"), 'div' => ezpI18n::tr('design/standard/ezoe', "Div"), 'pre' => ezpI18n::tr('design/standard/ezoe', "Literal"), 'h1' => ezpI18n::tr('design/standard/ezoe', "Heading 1"), 'h2' => ezpI18n::tr('design/standard/ezoe', "Heading 2"), 'h3' => ezpI18n::tr('design/standard/ezoe', "Heading 3"), 'h4' => ezpI18n::tr('design/standard/ezoe', "Heading 4"), 'h5' => ezpI18n::tr('design/standard/ezoe', "Heading 5"), 'h6' => ezpI18n::tr('design/standard/ezoe', "Heading 6"), 'code' => ezpI18n::tr('design/standard/ezoe', "Code"), 'samp' => ezpI18n::tr('design/standard/ezoe', "Code sample"), 'dt' => ezpI18n::tr('design/standard/ezoe', "Definition term"), 'dd' => ezpI18n::tr('design/standard/ezoe', "Definition description"), 'bold_desc' => ezpI18n::tr('design/standard/ezoe', "Bold (Ctrl+B)"), 'italic_desc' => ezpI18n::tr('design/standard/ezoe', "Italic (Ctrl+I)"), 'underline_desc' => ezpI18n::tr('design/standard/ezoe', "Underline (Ctrl+U)"), 'striketrough_desc' => ezpI18n::tr('design/standard/ezoe', "Strikethrough"), 'justifyleft_desc' => ezpI18n::tr('design/standard/ezoe', "Align left"), 'justifycenter_desc' => ezpI18n::tr('design/standard/ezoe', "Align center"), 'justifyright_desc' => ezpI18n::tr('design/standard/ezoe', "Align right"), 'justifyfull_desc' => ezpI18n::tr('design/standard/ezoe', "Align full"), 'bullist_desc' => ezpI18n::tr('design/standard/ezoe', "Unordered list"), 'numlist_desc' => ezpI18n::tr('design/standard/ezoe', "Ordered list"), 'outdent_desc' => ezpI18n::tr('design/standard/ezoe', "Outdent"), 'indent_desc' => ezpI18n::tr('design/standard/ezoe', "Indent"), 'undo_desc' => ezpI18n::tr('design/standard/ezoe', "Undo (Ctrl+Z)"), 'redo_desc' => ezpI18n::tr('design/standard/ezoe', "Redo (Ctrl+Y)"), 'link_desc' => ezpI18n::tr('design/standard/ezoe', "Insert/edit link"), 'unlink_desc' => ezpI18n::tr('design/standard/ezoe', "Unlink"), 'image_desc' => ezpI18n::tr('design/standard/ezoe', "Insert/edit image"), 'object_desc' => ezpI18n::tr('design/standard/ezoe', "Insert/edit object"), 'file_desc' => ezpI18n::tr('design/standard/ezoe', "Insert/edit file"), 'custom_desc' => ezpI18n::tr('design/standard/ezoe', "Insert custom tag"), 'literal_desc' => ezpI18n::tr('design/standard/ezoe', "Insert literal text"), 'pagebreak_desc' => ezpI18n::tr('design/standard/ezoe', "Insert pagebreak"), 'disable_desc' => ezpI18n::tr('design/standard/content/datatype', "Disable editor"), 'store_desc' => ezpI18n::tr('design/standard/content/edit', "Store draft"), 'publish_desc' => ezpI18n::tr('design/standard/content/edit', "Send for publishing"), 'discard_desc' => ezpI18n::tr('design/standard/content/edit', "Discard"), 'cleanup_desc' => ezpI18n::tr('design/standard/ezoe', "Cleanup messy code"), 'code_desc' => ezpI18n::tr('design/standard/ezoe', "Edit HTML Source"), 'sub_desc' => ezpI18n::tr('design/standard/ezoe', "Subscript"), 'sup_desc' => ezpI18n::tr('design/standard/ezoe', "Superscript"), 'hr_desc' => ezpI18n::tr('design/standard/ezoe', "Insert horizontal ruler"), 'removeformat_desc' => ezpI18n::tr('design/standard/ezoe', "Remove formatting"), 'custom1_desc' => ezpI18n::tr('design/standard/ezoe', "Your custom description here"), 'charmap_desc' => ezpI18n::tr('design/standard/ezoe', "Insert special character"), 'visualaid_desc' => ezpI18n::tr('design/standard/ezoe', "Toggle guidelines/invisible elements"), 'anchor_desc' => ezpI18n::tr('design/standard/ezoe', "Insert/edit anchor"), 'cut_desc' => ezpI18n::tr('design/standard/ezoe', "Cut"), 'copy_desc' => ezpI18n::tr('design/standard/ezoe', "Copy"), 'paste_desc' => ezpI18n::tr('design/standard/ezoe', "Paste"), 'image_props_desc' => ezpI18n::tr('design/standard/ezoe', "Image properties"), 'newdocument_desc' => ezpI18n::tr('design/standard/ezoe', "New document"), 'help_desc' => ezpI18n::tr('design/standard/ezoe', "Help"), 'clipboard_msg' => ezpI18n::tr('design/standard/ezoe', "Copy/Cut/Paste is not available in Mozilla and Firefox.\nDo you want more information about this issue?"), 'path' => ezpI18n::tr('design/standard/ezoe', "Path"), 'newdocument' => ezpI18n::tr('design/standard/ezoe', "Are you sure you want clear all contents?"), 'toolbar_focus' => ezpI18n::tr('design/standard/ezoe', "Jump to tool buttons - Alt+Q, Jump to editor - Alt-Z, Jump to element path - Alt-X"), 'next' => ezpI18n::tr('design/standard/ezoe', "Next"), 'previous' => ezpI18n::tr('design/standard/ezoe', "Previous"), 'select' => ezpI18n::tr('design/standard/ezoe', "Select"), 'type' => ezpI18n::tr('design/standard/ezoe', "Type")), 'advanced_dlg' => array('about_general' => ezpI18n::tr('design/standard/ezoe', "About"), 'about_help' => ezpI18n::tr('design/standard/ezoe', "Help"), 'about_license' => ezpI18n::tr('design/standard/ezoe', "License"), 'about_plugins' => ezpI18n::tr('design/standard/ezoe', "Plugins"), 'about_plugin' => ezpI18n::tr('design/standard/ezoe', "Plugin"), 'about_author' => ezpI18n::tr('design/standard/ezoe', "Author"), 'about_version' => ezpI18n::tr('design/standard/ezoe', "Version"), 'about_loaded' => ezpI18n::tr('design/standard/ezoe', "Loaded plugins"), 'code_title' => ezpI18n::tr('design/standard/ezoe', "HTML Source Editor"), 'code_wordwrap' => ezpI18n::tr('design/standard/ezoe', "Word wrap"), 'colorpicker_title' => ezpI18n::tr('design/standard/ezoe', "Select a color"), 'colorpicker_picker_tab' => ezpI18n::tr('design/standard/ezoe', "Picker"), 'colorpicker_picker_title' => ezpI18n::tr('design/standard/ezoe', "Color picker"), 'colorpicker_palette_tab' => ezpI18n::tr('design/standard/ezoe', "Palette"), 'colorpicker_palette_title' => ezpI18n::tr('design/standard/ezoe', "Palette colors"), 'colorpicker_named_tab' => ezpI18n::tr('design/standard/ezoe', "Named"), 'colorpicker_named_title' => ezpI18n::tr('design/standard/ezoe', "Named colors"), 'colorpicker_color' => ezpI18n::tr('design/standard/ezoe', "Color"), 'colorpicker_name' => ezpI18n::tr('design/standard/ezoe', "Name"), 'charmap_usage' => ezpI18n::tr('design/standard/ezoe', "Use left and right arrows to navigate."), 'charmap_title' => ezpI18n::tr('design/standard/ezoe', "Select special character")), 'ez' => array('root_node_name' => ezpI18n::tr('kernel/content', 'Top Level Nodes'), 'empty_search_result' => ezpI18n::tr('design/standard/content/search', 'No results were found when searching for &quot;%1&quot;', null, array('%1' => '<search_string>')), 'empty_bookmarks_result' => ezpI18n::tr('design/standard/content/view', 'You have no bookmarks')), 'searchreplace_dlg' => array('searchnext_desc' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Find again"), 'notfound' => ezpI18n::tr('design/standard/ezoe/searchreplace', "The search has been completed. The search string could not be found."), 'search_title' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Find"), 'replace_title' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Find/Replace"), 'allreplaced' => ezpI18n::tr('design/standard/ezoe/searchreplace', "All occurrences of the search string were replaced."), 'findwhat' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Find what"), 'replacewith' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Replace with"), 'direction' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Direction"), 'up' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Up"), 'down' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Down"), 'mcase' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Match case"), 'findnext' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Find next"), 'replace' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Replace"), 'replaceall' => ezpI18n::tr('design/standard/ezoe/searchreplace', "Replace all"))));
     $i18nString = json_encode($i18nArray);
     return 'tinyMCE.addI18n( ' . $i18nString . ' );';
 }
Ejemplo n.º 13
0
 static function fetchTranslatedNames( &$countries )
 {
     $locale = eZLocale::instance();
     $translatedCountryNames = $locale->translatedCountryNames();
     foreach ( array_keys( $countries ) as $countryKey )
     {
         $translatedName = isset( $translatedCountryNames[$countryKey] ) ? $translatedCountryNames[$countryKey] : false;
         if ( $translatedName )
             $countries[$countryKey]['Name'] = $translatedName;
     }
     usort( $countries, array( 'eZCountryType', 'compareCountryNames' ) );
 }
Ejemplo n.º 14
0
 function eZDate($date = false)
 {
     if ($date === false) {
         $date = mktime(0, 0, 0);
     } else {
         $arr = getdate($date);
         $date = mktime(0, 0, 0, $arr['mon'], $arr['mday'], $arr['year']);
     }
     $this->Date = $date;
     $this->Locale = eZLocale::instance();
     $this->IsValid = true;
 }
Ejemplo n.º 15
0
 function createRedirectionUrl($process)
 {
     //__DEBUG__
     $this->logger->writeTimedString("createRedirectionUrl");
     //___end____
     $paypalINI = eZINI::instance('paypal.ini');
     $paypalServer = $paypalINI->variable('ServerSettings', 'ServerName');
     $requestURI = $paypalINI->variable('ServerSettings', 'RequestURI');
     $business = urlencode($paypalINI->variable('PaypalSettings', 'Business'));
     $processParams = $process->attribute('parameter_list');
     $orderID = $processParams['order_id'];
     $indexDir = eZSys::indexDir();
     $localHost = eZSys::serverURL();
     $localURI = eZSys::serverVariable('REQUEST_URI');
     $order = eZOrder::fetch($orderID);
     $amount = urlencode($order->attribute('total_inc_vat'));
     $currency = urlencode($order->currencyCode());
     //        include_once( 'lib/ezlocale/classes/ezlocale.php' );
     $locale = eZLocale::instance();
     $countryCode = urlencode($locale->countryCode());
     $maxDescLen = $paypalINI->variable('PaypalSettings', 'MaxDescriptionLength');
     $itemName = urlencode($this->createShortDescription($order, $maxDescLen));
     $accountInfo = $order->attribute('account_information');
     $first_name = urlencode($accountInfo['first_name']);
     $last_name = urlencode($accountInfo['last_name']);
     $street = urlencode($accountInfo['street2']);
     $zip = urlencode($accountInfo['zip']);
     $state = urlencode($accountInfo['state']);
     $place = urlencode($accountInfo['place']);
     $image_url = "{$localHost}" . urlencode($paypalINI->variable('PaypalSettings', 'LogoURI'));
     $background = urlencode($paypalINI->variable('PaypalSettings', 'BackgroundColor'));
     $pageStyle = urlencode($paypalINI->variable('PaypalSettings', 'PageStyle'));
     $noNote = urlencode($paypalINI->variable('PaypalSettings', 'NoNote'));
     $noteLabel = $noNote == 1 ? '' : urlencode($paypalINI->variable('PaypalSettings', 'NoteLabel'));
     $noShipping = 1;
     $url = $paypalServer . $requestURI . "?cmd=_ext-enter" . "&redirect_cmd=_xclick" . "&business={$business}" . "&item_name={$itemName}" . "&custom={$orderID}" . "&amount={$amount}" . "&currency_code={$currency}" . "&first_name={$first_name}" . "&last_name={$last_name}" . "&address1={$street}" . "&zip={$zip}" . "&state={$state}" . "&city={$place}" . "&image_url={$image_url}" . "&cs={$background}" . "&page_style={$pageStyle}" . "&no_shipping={$noShipping}" . "&cn={$noteLabel}" . "&no_note={$noNote}" . "&lc={$countryCode}" . "&notify_url={$localHost}" . $indexDir . "/paypal/notify_url/" . "&return={$localHost}" . $indexDir . "/shop/checkout/" . "&cancel_return={$localHost}" . $indexDir . "/shop/basket/";
     //__DEBUG__
     $this->logger->writeTimedString("business       = {$business}");
     $this->logger->writeTimedString("item_name      = {$itemName}");
     $this->logger->writeTimedString("custom         = {$orderID}");
     $this->logger->writeTimedString("no_shipping    = {$noShipping}");
     $this->logger->writeTimedString("localHost      = {$localHost}");
     $this->logger->writeTimedString("amount         = {$amount}");
     $this->logger->writeTimedString("currency_code  = {$currency}");
     $this->logger->writeTimedString("notify_url     = {$localHost}" . $indexDir . "/paypal/notify_url/");
     $this->logger->writeTimedString("return         = {$localHost}" . $indexDir . "/shop/checkout/");
     $this->logger->writeTimedString("cancel_return  = {$localHost}" . $indexDir . "/shop/basket/");
     //___end____
     return $url;
 }
Ejemplo n.º 16
0
 function number($number, $is_integer)
 {
     $locale = eZLocale::instance();
     if ($is_integer && is_numeric($number) && (int) $number == $number) {
         $neg = $number < 0;
         $num = $neg ? -$number : $number;
         $text = number_format($num, 0, '', $locale->thousandsSeparator());
         $text = ($neg ? $locale->negativeSymbol() : $locale->positiveSymbol()) . $text;
         return $text;
     } else {
         if (is_numeric($number)) {
             return $locale->formatNumber($number);
         } else {
             return $number;
         }
     }
 }
Ejemplo n.º 17
0
 function attribute($attr)
 {
     if ($attr == 'settings') {
         return $this->settings(eZUser::currentUser());
     } else {
         if ($attr == 'all_week_days') {
             return eZLocale::instance()->attribute('weekday_name_list');
         } else {
             if ($attr == 'all_month_days') {
                 return range(1, 31);
             } else {
                 if ($attr == 'available_hours') {
                     return array('0:00', '1:00', '2:00', '3:00', '4:00', '5:00', '6:00', '7:00', '8:00', '9:00', '10:00', '11:00', '12:00', '13:00', '14:00', '15:00', '16:00', '17:00', '18:00', '19:00', '20:00', '21:00', '22:00', '23:00');
                 }
             }
         }
     }
     return eZNotificationEventHandler::attribute($attr);
 }
Ejemplo n.º 18
0
 function setAttribute($attr, $val)
 {
     switch ($attr) {
         case 'discount_percent':
             $locale = eZLocale::instance();
             $val = $locale->internalNumber($val);
             if ($val < 0.0) {
                 $val = 0.0;
             }
             if ($val > 100.0) {
                 $val = 100.0;
             }
             eZPersistentObject::setAttribute($attr, $val);
             break;
         default:
             eZPersistentObject::setAttribute($attr, $val);
             break;
     }
 }
Ejemplo n.º 19
0
 function eZDateTime($datetime = false)
 {
     if ($datetime instanceof eZDate) {
         $arr = getdate($datetime->timeStamp());
         $arr2 = getdate($this->DateTime);
         $datetime = mktime($arr2['hours'], $arr2['minutes'], $arr2['seconds'], $arr['mon'], $arr['mday'], $arr['year']);
     } else {
         if ($datetime instanceof eZTime) {
             $arr2 = getdate($datetime->timeStamp());
             $arr = getdate($this->DateTime);
             $datetime = mktime($arr2['hours'], $arr2['minutes'], $arr2['seconds'], $arr['mon'], $arr['mday'], $arr['year']);
         } else {
             if ($datetime === false) {
                 $datetime = time();
             }
         }
     }
     $this->DateTime = intval($datetime);
     $this->Locale = eZLocale::instance();
     $this->IsValid = true;
 }
Ejemplo n.º 20
0
 function i18nTrans($operatorName, &$node, $tpl, &$resourceData, $element, $lastElement, $elementList, $elementTree, &$parameters)
 {
     // i18n( $input, $context, $comment, $arguments )
     // Check if if the three first parameters are constants, if not we cannot compile it
     foreach (array_slice($parameters, 0, 3) as $parameter) {
         if ($parameter !== null && !eZTemplateNodeTool::isConstantElement($parameter)) {
             return false;
         }
     }
     $value = eZTemplateNodeTool::elementConstantValue($parameters[0]);
     $numParameters = count($parameters);
     $context = $numParameters > 1 ? eZTemplateNodeTool::elementConstantValue($parameters[1]) : null;
     $comment = $numParameters > 2 ? eZTemplateNodeTool::elementConstantValue($parameters[2]) : null;
     if ($numParameters < 4) {
         return array(eZTemplateNodeTool::createStringElement(ezpI18n::tr($context, $value, $comment, null)));
     }
     $values = array();
     $ini = eZINI::instance();
     if ($ini->variable('RegionalSettings', 'TextTranslation') != 'disabled') {
         $language = eZLocale::instance()->localeFullCode();
         if ($language != "eng-GB") {
             $file = 'translation.ts';
             $ini = eZINI::instance();
             $useCache = $ini->variable('RegionalSettings', 'TranslationCache') != 'disabled';
             eZTSTranslator::initialize($context, $language, $file, $useCache);
             $man = eZTranslatorManager::instance();
             $newValue = $man->translate($context, $value, $comment);
             if ($newValue) {
                 $value = $newValue;
             }
         }
     }
     $values[] = array(eZTemplateNodeTool::createStringElement($value));
     $values[] = $parameters[3];
     $code = '%tmp1% = array();' . "\n" . 'foreach ( %2% as %tmp2% => %tmp3% )' . "\n" . '{' . "\n" . '  if ( is_int( %tmp2% ) )' . "\n" . '    %tmp1%[\'%\' . ( (%tmp2%%9) + 1 )] = %tmp3%;' . "\n" . '  else' . "\n" . '    %tmp1%[%tmp2%] = %tmp3%;' . "\n" . '}' . "\n" . '%output% = strtr( %1%, %tmp1% );' . "\n";
     return array(eZTemplateNodeTool::createCodePieceElement($code, $values, false, 3));
 }
Ejemplo n.º 21
0
 static function compilationFilename($key, $resourceData)
 {
     $internalCharset = eZTextCodec::internalCharset();
     $templateFilepath = $resourceData['template-filename'];
     $extraName = '';
     if (preg_match("#^.+/(.*)\\.tpl\$#", $templateFilepath, $matches)) {
         $extraName = $matches[1] . '-';
     } else {
         if (preg_match("#^(.*)\\.tpl\$#", $templateFilepath, $matches)) {
             $extraName = $matches[1] . '-';
         }
     }
     $accessText = false;
     if (isset($GLOBALS['eZCurrentAccess']['name'])) {
         $accessText = '-' . $GLOBALS['eZCurrentAccess']['name'];
     }
     $locale = eZLocale::instance();
     $language = $locale->localeFullCode();
     $http = eZHTTPTool::instance();
     $useFullUrlText = $http->UseFullUrl ? 'full' : 'relative';
     $pageLayoutVariable = "";
     if (isset($GLOBALS['eZCustomPageLayout'])) {
         $pageLayoutVariable = $GLOBALS['eZCustomPageLayout'];
     }
     $ini = eZINI::instance();
     $shareTemplates = $ini->hasVariable('TemplateSettings', 'ShareCompiledTemplates') ? $ini->variable('TemplateSettings', 'ShareCompiledTemplates') == 'enabled' : false;
     if ($shareTemplates) {
         $cacheFileKey = $key . '-' . $language;
     } else {
         $cacheFileKey = $key . '-' . $internalCharset . '-' . $language . '-' . $useFullUrlText . $accessText . "-" . $pageLayoutVariable . '-' . eZSys::indexFile();
     }
     $cacheFileName = $extraName . md5($cacheFileKey) . '.php';
     return $cacheFileName;
 }
Ejemplo n.º 22
0
    {
        $selectedVersion = $http->postVariable( 'SelectedVersion' );
        // Kept for backwards compatibility, EditLanguage may also be set in URL
        if ( $http->hasPostVariable( 'ContentObjectLanguageCode' ) )
        {
            $EditLanguage = $http->postVariable( 'ContentObjectLanguageCode' );
        }

        return $Module->redirectToView( "edit", array( $ObjectID, $selectedVersion, $EditLanguage ) );
    }
}

//Check if there is corresponding locale for the supplied language code.
if ( $EditLanguage != null )
{
   $localeObject = eZLocale::instance( $EditLanguage );
       if ( !$localeObject || !$localeObject->isValid() )
       {
           eZDebug::writeError( "No such locale $EditLanguage!", 'Can not find language.' );
           return $Module->handleError( eZError::KERNEL_LANGUAGE_NOT_FOUND, 'kernel',
                     array( 'AccessList' => $obj->accessList( 'edit' ) ) );
       }
}

// Action for edit_draft.tpl page,
// This will create a new draft of the object which the user can edit.
if ( $http->hasPostVariable( 'NewDraftButton' ) )
{
    // Check permission for object in specified language
    if ( !$obj->canEdit( false, false, false, $EditLanguage ) )
    {
Ejemplo n.º 23
0
 function currency()
 {
     $locale = eZLocale::instance();
     $currencyCode = $locale->currencyShortName();
     return $currencyCode;
 }
Ejemplo n.º 24
0
 /**
  * @param string|bool $dbCharset Default charset used if false
  * @param array $overrideDBParameters
  * @return array
  */
 function checkDatabaseRequirements($dbCharset = false, $overrideDBParameters = array())
 {
     $result = array('error_code' => false, 'use_unicode' => false, 'db_version' => false, 'db_require_version' => false, 'site_charset' => false, 'status' => false);
     $databaseMap = eZSetupDatabaseMap();
     $databaseInfo = $this->PersistenceList['database_info'];
     $databaseInfo['info'] = $databaseMap[$databaseInfo['type']];
     $dbDriver = $databaseInfo['info']['driver'];
     if ($dbCharset === false) {
         $dbCharset = 'iso-8859-1';
     }
     $dbParameters = array('server' => $databaseInfo['server'], 'port' => $databaseInfo['port'], 'user' => $databaseInfo['user'], 'password' => $databaseInfo['password'], 'socket' => trim($databaseInfo['socket']) == '' ? false : $databaseInfo['socket'], 'database' => $databaseInfo['database'], 'charset' => $dbCharset);
     $dbParameters = array_merge($dbParameters, $overrideDBParameters);
     // PostgreSQL requires us to specify database name.
     // We use template1 here since it exists on all PostgreSQL installations.
     if ($dbParameters['database'] == '' and $this->PersistenceList['database_info']['type'] == 'pgsql') {
         $dbParameters['database'] = 'template1';
     }
     try {
         $db = eZDB::instance($dbDriver, $dbParameters, true);
         $result['db_instance'] = $db;
         $result['connected'] = $db->isConnected();
     } catch (eZDBNoConnectionException $e) {
         $result['error_code'] = self::DB_ERROR_CONNECTION_FAILED;
         return $result;
     }
     // Check if the version of the database fits the minimum required
     $dbVersion = $db->databaseServerVersion();
     $result['db_version'] = $dbVersion['string'];
     $result['db_required_version'] = $databaseInfo['info']['required_version'];
     if ($dbVersion != null) {
         if (version_compare($result['db_version'], $databaseInfo['info']['required_version']) == -1) {
             $result['connected'] = false;
             $result['error_code'] = self::DB_ERROR_VERSION_INVALID;
             return $result;
         }
     }
     // If we have PostgreSQL we need to make sure we have the 'digest' procedure available.
     if ($db->databaseName() == 'postgresql' and $dbParameters['database'] != 'template1') {
         $sql = "SELECT count(*) AS count FROM pg_proc WHERE proname='digest'";
         $rows = $db->arrayQuery($sql);
         $count = $rows[0]['count'];
         // If it is 0 we don't have it
         if ($count == 0) {
             $result['error_code'] = self::DB_ERROR_NO_DIGEST_PROC;
             return $result;
         }
     }
     $result['use_unicode'] = false;
     if ($db->isCharsetSupported('utf-8')) {
         $result['use_unicode'] = true;
     }
     // If we regional info we can start checking the charset
     if (isset($this->PersistenceList['regional_info'])) {
         if (isset($this->PersistenceList['regional_info']['site_charset']) and strlen($this->PersistenceList['regional_info']['site_charset']) > 0) {
             $charsetsList = array($this->PersistenceList['regional_info']['site_charset']);
         } else {
             // Figure out charset automatically if it is not set yet
             $primaryLanguage = null;
             $allLanguages = array();
             $allLanguageCodes = array();
             $variationsLanguages = array();
             $primaryLanguageCode = $this->PersistenceList['regional_info']['primary_language'];
             $extraLanguageCodes = isset($this->PersistenceList['regional_info']['languages']) ? $this->PersistenceList['regional_info']['languages'] : array();
             $extraLanguageCodes = array_diff($extraLanguageCodes, array($primaryLanguageCode));
             /*
             if ( isset( $this->PersistenceList['regional_info']['variations'] ) )
             {
                 $variations = $this->PersistenceList['regional_info']['variations'];
                 foreach ( $variations as $variation )
                 {
                     $locale = eZLocale::create( $variation );
                     if ( $locale->localeCode() == $primaryLanguageCode )
                     {
                         $primaryLanguage = $locale;
                     }
                     else
                     {
                         $variationsLanguages[] = $locale;
                     }
                 }
             }
             */
             if ($primaryLanguage === null) {
                 $primaryLanguage = eZLocale::create($primaryLanguageCode);
             }
             $allLanguages[] = $primaryLanguage;
             foreach ($extraLanguageCodes as $extraLanguageCode) {
                 $allLanguages[] = eZLocale::create($extraLanguageCode);
                 $allLanguageCodes[] = $extraLanguageCode;
             }
             $charsetsList = $this->findAppropriateCharsetsList($primaryLanguage, $allLanguages, $result['use_unicode']);
         }
         $checkedCharset = $db->checkCharset($charsetsList, $currentCharset);
         if ($checkedCharset === false) {
             // If the current charset is utf-8 we use that instead
             // since it can represent any character possible in the chosen languages
             if ($currentCharset == 'utf-8') {
                 $charset = 'utf-8';
                 $result['site_charset'] = $charset;
             } else {
                 $result['connected'] = false;
                 $this->PersistenceList['database_info']['requested_charset'] = implode(", ", $charsetsList);
                 $this->PersistenceList['database_info']['current_charset'] = $currentCharset;
                 $result['error_code'] = self::DB_ERROR_CHARSET_DIFFERS;
                 return $result;
             }
         } else {
             if ($checkedCharset === true) {
                 $result['site_charset'] = $charsetsList[0];
             } else {
                 $result['site_charset'] = $checkedCharset;
             }
         }
     }
     $result['status'] = true;
     return $result;
 }
Ejemplo n.º 25
0
 function languageFile($withVariation = false)
 {
     $type = $withVariation ? 'variation' : 'default';
     if (!$this->LanguageINI[$type] instanceof eZINI) {
         $language = $this->languageCode();
         $countryVariation = $this->countryVariation();
         $locale = $language;
         if ($withVariation) {
             if ($countryVariation !== '') {
                 $locale .= '@' . $countryVariation;
             }
         }
         $languageFile = 'language/' . $locale . '.ini';
         if (eZLocale::isDebugEnabled()) {
             eZDebug::writeNotice("Requesting {$languageFile}", __METHOD__);
         }
         if (eZINI::exists($languageFile, 'share/locale')) {
             $this->LanguageINI[$type] = eZINI::instance($languageFile, 'share/locale');
         }
     }
     return $this->LanguageINI[$type];
 }
    /**
     * Regression test for issue {@see #17632 http://issues.ez.no/17632}
     *
     * In a multi language environment, a node fetched with a language other than the prioritized one(s) will return the
     * URL alias in the prioritized language
     */
    public function testIssue17632()
    {
        $bkpLanguages = eZContentLanguage::prioritizedLanguageCodes();

        $strNameEngGB = __FUNCTION__ . " eng-GB";
        $strNameFreFR = __FUNCTION__ . " fre-FR";

        // add a secondary language
        $locale = eZLocale::instance( 'fre-FR' );
        $translation = eZContentLanguage::addLanguage( $locale->localeCode(), $locale->internationalLanguageName() );

        // set the prioritize language list to contain english
        // ezpINIHelper::setINISetting( 'site.ini', 'RegionalSettings', 'SiteLanguageList', array( 'fre-FR' ) );
        eZContentLanguage::setPrioritizedLanguages( array( 'fre-FR' ) );

        // Create an object with data in fre-FR and eng-GB
        $folder = new ezpObject( 'folder', 2, 14, 1, 'eng-GB' );
        $folder->publish();

        // Workaround as setting folder->name directly doesn't produce the expected result
        $folder->addTranslation( 'eng-GB', array( 'name' => $strNameEngGB ) );
        $folder->addTranslation( 'fre-FR', array( 'name' => $strNameFreFR ) );

        $nodeId = $folder->main_node_id;

        // fetch the node with no default parameters. Should return the french URL Alias
        $node = eZContentObjectTreeNode::fetch( $nodeId );
        self::assertEquals( 'testIssue17632-fre-FR' , $node->attribute( 'url_alias' ) );

        // fetch the node in english. Should return the english URL Alias
        $node = eZContentObjectTreeNode::fetch( $nodeId, 'eng-GB' );
        self::assertEquals( 'testIssue17632-eng-GB' , $node->attribute( 'url_alias' ) );

        ezpINIHelper::restoreINISettings();
        eZContentLanguage::setPrioritizedLanguages( $bkpLanguages );
    }
Ejemplo n.º 27
0
 function fixupClassAttributeHTTPInput($http, $base, $classAttribute)
 {
     $minValueName = $base . self::MIN_VARIABLE . $classAttribute->attribute("id");
     $maxValueName = $base . self::MAX_VARIABLE . $classAttribute->attribute("id");
     if ($http->hasPostVariable($minValueName) and $http->hasPostVariable($maxValueName)) {
         $locale = eZLocale::instance();
         $minValueValue = $http->postVariable($minValueName);
         $minValueValue = str_replace(" ", "", $minValueValue);
         $minValueValue = $locale->internalNumber($minValueValue);
         $maxValueValue = $http->postVariable($maxValueName);
         $maxValueValue = str_replace(" ", "", $maxValueValue);
         $maxValueValue = $locale->internalNumber($maxValueValue);
         if ($minValueValue > $maxValueValue) {
             $this->FloatValidator->setRange($minValueValue, false);
             $maxValueValue = $this->FloatValidator->fixup($maxValueValue);
             $http->setPostVariable($maxValueName, $maxValueValue);
         }
     }
 }
 public static function fetchLocale($localeCode)
 {
     // Fetch locale list
     $localeList = eZLocale::localeList(false, true);
     $localeObj = eZLocale::instance($localeCode);
     // Check if $localeName exists
     if ($localeObj === null or is_object($localeObj) and !in_array($localeObj->localeFullCode(), $localeList)) {
         $result = array('error' => array('error_type' => 'kernel', 'error_code' => eZError::KERNEL_NOT_FOUND));
     } else {
         $result = array('result' => $localeObj);
     }
     return $result;
 }
 unset($var1);
 if (!isset($var)) {
     $var = NULL;
 }
 while (is_object($var) and method_exists($var, 'templateValue')) {
     $var = $var->templateValue();
 }
 $text .= $var;
 unset($var);
 $text .= '
 </td>
 <td>
     ';
 unset($var);
 // l10nTransformation begin
 $locale = eZLocale::instance();
 // l10nTransformation: static
 unset($var1);
 unset($var1);
 $var1 = (array_key_exists($rootNamespace, $vars) and array_key_exists('latest_node', $vars[$rootNamespace])) ? $vars[$rootNamespace]['latest_node'] : null;
 $var2 = compiledFetchAttribute($var1, 'object');
 unset($var1);
 $var1 = $var2;
 $var2 = compiledFetchAttribute($var1, 'modified');
 unset($var1);
 $var1 = $var2;
 if (!isset($var1)) {
     $var1 = NULL;
 }
 while (is_object($var1) and method_exists($var1, 'templateValue')) {
     $var1 = $var1->templateValue();
 function init()
 {
     $this->Error = array('errors' => array());
     set_time_limit(10 * 60);
     $siteType = $this->chosenSiteType();
     // If we are installing a package without extension packages we
     // generate the autoload array for extensions.
     // For the time being we only do this for the plain_site package.
     if ($siteType['identifier'] == 'plain_site') {
         ezpAutoloader::updateExtensionAutoloadArray();
     }
     $saveData = true;
     // set to true to save data
     //$ini = eZINI::create();
     $accessMap = array('url' => array(), 'hostname' => array(), 'port' => array(), 'accesses' => array());
     $primaryLanguage = null;
     $allLanguages = array();
     $allLanguageCodes = array();
     $variationsLanguages = array();
     $primaryLanguageCode = $this->PersistenceList['regional_info']['primary_language'];
     $extraLanguageCodes = isset($this->PersistenceList['regional_info']['languages']) ? $this->PersistenceList['regional_info']['languages'] : array();
     $extraLanguageCodes = array_diff($extraLanguageCodes, array($primaryLanguageCode));
     /*
     if ( isset( $this->PersistenceList['regional_info']['variations'] ) )
     {
         $variations = $this->PersistenceList['regional_info']['variations'];
         foreach ( $variations as $variation )
         {
             $locale = eZLocale::create( $variation );
             if ( $locale->localeCode() == $primaryLanguageCode )
             {
                 $primaryLanguage = $locale;
             }
             else
             {
                 $variationsLanguages[] = $locale;
             }
         }
     }
     */
     if ($primaryLanguage === null) {
         $primaryLanguage = eZLocale::create($primaryLanguageCode);
     }
     $allLanguages[] = $primaryLanguage;
     foreach ($extraLanguageCodes as $extraLanguageCode) {
         $allLanguages[] = eZLocale::create($extraLanguageCode);
         $allLanguageCodes[] = $extraLanguageCode;
     }
     // If we have already figured out charset we used that
     if (isset($this->PersistenceList['regional_info']['site_charset']) and strlen($this->PersistenceList['regional_info']['site_charset']) > 0) {
         $charset = $this->PersistenceList['regional_info']['site_charset'];
     } else {
         // Figure out charset automatically if it is not set yet
         $canUseUnicode = $this->PersistenceList['database_info']['use_unicode'];
         $charset = $this->findAppropriateCharset($primaryLanguage, $allLanguages, $canUseUnicode);
     }
     if (!$charset) {
         // Make sure kickstart functionality stops
         $this->setAllowKickstart(false);
         return 'LanguageOptions';
     } else {
         $i18nINI = eZINI::create('i18n.ini');
         // Set ReadOnlySettingsCheck to false: towards
         // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
         $i18nINI->setReadOnlySettingsCheck(false);
         $i18nINI->setVariable('CharacterSettings', 'Charset', $charset);
         $i18nINI->save(false, '.php', 'append', true);
     }
     $siteINISettings = array();
     $result = true;
     $accessType = $siteType['access_type'];
     $resultArray = array('errors' => array());
     $result = $this->initializePackage($siteType, $accessMap, $charset, $allLanguageCodes, $allLanguages, $primaryLanguage, $this->PersistenceList['admin'], $resultArray);
     if (!$result) {
         $this->Error['errors'] = array_merge($this->Error['errors'], $resultArray['errors']);
         $this->Error['errors'][] = array('code' => 'EZSW-040', 'text' => "Failed to initialize site package '" . $siteType['identifier'] . "'");
         //$result = false;
         return false;
     }
     if ($resultArray['common_settings']) {
         $extraCommonSettings = $resultArray['common_settings'];
         foreach ($extraCommonSettings as $extraSetting) {
             if ($extraSetting === false) {
                 continue;
             }
             $iniName = $extraSetting['name'];
             $settings = $extraSetting['settings'];
             $resetArray = false;
             if (isset($extraSetting['reset_arrays'])) {
                 $resetArray = $extraSetting['reset_arrays'];
             }
             if ($iniName == 'site.ini') {
                 $siteINISettings[] = $settings;
                 continue;
             }
             if (file_exists('settings/override/' . $iniName . '.append') || file_exists('settings/override/' . $iniName . '.append.php')) {
                 $tmpINI = eZINI::instance($iniName, 'settings/override', null, null, false, true);
             } else {
                 $tmpINI = eZINI::create($iniName);
             }
             // Set ReadOnlySettingsCheck to false: towards
             // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
             $tmpINI->setReadOnlySettingsCheck(false);
             $tmpINI->setVariables($settings);
             $tmpINI->save(false, '.append.php', false, true, "settings/override", $resetArray);
         }
     }
     if (!$result) {
         // Display errors
         return false;
     }
     $ini = eZINI::instance();
     // Set ReadOnlySettingsCheck to false: towards
     // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
     $ini->setReadOnlySettingsCheck(false);
     $regionalInfo = $this->PersistenceList['regional_info'];
     $emailInfo = $this->PersistenceList['email_info'];
     $imageINI = eZINI::create('image.ini');
     // Set ReadOnlySettingsCheck to false: towards
     // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
     $imageINI->setReadOnlySettingsCheck(false);
     $imageINI->setVariable('ImageMagick', 'IsEnabled', 'false');
     if ($this->PersistenceList['imagemagick_program']['result']) {
         $imageINI->setVariable('ImageMagick', 'ExecutablePath', $this->PersistenceList['imagemagick_program']['path']);
         $imageINI->setVariable('ImageMagick', 'Executable', $this->PersistenceList['imagemagick_program']['program']);
         $imageINI->setVariable('ImageMagick', 'IsEnabled', 'true');
     }
     $saveResult = false;
     if (!$saveData) {
         $saveResult = true;
     }
     if ($saveData) {
         $saveResult = $imageINI->save(false, '.php', 'append', true);
     }
     if ($saveResult and $charset !== false) {
         /*$i18nINI = eZINI::create( 'i18n.ini' );
                     // Set ReadOnlySettingsCheck to false: towards
                     // Ignore site.ini[eZINISettings].ReadonlySettingList[] settings when saving ini variables.
                     $i18nINI->setReadOnlySettingsCheck( false );
         
                     $i18nINI->setVariable( 'CharacterSettings', 'Charset', $charset );
                     if ( $saveData )
                         $saveResult = $i18nINI->save( false, '.php', 'append', true );
                     */
     }
     switch ($accessType) {
         case 'port':
             $matchOrder = 'port';
             break;
         case 'hostname':
             $matchOrder = 'host';
             break;
         case 'url':
         default:
             $matchOrder = 'uri';
             break;
     }
     $hostMatchMapItems = array();
     foreach ($accessMap['hostname'] as $hostName => $siteAccessName) {
         $hostMatchMapItems[] = $hostName . ';' . $siteAccessName;
     }
     $portMatchMapItems = array();
     foreach ($accessMap['port'] as $port => $siteAccessName) {
         $portMatchMapItems[$port] = $siteAccessName;
     }
     $ini->setVariable('SiteAccessSettings', 'MatchOrder', $matchOrder);
     $ini->setVariable('SiteAccessSettings', 'HostMatchMapItems', $hostMatchMapItems);
     foreach ($portMatchMapItems as $port => $siteAccessName) {
         $ini->setVariable('PortAccessSettings', $port, $siteAccessName);
     }
     $ini->setVariable('SiteSettings', 'SiteList', $accessMap['sites']);
     $ini->setVariable('SiteAccessSettings', 'AvailableSiteAccessList', $accessMap['accesses']);
     $ini->setVariable("SiteAccessSettings", "CheckValidity", "false");
     $ini->setVariable('Session', 'SessionNameHandler', 'custom');
     $ini->setVariable('MailSettings', 'AdminEmail', $this->PersistenceList['admin']['email']);
     $ini->setVariable('MailSettings', 'EmailSender', false);
     $defaultAccess = 'admin';
     if (isset($accessMap['accesses'][0])) {
         $defaultAccess = $accessMap['accesses'][0];
     }
     $ini->setVariable('SiteSettings', 'DefaultAccess', $defaultAccess);
     if ($emailInfo['type'] == 1) {
         $ini->setVariable('MailSettings', 'Transport', 'sendmail');
     } else {
         $ini->setVariable('MailSettings', 'Transport', 'SMTP');
         $ini->setVariable('MailSettings', 'TransportServer', $emailInfo['server']);
         $ini->setVariable('MailSettings', 'TransportUser', $emailInfo['user']);
         $ini->setVariable('MailSettings', 'TransportPassword', $emailInfo['password']);
     }
     // Enable design location cache
     $ini->setVariable('DesignSettings', 'DesignLocationCache', 'enabled');
     if ($saveData) {
         foreach ($siteINISettings as $siteINISetting) {
             $ini->setVariables($siteINISetting);
         }
     }
     if ($saveData) {
         $saveResult = $ini->save(false, '.php', 'append', true, true, true);
     }
     return true;
     // Never show, generate sites
 }