類別AdminAddLocaleAction的繼承圖:

公開方法(Public Methods) | |
| AdminAddLocaleAction ($actionInfo, $request) | |
| validate () | |
| _performUploadLocale () | |
| perform () | |
私有方法(Private Methods) | |
| _performScanLocales () | |
定義在 adminaddlocaleaction.class.php 檔案之第 16 行.
|
||||||||||||
|
定義在 adminaddlocaleaction.class.php 檔案之第 19 行. 參考 $request, 及 SiteAdminAction::SiteAdminAction(). 00020 { 00021 $this->SiteAdminAction( $actionInfo, $request ); 00022 00023 // decide what to do based on which submit button was clicked 00024 if( $this->_request->getValue( "addLocale" ) != "" ) 00025 $this->_op = "uploadLocale"; 00026 else 00027 $this->_op = "scanLocales"; 00028 }
|
|
|
scans the locale folder looking for new locales
定義在 adminaddlocaleaction.class.php 檔案之第 55 行. 被參考於 perform(). 00056 { 00057 $locales = new Locales(); 00058 00059 // find all the new locales that we have not yet stored 00060 $f = new LocaleFinder(); 00061 $newLocaleCodes = $f->find(); 00062 00063 // success message 00064 $successMessage = ""; 00065 00066 // set up the view 00067 $this->_view = new AdminSiteLocalesListView( $this->_blogInfo ); 00068 00069 // if there are no new locales, there's no point in doing anything! 00070 if( count( $newLocaleCodes ) == 0 ) { 00071 $this->_view->setErrorMessage( $this->_locale->tr("error_no_new_locales_found" )); 00072 return false; 00073 } 00074 00075 foreach( $newLocaleCodes as $newLocaleCode ) { 00076 // add the locale to the config settings 00077 $res = $locales->addLocale( $newLocaleCode ); 00078 00079 // and create a success message 00080 $successMessage .= $this->_locale->pr("locale_added_ok", $newLocaleCode)."<br/>"; 00081 } 00082 00083 if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage ); 00084 00085 return true; 00086 }
|
|
|
定義在 adminaddlocaleaction.class.php 檔案之第 88 行. 參考 $result, 及 HttpVars::getFiles(). 被參考於 perform(). 00089 { 00090 // since we are here, the file name was validated to be ok, so we can 00091 // continue with the operation 00092 $files = HttpVars::getFiles(); 00093 $uploads = new FileUploads( $files ); 00094 00095 $this->_view = new AdminSiteLocalesListView( $this->_blogInfo ); 00096 00097 // we can first of all move the file to the destionation folder 00098 $result = $uploads->process( $this->_config->getValue( "locale_folder" )); 00099 00100 // the only thing that can happen is that the file was not correctly saved 00101 if( $result[0]->getError() != 0 ) { 00102 $this->_view->setErrorMessage( $this->_locale->tr("error_saving_locale")); 00103 return false; 00104 } 00105 00106 // and once it's there, we can do as if we were adding a locale code 00107 $upload = new FileUpload( $files["localeFile"] ); 00108 $res = preg_match( REGEXP_VALID_LOCALE, $upload->getFileName(), $matches ); 00109 $localeCode = $matches[1]; 00110 00111 // add the file to the list of locales 00112 $locales = new Locales(); 00113 $locales->addLocale( $localeCode ); 00114 00115 $this->_view->setSuccessMessage( $this->_locale->pr( "locale_added_ok", $localeCode )); 00116 00117 return true; 00118 }
|
|
|
Receives the HTTP request from the client as parameter, so that we can extract the parameters and perform our business logic. The result of this will be a view, which will normally be the output of the processing we just did or for example an error view showing an error message. Once we have completed processing, the controller will call the getView() method to get the resulting view and send it back to the customer.
依據Action重新實作. 定義在 adminaddlocaleaction.class.php 檔案之第 120 行. 參考 $result, _performScanLocales(), _performUploadLocale(), 及 AdminAction::setCommonData(). 00121 { 00122 if( $this->_op == "scanLocales" ) 00123 $result = $this->_performScanLocales(); 00124 else 00125 $result = $this->_performUploadLocale(); 00126 00127 $this->setCommonData(); 00128 00129 return $result; 00130 }
|
|
|
This method can be used for data validation and is always executed before perform(). If it returns 'true', execution will continue as normal. If it returns 'false', the process will be stopped and the current contents of the view will be returned. If the view is empty, an exception will be thrown. As of pLog 1.0, it is not necessary to implement data validation code here and it is recommended to use the data validation framework (see methods Action::registerFieldValidator() and related) There is more information about the data validation framework in the wiki: http://wiki.plogworld.net/index.php/PLog_1.0/Forms_and_data_validation. With the default code provided in the Action::validate() method, the callback method Action::validationErrorProcessing() will be called and after that, the view set via the Action::setValidationErrorView() will be used to generate the contents of the error message.
依據Action重新實作. 定義在 adminaddlocaleaction.class.php 檔案之第 30 行. 參考 HttpVars::getFiles(), Locales::isValidLocaleFileName(), 及 AdminAction::setCommonData(). 00031 { 00032 // first of all, we have to see if the name of the file is valid 00033 if( $this->_op == "uploadLocale" ) { 00034 $files = HttpVars::getFiles(); 00035 00036 $upload = new FileUpload( $files["localeFile"] ); 00037 00038 if( !Locales::isValidLocaleFileName( $upload->getFileName())) { 00039 $this->_view = new AdminTemplatedView( $this->_blogInfo, "newlocale" ); 00040 $this->_view->setErrorMessage( $this->_locale->tr("error_invalid_locale_file")); 00041 $this->setCommonData(); 00042 return false; 00043 } 00044 } 00045 00046 return true; 00047 }
|