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


PHP Locales::addLocale方法代碼示例

本文整理匯總了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;
 }
開發者ID:BackupTheBerlios,項目名稱:plogfr-svn,代碼行數:101,代碼來源:wizard.php

示例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;
 }
開發者ID:BackupTheBerlios,項目名稱:plogfr-svn,代碼行數:24,代碼來源:adminaddlocaleaction.class.php


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