Continued formatting of JCB code

This commit is contained in:
2017-12-15 03:10:10 +02:00
parent 8ac350e62b
commit e44b6bc272
91 changed files with 1516 additions and 1518 deletions

View File

@ -40,101 +40,101 @@ class ###Component###Model###Component### extends JModelList
{
public function getIcons()
{
// load user for access menus
$user = JFactory::getUser();
// reset icon array
// load user for access menus
$user = JFactory::getUser();
// reset icon array
$icons = array();
// view groups array
// view groups array
$viewGroups = array(
'main' => array(###DASHBOARDICONS###)
);###DASHBOARDICONACCESS###
foreach($viewGroups as $group => $views)
{
{
$i = 0;
if (###Component###Helper::checkArray($views))
{
{
foreach($views as $view)
{
$add = false;
if (strpos($view,'.') !== false)
{
$dwd = explode('.', $view);
if (count($dwd) == 3)
{
list($type, $name, $action) = $dwd;
}
elseif (count($dwd) == 2)
{
list($type, $name) = $dwd;
$action = false;
}
if ($action)
{
$viewName = $name;
switch($action)
{
case 'add':
$url ='index.php?option=com_###component###&view='.$name.'&layout=edit';
$image = $name.'_'.$action.'.'.$type;
$alt = $name.' '.$action;
$name = 'COM_###COMPONENT###_DASHBOARD_'.###Component###Helper::safeString($name,'U').'_ADD';
$add = true;
break;
default:
$url = 'index.php?option=com_categories&view=categories&extension=com_###component###.'.$name;
$image = $name.'_'.$action.'.'.$type;
$alt = $name.' '.$action;
$name = 'COM_###COMPONENT###_DASHBOARD_'.###Component###Helper::safeString($name,'U').'_'.###Component###Helper::safeString($action,'U');
break;
}
}
else
{
$viewName = $name;
$alt = $name;
$url = 'index.php?option=com_###component###&view='.$name;
$image = $name.'.'.$type;
$name = 'COM_###COMPONENT###_DASHBOARD_'.###Component###Helper::safeString($name,'U');
$hover = false;
}
}
else
{
$viewName = $view;
$alt = $view;
$url = 'index.php?option=com_###component###&view='.$view;
$image = $view.'.png';
$name = ucwords($view).'<br /><br />';
$hover = false;
}
// first make sure the view access is set
if (###Component###Helper::checkArray($viewAccess))
{
{
$dwd = explode('.', $view);
if (count($dwd) == 3)
{
list($type, $name, $action) = $dwd;
}
elseif (count($dwd) == 2)
{
list($type, $name) = $dwd;
$action = false;
}
if ($action)
{
$viewName = $name;
switch($action)
{
case 'add':
$url ='index.php?option=com_###component###&view='.$name.'&layout=edit';
$image = $name.'_'.$action.'.'.$type;
$alt = $name.'&nbsp;'.$action;
$name = 'COM_###COMPONENT###_DASHBOARD_'.###Component###Helper::safeString($name,'U').'_ADD';
$add = true;
break;
default:
$url = 'index.php?option=com_categories&view=categories&extension=com_###component###.'.$name;
$image = $name.'_'.$action.'.'.$type;
$alt = $name.'&nbsp;'.$action;
$name = 'COM_###COMPONENT###_DASHBOARD_'.###Component###Helper::safeString($name,'U').'_'.###Component###Helper::safeString($action,'U');
break;
}
}
else
{
$viewName = $name;
$alt = $name;
$url = 'index.php?option=com_###component###&view='.$name;
$image = $name.'.'.$type;
$name = 'COM_###COMPONENT###_DASHBOARD_'.###Component###Helper::safeString($name,'U');
$hover = false;
}
}
else
{
$viewName = $view;
$alt = $view;
$url = 'index.php?option=com_###component###&view='.$view;
$image = $view.'.png';
$name = ucwords($view).'<br /><br />';
$hover = false;
}
// first make sure the view access is set
if (###Component###Helper::checkArray($viewAccess))
{
// setup some defaults
$dashboard_add = false;
$dashboard_list = false;
$accessTo = '';
$accessAdd = '';
// acces checking start
$accessCreate = (isset($viewAccess[$viewName.'.create'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.create']):false;
$accessAccess = (isset($viewAccess[$viewName.'.access'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.access']):false;
$accessTo = '';
$accessAdd = '';
// acces checking start
$accessCreate = (isset($viewAccess[$viewName.'.create'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.create']):false;
$accessAccess = (isset($viewAccess[$viewName.'.access'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.access']):false;
// set main controllers
$accessDashboard_add = (isset($viewAccess[$viewName.'.dashboard_add'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.dashboard_add']):false;
$accessDashboard_list = (isset($viewAccess[$viewName.'.dashboard_list'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.dashboard_list']):false;
// check for adding access
if ($add && $accessCreate)
{
$accessAdd = $viewAccess[$viewName.'.create'];
}
elseif ($add)
{
$accessAdd = 'core.create';
}
// check if acces to view is set
if ($accessAccess)
{
$accessTo = $viewAccess[$viewName.'.access'];
}
// check for adding access
if ($add && $accessCreate)
{
$accessAdd = $viewAccess[$viewName.'.create'];
}
elseif ($add)
{
$accessAdd = 'core.create';
}
// check if acces to view is set
if ($accessAccess)
{
$accessTo = $viewAccess[$viewName.'.access'];
}
// set main access controllers
if ($accessDashboard_add)
{
@ -144,65 +144,65 @@ class ###Component###Model###Component### extends JModelList
{
$dashboard_list = $user->authorise($viewAccess[$viewName.'.dashboard_list'], 'com_###component###');
}
if (###Component###Helper::checkString($accessAdd) && ###Component###Helper::checkString($accessTo))
{
// check access
if($user->authorise($accessAdd, 'com_###component###') && $user->authorise($accessTo, 'com_###component###') && $dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (###Component###Helper::checkString($accessTo))
{
// check access
if($user->authorise($accessTo, 'com_###component###') && $dashboard_list)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (###Component###Helper::checkString($accessAdd))
{
// check access
if($user->authorise($accessAdd, 'com_###component###') && $dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
$i++;
}
}
else
{
$icons[$group][$i] = false;
if (###Component###Helper::checkString($accessAdd) && ###Component###Helper::checkString($accessTo))
{
// check access
if($user->authorise($accessAdd, 'com_###component###') && $user->authorise($accessTo, 'com_###component###') && $dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (###Component###Helper::checkString($accessTo))
{
// check access
if($user->authorise($accessTo, 'com_###component###') && $dashboard_list)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
elseif (###Component###Helper::checkString($accessAdd))
{
// check access
if($user->authorise($accessAdd, 'com_###component###') && $dashboard_add)
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
}
else
{
$icons[$group][$i] = new StdClass;
$icons[$group][$i]->url = $url;
$icons[$group][$i]->name = $name;
$icons[$group][$i]->image = $image;
$icons[$group][$i]->alt = $alt;
}
$i++;
}
}
else
{
$icons[$group][$i] = false;
}
}
return $icons;

View File

@ -74,15 +74,15 @@ class ###Component###View###Component### extends JViewLegacy
$canDo = ###Component###Helper::getActions('###component###');
JToolBarHelper::title(JText::_('COM_###COMPONENT###_DASHBOARD'), 'grid-2');
// set help url for this view if found
$help_url = ###Component###Helper::getHelpUrl('###component###');
if (###Component###Helper::checkString($help_url))
{
// set help url for this view if found
$help_url = ###Component###Helper::getHelpUrl('###component###');
if (###Component###Helper::checkString($help_url))
{
JToolbarHelper::help('COM_###COMPONENT###_HELP_MANAGER', false, $help_url);
}
}
if ($canDo->get('core.admin') || $canDo->get('core.options'))
{
{
JToolBarHelper::preferences('com_###component###');
}
}

View File

@ -37,10 +37,10 @@ abstract class ###Component###Helper
/**
* Load the Component xml manifest.
**/
public static function manifest()
public static function manifest()
{
$manifestUrl = JPATH_ADMINISTRATOR."/components/com_###component###/###component###.xml";
return simplexml_load_file($manifestUrl);
$manifestUrl = JPATH_ADMINISTRATOR."/components/com_###component###/###component###.xml";
return simplexml_load_file($manifestUrl);
}
/**
@ -55,22 +55,22 @@ abstract class ###Component###Helper
// get all Contributors (max 20)
$searchArray = range('0','20');
foreach($searchArray as $nr)
{
{
if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 1 || $params->get("showContributor".$nr) == 3))
{
{
// set link based of selected option
if($params->get("useContributor".$nr) == 1)
{
{
$link_front = '<a href="mailto:'.$params->get("emailContributor".$nr).'" target="_blank">';
$link_back = '</a>';
}
elseif($params->get("useContributor".$nr) == 2)
{
elseif($params->get("useContributor".$nr) == 2)
{
$link_front = '<a href="'.$params->get("linkContributor".$nr).'" target="_blank">';
$link_back = '</a>';
}
else
{
else
{
$link_front = '';
$link_back = '';
}
@ -86,10 +86,10 @@ abstract class ###Component###Helper
**/
public static function addSubmenu($submenu)
{
// load user for access menus
$user = JFactory::getUser();
// load the submenus to sidebar
###SUBMENU###
// load user for access menus
$user = JFactory::getUser();
// load the submenus to sidebar
###SUBMENU###
}###HELPER_CREATEUSER### ###HELPER_UIKIT### ###HELPER_EXEL###
public static function getVar($table, $where = null, $whereString = 'user', $what = 'id', $operator = '=', $main = '###component###')
@ -182,9 +182,9 @@ abstract class ###Component###Helper
public static function jsonToString($value, $sperator = ", ", $table = null)
{
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (self::checkArray($result))
@ -206,15 +206,15 @@ abstract class ###Component###Helper
}
return (string) implode($sperator,$result);
}
return (string) json_decode($value);
}
return $value;
}
return (string) json_decode($value);
}
return $value;
}
public static function isPublished($id,$type)
{
if ($type == 'raw')
{
{
$type = 'item';
}
$db = JFactory::getDbo();
@ -227,7 +227,7 @@ abstract class ###Component###Helper
$db->execute();
$found = $db->getNumRows();
if($found)
{
{
return true;
}
return false;
@ -244,33 +244,33 @@ abstract class ###Component###Helper
$db->execute();
$found = $db->getNumRows();
if($found)
{
{
return $db->loadResult();
}
return $id;
}
/**
/**
* Get the actions permissions
**/
public static function getActions($view,&$record = null,$views = null)
public static function getActions($view,&$record = null,$views = null)
{
jimport('joomla.access.access');
$user = JFactory::getUser();
$result = new JObject;
$view = self::safeString($view);
if (self::checkString($views))
{
if (self::checkString($views))
{
$views = self::safeString($views);
}
}
// get all actions from component
$actions = JAccess::getActions('com_###component###', 'component');
// set acctions only set in component settiongs
$componentActions = array('core.admin','core.manage','core.options','core.export');
// set acctions only set in component settiongs
$componentActions = array('core.admin','core.manage','core.options','core.export');
// loop the actions and set the permissions
foreach ($actions as $action)
{
{
// set to use component default
$fallback= true;
if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name,$componentActions))
@ -349,17 +349,17 @@ abstract class ###Component###Helper
}
elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0)
{
// make sure we use the core. action check for the categories
if (strpos($action->name,$view) !== false && strpos($action->name,'core.') === false ) {
$coreCheck = explode('.',$action->name);
$coreCheck[0] = 'core';
$categoryCheck = implode('.',$coreCheck);
}
else
{
$categoryCheck = $action->name;
}
// The record has a category. Check the category permissions.
// make sure we use the core. action check for the categories
if (strpos($action->name,$view) !== false && strpos($action->name,'core.') === false ) {
$coreCheck = explode('.',$action->name);
$coreCheck[0] = 'core';
$categoryCheck = implode('.',$coreCheck);
}
else
{
$categoryCheck = $action->name;
}
// The record has a category. Check the category permissions.
$catpermission = $user->authorise($categoryCheck, 'com_###component###.'.$views.'.category.' . (int) $record->catid);
if (!$catpermission && !is_null($catpermission))
{
@ -740,8 +740,8 @@ abstract class ###Component###Helper
$string = self::replaceNumbers($string);
}
// 0nly continue if we have a string
if (self::checkString($string))
{
if (self::checkString($string))
{
// create file name without the extention that is safe
if ($type === 'filename')
{
@ -764,12 +764,12 @@ abstract class ###Component###Helper
$string = preg_replace("/[^A-Za-z ]/", '', $string);
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no undersocre)
@ -790,21 +790,21 @@ abstract class ###Component###Helper
// return a string with all the uppercase(no undersocre)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
@ -813,14 +813,14 @@ abstract class ###Component###Helper
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
// return string
return $string;
}
// not a string
return '';
}
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)
{
if (self::checkString($var))
{
@ -831,11 +831,11 @@ abstract class ###Component###Helper
return self::shorten($string,$length);
}
return $string;
}
}
else
{
return '';
}
}
}###HELPER_LICENSE_LOCK###
public static function replaceNumbers($string)

View File

@ -190,8 +190,7 @@ abstract class ###Component###Email
// load the bounce email as sender if set
if (!is_null($bounce_email))
{
{
$mail->Sender = $bounce_email;
}

View File

@ -37,9 +37,9 @@ abstract class ###Component###Helper
public static function jsonToString($value, $sperator = ", ", $table = null)
{
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
// check if string is JSON
$result = json_decode($value, true);
if (json_last_error() === JSON_ERROR_NONE)
{
// is JSON
if (self::checkArray($result))
@ -69,10 +69,10 @@ abstract class ###Component###Helper
/**
* Load the Component xml manifest.
**/
public static function manifest()
{
$manifestUrl = JPATH_ADMINISTRATOR."/components/com_###component###/###component###.xml";
return simplexml_load_file($manifestUrl);
public static function manifest()
{
$manifestUrl = JPATH_ADMINISTRATOR."/components/com_###component###/###component###.xml";
return simplexml_load_file($manifestUrl);
}
/**
@ -87,9 +87,9 @@ abstract class ###Component###Helper
// get all Contributors (max 20)
$searchArray = range('0','20');
foreach($searchArray as $nr)
{
{
if ((NULL !== $params->get("showContributor".$nr)) && ($params->get("showContributor".$nr) == 2 || $params->get("showContributor".$nr) == 3))
{
{
// set link based of selected option
if($params->get("useContributor".$nr) == 1)
{
@ -368,7 +368,7 @@ abstract class ###Component###Helper
public static function isPublished($id,$type)
{
if ($type == 'raw')
{
{
$type = 'item';
}
$db = JFactory::getDbo();
@ -381,7 +381,7 @@ abstract class ###Component###Helper
$db->execute();
$found = $db->getNumRows();
if($found)
{
{
return true;
}
return false;
@ -398,7 +398,7 @@ abstract class ###Component###Helper
$db->execute();
$found = $db->getNumRows();
if($found)
{
{
return $db->loadResult();
}
return $id;
@ -407,24 +407,24 @@ abstract class ###Component###Helper
/**
* Get the actions permissions
**/
public static function getActions($view,&$record = null,$views = null)
public static function getActions($view,&$record = null,$views = null)
{
jimport('joomla.access.access');
$user = JFactory::getUser();
$result = new JObject;
$view = self::safeString($view);
if (self::checkString($views))
{
if (self::checkString($views))
{
$views = self::safeString($views);
}
}
// get all actions from component
$actions = JAccess::getActions('com_###component###', 'component');
// set acctions only set in component settiongs
$componentActions = array('core.admin','core.manage','core.options','core.export');
// set acctions only set in component settiongs
$componentActions = array('core.admin','core.manage','core.options','core.export');
// loop the actions and set the permissions
foreach ($actions as $action)
{
{
// set to use component default
$fallback = true;
if (self::checkObject($record) && isset($record->id) && $record->id > 0 && !in_array($action->name,$componentActions))
@ -503,17 +503,17 @@ abstract class ###Component###Helper
}
elseif (self::checkString($views) && isset($record->catid) && $record->catid > 0)
{
// make sure we use the core. action check for the categories
if (strpos($action->name,$view) !== false && strpos($action->name,'core.') === false ) {
$coreCheck = explode('.',$action->name);
$coreCheck[0] = 'core';
$categoryCheck = implode('.',$coreCheck);
}
else
{
$categoryCheck = $action->name;
}
// The record has a category. Check the category permissions.
// make sure we use the core. action check for the categories
if (strpos($action->name,$view) !== false && strpos($action->name,'core.') === false ) {
$coreCheck = explode('.',$action->name);
$coreCheck[0] = 'core';
$categoryCheck = implode('.',$coreCheck);
}
else
{
$categoryCheck = $action->name;
}
// The record has a category. Check the category permissions.
$catpermission = $user->authorise($categoryCheck, 'com_###component###.'.$views.'.category.' . (int) $record->catid);
if (!$catpermission && !is_null($catpermission))
{
@ -655,7 +655,7 @@ abstract class ###Component###Helper
{
// If example.com is down, then probably the whole internet is down, since IANA maintains the domain. Right?
$connected = @fsockopen("www.example.com", 80);
// website, port (try 80 or 443)
// website, port (try 80 or 443)
if ($connected)
{
//action when connected
@ -735,8 +735,8 @@ abstract class ###Component###Helper
$string = self::replaceNumbers($string);
}
// 0nly continue if we have a string
if (self::checkString($string))
{
if (self::checkString($string))
{
// create file name without the extention that is safe
if ($type === 'filename')
{
@ -759,12 +759,12 @@ abstract class ###Component###Helper
$string = preg_replace("/[^A-Za-z ]/", '', $string);
// select final adaptations
if ($type === 'L' || $type === 'strtolower')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// default is to return lower
return strtolower($string);
}
elseif ($type === 'W')
{
// return a string with all first letter of each word uppercase(no undersocre)
@ -785,21 +785,21 @@ abstract class ###Component###Helper
// return a string with all the uppercase(no undersocre)
return strtoupper($string);
}
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
elseif ($type === 'U' || $type === 'strtoupper')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return all upper
return strtoupper($string);
}
elseif ($type === 'F' || $type === 'ucfirst')
{
// replace white space with underscore
$string = preg_replace('/\s+/', $spacer, $string);
// return with first caracter to upper
return ucfirst(strtolower($string));
}
elseif ($type === 'cA' || $type === 'cAmel' || $type === 'camelcase')
{
// convert all words to first letter uppercase
$string = ucwords(strtolower($string));
@ -808,11 +808,11 @@ abstract class ###Component###Helper
// now return first letter lowercase
return lcfirst($string);
}
// return string
return $string;
}
// not a string
return '';
// return string
return $string;
}
// not a string
return '';
}
public static function htmlEscape($var, $charset = 'UTF-8', $shorten = false, $length = 40)

View File

@ -49,11 +49,11 @@ class ###Component###Model###SView### extends JModelItem
*
* @var strings
*/
protected $user;
protected $userId;
protected $guest;
protected $groups;
protected $levels;
protected $user;
protected $userId;
protected $guest;
protected $groups;
protected $levels;
protected $app;
protected $input;
protected $uikitComp;
@ -74,10 +74,10 @@ class ###Component###Model###SView### extends JModelItem
*/
protected function populateState()
{
$this->app = JFactory::getApplication();
$this->input = $this->app->input;
$this->app = JFactory::getApplication();
$this->input = $this->app->input;
// Get the item main id
$id = $this->input->getInt('id', null);
$id = $this->input->getInt('id', null);
$this->setState('###sview###.id', $id);
// Load the parameters.
@ -94,21 +94,21 @@ class ###Component###Model###SView### extends JModelItem
public function getItem($pk = null)
{
$this->user = JFactory::getUser();
// check if this user has permission to access item
if (!$this->user->authorise('###sview###.access', 'com_###component###'))
{
// check if this user has permission to access item
if (!$this->user->authorise('###sview###.access', 'com_###component###'))
{
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_('Not authorised!'), 'error');
// redirect away if not a correct to cPanel/default view
$app->redirect('index.php?option=com_###component###');
return false;
}
$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;
}
$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;
$pk = (!empty($pk)) ? $pk : (int) $this->getState('###sview###.id');###CUSTOM_ADMIN_BEFORE_GET_ITEM###

View File

@ -74,10 +74,10 @@ class ###Component###Model###SView### extends JModelItem
*/
protected function populateState()
{
$this->app = JFactory::getApplication();
$this->input = $this->app->input;
$this->app = JFactory::getApplication();
$this->input = $this->app->input;
// Get the itme main id
$id = $this->input->getInt('id', null);
$id = $this->input->getInt('id', null);
$this->setState('###sview###.id', $id);
// Load the parameters.
@ -95,13 +95,13 @@ class ###Component###Model###SView### extends JModelItem
*/
public function getItem($pk = null)
{
$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;
$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;
$pk = (!empty($pk)) ? $pk : (int) $this->getState('###sview###.id');###SITE_BEFORE_GET_ITEM###

View File

@ -92,10 +92,10 @@ class ###Component###ModelImport extends JModelLegacy
public function import()
{
$this->setState('action', 'import');
$app = JFactory::getApplication();
$session = JFactory::getSession();
$package = null;
$continue = false;
$app = JFactory::getApplication();
$session = JFactory::getSession();
$package = null;
$continue = false;
// get import type
$this->getType = $app->input->getString('gettype', NULL);
// get import type
@ -150,7 +150,7 @@ class ###Component###ModelImport extends JModelLegacy
// first link data to table headers
if(!$continue){
$package = json_encode($package);
$package = json_encode($package);
$session->set('package', $package);
$session->set('dataType', $this->dataType);
$session->set('hasPackage', true);
@ -202,8 +202,8 @@ class ###Component###ModelImport extends JModelLegacy
protected function _getPackageFromUpload()
{
// Get the uploaded file information
$app = JFactory::getApplication();
$input = $app->input;
$app = JFactory::getApplication();
$input = $app->input;
// Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get.
$userfile = $input->files->get('import_package', null, 'raw');
@ -230,9 +230,9 @@ class ###Component###ModelImport extends JModelLegacy
}
// Build the appropriate paths
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path') . '/' . $userfile['name'];
$tmp_src = $userfile['tmp_name'];
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path') . '/' . $userfile['name'];
$tmp_src = $userfile['tmp_name'];
// Move uploaded file
jimport('joomla.filesystem.file');
@ -263,8 +263,8 @@ class ###Component###ModelImport extends JModelLegacy
*/
protected function _getPackageFromFolder()
{
$app = JFactory::getApplication();
$input = $app->input;
$app = JFactory::getApplication();
$input = $app->input;
// Get the path to the package to import
$p_dir = $input->getString('import_directory');
@ -294,8 +294,8 @@ class ###Component###ModelImport extends JModelLegacy
}
$package['packagename'] = null;
$package['dir'] = $p_dir;
$package['type'] = $type;
$package['dir'] = $p_dir;
$package['type'] = $type;
return $package;
}
@ -308,8 +308,8 @@ class ###Component###ModelImport extends JModelLegacy
*/
protected function _getPackageFromUrl()
{
$app = JFactory::getApplication();
$input = $app->input;
$app = JFactory::getApplication();
$input = $app->input;
// Get the URL of the package to import
$url = $input->getString('import_url');
@ -348,7 +348,7 @@ class ###Component###ModelImport extends JModelLegacy
*/
protected function check($archivename)
{
$app = JFactory::getApplication();
$app = JFactory::getApplication();
// Clean the name
$archivename = JPath::clean($archivename);
@ -361,15 +361,15 @@ class ###Component###ModelImport extends JModelLegacy
return false;
}
$config = JFactory::getConfig();
$config = JFactory::getConfig();
// set Package Name
$check['packagename'] = $archivename;
$check['packagename'] = $archivename;
// set directory
$check['dir'] = $config->get('tmp_path'). '/' .$archivename;
$check['dir'] = $config->get('tmp_path'). '/' .$archivename;
// set type
$check['type'] = $this->getType;
$check['type'] = $this->getType;
return $check;
}
@ -408,8 +408,8 @@ class ###Component###ModelImport extends JModelLegacy
{
jimport('joomla.filesystem.file');
$config = JFactory::getConfig();
$package = $config->get('tmp_path'). '/' .$package;
$config = JFactory::getConfig();
$package = $config->get('tmp_path'). '/' .$package;
// Is the package file a valid file?
if (is_file($package))
@ -472,11 +472,11 @@ class ###Component###ModelImport extends JModelLegacy
if(###Component###Helper::checkArray($data['array']))
{
// get user object
$user = JFactory::getUser();
$user = JFactory::getUser();
// remove header if it has headers
$id_key = $data['target_headers']['id'];
$published_key = $data['target_headers']['published'];
$ordering_key = $data['target_headers']['ordering'];
$id_key = $data['target_headers']['id'];
$published_key = $data['target_headers']['published'];
$ordering_key = $data['target_headers']['ordering'];
// get the first array set
$firstSet = reset($data['array']);
@ -494,13 +494,13 @@ class ###Component###ModelImport extends JModelLegacy
// Get a db connection.
$db = JFactory::getDbo();
// set some defaults
$todayDate = JFactory::getDate()->toSql();
$todayDate = JFactory::getDate()->toSql();
// get global action permissions
$canDo = ###Component###Helper::getActions($table);
$canEdit = $canDo->get('core.edit');
$canState = $canDo->get('core.edit.state');
$canCreate = $canDo->get('core.create');
$hasAlias = $this->getAliasesUsed($table);
$canDo = ###Component###Helper::getActions($table);
$canEdit = $canDo->get('core.edit');
$canState = $canDo->get('core.edit.state');
$canCreate = $canDo->get('core.create');
$hasAlias = $this->getAliasesUsed($table);
// prosses the data
foreach($data['array'] as $row)
{
@ -522,11 +522,11 @@ class ###Component###ModelImport extends JModelLegacy
if($found && $canEdit)
{
// update item
$id = $row[$id_key];
$version = $db->loadResult();
$id = $row[$id_key];
$version = $db->loadResult();
// reset all buckets
$query = $db->getQuery(true);
$fields = array();
$query = $db->getQuery(true);
$fields = array();
// Fields to update.
foreach($row as $key => $cell)
{
@ -571,8 +571,8 @@ class ###Component###ModelImport extends JModelLegacy
}
}
// load the defaults
$fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id);
$fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate);
$fields[] = $db->quoteName('modified_by') . ' = ' . $db->quote($user->id);
$fields[] = $db->quoteName('modified') . ' = ' . $db->quote($todayDate);
// Conditions for which records should be updated.
$conditions = array(
$db->quoteName('id') . ' = ' . $id
@ -587,9 +587,9 @@ class ###Component###ModelImport extends JModelLegacy
// insert item
$query = $db->getQuery(true);
// reset all buckets
$columns = array();
$values = array();
$version = false;
$columns = array();
$values = array();
$version = false;
// Insert columns. Insert values.
foreach($row as $key => $cell)
{
@ -627,30 +627,30 @@ class ###Component###ModelImport extends JModelLegacy
// set to insert array
if(in_array($key, $data['target_headers']) && is_numeric($cell))
{
$columns[] = $target[$key];
$values[] = $cell;
$columns[] = $target[$key];
$values[] = $cell;
}
elseif(in_array($key, $data['target_headers']) && is_string($cell))
{
$columns[] = $target[$key];
$values[] = $db->quote($cell);
$columns[] = $target[$key];
$values[] = $db->quote($cell);
}
elseif(in_array($key, $data['target_headers']) && is_null($cell))
{
// if import data is null then set empty
$columns[] = $target[$key];
$values[] = "''";
$columns[] = $target[$key];
$values[] = "''";
}
}
// load the defaults
$columns[] = 'created_by';
$values[] = $db->quote($user->id);
$columns[] = 'created';
$values[] = $db->quote($todayDate);
$columns[] = 'created_by';
$values[] = $db->quote($user->id);
$columns[] = 'created';
$values[] = $db->quote($todayDate);
if (!$version)
{
$columns[] = 'version';
$values[] = 1;
$columns[] = 'version';
$values[] = 1;
}
// Prepare the insert query.
$query

View File

@ -59,8 +59,8 @@ class ###Component###Model###View### extends JModelLegacy
/**
* Import Settings
*/
protected $getType = NULL;
protected $dataType = NULL;
protected $getType = NULL;
protected $dataType = NULL;
/**
* Method to auto-populate the model state.
@ -92,8 +92,8 @@ class ###Component###Model###View### extends JModelLegacy
protected function _getPackageFromUpload()
{
// Get the uploaded file information
$app = JFactory::getApplication();
$input = $app->input;
$app = JFactory::getApplication();
$input = $app->input;
// Do not change the filter type 'raw'. We need this to let files containing PHP code to upload. See JInputFiles::get.
$userfile = $input->files->get('import_package', null, 'raw');
@ -120,9 +120,9 @@ class ###Component###Model###View### extends JModelLegacy
}
// Build the appropriate paths
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path') . '/' . $userfile['name'];
$tmp_src = $userfile['tmp_name'];
$config = JFactory::getConfig();
$tmp_dest = $config->get('tmp_path') . '/' . $userfile['name'];
$tmp_src = $userfile['tmp_name'];
// Move uploaded file
jimport('joomla.filesystem.file');
@ -153,8 +153,8 @@ class ###Component###Model###View### extends JModelLegacy
*/
protected function _getPackageFromFolder()
{
$app = JFactory::getApplication();
$input = $app->input;
$app = JFactory::getApplication();
$input = $app->input;
// Get the path to the package to import
$p_dir = $input->getString('import_directory');
@ -184,8 +184,8 @@ class ###Component###Model###View### extends JModelLegacy
}
$package['packagename'] = null;
$package['dir'] = $p_dir;
$package['type'] = $type;
$package['dir'] = $p_dir;
$package['type'] = $type;
return $package;
}
@ -198,8 +198,8 @@ class ###Component###Model###View### extends JModelLegacy
*/
protected function _getPackageFromUrl()
{
$app = JFactory::getApplication();
$input = $app->input;
$app = JFactory::getApplication();
$input = $app->input;
// Get the URL of the package to import
$url = $input->getString('import_url');
@ -238,7 +238,7 @@ class ###Component###Model###View### extends JModelLegacy
*/
protected function check($archivename)
{
$app = JFactory::getApplication();
$app = JFactory::getApplication();
// Clean the name
$archivename = JPath::clean($archivename);
@ -251,15 +251,15 @@ class ###Component###Model###View### extends JModelLegacy
return false;
}
$config = JFactory::getConfig();
$config = JFactory::getConfig();
// set Package Name
$check['packagename'] = $archivename;
$check['packagename'] = $archivename;
// set directory
$check['dir'] = $config->get('tmp_path'). '/' .$archivename;
$check['dir'] = $config->get('tmp_path'). '/' .$archivename;
// set type
$check['type'] = $this->getType;
$check['type'] = $this->getType;
return $check;
}
@ -277,8 +277,8 @@ class ###Component###Model###View### extends JModelLegacy
{
jimport('joomla.filesystem.file');
$config = JFactory::getConfig();
$package = $config->get('tmp_path'). '/' .$package;
$config = JFactory::getConfig();
$package = $config->get('tmp_path'). '/' .$package;
// Is the package file a valid file?
if (is_file($package))

View File

@ -59,15 +59,15 @@ class ###Component###Model###SViews### extends JModelList
protected function getListQuery()
{
// Get the current user for authorisation checks
$this->user = JFactory::getUser();
$this->userId = $this->user->get('id');
$this->guest = $this->user->get('guest');
$this->groups = $this->user->get('groups');
$this->user = JFactory::getUser();
$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->app = JFactory::getApplication();
$this->input = $this->app->input;
$this->initSet = true; ###CUSTOM_ADMIN_GET_LIST_QUERY###
$this->levels = $this->user->getAuthorisedViewLevels();
$this->app = JFactory::getApplication();
$this->input = $this->app->input;
$this->initSet = true; ###CUSTOM_ADMIN_GET_LIST_QUERY###
}
/**

View File

@ -59,15 +59,15 @@ class ###Component###Model###SViews### extends JModelList
protected function getListQuery()
{
// Get the current user for authorisation checks
$this->user = JFactory::getUser();
$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->app = JFactory::getApplication();
$this->input = $this->app->input;
$this->initSet = true; ###SITE_GET_LIST_QUERY###
$this->user = JFactory::getUser();
$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->app = JFactory::getApplication();
$this->input = $this->app->input;
$this->initSet = true; ###SITE_GET_LIST_QUERY###
}
/**

View File

@ -41,13 +41,13 @@ class ###Component###View###SView### extends JViewLegacy
function display($tpl = null)
{
// get component params
$this->params = JComponentHelper::getParams('com_###component###');
$this->params = JComponentHelper::getParams('com_###component###');
// get the application
$this->app = JFactory::getApplication();
$this->app = JFactory::getApplication();
// get the user object
$this->user = JFactory::getUser();
$this->user = JFactory::getUser();
// get global action permissions
$this->canDo = ###Component###Helper::getActions('###sview###');###CUSTOM_ADMIN_DIPLAY_METHOD###
$this->canDo = ###Component###Helper::getActions('###sview###');###CUSTOM_ADMIN_DIPLAY_METHOD###
}###CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS###
/**

View File

@ -44,17 +44,17 @@ class ###Component###View###View### extends JViewLegacy
public function display($tpl = null)
{
// Assign the variables
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->script = $this->get('Script');
$this->state = $this->get('State');
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->script = $this->get('Script');
$this->state = $this->get('State');
// get action permissions
$this->canDo = ###Component###Helper::getActions('###view###',$this->item);
$this->canDo = ###Component###Helper::getActions('###view###',$this->item);
// get input
$jinput = JFactory::getApplication()->input;
$this->ref = $jinput->get('ref', 0, 'word');
$this->refid = $jinput->get('refid', 0, 'int');
$this->referral = '';
$this->ref = $jinput->get('ref', 0, 'word');
$this->refid = $jinput->get('refid', 0, 'int');
$this->referral = '';
if ($this->refid)
{
// return to the item that refered to this item

View File

@ -50,15 +50,15 @@ class ###Component###View###Views### extends JViewLegacy
}
// Assign data to the view
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->user = JFactory::getUser();
$this->listOrder = $this->escape($this->state->get('list.ordering'));
$this->listDirn = $this->escape($this->state->get('list.direction'));
$this->saveOrder = $this->listOrder == 'ordering';
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->user = JFactory::getUser();
$this->listOrder = $this->escape($this->state->get('list.ordering'));
$this->listDirn = $this->escape($this->state->get('list.direction'));
$this->saveOrder = $this->listOrder == 'ordering';
// get global action permissions
$this->canDo = ###Component###Helper::getActions('###view###');###JVIEWLISTCANDO###
$this->canDo = ###Component###Helper::getActions('###view###');###JVIEWLISTCANDO###
// We don't need toolbar in the modal window.
if ($this->getLayout() !== 'modal')
@ -153,7 +153,7 @@ class ###Component###View###Views### extends JViewLegacy
// add the options comp button
if ($this->canDo->get('core.admin') || $this->canDo->get('core.options'))
{
JToolBarHelper::preferences('com_###component###');
JToolBarHelper::preferences('com_###component###');
}
if ($this->canState)

View File

@ -41,13 +41,13 @@ class ###Component###View###SViews### extends JViewLegacy
function display($tpl = null)
{
// get component params
$this->params = JComponentHelper::getParams('com_###component###');
$this->params = JComponentHelper::getParams('com_###component###');
// get the application
$this->app = JFactory::getApplication();
$this->app = JFactory::getApplication();
// get the user object
$this->user = JFactory::getUser();
// get global action permissions
$this->canDo = ###Component###Helper::getActions('###sview###');###CUSTOM_ADMIN_DIPLAY_METHOD###
$this->canDo = ###Component###Helper::getActions('###sview###');###CUSTOM_ADMIN_DIPLAY_METHOD###
}###CUSTOM_ADMIN_EXTRA_DIPLAY_METHODS###
/**