| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | //------------------------------------------------------------------------- | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | // OVIDENTIA http://www.ovidentia.org | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | // Ovidentia is free software; you can redistribute it and/or modify | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | // it under the terms of the GNU General Public License as published by | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | // the Free Software Foundation; either version 2, or (at your option) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | // any later version. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | // This program is distributed in the hope that it will be useful, but | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | // WITHOUT ANY WARRANTY; without even the implied warranty of | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | // See the GNU General Public License for more details. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | // | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | // You should have received a copy of the GNU General Public License | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | // along with this program; if not, write to the Free Software | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | // USA. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | //------------------------------------------------------------------------- | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  * @license http://opensource.org/licenses/gpl-license.php GNU General Public License (GPL) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |  * @copyright Copyright (c) 2008 by CANTICO ({@link http://www.cantico.fr}) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | require_once $GLOBALS['babInstallPath'] . 'utilit/controller.class.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | require_once $GLOBALS['babInstallPath'] . 'utilit/json.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | require_once dirname(__FILE__). '/functions.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | $App = app_App(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  | $App->includeBase(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  | class app_UnknownActionException extends Exception | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  | 	public function __construct($action, $code = 0) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  | 	{ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  | 		$message = 'Unknown method "' . $action->getController() . '::' . $action->getMethod() . '"'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  | 		parent::__construct($message, $code); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  | 	} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  | } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  | class app_Controller extends bab_Controller implements app_Object_Interface | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      * @var Func_App | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |     protected $app = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      * @var string[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |     protected $reloadSelectors = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * @param string $reloadSelector | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |     public function addReloadSelector($reloadSelector) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |         $this->reloadSelectors[$reloadSelector] = $reloadSelector; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |      * @return string[] | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |     public function getReloadSelectors() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |         return $this->reloadSelectors; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * Can be used in a controller to check if the current request was made by ajax. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * @var bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |     protected $isAjaxRequest = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |      * Name of method to use to create action | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |      * @var string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |     public $createActionMethod = 'createActionForTg'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |      * @param Func_App $app | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |     public function __construct(Func_App $app = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         $this->setApp($app); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |      * {@inheritDoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * @see app_Object::setApp() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     public function setApp(Func_App $app = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |         $this->app = $app; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |         return $this; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * {@inheritDoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      * @see app_Object::App() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     public function App() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         return $this->app; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |      * @return string | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |     protected function getControllerTg() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         return $this->App()->controllerTg; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |      * Can be used in a controller to check if the current request was made by ajax. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |      * @return bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     public function isAjaxRequest() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |         if (!isset($this->isAjaxRequest)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |             $this->isAjaxRequest = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |         return $this->isAjaxRequest; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |      * Ensures that the user is logged in. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      * Tries to use the appropriate authentication type depending on the situation. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     public function requireCredential($message = null) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         if ($this->isAjaxRequest()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |             $authType = 'Basic'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |             $authType = ''; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |         if (!isset($message)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |             $message = $this->App()->translate('You must be logged in to access this page.'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |         bab_requireCredential($message, $authType); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |      * Returns an instance of the specific controller class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |      * If $proxy is true, a proxy to this controller is returned instead. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      * @deprecated use $App->ControllerProxy() instead | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |      * @param string	$classname | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |      * @param bool		$proxy | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |      * @return app_Controller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |     public static function getInstance($classname, $proxy = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |         // If the app object was not specified (through the setApp() method) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |         // we try to select one according to the classname prefix. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |         list($prefix) = explode('_', __CLASS__); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |         $functionalityName = ucwords($prefix); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         $App = @bab_functionality::get('App/' . $functionalityName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |         if (!$App) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             throw new app_Exception('Faild to autodetect functionality App/' . $functionalityName.', the getInstance method is deprecated, use $App->ControllerProxy() instead'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |         $controller = $App->ControllerProxy($classname, $proxy); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         return $controller; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |      * Dynamically creates a proxy class for this controller with all public, non-final and non-static functions | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |      * overriden so that they return an action (Widget_Action) corresponding to each of them. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |      * @param string $classname | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |      * @return app_Controller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |     static function getProxyInstance(Func_App $App, $classname) | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |         $class = new ReflectionClass($classname); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |         $proxyClassname = $class->name . self::PROXY_CLASS_SUFFIX; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |         if (!class_exists($proxyClassname)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |             $classStr = 'class ' . $proxyClassname . ' extends ' . $class->name . ' {' . "\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |             $methods = $class->getMethods(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |             $classStr .= '	public function __construct(Func_App $App) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |                 $this->setApp($App); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |             }' . "\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |             foreach ($methods as $method) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |                 if ($method->name === '__construct' || !$method->isPublic() || $method->isStatic() || $method->isFinal() || $method->name === 'setApp' || $method->name === 'App') { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |                     continue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |                 $classStr .= '	public function ' . $method->name . '('; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |                 $parameters = $method->getParameters(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |                 $parametersStr = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |                 foreach ($parameters as $parameter) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |                     if ($parameter->isDefaultValueAvailable()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |                         $parametersStr[] = '$' . $parameter->name . ' = ' . var_export($parameter->getDefaultValue(), true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |                     } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |                         $parametersStr[] = '$' . $parameter->name; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |                 $classStr .= implode(', ', $parametersStr); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |                 $classStr .= ') {' . "\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |                 $classStr .= '		$args = func_get_args();' . "\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |                 $classStr .= '		return $this->getMethodAction(__FUNCTION__, $args);' . "\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |                 $classStr .= '	}' . "\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |             $classStr .= '}' . "\n"; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |             // We define the proxy class | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |             eval($classStr); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |         $proxy = new $proxyClassname($App); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |         //$proxy = bab_getInstance($proxyClassname); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |         return $proxy; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |      * @return self | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 256 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 257 |  |  |     public function proxy() | 
            
                                                                        
                            
            
                                    
            
            
                | 258 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 259 |  |  |         return self::getProxyInstance($this->App(), get_class($this)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |      * Get proxy class with action from the new addon controller | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |      * @return self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |     protected function quickProxy() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |         $proxy = $this->proxy(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |         $proxy->createActionMethod = 'createActionForAddon'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |         return $proxy; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |      * {@inheritDoc} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |      * @see bab_Controller::getObjectName() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |     protected function getObjectName($classname) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |         list(, $objectname) = explode('_Ctrl', $classname); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |         return strtolower($objectname); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  | //     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  | //      * Returns the action object corresponding to the current object method $methodName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  | //      * with the parameters $args. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  | //      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  | //      * @param string $methodName | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  | //      * @param array $args | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  | //      * @return Widget_Action	Or null on error. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  | //      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  | //     protected function getMethodAction($methodName, $args) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  | //     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  | //         $classname = substr(get_class($this), 0, -strlen(self::PROXY_CLASS_SUFFIX)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  | //         if (!method_exists($classname, $methodName)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  | //             throw new bab_InvalidActionException($classname . '::' . $methodName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  | //         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  | //         $cls = new ReflectionClass($classname); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  | //         $filename = $cls->getFileName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  | //         $method = new ReflectionMethod($classname, $methodName); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  | //         $objectName = basename($filename, '.ctrl.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  | //         $parameters = $method->getParameters(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  | //         $actionParams = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  | //         $argNumber = 0; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  | //         foreach ($parameters as $parameter) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  | //             $parameterName = $parameter->getName(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  | //             if (isset($args[$argNumber])) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  | //                 $actionParams[$parameterName] = $args[$argNumber]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  | //             } elseif ($parameter->isDefaultValueAvailable()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  | //                 $actionParams[$parameterName] = $parameter->getDefaultValue(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  | //             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  | //                 $actionParams[$parameterName] = null; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  | //             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  | //             $argNumber++; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  | //         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  | //         /* @var $action Widget_Action */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  | //         $action = $this->{$this->createActionMethod}($objectName. '.' . $methodName, $actionParams); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  | //         $docComment = $method->getDocComment(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  | //         if (strpos($docComment, '@ajax') !== false) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  | //             $action->setAjax(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  | //         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  | //         if (strpos($docComment, '@requireSaveMethod') !== false && method_exists($action, 'setRequireSaveMethod')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  | //             $action->setRequireSaveMethod(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  | //         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  | //         if (strpos($docComment, '@requireDeleteMethod') !== false && method_exists($action, 'setRequireDeleteMethod')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  | //             $action->setRequireDeleteMethod(true); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  | //         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  | //         return $action; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  | //     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |      * @return Widget_Action | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |     protected function createActionForTg($idx, $actionParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |         $action = new Widget_Action(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |         $action->setMethod($this->App()->controllerTg, $idx, $actionParams); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |         return $action; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |      * @return Widget_Action | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |     protected function createActionForAddon($idx, $actionParams) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |         $App = $this->App(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |         $action = new Widget_Action(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |         $action->setParameters($actionParams); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |         list(,,$file) = explode('/', $App->controllerTg); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |         $action->setParameter('addon', $App->getAddonName().'.'.$file); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |         $action->setParameter('idx', $idx); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |         return $action; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |      * Tries to dispatch the action to the correct sub-controller. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |      * @param Widget_Action 	$action | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |      * @return mixed | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |     final public function execute(Widget_Action $action) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |         $method = $action->getMethod(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |         if (!isset($method) || '' === $method) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |         list($objectName, ) = explode('.', $method); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |         if (!method_exists($this, $objectName)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |             header('HTTP/1.0 400 Bad Request'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |             throw new app_UnknownActionException($action); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |         $objectController = $this->{$objectName}(false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |         if ( ! ($objectController instanceof app_Controller)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |             return false; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |         $returnedValue = null; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |         try { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |             $returnedValue = $objectController->execAction($action); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |         } catch (app_AccessException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |             if (!bab_isUserLogged() && $e->requireCredential) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |                 bab_requireCredential($e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |                 if ($this->isAjaxRequest()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |                     header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |                     die( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |                         bab_json_encode( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |                             array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |                                 'exception' => 'app_AccessException', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |                                 'message' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |                                 'errorMessage' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |                             ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |                         ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |                     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |                 app_addPageInfo($e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |                 $returnedValue = $this->App()->Ui()->Page(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |                 // $returnedValue->addError($e->getMessage()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |         } catch (app_SaveException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |             if ($this->isAjaxRequest()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |                 header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |                 header('Cache-Control: no-cache, must-revalidate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |                 header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |                 header('Content-type: application/json'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |                 die( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |                     bab_json_encode( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |                         array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |                             'exception' => 'app_SaveException', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |                             'message' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |                             'errorMessage' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |                         ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |                 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |         } catch (app_DeletedRecordException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |             $this->deletedItemPage($action, $e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 450 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 451 |  |  |         } catch (app_NotFoundException $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 452 |  |  |             $this->notFoundPage($action, $e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 453 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 454 |  |  |         } catch (ORM_Exception $e) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 455 |  |  |             $this->errorPage($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 456 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 457 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 458 |  |  |         $W = bab_Widgets(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 459 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 460 |  |  |         if ($returnedValue instanceof Widget_Displayable_Interface) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 461 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 462 |  |  |             if ($returnedValue instanceof Widget_BabPage && !$this->isAjaxRequest()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 463 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |                 // If the action returned a page, we display it. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |                 $returnedValue->displayHtml(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |             } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |                 $htmlCanvas = $W->HtmlCanvas(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |                 if (self::$acceptJson) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |                     $itemId = $returnedValue->getId(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |                     $returnArray = array($itemId => $returnedValue->display($htmlCanvas)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |                     header('Cache-Control: no-cache, must-revalidate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |                     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |                     header('Content-type: application/json'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |                     die(app_json_encode($returnArray)); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |                     header('Cache-Control: no-cache, must-revalidate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |                     header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |                     header('Content-type: text/html'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |                     if ($returnedValue instanceof Widget_Page && method_exists($returnedValue, 'getPageTitle')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |                         $pageTitle = $returnedValue->getPageTitle(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |                         if (method_exists($htmlCanvas, 'sendPageTitle')) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |                             $htmlCanvas->sendPageTitle($pageTitle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |                         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |                             header('X-Cto-PageTitle: ' . $pageTitle); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |                     $html = $returnedValue->display($htmlCanvas); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |                     die($html); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |         } elseif (is_array($returnedValue)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |             $htmlCanvas = $W->HtmlCanvas(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |             $returnedArray = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |             foreach ($returnedValue as $key => &$item) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |                 if ($item instanceof Widget_Displayable_Interface) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |                     $returnedArray[$item->getId()] = $item->display($htmlCanvas); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |                 } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |                     $returnedArray[$key] = $item; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |             header('Cache-Control: no-cache, must-revalidate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |             header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |             header('Content-type: application/json'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |             die(bab_convertStringFromDatabase(bab_json_encode($returnedArray), bab_charset::UTF_8)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |         } elseif (true === $returnedValue || is_string($returnedValue)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |             if ($this->isAjaxRequest()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |                 $body = bab_getBody(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |                 $json = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |                 $json['messages'] = array(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |                 foreach ($body->messages as $message) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |                     $json['messages'][] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |                         'level' => 'info', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |                         'content' => $message, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |                         'time' => 4000 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |                     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |                 foreach ($body->errors as $message) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |                     $json['messages'][] = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |                         'level' => 'danger', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |                         'content' => $message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |                     ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |                 if ($objectController->getReloadSelectors()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |                     $json['reloadSelector'] = implode(',', $objectController->getReloadSelectors()); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |                 echo bab_json_encode($json); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |                 die; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |             } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |         return $returnedValue; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |     private function deletedItemPage(Widget_Action $action, app_DeletedRecordException $e) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |         if ($this->isAjaxRequest()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |             header($_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden', true, 403); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |             header('Cache-Control: no-cache, must-revalidate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |             header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |             header('Content-type: application/json'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |             die( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |                 app_json_encode( | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |                     array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |                         'exception' => 'app_SaveException', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |                         'message' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |                         'errorMessage' => bab_convertStringFromDatabase($e->getMessage(), 'UTF-8'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |                 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |         header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |         $App = $this->App(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |         $W = bab_Widgets(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |         $page = $App->Ui()->Page(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |         $dialog = $W->Frame(null, $W->VBoxLayout()->setVerticalSpacing(2, 'em')) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |         ->addClass(Func_Icons::ICON_LEFT_16); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |         $page->addItem($dialog); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |         //TRANSLATORS: %s can be task, contact, organization ... | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |         $dialog->addItem($W->Title(sprintf(app_translate('This %s has been deleted'), $e->getObjectTitle()), 1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |         if ($e instanceof app_DeletedRecordException) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |             $dialog->addItem( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |                 $W->VBoxItems( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |                     $e->getDeletedBy(), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |                     $e->getDeletedOn() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |                 ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |         $page->displayHtml(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |     private function notFoundPage(Widget_Action $action, app_NotFoundException $e) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |         if ($this->isAjaxRequest()) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |             $message = sprintf(app_translate('This %s does not exists'), $e->getObjectTitle() . ' (' . $e->getId() . ')'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |             $json = array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |                 'messages' => array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |                     array( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |                         'level' => 'danger', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |                         'content' => $message | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |                     ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |                 ) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |             echo bab_json_encode($json); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |             die; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |         header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found', true, 404); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |         header('Cache-Control: no-cache, must-revalidate'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |         header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |         $App = $this->App(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |         $W = bab_Widgets(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |         $page = $App->Ui()->Page(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |         $page->addClass(Func_Icons::ICON_LEFT_16); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |         //TRANSLATORS: %s can be task, contact, organization ... | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |         $page->addItem($W->Title(sprintf(app_translate('This %s does not exists'), $e->getObjectTitle()), 1)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  |         $page->displayHtml(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |     private function errorPage(Exception $e) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |         header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal server error', true, 500); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |         require_once $GLOBALS['babInstallPath'] . 'utilit/uiutil.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |         $popup = new babBodyPopup(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |         $popup->babEcho( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |             '<h1>' . $this->App()->translate('There was a problem when trying to perform this operation') . '</h1>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  |             . '<h2 class="error">' . $this->App()->translate('Additional debugging information:') . '</h2>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  |             . '<p class="error">' . $e->getMessage() . ' ' .  $e->getFile() . ' ' . $e->getLine()  . ' ' . $e->getTraceAsString() . '</p>' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |             ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |         die($popup->printout()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  |      * Method to call before saving | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  |      * @since 1.0.22 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  |      * @return self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  |     public function requireSaveMethod() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  |         if ('GET' === $_SERVER['REQUEST_METHOD']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  |             throw new app_Exception('Method not allowed'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |      * Method to call before deleting | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |      * @since 1.0.22 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |      * @return self | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  |     public function requireDeleteMethod() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  |         if ('GET' === $_SERVER['REQUEST_METHOD']) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |             throw new app_Exception('Method not allowed'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  |      * Custom fields | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |      * @return app_CtrlCustomField | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  |     public function CustomField($proxy = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  |         require_once APP_CTRL_PATH . 'customfield.ctrl.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  |         return $this->App()->ControllerProxy('app_CtrlCustomField', $proxy); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  |      * Custom sections | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  |      * @return app_CtrlCustomSection | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |     public function CustomSection($proxy = true) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  |         require_once APP_CTRL_PATH . 'customsection.ctrl.php'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  |         return $this->App()->ControllerProxy('app_CtrlCustomSection', $proxy); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 695 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 696 |  |  |  | 
            
                        
In the issue above, the returned value is violating the contract defined by the mentioned interface.
Let's take a look at an example: