本文整理汇总了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);
//.........这里部分代码省略.........