| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/web_app/src/controller/lmbController.class.php'); 10 11 /** 12 * abstract class AdminNodeController. 13 * 14 * @package cms 15 * @version $Id: AdminNodeController.class.php 5991 2007-06-13 14:00:24Z tony $ 16 */ 17 abstract class AdminNodeController extends lmbController 18 { 19 protected $_form_id = 'node_form'; 20 protected $_controller_name = 'node'; 21 protected $_node_class_name = 'lmbCmsNode'; 22 23 protected $node = null; 24 25 protected function _initNode($id = null) 26 { 27 $this->node = new $this->_node_class_name($id); 28 } 29 30 function doCreate() 31 { 32 $this->node = new $this->_node_class_name(); 33 $this->useForm($this->_form_id); 34 $this->setFormDatasource($this->request); 35 36 if($this->request->hasPost()) 37 { 38 $this->node->setControllerName($this->_controller_name); 39 $this->_import(); 40 41 if($this->request->get('auto_identifier')) 42 $this->node->setIdentifier(lmbCmsNode :: generateIdentifier($this->request->get('parent'))); 43 44 $this->_validateAndSave(true); 45 } 46 else 47 { 48 $this->_initCreateForm(); 49 } 50 } 51 52 function doEdit() 53 { 54 $this->node = lmbActiveRecord :: findById($this->_node_class_name, $this->request->getInteger('id')); 55 $this->useForm($this->_form_id); 56 $this->setFormDatasource($this->request); 57 58 if($this->request->hasPost()) 59 { 60 $this->_import(); 61 $this->_validateAndSave(false); 62 } 63 else 64 { 65 $this->_initEditForm(); 66 } 67 } 68 69 protected function _import() 70 { 71 $this->node->import($this->request); 72 } 73 74 protected function _validateAndSave($is_create = false) 75 { 76 $this->_onBeforeValidate(); 77 $this->node->validate($this->error_list); 78 $this->_onAfterValidate(); 79 80 if($this->error_list->isValid()) 81 { 82 if($is_create) 83 $this->_onBeforeCreate(); 84 else 85 $this->_onBeforeEdit(); 86 87 $this->_onBeforeSave(); 88 $this->node->saveSkipValidation(); 89 $this->_onAfterSave(); 90 91 if($is_create) 92 $this->_onAfterCreate(); 93 else 94 $this->_onAfterEdit(); 95 96 $this->closePopup(); 97 } 98 } 99 100 protected function _initCreateForm(){} 101 102 protected function _initEditForm() 103 { 104 $this->request->merge($this->node->export()); 105 $this->request->set('node', $this->node); 106 } 107 108 protected function _onBeforeSave() {} 109 protected function _onAfterSave() {} 110 protected function _onBeforeCreate() {} 111 protected function _onAfterCreate() {} 112 protected function _onBeforeEdit() {} 113 protected function _onAfterEdit() {} 114 protected function _onBeforeDelete() {} 115 protected function _onAfterDelete() {} 116 protected function _onBeforeValidate() {} 117 protected function _onAfterValidate() {} 118 119 function doDelete() 120 { 121 if($this->request->hasPost()) 122 $this->_onBeforeDelete(); 123 $this->performCommand('limb/cms/src/command/lmbCmsDeleteNodeCommand'); 124 if($this->request->hasPost()) 125 $this->_onAfterDelete(); 126 } 127 } 128 129 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Sat Nov 22 03:48:54 2008 | Cross-referenced by PHPXref 0.7 |