A generic MVC model implementation
Пример #1
0
 /**
  * Public constructor. Initialises the protected members as well. Useful $config keys:
  * update_component		The component name, e.g. com_foobar
  * update_version		The default version if the manifest cache is unreadable
  * update_site			The URL to the component's update XML stream
  * update_extraquery	The extra query to append to (commercial) components' download URLs
  * update_sitename		The update site's name (description)
  *
  * @param array $config
  */
 public function __construct($config = array())
 {
     $container = Container::getInstance('com_FOOBAR');
     parent::__construct($container);
     // Get an instance of the updater class
     $this->updater = JUpdater::getInstance();
     // Get the component name
     if (isset($config['update_component'])) {
         $this->component = $config['update_component'];
     } else {
         $this->component = $this->input->getCmd('option', '');
     }
     // Get the component version
     if (isset($config['update_version'])) {
         $this->version = $config['update_version'];
     }
     // Get the update site
     if (isset($config['update_site'])) {
         $this->updateSite = $config['update_site'];
     }
     // Get the extra query
     if (isset($config['update_extraquery'])) {
         $this->extraQuery = $config['update_extraquery'];
     }
     // Get the extra query
     if (isset($config['update_sitename'])) {
         $this->updateSiteName = $config['update_sitename'];
     }
     // Get the extension type
     list($extensionPrefix, $extensionName) = explode('_', $this->component);
     switch ($extensionPrefix) {
         default:
         case 'com':
             $type = 'component';
             $name = $this->component;
             break;
         case 'pkg':
             $type = 'package';
             $name = $this->component;
             break;
     }
     // Find the extension ID
     $db = $this->container->db;
     $query = $db->getQuery(true)->select('*')->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q($type))->where($db->qn('element') . ' = ' . $db->q($name));
     $db->setQuery($query);
     $extension = $db->loadObject();
     if (is_object($extension)) {
         $this->extension_id = $extension->extension_id;
         $data = json_decode($extension->manifest_cache, true);
         if (isset($data['version'])) {
             $this->version = $data['version'];
         }
     }
 }
Пример #2
0
 /**
  * Public constructor.
  *
  * @param   Container  $container  The configuration variables to this model
  * @param   array      $config     Configuration values for this model
  */
 public function __construct(Container $container, array $config)
 {
     $defaultConfig = ['tableName' => '#__ak_stats', 'idFieldName' => 'id'];
     if (!is_array($config) || empty($config)) {
         $config = [];
     }
     $config = array_merge($defaultConfig, $config);
     parent::__construct($container, $config);
     $platform = $this->container->platform;
     $defaultLimit = $platform->getConfig()->get('list_limit', 10);
     $limit = $platform->getUserStateFromRequest('global.list.limit', 'limit', $this->input, $defaultLimit);
     $limitstart = $platform->getUserStateFromRequest('com_akeeba.stats.limitstart', 'limitstart', $this->input, 0);
     if ($platform->isFrontend()) {
         $limit = 0;
         $limitstart = 0;
     }
     // Set the page pagination variables
     $this->setState('limit', $limit);
     $this->setState('limitstart', $limitstart);
 }
Пример #3
0
 /**
  * Pushes the default Model to the View
  *
  * @param   Model $model The model to push
  */
 public function setDefaultModel(Model &$model)
 {
     $name = $model->getName();
     $this->setDefaultModelName($name);
     $this->setModel($this->defaultModel, $model);
 }
Пример #4
0
 public function __construct(Container $container, array $config)
 {
     parent::__construct($container, $config);
     $this->knownFilterTypes = ['directories', 'files', 'skipdirs', 'skipfiles'];
 }
Пример #5
0
 /**
  * Returns a temporary instance of the model. Please note that this returns a _clone_ of the model object, not the
  * original object. The new object is set up to not save its stats, ignore the request when getting state variables
  * and comes with an empty state. The temporary object instance has its data reset as well.
  *
  * @return  $this
  */
 public function tmpInstance()
 {
     return parent::tmpInstance()->reset(true, true);
 }
Пример #6
0
 public function savestate($newState)
 {
     $this->methodCounter['savestate']++;
     return parent::savestate($newState);
 }
Пример #7
0
 /**
  * Constructs the model. Also sets the protected $integration property to the object of the active integration (or
  * null if none is available).
  *
  * @param   Container  $container  The component's DI container
  * @param   array      $config     Configuration overrides
  */
 public function __construct(Container $container, array $config = array())
 {
     parent::__construct($container, $config);
     $this->integration = $this->getIntegration();
 }
Пример #8
0
	/**
	 * Overridden constructor
	 *
	 * Sets up the encapsulation.
	 *
	 * @param   Container  $container  The configuration variables to this model
	 * @param   array      $config     Configuration values for this model
	 */
	public function __construct(Container $container, array $config)
	{
		parent::__construct($container, $config);

		$this->encapsulation = new Encapsulation($this->serverKey());
	}
Пример #9
0
 public function __construct(Container $container, array $config)
 {
     parent::__construct($container, $config);
     $this->knownFilterTypes = ['tables', 'tabledata'];
 }