當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Languages::localeExists方法代碼示例

本文整理匯總了PHP中Languages::localeExists方法的典型用法代碼示例。如果您正苦於以下問題:PHP Languages::localeExists方法的具體用法?PHP Languages::localeExists怎麽用?PHP Languages::localeExists使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Languages的用法示例。


在下文中一共展示了Languages::localeExists方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: import

 /**
  * Import language from XML form
  * 
  * @param void
  * @return null
  */
 function import()
 {
     if (!extension_loaded('xml') || !function_exists('xml_parser_create')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     $import_url = assemble_url('admin_languages_import');
     $this->wireframe->addBreadCrumb(lang('Import Language'), $import_url);
     $step = $this->request->post('wizard_step') ? $this->request->post('wizard_step') : 'initial';
     if ($step == 'initial') {
         $next_step = 'review';
     } else {
         if ($step == 'review') {
             $next_step = 'finalize';
         }
     }
     // if
     if (!folder_is_writable(LOCALIZATION_PATH)) {
         $this->wireframe->addPageMessage(lang('Localization folder: <strong>:folder</strong> is not writable', array('folder' => LOCALIZATION_PATH)), PAGE_MESSAGE_ERROR);
         $this->smarty->assign('import_enabled', false);
     } else {
         $this->smarty->assign(array('import_url' => $import_url, 'step' => $step, 'next_step' => $next_step, 'import_enabled' => true));
         if ($this->request->isSubmitted()) {
             switch ($step) {
                 case 'initial':
                     break;
                 case 'review':
                     $xml_file = $_FILES['xml']['tmp_name'];
                     if (!is_file($xml_file)) {
                         flash_error('You need to upload XML file first');
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     require_once ANGIE_PATH . '/classes/xml/xml2array.php';
                     $language = xml2array(file_get_contents($xml_file));
                     if (!$language) {
                         flash_error('Language XML file is corrupted');
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     $locale = $language['language']['info']['locale']['value'];
                     $name = $language['language']['info']['name']['value'];
                     $ac_version = $language['language']['info']['ac_version']['value'];
                     $system_version = $this->application->version ? $this->application->version : '1.0';
                     if (!$locale || !$name) {
                         flash_error('Language XML file is corrupted');
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     if (Languages::localeExists($locale)) {
                         flash_error('Language with locale :locale is already installed on system', array('locale' => $locale));
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     if (Languages::nameExists($name)) {
                         flash_error('Language with name :name is already installed on system', array('name' => $name));
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     $attachment = make_attachment($_FILES['xml']);
                     if (!$attachment || is_error($attachment)) {
                         flash_error($attachment->getMessage(), array('name' => $name));
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     if (version_compare($ac_version, $system_version, '=') != true) {
                         $this->wireframe->addPageMessage(lang('Current activeCollab version is <strong>:system_version</strong> and this translation is made for <strong>:ac_version</strong> version. Importing can continue, but this translation may not work on your system', array('system_version' => $system_version, 'ac_version' => $ac_version)), 'warning');
                     }
                     // if
                     $this->smarty->assign(array('language_ac_version' => $ac_version, 'language_name' => $name, 'language_locale' => $locale, 'system_version' => $system_version, 'attachment_id' => $attachment->getId()));
                     $this->setTemplate('import_review');
                     break;
                 case 'finalize':
                     $attachment_id = $this->request->post('attachment_id');
                     $attachment = Attachments::findById($attachment_id);
                     if (!instance_of($attachment, 'Attachment')) {
                         flash_error('There was some unknown error, please try again');
                         $this->redirectTo($import_url);
                     }
                     // if
                     require_once ANGIE_PATH . '/classes/xml/xml2array.php';
                     $language_array = xml2array(file_get_contents(UPLOAD_PATH . '/' . $attachment->getLocation()));
                     if (!$language_array) {
                         flash_error('Uploaded file is not valid XML');
                         $this->redirectToReferer($import_url);
                     }
                     // if
                     $language_locale = $language_array['language']['info']['locale']['value'];
                     $language_name = $language_array['language']['info']['name']['value'];
                     $language_version = $language_array['language']['info']['ac_version']['value'];
                     $language = new Language();
                     $language->setLocale($language_locale);
                     $language->setName($language_name);
                     $result = recursive_mkdir($language->getLocalizationPath(), 0777, LOCALIZATION_PATH);
//.........這裏部分代碼省略.........
開發者ID:NaszvadiG,項目名稱:activecollab_loc,代碼行數:101,代碼來源:LanguagesAdminController.class.php


注:本文中的Languages::localeExists方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。