当前位置: 首页>>代码示例>>PHP>>正文


PHP Language::getWorkingLanguages方法代码示例

本文整理汇总了PHP中Backend\Core\Language\Language::getWorkingLanguages方法的典型用法代码示例。如果您正苦于以下问题:PHP Language::getWorkingLanguages方法的具体用法?PHP Language::getWorkingLanguages怎么用?PHP Language::getWorkingLanguages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Backend\Core\Language\Language的用法示例。


在下文中一共展示了Language::getWorkingLanguages方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadForm

 /**
  * Load the form
  */
 private function loadForm()
 {
     if ($this->getParameter('id') != null) {
         // get the translation
         $translation = BackendLocaleModel::get($this->getParameter('id', 'int'));
         // if not empty, set the filter
         if (!empty($translation)) {
             // we are copying the given translation
             $isCopy = true;
         } else {
             $this->redirect(BackendModel::createURLForAction('Index') . '&error=non-existing' . $this->filterQuery);
         }
     } else {
         $isCopy = false;
     }
     // create form
     $this->frm = new BackendForm('add', BackendModel::createURLForAction() . $this->filterQuery);
     // create and add elements
     $this->frm->addDropdown('application', array('Backend' => 'Backend', 'Frontend' => 'Frontend'), $isCopy ? $translation['application'] : $this->filter['application']);
     $this->frm->addDropdown('module', BackendModel::getModulesForDropDown(), $isCopy ? $translation['module'] : $this->filter['module']);
     $this->frm->addDropdown('type', BackendLocaleModel::getTypesForDropDown(), $isCopy ? $translation['type'] : $this->filter['type'][0]);
     $this->frm->addText('name', $isCopy ? $translation['name'] : $this->filter['name']);
     $this->frm->addTextarea('value', $isCopy ? $translation['value'] : $this->filter['value'], null, null, true);
     $this->frm->addDropdown('language', BL::getWorkingLanguages(), $isCopy ? $translation['language'] : $this->filter['language'][0]);
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:28,代码来源:Add.php

示例2: execute

 /**
  * Execute the action
  * We will build the classname, require the class and call the execute method.
  */
 public function execute()
 {
     $this->loadConfig();
     // is the requested action available? If not we redirect to the error page.
     if (!$this->config->isActionAvailable($this->action)) {
         // build the url
         $errorUrl = '/' . NAMED_APPLICATION . '/' . $this->get('request')->getLocale() . '/error?type=action-not-allowed';
         // redirect to the error page
         return $this->redirect($errorUrl, 307);
     }
     // build action-class
     $actionClass = 'Backend\\Modules\\' . $this->getModule() . '\\Actions\\' . $this->getAction();
     if ($this->getModule() == 'Core') {
         $actionClass = 'Backend\\Core\\Actions\\' . $this->getAction();
     }
     if (!class_exists($actionClass)) {
         throw new Exception('The class ' . $actionClass . ' could not be found.');
     }
     // get working languages
     $languages = BackendLanguage::getWorkingLanguages();
     $workingLanguages = array();
     // loop languages and build an array that we can assign
     foreach ($languages as $abbreviation => $label) {
         $workingLanguages[] = array('abbr' => $abbreviation, 'label' => $label, 'selected' => $abbreviation == BackendLanguage::getWorkingLanguage());
     }
     // assign the languages
     $this->tpl->assign('workingLanguages', $workingLanguages);
     // create action-object
     /** @var $object BackendBaseAction */
     $object = new $actionClass($this->getKernel());
     $this->getContainer()->get('logger')->info("Executing backend action '{$object->getAction()}' for module '{$object->getModule()}'.");
     $object->execute();
     return $object->getContent();
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:38,代码来源:Action.php

示例3: loadForm

 /**
  * Load the form
  */
 private function loadForm()
 {
     $this->frm = new BackendForm('edit', BackendModel::createURLForAction(null, null, null, array('id' => $this->id)) . $this->filterQuery);
     $this->frm->addDropdown('application', array('Backend' => 'Backend', 'Frontend' => 'Frontend'), $this->record['application']);
     $this->frm->addDropdown('module', BackendModel::getModulesForDropDown(), $this->record['module']);
     $this->frm->addDropdown('type', BackendLocaleModel::getTypesForDropDown(), $this->record['type']);
     $this->frm->addText('name', $this->record['name']);
     $this->frm->addTextarea('value', $this->record['value'], null, null, true);
     $this->frm->addDropdown('language', BL::getWorkingLanguages(), $this->record['language']);
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:13,代码来源:Edit.php

示例4: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     $isGod = BackendAuthentication::getUser()->isGod();
     // get possible languages
     if ($isGod) {
         $possibleLanguages = array_unique(array_merge(BL::getWorkingLanguages(), BL::getInterfaceLanguages()));
     } else {
         $possibleLanguages = BL::getWorkingLanguages();
     }
     // get parameters
     $language = \SpoonFilter::getPostValue('language', array_keys($possibleLanguages), null, 'string');
     $module = \SpoonFilter::getPostValue('module', BackendModel::getModules(), null, 'string');
     $name = \SpoonFilter::getPostValue('name', null, null, 'string');
     $type = \SpoonFilter::getPostValue('type', BackendModel::getContainer()->get('database')->getEnumValues('locale', 'type'), null, 'string');
     $application = \SpoonFilter::getPostValue('application', array('Backend', 'Frontend'), null, 'string');
     $value = \SpoonFilter::getPostValue('value', null, null, 'string');
     // validate values
     if (trim($value) == '' || $language == '' || $module == '' || $type == '' || $application == '' || $application == 'Frontend' && $module != 'Core') {
         $error = BL::err('InvalidValue');
     }
     // in case this is a 'act' type, there are special rules concerning possible values
     if ($type == 'act' && !isset($error)) {
         if (rawurlencode($value) != CommonUri::getUrl($value)) {
             $error = BL::err('InvalidActionValue', $this->getModule());
         }
     }
     // no error?
     if (!isset($error)) {
         // build item
         $item['language'] = $language;
         $item['module'] = $module;
         $item['name'] = $name;
         $item['type'] = $type;
         $item['application'] = $application;
         $item['value'] = $value;
         $item['edited_on'] = BackendModel::getUTCDate();
         $item['user_id'] = BackendAuthentication::getUser()->getUserId();
         // does the translation exist?
         if (BackendLocaleModel::existsByName($name, $type, $module, $language, $application)) {
             // add the id to the item
             $item['id'] = (int) BackendLocaleModel::getByName($name, $type, $module, $language, $application);
             // update in db
             BackendLocaleModel::update($item);
         } else {
             // insert in db
             BackendLocaleModel::insert($item);
         }
         // output OK
         $this->output(self::OK);
     } else {
         $this->output(self::ERROR, null, $error);
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:57,代码来源:SaveTranslation.php

示例5: setLanguage

 /**
  * @param string $language
  *
  * @throws Exception If the provided language is not valid
  */
 public function setLanguage($language)
 {
     // get the possible languages
     $possibleLanguages = BackendLanguage::getWorkingLanguages();
     // validate
     if (!array_key_exists($language, $possibleLanguages)) {
         throw new Exception('Language invalid.');
     }
     // set working language
     BackendLanguage::setWorkingLanguage($language);
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:16,代码来源:Ajax.php

示例6: getWorkingLanguages

 /**
  * Get all possible working languages
  *
  * @deprecated
  *
  * @return array
  */
 public static function getWorkingLanguages()
 {
     trigger_error('Backend\\Core\\Engine\\Language is deprecated.
          It has been moved to Backend\\Core\\Language\\Language', E_USER_DEPRECATED);
     return parent::getWorkingLanguages();
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:13,代码来源:Language.php

示例7: getPossibleLanguages

 /**
  * {@inheritdoc}
  */
 protected function getPossibleLanguages()
 {
     return Language::getWorkingLanguages();
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:7,代码来源:Locale.php

示例8: processQueryString

 /**
  * Process the querystring
  */
 private function processQueryString()
 {
     // store the querystring local, so we don't alter it.
     $queryString = $this->getQueryString();
     // find the position of ? (which separates real URL and GET-parameters)
     $positionQuestionMark = mb_strpos($queryString, '?');
     // separate the GET-chunk from the parameters
     $getParameters = '';
     if ($positionQuestionMark === false) {
         $processedQueryString = $queryString;
     } else {
         $processedQueryString = mb_substr($queryString, 0, $positionQuestionMark);
         $getParameters = mb_substr($queryString, $positionQuestionMark);
     }
     // split into chunks, a Backend URL will always look like /<lang>/<module>/<action>(?GET)
     $chunks = (array) explode('/', trim($processedQueryString, '/'));
     // check if this is a request for a AJAX-file
     $isAJAX = isset($chunks[1]) && $chunks[1] == 'ajax';
     // get the language, this will always be in front
     $language = '';
     if (isset($chunks[1]) && $chunks[1] != '') {
         $language = \SpoonFilter::getValue($chunks[1], array_keys(BackendLanguage::getWorkingLanguages()), '');
     }
     // no language provided?
     if ($language == '' && !$isAJAX) {
         // remove first element
         array_shift($chunks);
         // redirect to login
         $this->redirect('/' . NAMED_APPLICATION . '/' . SITE_DEFAULT_LANGUAGE . (empty($chunks) ? '' : '/') . implode('/', $chunks) . $getParameters);
     }
     // get the module, null will be the default
     $module = isset($chunks[2]) && $chunks[2] != '' ? $chunks[2] : 'Dashboard';
     $module = \SpoonFilter::toCamelCase($module);
     // get the requested action, if it is passed
     if (isset($chunks[3]) && $chunks[3] != '') {
         $action = \SpoonFilter::toCamelCase($chunks[3]);
     } elseif (!$isAJAX) {
         // Check if we can load the config file
         $configClass = 'Backend\\Modules\\' . $module . '\\Config';
         if ($module == 'Core') {
             $configClass = 'Backend\\Core\\Config';
         }
         try {
             // when loading a backend url for a module that doesn't exist, without
             // providing an action, a FatalErrorException occurs, because the config
             // class we're trying to load doesn't exist. Let's just throw instead,
             // and catch it immediately.
             if (!class_exists($configClass)) {
                 throw new Exception('The config class does not exist');
             }
             /** @var BackendBaseConfig $config */
             $config = new $configClass($this->getKernel(), $module);
             // set action
             $action = $config->getDefaultAction() !== null ? $config->getDefaultAction() : 'Index';
         } catch (Exception $ex) {
             if (BackendModel::getContainer()->getParameter('kernel.debug')) {
                 throw new Exception('The config file for the module (' . $module . ') can\'t be found.');
             } else {
                 // @todo    don't use redirects for error, we should have something like an invoke method.
                 // build the url
                 $errorUrl = '/' . NAMED_APPLICATION . '/' . $language . '/error?type=action-not-allowed';
                 // add the querystring, it will be processed by the error-handler
                 $errorUrl .= '&querystring=' . rawurlencode('/' . $this->getQueryString());
                 // redirect to the error page
                 $this->redirect($errorUrl, 307);
             }
         }
     }
     // AJAX parameters are passed via GET or POST
     if ($isAJAX) {
         $module = isset($_GET['fork']['module']) ? $_GET['fork']['module'] : '';
         $action = isset($_GET['fork']['action']) ? $_GET['fork']['action'] : '';
         $language = isset($_GET['fork']['language']) ? $_GET['fork']['language'] : SITE_DEFAULT_LANGUAGE;
         $module = isset($_POST['fork']['module']) ? $_POST['fork']['module'] : $module;
         $action = isset($_POST['fork']['action']) ? $_POST['fork']['action'] : $action;
         $language = isset($_POST['fork']['language']) ? $_POST['fork']['language'] : $language;
         $this->setModule($module);
         $this->setAction($action);
         BackendLanguage::setWorkingLanguage($language);
     } else {
         $this->processRegularRequest($module, $action, $language);
     }
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:86,代码来源:Url.php

示例9: importXML

 /**
  * Import a locale XML file.
  *
  * @param \SimpleXMLElement $xml                The locale XML.
  * @param bool              $overwriteConflicts Should we overwrite when there is a conflict?
  * @param array             $frontendLanguages  The frontend languages to install locale for.
  * @param array             $backendLanguages   The backend languages to install locale for.
  * @param int               $userId             Id of the user these translations should be inserted for.
  * @param int               $date               The date the translation has been inserted.
  *
  * @return array The import statistics
  */
 public static function importXML(\SimpleXMLElement $xml, $overwriteConflicts = false, $frontendLanguages = null, $backendLanguages = null, $userId = null, $date = null)
 {
     $overwriteConflicts = (bool) $overwriteConflicts;
     $statistics = array('total' => 0, 'imported' => 0);
     // set defaults if necessary
     // we can't simply use these right away, because this function is also calls by the installer,
     // which does not have Backend-functions
     if ($frontendLanguages === null) {
         $frontendLanguages = array_keys(BL::getWorkingLanguages());
     }
     if ($backendLanguages === null) {
         $backendLanguages = array_keys(BL::getInterfaceLanguages());
     }
     if ($userId === null) {
         $userId = BackendAuthentication::getUser()->getUserId();
     }
     if ($date === null) {
         $date = BackendModel::getUTCDate();
     }
     // get database instance
     $db = BackendModel::getContainer()->get('database');
     // possible values
     $possibleApplications = array('Frontend', 'Backend');
     $possibleModules = (array) $db->getColumn('SELECT m.name FROM modules AS m');
     // types
     $typesShort = (array) $db->getEnumValues('locale', 'type');
     foreach ($typesShort as $type) {
         $possibleTypes[$type] = self::getTypeName($type);
     }
     // install English translations anyhow, they're fallback
     $possibleLanguages = array('Frontend' => array_unique(array_merge(array('en'), $frontendLanguages)), 'Backend' => array_unique(array_merge(array('en'), $backendLanguages)));
     // current locale items (used to check for conflicts)
     $currentLocale = (array) $db->getColumn('SELECT CONCAT(application, module, type, language, name)
          FROM locale');
     // applications
     foreach ($xml as $application => $modules) {
         // application does not exist
         if (!in_array($application, $possibleApplications)) {
             continue;
         }
         // modules
         foreach ($modules as $module => $items) {
             // module does not exist
             if (!in_array($module, $possibleModules)) {
                 continue;
             }
             // items
             foreach ($items as $item) {
                 // attributes
                 $attributes = $item->attributes();
                 $type = \SpoonFilter::getValue($attributes['type'], $possibleTypes, '');
                 $name = ucfirst(\SpoonFilter::getValue($attributes['name'], null, ''));
                 // missing attributes
                 if ($type == '' || $name == '') {
                     continue;
                 }
                 // real type (shortened)
                 $type = array_search($type, $possibleTypes);
                 // translations
                 foreach ($item->translation as $translation) {
                     // statistics
                     ++$statistics['total'];
                     // attributes
                     $attributes = $translation->attributes();
                     $language = \SpoonFilter::getValue($attributes['language'], $possibleLanguages[$application], '');
                     // language does not exist
                     if ($language == '') {
                         continue;
                     }
                     // the actual translation
                     $translation = (string) $translation;
                     // locale item
                     $locale['user_id'] = $userId;
                     $locale['language'] = $language;
                     $locale['application'] = $application;
                     $locale['module'] = $module;
                     $locale['type'] = $type;
                     $locale['name'] = $name;
                     $locale['value'] = $translation;
                     $locale['edited_on'] = $date;
                     // check if translation does not yet exist, or if the translation can be overridden
                     if (!in_array($application . $module . $type . $language . $name, $currentLocale) || $overwriteConflicts) {
                         $db->execute('INSERT INTO locale (user_id, language, application, module, type, name, value, edited_on)
                              VALUES (?, ?, ?, ?, ?, ?, ?, ?)
                              ON DUPLICATE KEY UPDATE user_id = ?, value = ?, edited_on = ?', array($locale['user_id'], $locale['language'], $locale['application'], $locale['module'], $locale['type'], $locale['name'], $locale['value'], $locale['edited_on'], $locale['user_id'], $locale['value'], $locale['edited_on']));
                         // statistics
                         ++$statistics['imported'];
                     }
//.........这里部分代码省略.........
开发者ID:forkcms,项目名称:forkcms,代码行数:101,代码来源:Model.php

示例10: setLanguage

 /**
  * Set language
  *
  * @param string $value The language to load.
  *
  * @throws Exception
  */
 public function setLanguage($value)
 {
     // get the possible languages
     $possibleLanguages = BackendLanguage::getWorkingLanguages();
     // validate
     if (!array_key_exists($value, $possibleLanguages)) {
         throw new Exception('Invalid language.');
     }
     // set property
     $this->language = $value;
     // set the locale (we need this for the labels)
     BackendLanguage::setLocale($this->language);
     // set working language
     BackendLanguage::setWorkingLanguage($this->language);
 }
开发者ID:forkcms,项目名称:forkcms,代码行数:22,代码来源:Cronjob.php


注:本文中的Backend\Core\Language\Language::getWorkingLanguages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。