| @@ -1,0 +1,60 @@ | ||
| 1 | +<?php | |
| 2 | +/** | |
| 3 | + * @package VikWP - Libraries | |
| 4 | + * @subpackage adapter.mvc | |
| 5 | + * @author E4J s.r.l. | |
| 6 | + * @copyright Copyright (C) 2023 E4J s.r.l. All Rights Reserved. | |
| 7 | + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL | |
| 8 | + * @link https://vikwp.com | |
| 9 | + */ | |
| 10 | + | |
| 11 | +// No direct access | |
| 12 | +defined('ABSPATH') or die('No script kiddies please!'); | |
| 13 | + | |
| 14 | +JLoader::import('adapter.mvc.controller'); | |
| 15 | + | |
| 16 | +/** | |
| 17 | + * The controller used by the views on the MVC framework. | |
| 18 | + * An admin-controller is used to handle the actions requested | |
| 19 | + * by the related view. | |
| 20 | + * | |
| 21 | + * The controller can be invoked when the value contained | |
| 22 | + * in $_REQUEST['task'] is equals to 'MyPluginController' + $_REQUEST['task']. | |
| 23 | + * | |
| 24 | + * e.g. $_REQUEST['task'] = 'groups.save' -> MyPluginControllerGroups | |
| 25 | + * | |
| 26 | + * @since 10.0 | |
| 27 | + */ | |
| 28 | +abstract class JControllerAdmin extends JController | |
| 29 | +{ | |
| 30 | + /** | |
| 31 | + * The controller model. | |
| 32 | + * | |
| 33 | + * @var JModel | |
| 34 | + */ | |
| 35 | + private $_model = null; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * Magic method to access private properties. | |
| 39 | + * | |
| 40 | + * @param string $name The property name to access. | |
| 41 | + * | |
| 42 | + * @return mixed The property value if exists, otherwise null. | |
| 43 | + */ | |
| 44 | + public function __get($name) | |
| 45 | + { | |
| 46 | + if ($name == 'model' && !isset($this->_model)) | |
| 47 | + { | |
| 48 | + $this->_model = $this->getModel(); | |
| 49 | + } | |
| 50 | + | |
| 51 | + $name = '_' . $name; | |
| 52 | + | |
| 53 | + if (property_exists($this, $name)) | |
| 54 | + { | |
| 55 | + return $this->{$name}; | |
| 56 | + } | |
| 57 | + | |
| 58 | + return null; | |
| 59 | + } | |
| 60 | +} | |