getInstance() публичный статический Метод

Return a static instance of the I18n class
public static getInstance ( ) : I18n
Результат I18n
 /**
  * Creates a new local user in the application data base.
  * 
  * @param WebSoccer $websoccer Application context.
  * @param DbConnection $db DB Connection.
  * @param string $nick User name of new user. Optional if e-mail address is provided. Must be unique in local data base. Case sensitive.
  * @param string $email E-mail address of new user. Optional if nick is provided. Must be unique in local data base. Case insensitive (will be stored with lower letters).
  * @throws Exception if both nick and e-mail are blank, or if nick name or e-mail address is already in use. Messages are not internationalized. Method assumes appropriate checks before calling it.
  * @return int ID of newly created user.
  */
 public static function createLocalUser(WebSoccer $websoccer, DbConnection $db, $nick = null, $email = null)
 {
     $username = trim($nick);
     $emailAddress = strtolower(trim($email));
     // check if either nick or e-mail is provided. If not, it most probably is a wrong API call,
     // hence message is not required to be translated.
     if (!strlen($username) && !strlen($emailAddress)) {
         throw new Exception("UsersDataService::createBlankUser(): Either user name or e-mail must be provided in order to create a new internal user.");
     }
     // verify that there is not already such a user. If so, the calling function is wrongly implemented, hence
     // no translation of message.
     if (strlen($username) && self::getUserIdByNick($websoccer, $db, $username) > 0) {
         throw new Exception("Nick name is already in use.");
     }
     if (strlen($emailAddress) && self::getUserIdByEmail($websoccer, $db, $emailAddress) > 0) {
         throw new Exception("E-Mail address is already in use.");
     }
     // creates user.
     $i18n = I18n::getInstance($websoccer->getConfig("supported_languages"));
     $columns = array("nick" => $username, "email" => $emailAddress, "status" => "1", "datum_anmeldung" => $websoccer->getNowAsTimestamp(), "lang" => $i18n->getCurrentLanguage());
     if ($websoccer->getConfig("premium_initial_credit")) {
         $columns["premium_balance"] = $websoccer->getConfig("premium_initial_credit");
     }
     $db->queryInsert($columns, $websoccer->getConfig("db_prefix") . "_user");
     // provide ID of created user.
     if (strlen($username)) {
         $userId = self::getUserIdByNick($websoccer, $db, $username);
     } else {
         $userId = self::getUserIdByEmail($websoccer, $db, $emailAddress);
     }
     // trigger plug-ins
     $event = new UserRegisteredEvent($websoccer, $db, I18n::getInstance($websoccer->getConfig("supported_languages")), $userId, $username, $emailAddress);
     PluginMediator::dispatchEvent($event);
     return $userId;
 }
Пример #2
0
 /**
  * initialize method
  *
  * Merge settings and set Config.language to a valid locale
  *
  * @return void
  * @access public
  */
 function initialize(&$Controller, $config = array())
 {
     App::import('Vendor', 'Mi.MiCache');
     $lang = MiCache::setting('Site.lang');
     if (!$lang) {
         if (!defined('DEFAULT_LANGUAGE')) {
             return;
         }
         $lang = DEFAULT_LANGUAGE;
     } elseif (!defined('DEFAULT_LANGUAGE')) {
         define('DEFAULT_LANGUAGE', $lang);
     }
     Configure::write('Config.language', $lang);
     App::import('Core', 'I18n');
     $I18n =& I18n::getInstance();
     $I18n->domain = 'default_' . $lang;
     $I18n->__lang = $lang;
     $I18n->l10n->get($lang);
     if (!empty($Controller->plugin)) {
         $config['plugins'][] = Inflector::underscore($Controller->plugin);
     }
     if (!empty($config['plugins'])) {
         $plugins = array_intersect(MiCache::mi('plugins'), $config['plugins']);
         $Inst = App::getInstance();
         foreach ($plugins as $path => $name) {
             $Inst->locales[] = $path . DS . 'locale' . DS;
         }
     }
 }
Пример #3
0
 /**
  * Read Metadata from xml array
  * @param array $xmlArr
  */
 protected function readMetadata(&$xmlArr)
 {
     parent::readMetaData($xmlArr);
     $this->m_InheritFrom = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["INHERITFROM"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["INHERITFROM"] : null;
     $this->m_Title = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["TITLE"]) ? I18n::getInstance()->translate($xmlArr["BIZFORM"]["ATTRIBUTES"]["TITLE"]) : null;
     $this->m_Description = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["DESCRIPTION"]) ? I18n::getInstance()->translate($xmlArr["BIZFORM"]["ATTRIBUTES"]["DESCRIPTION"]) : null;
     //added by Jixian
     $this->m_SearchRule = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["SEARCHRULE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["SEARCHRULE"] : null;
     $this->m_BaseSearchRule = $this->m_SearchRule;
     $this->m_jsClass = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["JSCLASS"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["JSCLASS"] : null;
     $this->m_Height = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["HEIGHT"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["HEIGHT"] : null;
     $this->m_Width = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["WIDTH"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["WIDTH"] : null;
     $this->m_Range = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["PAGESIZE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["PAGESIZE"] : null;
     $this->m_FullPage = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["FULLPAGE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["FULLPAGE"] : null;
     $this->m_Stateless = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["STATELESS"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["STATELESS"] : null;
     $this->m_Style = isset($xmlArr["BIZFORM"]["ATTRIBUTES"]["STYLE"]) ? $xmlArr["BIZFORM"]["ATTRIBUTES"]["STYLE"] : 'display: block';
     //Get the style of a form from xml --jmmz
     $this->m_Name = $this->prefixPackage($this->m_Name);
     $this->m_DataObjName = $this->prefixPackage($xmlArr["BIZFORM"]["ATTRIBUTES"]["BIZDATAOBJ"]);
     $this->m_DisplayModes = new MetaIterator($xmlArr["BIZFORM"]["DISPLAYMODES"]["MODE"], "DisplayMode");
     $this->m_RecordRow = new RecordRow($xmlArr["BIZFORM"]["BIZCTRLLIST"]["BIZCTRL"], "FieldControl", $this);
     $this->m_ToolBar = new ToolBar($xmlArr["BIZFORM"]["TOOLBAR"]["CONTROL"], "HTMLControl", $this);
     $this->m_NavBar = new NavBar($xmlArr["BIZFORM"]["NAVBAR"]["CONTROL"], "HTMLControl", $this);
     $this->m_Parameters = new MetaIterator($xmlArr["BIZFORM"]["PARAMETERS"]["PARAMETER"], "Parameter");
 }
Пример #4
0
 /**
  * Render element, according to the mode
  *
  * @return string HTML text
  */
 public function render()
 {
     BizSystem::clientProxy()->includeCKEditorScripts();
     $elementName = $this->m_Name;
     $value = $this->getValue();
     $style = $this->getStyle();
     $width = $this->m_Width ? $this->m_Width : 600;
     $height = $this->m_Height ? $this->m_Height : 300;
     //$func = "onclick=\"editRichText('$elementName', $width, $height);\"";
     if (!strlen($value) > 0) {
         // fix suggested by smarques
         $value = " ";
     }
     $type = strtolower($this->m_Mode);
     $fileBrowserPage = APP_URL . "/bin/filebrowser/browser.html";
     $languageCode = I18n::getInstance()->getCurrentLanguage();
     $languageCode = str_replace("_", "-", $languageCode);
     $config = $this->m_Config;
     $sHTML .= "<textarea id=\"{$elementName}\" name=\"{$elementName}\" >{$value}</textarea>\n";
     $sHTML .= "<script type=\"text/javascript\">\n";
     if ($config) {
         //remove the last commas
         $config = trim($config);
         if (substr($config, strlen($config) - 1, 1) == ',') {
             $config = substr($config, strlen($config) - 1);
         }
         $sHTML .= "Openbiz.CKEditor.init('{$elementName}',{'type':'{$type}','filebrowserBrowseUrl':'{$fileBrowserPage}','language':'{$languageCode}','height':'{$height}','width':'{$width}',{$config}});\n";
     } else {
         $sHTML .= "Openbiz.CKEditor.init('{$elementName}',{'type':'{$type}','filebrowserBrowseUrl':'{$fileBrowserPage}','language':'{$languageCode}','height':'{$height}','width':'{$width}'});\n";
     }
     $sHTML .= "</script>\n";
     return $sHTML;
 }
Пример #5
0
 /**
  * Initialize FieldControl with xml array
  *
  * @param array $xmlArr xml array
  * @param BizForm $formObj BizForm instance
  * @return void
  */
 function __construct(&$xmlArr, $formObj)
 {
     parent::__construct($xmlArr, $formObj);
     $this->m_BizFormName = $formObj->m_Name;
     $this->m_BizFieldName = isset($xmlArr["ATTRIBUTES"]["FIELDNAME"]) ? $xmlArr["ATTRIBUTES"]["FIELDNAME"] : null;
     $this->m_DisplayName = isset($xmlArr["ATTRIBUTES"]["DISPLAYNAME"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["DISPLAYNAME"]) : null;
     $this->m_Description = isset($xmlArr["ATTRIBUTES"]["DESCRIPTION"]) ? $xmlArr["ATTRIBUTES"]["DESCRIPTION"] : null;
     $this->m_ValuePicker = isset($xmlArr["ATTRIBUTES"]["VALUEPICKER"]) ? $xmlArr["ATTRIBUTES"]["VALUEPICKER"] : null;
     $this->m_PickerMap = isset($xmlArr["ATTRIBUTES"]["PICKERMAP"]) ? $xmlArr["ATTRIBUTES"]["PICKERMAP"] : null;
     if (isset($xmlArr["ATTRIBUTES"]["DRILLDOWNLINK"])) {
         $this->_setDrillDownLink($xmlArr["ATTRIBUTES"]["DRILLDOWNLINK"]);
     }
     $this->m_Enabled = isset($xmlArr["ATTRIBUTES"]["ENABLED"]) ? $xmlArr["ATTRIBUTES"]["ENABLED"] : null;
     $this->m_Sortable = isset($xmlArr["ATTRIBUTES"]["SORTABLE"]) ? $xmlArr["ATTRIBUTES"]["SORTABLE"] : null;
     $this->m_DataType = isset($xmlArr["ATTRIBUTES"]["DATATYPE"]) ? $xmlArr["ATTRIBUTES"]["DATATYPE"] : null;
     $this->m_Order = isset($xmlArr["ATTRIBUTES"]["ORDER"]) ? $xmlArr["ATTRIBUTES"]["ORDER"] : null;
     $this->m_DefaultValue = isset($xmlArr["ATTRIBUTES"]["DEFAULTVALUE"]) ? $xmlArr["ATTRIBUTES"]["DEFAULTVALUE"] : null;
     $this->m_ColumnStyle = isset($xmlArr["ATTRIBUTES"]["COLUMNSTYLE"]) ? $xmlArr["ATTRIBUTES"]["COLUMNSTYLE"] : null;
     $this->m_Mode = MODE_R;
     // if no class name, add default class name. i.e. NewRecord => ObjName.NewRecord
     $this->m_ValuePicker = $this->prefixPackage($this->m_ValuePicker);
     if (!$this->m_BizFieldName) {
         $this->m_BizFieldName = $this->m_Name;
     }
 }
Пример #6
0
 public function getFromList(&$list)
 {
     $current_locale = I18n::getInstance()->getCurrentLanguage();
     $country = BizSystem::clientProxy()->getFormInputs("fld_region");
     $country = strtoupper($country);
     if (!$country) {
         $locale = explode('_', $current_locale);
         $country = strtoupper($locale[0]);
     }
     require_once 'Zend/Locale.php';
     $locale = new Zend_Locale($current_locale);
     $code2name = $locale->getTranslationList('territorytolanguage', $locale);
     $list = array();
     $i = 0;
     foreach ($code2name as $key => $value) {
         if (preg_match('/' . $country . '/', $value) || strtoupper($key) == $country) {
             $lang_list = explode(" ", $value);
             foreach ($lang_list as $lang) {
                 $list[$i]['txt'] = strtolower($key) . "_" . strtoupper($lang);
                 $list[$i]['val'] = strtolower($key) . "_" . strtoupper($lang);
                 $i++;
             }
         }
     }
     return $list;
 }
Пример #7
0
 protected function readMetaData(&$xmlArr)
 {
     parent::readMetaData($xmlArr);
     $this->m_cssClass = isset($xmlArr["ATTRIBUTES"]["CSSCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSCLASS"] : "input_text";
     $this->m_cssErrorClass = isset($xmlArr["ATTRIBUTES"]["CSSERRORCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSERRORCLASS"] : $this->m_cssClass . "_error";
     $this->m_cssFocusClass = isset($xmlArr["ATTRIBUTES"]["CSSFOCUSCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSFOCUSCLASS"] : $this->m_cssClass . "_focus";
     $this->m_cssHoverClass = isset($xmlArr["ATTRIBUTES"]["CSSHOVERCLASS"]) ? $xmlArr["ATTRIBUTES"]["CSSHOVERCLASS"] : $this->m_cssClass . "_hover";
     $this->m_Value = isset($xmlArr["ATTRIBUTES"]["DEFAULTVALUE"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["DEFAULTVALUE"]) : null;
     $this->m_ReadOnly = isset($xmlArr["ATTRIBUTES"]["READONLY"]) ? $xmlArr["ATTRIBUTES"]["READONLY"] : "N";
 }
Пример #8
0
 /**
  * Constructor of TypeManager, set locale with $localCode parameter
  *
  * @param string $localeCode
  * @return void
  **/
 public function __construct($localeCode = "")
 {
     //try to set correct locale for current language as defined in app.inc section I18n
     $currentLanguage = I18n::getInstance()->getCurrentLanguage();
     $localeCode = $GLOBALS["local"][$currentLanguage];
     setlocale(LC_ALL, $localeCode);
     $this->_localeInfo = localeconv();
     if ($this->_localeInfo['frac_digits'] > 10) {
         $this->_localeInfo = null;
     }
 }
 /**
  *导航.
  */
 public function index()
 {
     $n = $this->Navigation->findall();
     //	pr($n);
     if (!class_exists('I18n')) {
         App::import('Core', 'i18n');
     }
     $I18n =& I18n::getInstance();
     echo $I18n->l10n->locale;
     exit;
 }
Пример #10
0
 /**
  * Action to change the current language
  *
  * The expected HTTP parameters are:
  * <ul>
  * <li>lang: lange to change to (via HTTP GET)</li>
  * </ul>
  * 
  * @return void
  */
 public function change()
 {
     if (!isset($_GET["lang"])) {
         throw new Exception("no lang parameter was provided");
     }
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     I18n::getInstance()->setLanguage($_GET["lang"]);
     // go back to previous page
     header("Location: " . $_SERVER["HTTP_REFERER"]);
     die;
 }
Пример #11
0
 /**
  * Read array meta data, and store to meta object
  *
  * @param array $xmlArr
  * @return void
  */
 protected function readMetaData(&$xmlArr)
 {
     parent::readMetaData($xmlArr);
     $this->m_FieldName = isset($xmlArr["ATTRIBUTES"]["FIELDNAME"]) ? $xmlArr["ATTRIBUTES"]["FIELDNAME"] : null;
     $this->m_Label = isset($xmlArr["ATTRIBUTES"]["LABEL"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["LABEL"]) : null;
     $this->m_Description = isset($xmlArr["ATTRIBUTES"]["DESCRIPTION"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["DESCRIPTION"]) : null;
     $this->m_DefaultValue = isset($xmlArr["ATTRIBUTES"]["DEFAULTVALUE"]) ? $xmlArr["ATTRIBUTES"]["DEFAULTVALUE"] : null;
     $this->m_Required = isset($xmlArr["ATTRIBUTES"]["REQUIRED"]) ? $xmlArr["ATTRIBUTES"]["REQUIRED"] : null;
     $this->m_Enabled = isset($xmlArr["ATTRIBUTES"]["ENABLED"]) ? $xmlArr["ATTRIBUTES"]["ENABLED"] : null;
     $this->m_Text = isset($xmlArr["ATTRIBUTES"]["TEXT"]) ? I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["TEXT"]) : null;
     // if no class name, add default class name. i.e. NewRecord => ObjName.NewRecord
     $this->m_ValuePicker = $this->prefixPackage($this->m_ValuePicker);
 }
Пример #12
0
 public function render()
 {
     $func_up = $this->getBtnFunction('fld_sortorder_up');
     $func_down = $this->getBtnFunction('fld_sortorder_down');
     $formobj = $this->getFormObj();
     //$this->m_EventHandlers = null;
     $value = $this->m_Text ? $this->getText() : $this->m_Value;
     if ($value == null || $value == "") {
         return "";
     }
     $style = $this->getStyle();
     $id = $this->m_Name;
     if ($this->m_Translatable == 'Y') {
         if (defined($value)) {
             $value = constant($value);
         }
         $value = I18n::getInstance()->translate($value);
     }
     if ((int) $this->m_MaxLength > 0) {
         if (function_exists('mb_strlen') && function_exists('mb_substr')) {
             if (mb_strlen($value, 'UTF8') > (int) $this->m_MaxLength) {
                 $value = mb_substr($value, 0, (int) $this->m_MaxLength, 'UTF8') . '...';
             }
         } else {
             if (strlen($value) > (int) $this->m_MaxLength) {
                 $value = substr($value, 0, (int) $this->m_MaxLength) . '...';
             }
         }
     }
     if ($value != null) {
         if ($this->m_DisplayFormat) {
             $value = sprintf($this->m_DisplayFormat, $value);
         }
         if ($this->m_Percent == 'Y') {
             $value = sprintf("%.2f", $value * 100) . '%';
         }
         if ($this->m_Link) {
             $link = $this->getLink();
             $target = $this->getTarget();
             //$sHTML = "<a href=\"$link\" onclick=\"SetOnLoadNewView();\" $style>" . $val . "</a>";
             $sHTML = "<a id=\"{$id}\" href=\"{$link}\" {$target} {$func} {$style}>" . $value . "</a>";
         } else {
             $sHTML = "<span style=\"width:auto;height:auto;\" {$func}>" . $value . "</span>";
         }
     }
     $sHTML = "<a {$func_up}  class=\"arrow_up\" href=\"javascript:;\"></a> " . $sHTML . " <a {$func_down}  class=\"arrow_down\" href=\"javascript:;\"></a>";
     return $sHTML;
 }
Пример #13
0
 public function getFromList(&$list)
 {
     require_once 'Zend/Locale.php';
     $locale = new Zend_Locale(I18n::getInstance()->getCurrentLanguage());
     $code2name = $locale->getTranslationList('territory', $locale, 2);
     $list = array();
     $i = 0;
     foreach ($code2name as $key => $value) {
         if ((int) $key == 0) {
             $list[$i]['val'] = $key;
             $list[$i]['txt'] = $value;
             $i++;
         }
     }
     return $list;
 }
Пример #14
0
 protected function readMetadata(&$xmlArr)
 {
     parent::readMetaData($xmlArr);
     $this->m_Name = $this->prefixPackage($this->m_Name);
     $this->m_Title = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TITLE"]) ? I18n::getInstance()->translate($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TITLE"]) : null;
     $this->m_Description = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["DESCRIPTION"]) ? I18n::getInstance()->translate($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["DESCRIPTION"]) : null;
     $this->m_CssClass = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["CSSCLASS"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["CSSCLASS"] : null;
     $this->m_TemplateEngine = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TEMPLATEENGINE"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TEMPLATEENGINE"] : null;
     $this->m_TemplateFile = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TEMPLATEFILE"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["TEMPLATEFILE"] : null;
     $this->m_StartMenuItem = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["STARTMENUITEM"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["STARTMENUITEM"] : null;
     $this->m_StartMenuID = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["STARTMENUID"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["STARTMENUID"] : null;
     $this->m_SearchRule = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["SEARCHRULE"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["SEARCHRULE"] : null;
     $this->m_GlobalSearchRule = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["GLOBALSEARCHRULE"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["GLOBALSEARCHRULE"] : null;
     $this->m_MenuDeep = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["MENUDEEP"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["MENUDEEP"] : null;
     $this->m_DataObjName = $this->prefixPackage($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["BIZDATAOBJ"]);
     $this->m_CacheLifeTime = isset($xmlArr["MENUWIDGET"]["ATTRIBUTES"]["CACHELIFETIME"]) ? $xmlArr["MENUWIDGET"]["ATTRIBUTES"]["CACHELIFETIME"] : "0";
 }
Пример #15
0
 public function fetchData()
 {
     preg_match("/\\[([\\S]*?)\\]=\\'file_(.*?)\\'/si", $this->m_FixSearchRule, $match);
     $Id = $match[2];
     $resultArr = $this->fetchDataSet();
     $record = $resultArr[$Id];
     require_once 'Zend/Locale.php';
     $locale = new Zend_Locale(I18n::getInstance()->getCurrentLanguage());
     $code2name = $locale->getTranslationList('language', $locale);
     $lang_code = $this->getLang();
     $locale = explode('_', $lang_code);
     $lang = $code2name[$locale[0]];
     $image_path = APP_URL . "/images/nations/22x14/" . strtolower($locale[1]) . '.png';
     $image = "<image  style=\"float:left;display:block;margin-right:5px;padding-top:2px;\" src=\"{$image_path}\" />";
     $record['lang'] = "<div>" . $image . " <span style=\"float:left;display:block;\">{$lang} ( {$lang_code} )</span></div>";
     $record['translation'] = file_get_contents($record['path']);
     $this->m_RecordId = "file_" . $Id;
     return $record;
 }
Пример #16
0
 function getList()
 {
     $list = array();
     $lang_dir = APP_HOME . DIRECTORY_SEPARATOR . "languages" . DIRECTORY_SEPARATOR . $lang;
     if (!is_dir($lang_dir)) {
         return $result;
     }
     $current_locale = I18n::getInstance()->getCurrentLanguage();
     require_once 'Zend/Locale.php';
     $locale = new Zend_Locale($current_locale);
     $code2name = $locale->getTranslationList('language', $locale);
     foreach (glob($lang_dir . DIRECTORY_SEPARATOR . "*") as $dir) {
         $lang_code = basename($dir);
         if ($lang_code == 'dictionary') {
             continue;
         }
         $locale = explode('_', $lang_code);
         $lang_name = $code2name[strtolower($locale[0])];
         array_push($list, array("val" => $lang_code, "txt" => $lang_name . " ( {$lang_code} )", "pic" => APP_URL . "/images/nations/22x14/" . strtolower($locale[1]) . ".png"));
     }
     return $list;
 }
Пример #17
0
S2Paths::set($s2_app, 'S2_JS_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'js' . _DS);
S2Paths::set($s2_app, 'S2_ADMIN_VIEWS_OVERRIDES', S2Paths::get($s2_app, 'S2_APP_OVERRIDES') . 'views' . DS . 'admin' . DS);
S2Paths::set($s2_app, 'S2_ADMIN_HELPERS_OVERRIDES', S2Paths::get($s2_app, 'S2_ADMIN_VIEWS_OVERRIDES') . 'helpers' . DS);
S2Paths::set($s2_app, 'S2_ADMIN_VIEWS_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_VIEWS_URL_OVERRIDES') . 'admin' . _DS);
S2Paths::set($s2_app, 'S2_CSS_ADMIN_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_ADMIN_VIEWS_URL_OVERRIDES') . 'css' . _DS);
S2Paths::set($s2_app, 'S2_JS_ADMIN_URL_OVERRIDES', S2Paths::get($s2_app, 'S2_ADMIN_VIEWS_URL_OVERRIDES') . 'js' . _DS);
// Create the file registry
$Configure =& Configure::getInstance($s2_app);
$s2App =& App::getInstance($s2_app);
require_once dirname(__FILE__) . DS . 'config' . DS . 'core.php';
# Set app variable in I18n class
$import = App::import('Lib', 'I18n');
if (!$import) {
    $clear = clearCache('', 'core');
    if (!$clear) {
        echo 'You need to delete the file registry in /components/com_s2framework/tmp/cache/core/';
        exit;
    }
    $page = $_SERVER['PHP_SELF'];
    header("Location: index.php?option=com_jreviews");
    exit;
}
$Translate =& I18n::getInstance();
$Translate->app = $s2_app;
# Load app files ...
if (defined('MVC_FRAMEWORK_ADMIN')) {
    App::import('admin_controller', 'my', 'jreviews');
} else {
    App::import('controller', 'my', 'jreviews');
}
App::import('model', 'my_model', 'jreviews');
Пример #18
0
 /**
  * Parses a locale definition file following the POSIX standard
  *
  * @param string $filename Locale definition filename
  * @return mixed Array of definitions on success or false on failure
  */
 public static function loadLocaleDefinition($filename)
 {
     if (!($file = fopen($filename, "r"))) {
         return false;
     }
     $definitions = array();
     $comment = '#';
     $escape = '\\';
     $currentToken = false;
     $value = '';
     $_this = I18n::getInstance();
     while ($line = fgets($file)) {
         $line = trim($line);
         if (empty($line) || $line[0] === $comment) {
             continue;
         }
         $parts = preg_split("/[[:space:]]+/", $line);
         if ($parts[0] === 'comment_char') {
             $comment = $parts[1];
             continue;
         }
         if ($parts[0] === 'escape_char') {
             $escape = $parts[1];
             continue;
         }
         $count = count($parts);
         if ($count == 2) {
             $currentToken = $parts[0];
             $value = $parts[1];
         } elseif ($count == 1) {
             $value .= $parts[0];
         } else {
             continue;
         }
         $len = strlen($value) - 1;
         if ($value[$len] === $escape) {
             $value = substr($value, 0, $len);
             continue;
         }
         $mustEscape = array($escape . ',', $escape . ';', $escape . '<', $escape . '>', $escape . $escape);
         $replacements = array_map('crc32', $mustEscape);
         $value = str_replace($mustEscape, $replacements, $value);
         $value = explode(';', $value);
         $_this->_escape = $escape;
         foreach ($value as $i => $val) {
             $val = trim($val, '"');
             $val = preg_replace_callback('/(?:<)?(.[^>]*)(?:>)?/', array(&$_this, '_parseLiteralValue'), $val);
             $val = str_replace($replacements, $mustEscape, $val);
             $value[$i] = $val;
         }
         if (count($value) == 1) {
             $definitions[$currentToken] = array_pop($value);
         } else {
             $definitions[$currentToken] = $value;
         }
     }
     return $definitions;
 }
Пример #19
0
 /**
  * Get selected locale for model
  *
  * @param Model $Model Model the locale needs to be set/get on.
  * @return mixed string or false
  */
 protected function _getLocale(Model $Model)
 {
     if (!isset($Model->locale) || $Model->locale === null) {
         $I18n = I18n::getInstance();
         $I18n->l10n->get(Configure::read('Config.language'));
         $Model->locale = $I18n->l10n->lang;
     }
     return $Model->locale;
 }
Пример #20
0
 /**
  * Object destructor
  *
  * Write cache file if changes have been made to the $__map or $__paths
  * @access private
  */
 function __destruct()
 {
     $_this =& I18n::getInstance();
     if ($_this->__cache) {
         Cache::write($_this->domain, array_filter($_this->__domains), '_cake_core_');
     }
 }
Пример #21
0
Файл: Mi.php Проект: razzman/mi
 /**
  * viewPaths method
  *
  * @param mixed $locale null
  * @param mixed $plugin null
  * @return void
  * @access protected
  */
 protected function _viewPaths($plugin = null, $locale = null)
 {
     if (!$locale) {
         App::import('Vendor', 'Mi.MiCache');
         $locale = MiCache::setting('Site.lang');
         if (!$locale) {
             $locale = Configure::read('Config.language');
             if (!$locale && defined('DEFAULT_LANGUAGE')) {
                 $locale = 'DEFAULT_LANGUAGE';
             }
         }
         if ($locale) {
             Configure::write('Config.language', $locale);
             App::import('Core', 'I18n');
             $I18n =& I18n::getInstance();
             $I18n->domain = 'default_' . $locale;
             $I18n->__lang = $locale;
             $I18n->l10n->get($locale);
         }
     }
     if (Mi::cakeVersion() === '1.2') {
         $viewPaths = Configure::read('viewPaths');
         $localePaths = Configure::read('localePaths');
     } else {
         $viewPaths = App::path('views');
         $localePaths = App::path('locales');
     }
     if (!class_exists('I18n')) {
         App::import('Core', array('I18n'));
     }
     $languagePaths = array_filter(array_unique(I18n::getInstance()->l10n->languagePath));
     $paths = array();
     if ($plugin) {
         $count = count($viewPaths);
         for ($i = 0; $i < $count; $i++) {
             $base = $viewPaths[$i] . 'plugins' . DS . $plugin . DS;
             if ($locale) {
                 foreach ($localePaths as $path) {
                     foreach ($localePaths as $_locale) {
                         $paths[] = $_locale . $locale . DS . 'views' . DS . 'plugins' . DS . $plugin . DS;
                     }
                 }
             }
             $paths[] = $base;
         }
         if (Mi::cakeVersion() === '1.2') {
             $pluginPaths = Configure::read('pluginPaths');
         } else {
             $pluginPaths = App::path('plugins');
         }
         $count = count($pluginPaths);
         for ($i = 0; $i < $count; $i++) {
             $base = $pluginPaths[$i] . $plugin . DS;
             if ($locale) {
                 foreach ($localePaths as $path) {
                     foreach ($languagePaths as $_locale) {
                         $paths[] = $pluginPaths[$i] . $plugin . DS . 'locale' . DS . $_locale . DS . 'views' . DS;
                     }
                 }
             }
             $paths[] = $base . 'views' . DS;
         }
     }
     if ($locale) {
         foreach ($localePaths as $path) {
             foreach ($languagePaths as $_locale) {
                 $paths[] = $path . $_locale . DS . 'views' . DS;
             }
         }
     }
     if ($paths) {
         $viewPaths = array_merge($paths, $viewPaths);
     }
     if (!empty($theme)) {
         $themePaths = array();
         $count = count($paths);
         for ($i = 0; $i < $count; $i++) {
             if (strpos($paths[$i], DS . 'plugins' . DS) === false && strpos($paths[$i], DS . 'libs' . DS . 'view') === false) {
                 if ($plugin) {
                     $themePaths[] = $paths[$i] . 'themed' . DS . $theme . DS . 'plugins' . DS . $plugin . DS;
                 }
                 $themePaths[] = $paths[$i] . 'themed' . DS . $theme . DS;
             }
         }
         $viewPaths = array_merge($themePaths, $viewPaths);
     }
     return array_unique($viewPaths);
 }
Пример #22
0
 /**
  * Get selected locale for model
  *
  * @param Model $model Model the locale needs to be set/get on.
  * @return mixed string or false
  */
 protected function _getLocale($model)
 {
     if (!isset($model->locale) || is_null($model->locale)) {
         if (!class_exists('I18n')) {
             App::import('Core', 'i18n');
         }
         $I18n = I18n::getInstance();
         $I18n->l10n->get(Configure::read('Config.language'));
         $model->locale = $I18n->l10n->locale;
     }
     return $model->locale;
 }
Пример #23
0
 /**
  * Render single menu item
  * @param array $menuItem menu item metadata xml array
  * @return string html content of each menu item
  */
 protected function renderSingleMenuItem(&$menuItem)
 {
     global $g_BizSystem;
     $profile = $g_BizSystem->getUserProfile();
     $svcobj = BizSystem::getService("accessService");
     $role = isset($profile["ROLE"]) ? $profile["ROLE"] : null;
     if (array_key_exists('URL', $menuItem["ATTRIBUTES"])) {
         $url = $menuItem["ATTRIBUTES"]["URL"];
     } elseif (array_key_exists('VIEW', $menuItem["ATTRIBUTES"])) {
         $view = $menuItem["ATTRIBUTES"]["VIEW"];
         // menuitem's containing VIEW attribute is renderd if access is granted in accessservice.xml
         // menuitem's are rendered if no definition is found in accessservice.xml (default)
         if ($svcobj->allowViewAccess($view, $role)) {
             $url = "javascript:GoToView('" . $view . "')";
         } else {
             return '';
         }
     }
     $caption = I18n::getInstance()->translate($menuItem["ATTRIBUTES"]["CAPTION"]);
     $target = $menuItem["ATTRIBUTES"]["TARGET"];
     $icon = $menuItem["ATTRIBUTES"]["ICON"];
     $img = $icon ? "<img src='" . Resource::getImageUrl() . "/{$icon}' class=menu_img> " : "";
     if ($view) {
         $url = "javascript:GoToView('" . $view . "')";
     }
     if ($target) {
         $sHTML .= "<li><a href=\"" . $url . "\" target='{$target}'>{$img}" . $caption . "</a>";
     } else {
         $sHTML .= "<li><a href=\"" . $url . "\">{$img}" . $caption . "</a>";
     }
     if ($menuItem["MENUITEM"]) {
         $sHTML .= "\n<ul>\n";
         $sHTML .= $this->renderMenuItems($menuItem["MENUITEM"]);
         $sHTML .= "</ul>";
     }
     $sHTML .= "</li>\n";
     return $sHTML;
 }
Пример #24
0
 /**
  * Used by the translation functions in basics.php
  * Can also be used like I18n::translate(); but only if the App::import('I18n'); has been used to load the class.
  *
  * @param string $singular String to translate
  * @param string $plural Plural string (if any)
  * @param string $domain Domain
  * @param string $category Category
  * @param integer $count Count
  * @return string translated strings.
  * @access public
  */
 function translate($singular, $plural = null, $domain = null, $category = 6, $count = null)
 {
     $_this =& I18n::getInstance();
     if (strpos($singular, "\r\n") !== false) {
         $singular = str_replace("\r\n", "\n", $singular);
     }
     if ($plural !== null && strpos($plural, "\r\n") !== false) {
         $plural = str_replace("\r\n", "\n", $plural);
     }
     if (is_numeric($category)) {
         $_this->category = $_this->__categories[$category];
     }
     $language = Configure::read('Config.language');
     if (!empty($_SESSION['Config']['language'])) {
         $language = $_SESSION['Config']['language'];
     }
     if ($_this->__lang && $_this->__lang !== $language || !$_this->__lang) {
         $lang = $_this->l10n->get($language);
         $_this->__lang = $lang;
     }
     if (is_null($domain)) {
         $domain = 'default';
     }
     $_this->domain = $domain . '_' . $_this->l10n->locale;
     if (empty($_this->__domains)) {
         $_this->__domains = Cache::read($_this->domain, '_cake_core_');
     }
     if (!isset($_this->__domains[$_this->category][$_this->__lang][$domain])) {
         $_this->__bindTextDomain($domain);
         $_this->__cache = true;
     }
     if (!isset($count)) {
         $plurals = 0;
     } elseif (!empty($_this->__domains[$_this->category][$_this->__lang][$domain]["%plural-c"]) && $_this->__noLocale === false) {
         $header = $_this->__domains[$_this->category][$_this->__lang][$domain]["%plural-c"];
         $plurals = $_this->__pluralGuess($header, $count);
     } else {
         if ($count != 1) {
             $plurals = 1;
         } else {
             $plurals = 0;
         }
     }
     if (!empty($_this->__domains[$_this->category][$_this->__lang][$domain][$singular])) {
         if (($trans = $_this->__domains[$_this->category][$_this->__lang][$domain][$singular]) || $plurals && ($trans = $_this->__domains[$_this->category][$_this->__lang][$domain][$plural])) {
             if (is_array($trans)) {
                 if (isset($trans[$plurals])) {
                     $trans = $trans[$plurals];
                 }
             }
             if (strlen($trans)) {
                 $singular = $trans;
                 return $singular;
             }
         }
     }
     if (!empty($plurals)) {
         return $plural;
     }
     return $singular;
 }
Пример #25
0
 /**
  * Get Message
  *
  * @param <type> $msgid message Id
  * @param array $params
  * @return string
  */
 protected function getMessage($msgid, $params = array())
 {
     $message = isset($this->m_Messages[$msgid]) ? $this->m_Messages[$msgid] : constant($msgid);
     $message = I18n::getInstance()->translate($message);
     return vsprintf($message, $params);
 }
Пример #26
0
// do not execute if site is in offline mode
if ($website->getConfig('offline') == 'offline') {
    die('Site is in offline mode');
}
if (!isset($_REQUEST['sectoken'])) {
    die('no security token provided');
}
if (!isset($_REQUEST['jobid'])) {
    die('no job ID provided');
}
$securityToken = $_REQUEST['sectoken'];
$jobId = $_REQUEST['jobid'];
// check security token
if ($website->getConfig('webjobexecution_key') !== $securityToken) {
    die('invalid security token');
}
// get job
$xml = simplexml_load_file(JOBS_CONFIG_FILE);
$jobConfig = $xml->xpath('//job[@id = \'' . $jobId . '\']');
if (!$jobConfig) {
    die('Job config not found.');
}
// execute
$jobClass = (string) $jobConfig[0]->attributes()->class;
if (class_exists($jobClass)) {
    $i18n = I18n::getInstance($website->getConfig('supported_languages'));
    $job = new $jobClass($website, $db, $i18n, $jobId);
} else {
    die('class not found: ' . $jobClass);
}
$job->execute();
Пример #27
0
 /**
  * Initialize TabView with xml array
  *
  * @param array $xmlArr
  * @return void
  */
 function __construct(&$xmlArr)
 {
     $this->m_Name = $xmlArr["ATTRIBUTES"]["NAME"];
     $this->m_View = $xmlArr["ATTRIBUTES"]["VIEW"];
     $this->m_ViewSet = $xmlArr["ATTRIBUTES"]["VIEWSET"];
     $this->m_Caption = I18n::getInstance()->translate($xmlArr["ATTRIBUTES"]["CAPTION"]);
     $this->m_URL = $xmlArr["ATTRIBUTES"]["URL"];
     $this->m_Target = $xmlArr["ATTRIBUTES"]["TARGET"];
     $this->m_Icon = $xmlArr["ATTRIBUTES"]["ICON"];
     $this->m_Forms = !is_null($xmlArr["FORM"]) ? $this->_getForms($xmlArr["FORM"]) : null;
     //Get form or forms to hide or show
 }
Пример #28
0
 /**
  * Clears the domains internal data array.  Useful for testing i18n.
  *
  * @return void
  */
 function clear()
 {
     $self =& I18n::getInstance();
     $self->__domains = array();
 }
Пример #29
0
 /**
  * Get the loaded domains cache.
  *
  * @return array
  */
 public static function domains()
 {
     $self = I18n::getInstance();
     return $self->__domains;
 }
Пример #30
0
 /**
  * Render single node item
  *
  * @param array $nodeItem
  * @return <type>
  */
 protected function renderSingleNodeItem(&$nodeItem)
 {
     $url = $nodeItem["ATTRIBUTES"]["URL"];
     $caption = I18n::getInstance()->translate($nodeItem["ATTRIBUTES"]["CAPTION"]);
     $target = $nodeItem["ATTRIBUTES"]["TARGET"];
     //$img = $nodeItem["ATTRIBUTES"]["IMAGE"];
     if ($nodeItem["NODE"]) {
         $image = "<img src='" . Resource::getImageUrl() . "/plus.gif' class='collapsed' onclick='mouseClickHandler(this)'>";
     } else {
         $image = "<img src='" . Resource::getImageUrl() . "/topic.gif'>";
     }
     if ($target) {
         if ($url) {
             $sHTML .= "<li class='tree'>{$image} <a href=\"" . $url . "\" target='{$target}'>" . $caption . "</a>";
         } else {
             $sHTML .= "<li class='tree'>{$image} {$caption}";
         }
     } else {
         if ($url) {
             $sHTML .= "<li class='tree'>{$image} <a href=\"" . $url . "\">" . $caption . "</a>";
         } else {
             $sHTML .= "<li class='tree'>{$image} {$caption}";
         }
     }
     if ($nodeItem["NODE"]) {
         $sHTML .= "\n<ul class='collapsed'>\n";
         $sHTML .= $this->renderNodeItems($nodeItem["NODE"]);
         $sHTML .= "</ul>";
     }
     $sHTML .= "</li>\n";
     return $sHTML;
 }