| @@ -1,7 +1,7 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | -* | |
| 3 | +* | |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | 6 | // Disallow direct access. |
| 7 | 7 | defined('ABSPATH') or die("Access denied"); |
| @@ -9,60 +9,60 @@ | ||
| 9 | 9 | /** |
| 10 | 10 | * Access Point interface |
| 11 | 11 | */ |
| 12 | 12 | interface CJTIAccessPoint { |
| 13 | - | |
| 13 | + | |
| 14 | 14 | /** |
| 15 | 15 | * put your comment there... |
| 16 | - * | |
| 16 | + * | |
| 17 | 17 | */ |
| 18 | 18 | public function listen(); |
| 19 | - | |
| 19 | + | |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | -* | |
| 23 | +* | |
| 24 | 24 | */ |
| 25 | 25 | abstract class CJTAccessPoint extends CJTHookableClass implements CJTIAccessPoint { |
| 26 | - | |
| 26 | + | |
| 27 | 27 | /** |
| 28 | 28 | * put your comment there... |
| 29 | - * | |
| 29 | + * | |
| 30 | 30 | * @var mixed |
| 31 | 31 | */ |
| 32 | 32 | protected static $connected; |
| 33 | - | |
| 33 | + | |
| 34 | 34 | /** |
| 35 | 35 | * put your comment there... |
| 36 | - * | |
| 36 | + * | |
| 37 | 37 | * @var mixed |
| 38 | 38 | */ |
| 39 | 39 | protected $controller; |
| 40 | - | |
| 40 | + | |
| 41 | 41 | /** |
| 42 | 42 | * put your comment there... |
| 43 | - * | |
| 43 | + * | |
| 44 | 44 | * @var mixed |
| 45 | 45 | */ |
| 46 | 46 | protected $controllerName; |
| 47 | - | |
| 47 | + | |
| 48 | 48 | /** |
| 49 | 49 | * put your comment there... |
| 50 | - * | |
| 50 | + * | |
| 51 | 51 | * @var mixed |
| 52 | 52 | */ |
| 53 | 53 | protected $name; |
| 54 | - | |
| 54 | + | |
| 55 | 55 | /** |
| 56 | 56 | * put your comment there... |
| 57 | - * | |
| 57 | + * | |
| 58 | 58 | * @var mixed |
| 59 | 59 | */ |
| 60 | 60 | protected $onconnected = array('parameters' => array('state')); |
| 61 | - | |
| 61 | + | |
| 62 | 62 | /** |
| 63 | 63 | * put your comment there... |
| 64 | - * | |
| 64 | + * | |
| 65 | 65 | * @var mixed |
| 66 | 66 | */ |
| 67 | 67 | protected $ongetdefaultcontrollername = array('parameters' => array('controller')); |
| 68 | 68 | |
| @@ -67,61 +67,41 @@ | ||
| 67 | 67 | protected $ongetdefaultcontrollername = array('parameters' => array('controller')); |
| 68 | 68 | |
| 69 | 69 | /** |
| 70 | 70 | * put your comment there... |
| 71 | - * | |
| 71 | + * | |
| 72 | 72 | * @var mixed |
| 73 | 73 | */ |
| 74 | 74 | protected $onlisten = array('hookType' =>CJTWordpressEvents::HOOK_ACTION); |
| 75 | - | |
| 75 | + | |
| 76 | 76 | /** |
| 77 | 77 | * put your comment there... |
| 78 | - * | |
| 78 | + * | |
| 79 | 79 | * @var mixed |
| 80 | 80 | */ |
| 81 | 81 | protected $onsetcontroller = array('parameters' => array('controller')); |
| 82 | - | |
| 82 | + | |
| 83 | 83 | /** |
| 84 | 84 | * put your comment there... |
| 85 | - * | |
| 85 | + * | |
| 86 | 86 | * @var mixed |
| 87 | 87 | */ |
| 88 | - protected $overrideControllersPath = null; | |
| 89 | - | |
| 90 | - /** | |
| 91 | - * put your comment there... | |
| 92 | - * | |
| 93 | - * @var mixed | |
| 94 | - */ | |
| 95 | - protected $overrideControllersPrefix = null; | |
| 96 | - | |
| 97 | - /** | |
| 98 | - * put your comment there... | |
| 99 | - * | |
| 100 | - * @var mixed | |
| 101 | - */ | |
| 102 | 88 | protected $pageId = CJTPlugin::PLUGIN_REQUEST_ID; |
| 103 | - | |
| 89 | + | |
| 104 | 90 | /** |
| 105 | 91 | * put your comment there... |
| 106 | - * | |
| 92 | + * | |
| 107 | 93 | */ |
| 108 | 94 | public function __construct($defaultController = 'blocks') { |
| 109 | 95 | // Initialize Hookable. |
| 110 | 96 | parent::__construct(); |
| 111 | - // Overrides controllers path using current Access Point model class path | |
| 112 | - $accessPointClassLoader =& CJT_Framework_Autoload_Loader::findClassLoader(get_class($this)); | |
| 113 | - if ($accessPointClassLoader) { | |
| 114 | - $this->overrideControllersPath = $accessPointClassLoader->getPath() . DIRECTORY_SEPARATOR . 'controllers'; | |
| 115 | - $this->overrideControllersPrefix = $accessPointClassLoader->getPrefix(); | |
| 116 | - } | |
| 117 | 97 | // Initialize! |
| 118 | - $this->controllerName = $this->ongetdefaultcontrollername(isset($_REQUEST['controller']) ? esc_html($_REQUEST['controller']) : $defaultController); | |
| 98 | + $this->controllerName = $this->ongetdefaultcontrollername(isset($_REQUEST['controller']) ? $_REQUEST['controller'] : $defaultController); | |
| 119 | 99 | } |
| 120 | - | |
| 100 | + | |
| 121 | 101 | /** |
| 122 | 102 | * put your comment there... |
| 123 | - * | |
| 103 | + * | |
| 124 | 104 | * @return Boolean TRUE if it wasn't connected! FALSE otherwise. |
| 125 | 105 | */ |
| 126 | 106 | protected function connected() { |
| 127 | 107 | // Do connect only if not connected yet |
| @@ -132,58 +112,58 @@ | ||
| 132 | 112 | self::$connected = $this; |
| 133 | 113 | } |
| 134 | 114 | return $returns; |
| 135 | 115 | } |
| 136 | - | |
| 116 | + | |
| 137 | 117 | /** |
| 138 | 118 | * put your comment there... |
| 139 | - * | |
| 119 | + * | |
| 140 | 120 | */ |
| 141 | 121 | protected abstract function doListen(); |
| 142 | - | |
| 122 | + | |
| 143 | 123 | /** |
| 144 | 124 | * put your comment there... |
| 145 | - * | |
| 125 | + * | |
| 146 | 126 | */ |
| 147 | 127 | public function & getController() { |
| 148 | - return $this->controller; | |
| 128 | + return $this->controller; | |
| 149 | 129 | } |
| 150 | - | |
| 130 | + | |
| 151 | 131 | /** |
| 152 | 132 | * put your comment there... |
| 153 | - * | |
| 133 | + * | |
| 154 | 134 | */ |
| 155 | 135 | public function getControllerName() { |
| 156 | - return $this->controllerName; | |
| 136 | + return $this->controllerName; | |
| 157 | 137 | } |
| 158 | - | |
| 138 | + | |
| 159 | 139 | /** |
| 160 | 140 | * put your comment there... |
| 161 | - * | |
| 141 | + * | |
| 162 | 142 | */ |
| 163 | 143 | public function getName() { |
| 164 | 144 | return $this->name; |
| 165 | 145 | } |
| 166 | - | |
| 146 | + | |
| 167 | 147 | /** |
| 168 | 148 | * put your comment there... |
| 169 | - * | |
| 149 | + * | |
| 170 | 150 | */ |
| 171 | 151 | public static function & isConnected() { |
| 172 | 152 | return self::$connected; |
| 173 | 153 | } |
| 174 | - | |
| 154 | + | |
| 175 | 155 | /** |
| 176 | 156 | * put your comment there... |
| 177 | - * | |
| 157 | + * | |
| 178 | 158 | */ |
| 179 | 159 | public function hasAccess() { |
| 180 | 160 | return current_user_can('administrator'); |
| 181 | 161 | } |
| 182 | - | |
| 162 | + | |
| 183 | 163 | /** |
| 184 | 164 | * put your comment there... |
| 185 | - * | |
| 165 | + * | |
| 186 | 166 | */ |
| 187 | 167 | public function listen() { |
| 188 | 168 | // Fire listen event! |
| 189 | 169 | $this->onlisten(); |
| @@ -190,12 +170,12 @@ | ||
| 190 | 170 | // Allow access points to bind their hooks |
| 191 | 171 | $this->doListen(); |
| 192 | 172 | return $this; |
| 193 | 173 | } |
| 194 | - | |
| 174 | + | |
| 195 | 175 | /** |
| 196 | 176 | * put your comment there... |
| 197 | - * | |
| 177 | + * | |
| 198 | 178 | * @param mixed $request |
| 199 | 179 | */ |
| 200 | 180 | public function route($loadView = null, $request = null) { |
| 201 | 181 | // Only loading one controller is allowed. |
| @@ -202,20 +182,13 @@ | ||
| 202 | 182 | if (!$this->controller) { |
| 203 | 183 | // Import view class. |
| 204 | 184 | require_once CJTOOLBOX_MVC_FRAMEWOK . '/view.inc.php'; |
| 205 | 185 | // Instantiate controller! |
| 206 | - $this->controller = $this->onsetcontroller( | |
| 207 | - CJTController::getInstance( | |
| 208 | - $this->controllerName, | |
| 209 | - $loadView, | |
| 210 | - $request, | |
| 211 | - $this->overrideControllersPath, | |
| 212 | - $this->overrideControllersPrefix | |
| 213 | - )); | |
| 186 | + $this->controller = $this->onsetcontroller(CJTController::getInstance($this->controllerName, $loadView, $request)); | |
| 214 | 187 | } |
| 215 | 188 | return $this->controller; |
| 216 | 189 | } |
| 217 | - | |
| 190 | + | |
| 218 | 191 | } // End class. |
| 219 | 192 | |
| 220 | 193 | // Hookable! |
| 221 | -CJTAccessPoint::define('CJTAccessPoint', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); | |
| 194 | +CJTAccessPoint::define('CJTAccessPoint', array('hookType' => CJTWordpressEvents::HOOK_FILTER)); | |