| [ 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/adminblogtemplatesetslistview.class.php" ); 5 lt_include( PLOG_CLASS_PATH."class/data/validator/stringvalidator.class.php" ); 6 lt_include( PLOG_CLASS_PATH."class/data/validator/arrayvalidator.class.php" ); 7 lt_include( PLOG_CLASS_PATH."class/template/templatesets/templatesetstorage.class.php" ); 8 9 /** 10 * \ingroup Action 11 * @private 12 * 13 * Removes a global template from disk. 14 */ 15 class AdminDeleteBlogTemplateAction extends AdminAction 16 { 17 18 var $_templateIds; 19 20 function AdminDeleteBlogTemplateAction( $actionInfo, $request ) 21 { 22 $this->AdminAction( $actionInfo, $request ); 23 24 $this->_op = $actionInfo->getActionParamValue(); 25 if( $this->_op == "deleteBlogTemplate" ) 26 $this->registerFieldValidator( "templateId", new StringValidator()); 27 else 28 $this->registerFieldValidator( "templateIds", new ArrayValidator()); 29 $view = new AdminBlogTemplateSetsListView( $this->_blogInfo ); 30 $view->setErrorMessage( $this->_locale->tr("error_no_templates_selected" )); 31 $this->setValidationErrorView( $view ); 32 33 $this->requirePermission( "update_blog_template" ); 34 } 35 36 function perform() 37 { 38 if( $this->_op == "deleteBlogTemplate" ) { 39 $this->_templateId = $this->_request->getValue( "templateId" ); 40 $this->_templateIds = Array(); 41 $this->_templateIds[] = $this->_templateId; 42 } 43 else 44 $this->_templateIds = $this->_request->getValue( "templateIds" ); 45 46 $this->_deleteTemplates(); 47 } 48 49 /** 50 * Carries out the specified action 51 * @private 52 */ 53 function _deleteTemplates() 54 { 55 $ts = new TemplateSetStorage(); 56 $errorMessage = ""; 57 $successMessage = ""; 58 $totalOk = 0; 59 $blogTemplate = $this->_blogInfo->getTemplateSet(); 60 61 foreach( $this->_templateIds as $templateId ) { 62 // we can't remove the current template! 63 if( $blogTemplate->getName() == $templateId ) { 64 $errorMessage .= $this->_locale->pr("error_template_is_current", $templateId )."<br/>"; 65 } 66 else { 67 // otherwise, let's proceed 68 if( !$ts->removeTemplate( $templateId, $this->_blogInfo->getId() )) 69 $errorMessage .= $this->_locale->pr("error_removing_template", $templateId )."<br/>"; 70 else { 71 $totalOk++; 72 if( $totalOk < 2 ) 73 $successMessage = $this->_locale->pr("template_removed_ok", $templateId); 74 else 75 $successMessage = $this->_locale->pr("templates_removed_ok", $totalOk ); 76 } 77 } 78 } 79 80 $this->_view = new AdminBlogTemplateSetsListView( $this->_blogInfo ); 81 if( $errorMessage != "" ) $this->_view->setErrorMessage( $errorMessage ); 82 if( $successMessage != "" ) $this->_view->setSuccessMessage( $successMessage ); 83 $this->setCommonData(); 84 85 // We should update the session too, or we will get data dirty 86 lt_include( PLOG_CLASS_PATH."class/dao/blogs.class.php" ); 87 $blogs = new Blogs(); 88 $blogInfo = $blogs->getBlogInfo( $this->_blogInfo->getId() ); 89 $this->_session->setValue( "blogInfo", $blogInfo ); 90 $this->saveSession(); 91 92 return true; 93 } 94 } 95 ?>
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 |
|