Component-Builder/admin/compiler/joomla_3/JModelItem_site.php

136 lines
4.4 KiB
PHP
Raw Normal View History

2016-01-30 20:28:43 +00:00
<?php
/*--------------------------------------------------------------------------------------------------------| www.vdm.io |------/
__ __ _ _____ _ _ __ __ _ _ _
\ \ / / | | | __ \ | | | | | \/ | | | | | | |
\ \ / /_ _ ___| |_ | | | | _____ _____| | ___ _ __ _ __ ___ ___ _ __ | |_ | \ / | ___| |_| |__ ___ __| |
\ \/ / _` / __| __| | | | |/ _ \ \ / / _ \ |/ _ \| '_ \| '_ ` _ \ / _ \ '_ \| __| | |\/| |/ _ \ __| '_ \ / _ \ / _` |
\ / (_| \__ \ |_ | |__| | __/\ V / __/ | (_) | |_) | | | | | | __/ | | | |_ | | | | __/ |_| | | | (_) | (_| |
\/ \__,_|___/\__| |_____/ \___| \_/ \___|_|\___/| .__/|_| |_| |_|\___|_| |_|\__| |_| |_|\___|\__|_| |_|\___/ \__,_|
| |
|_|
/-------------------------------------------------------------------------------------------------------------------------------/
@package Component Builder
@subpackage componentbuilder.php
@author Llewellyn van der Merwe <https://www.vdm.io/joomla-component-builder>
@my wife Roline van der Merwe <http://www.vdm.io/>
@copyright Copyright (C) 2015. All Rights Reserved
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
Builds Complex Joomla Components
/-----------------------------------------------------------------------------------------------------------------------------*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
?>
###BOM###
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla modelitem library
jimport('joomla.application.component.modelitem');
/**
* ###Component### ###SView### Model
*/
class ###Component###Model###SView### extends JModelItem
{
/**
* Model context string.
*
* @var string
*/
protected $_context = 'com_###component###.###sview###';
/**
* Model user data.
*
* @var strings
*/
protected $user;
protected $userId;
protected $guest;
protected $groups;
protected $levels;
protected $app;
protected $input;
protected $uikitComp;
/**
* @var object item
*/
protected $item;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*
* @return void
*/
protected function populateState()
{
2017-12-15 01:10:10 +00:00
$this->app = JFactory::getApplication();
$this->input = $this->app->input;
2016-01-30 20:28:43 +00:00
// Get the itme main id
2017-12-15 01:10:10 +00:00
$id = $this->input->getInt('id', null);
2016-01-30 20:28:43 +00:00
$this->setState('###sview###.id', $id);
// Load the parameters.
$params = $this->app->getParams();
$this->setState('params', $params);
parent::populateState();
}
/**
* Method to get article data.
*
* @param integer $pk The id of the article.
*
* @return mixed Menu item data object on success, false on failure.
*/
public function getItem($pk = null)
{
2017-12-15 01:10:10 +00:00
$this->user = JFactory::getUser();###USER_PERMISSION_CHECK_ACCESS###
$this->userId = $this->user->get('id');
$this->guest = $this->user->get('guest');
$this->groups = $this->user->get('groups');
$this->authorisedGroups = $this->user->getAuthorisedGroups();
$this->levels = $this->user->getAuthorisedViewLevels();
$this->initSet = true;
2016-01-30 20:28:43 +00:00
$pk = (!empty($pk)) ? $pk : (int) $this->getState('###sview###.id');###SITE_BEFORE_GET_ITEM###
if ($this->_item === null)
{
$this->_item = array();
}###LICENSE_LOCKED_CHECK###
if (!isset($this->_item[$pk]))
{
try
{###SITE_GET_ITEM###
}
catch (Exception $e)
{
if ($e->getCode() == 404)
{
// Need to go thru the error handler to allow Redirect to work.
JError::raiseWaring(404, $e->getMessage());
2016-01-30 20:28:43 +00:00
}
else
{
$this->setError($e);
$this->_item[$pk] = false;
}
}
}###SITE_AFTER_GET_ITEM###
return $this->_item[$pk];
}###LICENSE_LOCKED_SET_BOOL### ###SITE_CUSTOM_METHODS### ###SITE_CUSTOM_BUTTONS_METHOD### ###SITE_CUSTOM_GET_FORM_METHOD###
}