[ Index ] |
|
Code source de LifeType 1.2.4 |
1 <?php 2 3 lt_include( PLOG_CLASS_PATH."class/action/admin/adminaction.class.php" ); 4 lt_include( PLOG_CLASS_PATH."class/view/admin/adminsitelocaleslistview.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/locale/locales.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" ); 8 9 /** 10 * \ingroup Action 11 * @private 12 */ 13 class AdminDeleteLocalesAction extends AdminAction 14 { 15 var $_op; 16 var $_localeIds; 17 18 function AdminDeleteLocalesAction( $actionInfo, $request ) 19 { 20 $this->AdminAction( $actionInfo, $request ); 21 22 $this->_op = $actionInfo->getActionParamValue(); 23 if( $this->_op == "deleteLocale" ) 24 $this->registerFieldValidator( "localeId", new StringValidator()); 25 else 26 $this->registerFieldValidator( "localeIds", new ArrayValidator()); 27 $view = new AdminSiteLocalesListView( $this->_blogInfo ); 28 $view->setErrorMessage( $this->_locale->tr("error_no_locales_selected")); 29 $this->setValidationErrorView( $view ); 30 31 $this->requireAdminPermission( "update_locale" ); 32 } 33 34 function perform() 35 { 36 if( $this->_op == "deleteLocale" ) { 37 $localeId = $this->_request->getValue( "localeId" ); 38 $this->_localeIds = Array(); 39 $this->_localeIds[] = $localeId; 40 } 41 else 42 $this->_localeIds = $this->_request->getValue( "localeIds" ); 43 44 $this->_deleteLocales(); 45 46 return true; 47 } 48 49 /** 50 * @private 51 */ 52 function _deleteLocales() 53 { 54 55 $locales = new Locales(); 56 57 // if there is only one locale available in the system, we should 58 // not allow to remove it either 59 if( count($locales->getAvailableLocales()) == 1 ) { 60 $this->_view = new AdminSiteLocalesListView( $this->_blogInfo ); 61 $this->_view->setErrorMessage( $this->_locale->tr("error_deleting_only_locale")); 62 $this->setCommonData(); 63 64 return false; 65 } 66 67 // keep the value of the default locale because plog should not allow 68 // to remove the default one 69 $defaultLocale = $this->_config->getValue( "default_locale" ); 70 71 $errorMessage = ""; 72 $successMessage = ""; 73 $totalOk = 0; 74 75 foreach( $this->_localeIds as $localeId ) { 76 if( $localeId != $defaultLocale ) { 77 if( $locales->removeLocale( $localeId )) { 78 $totalOk++; 79 if( $totalOk < 2 ) 80 $successMessage = $this->_locale->pr( "locale_deleted_ok", $localeId ); 81 else 82 $successMessage = $this->_locale->pr( "locales_deleted_ok", $totalOk ); 83 } 84 else 85 $errorMessage .= $this->_locale->pr("error_deleting_locale", $localeId)."<br/>"; 86 } 87 else { 88 $errorMessage .= $this->_locale->pr("error_locale_is_default", $localeId)."<br/>"; 89 } 90 } 91 92 $this->_view = new AdminSiteLocalesListView( $this->_blogInfo ); 93 if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage ); 94 if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage ); 95 $this->setCommonData(); 96 97 return true; 98 } 99 } 100 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 21:04:15 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |