本文整理汇总了PHP中Locales::addLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Locales::addLocale方法的具体用法?PHP Locales::addLocale怎么用?PHP Locales::addLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locales
的用法示例。
在下文中一共展示了Locales::addLocale方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: perform
//.........这里部分代码省略.........
$errors = false;
foreach ($Tables as $table) {
$query = str_replace("{dbprefix}", $this->_dbPrefix, $table["code"]);
if ($this->_db->Execute($query)) {
$message .= "Table <strong>" . $table["desc"] . "</strong> created successfully.<br/>";
} else {
$message .= "Error creating table: " . $this->_db->ErrorMsg() . "<br/>";
$errors = true;
}
}
if ($errors) {
$message = "There was an error creating the tables in the database. Please make sure that the user chosen to connect to the database has enough permissions to create tables.<br/><br/>{$message}";
$this->_view = new WizardView("step1");
$this->_view->setErrorMessage($message);
$this->setDbConfigValues($this->_view);
$this->setCommonData();
return false;
}
// try to guess the url where plog is running
// try to guess the url where plog is running
$httpProtocol = array_key_exists("HTTPS", $_SERVER) && $_SERVER["HTTPS"] == "on" ? "https://" : "http://";
$httpHost = $_SERVER["HTTP_HOST"];
$requestUrl = $_SERVER["REQUEST_URI"];
$requestUrl = str_replace("/wizard.php", "", $requestUrl);
$plogUrl = $httpProtocol . $httpHost . $requestUrl;
// Find some of the tools we are going to need (last one is for os x, with fink installed)
// TBD: support for Windows specific directories
$folders = array("/bin/", "/usr/bin/", "/usr/local/bin/", "/sw/bin/");
$finder = new FileFinder();
$pathToUnzip = $finder->findBinary("unzip", $folders);
$pathToTar = $finder->findBinary("tar", $folders);
$pathToGzip = $finder->findBinary("gzip", $folders);
$pathToBzip2 = $finder->findBinary("bzip2", $folders);
$pathToConvert = $finder->findBinary("convert", $folders);
// and execute some insert's
foreach ($Inserts as $insert) {
$query = str_replace("{dbprefix}", $this->_dbPrefix, $insert);
$query = str_replace("{plog_base_url}", $plogUrl, $query);
// replace also the placeholders for the paths to the tools
$query = str_replace("{path_to_tar}", $pathToTar, $query);
$query = str_replace("{path_to_unzip}", $pathToUnzip, $query);
$query = str_replace("{path_to_bz2}", $pathToBzip2, $query);
$query = str_replace("{path_to_gzip}", $pathToGzip, $query);
$query = str_replace("{path_to_convert}", $pathToConvert, $query);
$query = str_replace("{path_to_convert}", $pathToConvert, $query);
if (!$this->_db->Execute($query)) {
$message .= "Error executing code: " . $this->_db->ErrorMsg() . "<br/>";
$errors = true;
}
}
//
// show some information regarding the helper tools we're going to need
// and wether they were found or not
//
$message .= "<br/><b>-- Helper tools --</b><br/>";
if ($pathToTar == "") {
$message .= "The helper tool 'tar' was not found<br/>";
} else {
$message .= "The helper tool 'tar' was found in {$pathToTar}<br/>";
}
if ($pathToGzip == "") {
$message .= "The helper tool 'gzip' was not found<br/>";
} else {
$message .= "The helper tool 'gzip' was found in {$pathToGzip}<br/>";
}
if ($pathToUnzip == "") {
$message .= "The helper tool 'unzip' was not found<br/>";
} else {
$message .= "The helper tool 'unzip' was found in {$pathToUnzip}<br/>";
}
if ($pathToBzip2 == "") {
$message .= "The helper tool 'bzip2' was not found<br/>";
} else {
$message .= "The helper tool 'bzip2' was found in {$pathToTar}<br/>";
}
if ($pathToConvert == "") {
$message .= "The helper tool 'convert' (from the ImageMagick package) was not found<br/>";
} else {
$message .= "The helper tool 'convert' (from the ImageMagick package) was found in {$pathToConvert}<br/>";
}
if ($errors) {
$this->_view = new WizardView("step1");
$this->setDbConfigValues($this->_view);
$message = "There was an error initializing some of the tables. Please make sure that the user chosen to connect to the database has enough permissions to add records to the database.<br/><br/>{$message}";
$this->_view->setErrorMessage($message);
$this->setCommonData();
} else {
$this->_view = new WizardView("step2");
$this->_view->setValue("message", $message);
}
// Scan for locales
$locales = new Locales();
// find all the new locales that we have not yet stored
$f = new LocaleFinder();
$newLocaleCodes = $f->find();
foreach ($newLocaleCodes as $newLocaleCode) {
$res = $locales->addLocale($newLocaleCode);
}
return true;
}
示例2: FileUploads
function _performUploadLocale()
{
// since we are here, the file name was validated to be ok, so we can
// continue with the operation
$files = HttpVars::getFiles();
$uploads = new FileUploads($files);
$this->_view = new AdminSiteLocalesListView($this->_blogInfo);
// we can first of all move the file to the destionation folder
$result = $uploads->process($this->_config->getValue("locale_folder"));
// the only thing that can happen is that the file was not correctly saved
if ($result[0]->getError() != 0) {
$this->_view->setErrorMessage($this->_locale->tr("error_saving_locale"));
return false;
}
// and once it's there, we can do as if we were adding a locale code
$upload = new FileUpload($files["localeFile"]);
$res = preg_match(REGEXP_VALID_LOCALE, $upload->getFileName(), $matches);
$localeCode = $matches[1];
// add the file to the list of locales
$locales = new Locales();
$locales->addLocale($localeCode);
$this->_view->setSuccessMessage($this->_locale->pr("locale_added_ok", $localeCode));
return true;
}