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

221 lines
7.2 KiB
PHP
Raw Normal View History

2016-01-30 20:28:43 +00:00
<?php
/**
* @package Joomla.Component.Builder
*
* @created 30th April, 2015
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
2016-01-30 20:28:43 +00:00
// 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');
/**
* ###Component### Model
*/
class ###Component###Model###Component### extends JModelList
{
public function getIcons()
{
2017-12-15 01:10:10 +00:00
// load user for access menus
$user = JFactory::getUser();
// reset icon array
2016-01-30 20:28:43 +00:00
$icons = array();
2017-12-15 01:10:10 +00:00
// view groups array
2016-01-30 20:28:43 +00:00
$viewGroups = array(
'main' => array(###DASHBOARDICONS###)
);###DASHBOARDICONACCESS###
// loop over the $views
2016-01-30 20:28:43 +00:00
foreach($viewGroups as $group => $views)
2017-12-15 01:10:10 +00:00
{
2016-01-30 20:28:43 +00:00
$i = 0;
if (###Component###Helper::checkArray($views))
2017-12-15 01:10:10 +00:00
{
2016-01-30 20:28:43 +00:00
foreach($views as $view)
{
$add = false;
// external views (links)
if (strpos($view,'||') !== false)
2017-12-15 01:10:10 +00:00
{
$dwd = explode('||', $view);
if (count($dwd) == 3)
{
list($type, $name, $url) = $dwd;
$viewName = $name;
$alt = $name;
$url = $url;
$image = $name . '.' . $type;
$name = 'COM_###COMPONENT###_DASHBOARD_' . ###Component###Helper::safeString($name,'U');
}
}
// internal views
elseif (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)
2017-12-15 01:10:10 +00:00
{
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:
// check for new convention (more stable)
if (strpos($action, '_qpo0O0oqp_') !== false)
{
list($action, $extension) = (array) explode('_qpo0O0oqp_', $action);
$extension = str_replace('_po0O0oq_', '.', $extension);
}
else
{
$extension = 'com_###component###.' . $name;
}
$url = 'index.php?option=com_categories&view=categories&extension=' . $extension;
$image = $name . '_' . $action . '.' . $type;
$alt = $viewName . '&nbsp;' . $action;
$name = 'COM_###COMPONENT###_DASHBOARD_' . ###Component###Helper::safeString($name,'U') . '_' . ###Component###Helper::safeString($action,'U');
break;
2017-12-15 01:10:10 +00:00
}
}
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;
}
2017-12-15 01:10:10 +00:00
}
else
{
$viewName = $view;
$alt = $view;
$url = 'index.php?option=com_###component###&view=' . $view;
$image = $view . '.png';
2017-12-15 01:10:10 +00:00
$name = ucwords($view).'<br /><br />';
$hover = false;
}
// first make sure the view access is set
if (###Component###Helper::checkArray($viewAccess))
{
2016-01-30 20:28:43 +00:00
// setup some defaults
$dashboard_add = false;
$dashboard_list = false;
2017-12-15 01:10:10 +00:00
$accessTo = '';
$accessAdd = '';
// access checking start
2017-12-15 01:10:10 +00:00
$accessCreate = (isset($viewAccess[$viewName.'.create'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.create']):false;
$accessAccess = (isset($viewAccess[$viewName.'.access'])) ? ###Component###Helper::checkString($viewAccess[$viewName.'.access']):false;
2016-01-30 20:28:43 +00:00
// 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;
2017-12-15 01:10:10 +00:00
// check for adding access
if ($add && $accessCreate)
{
$accessAdd = $viewAccess[$viewName.'.create'];
}
elseif ($add)
{
$accessAdd = 'core.create';
}
// check if access to view is set
2017-12-15 01:10:10 +00:00
if ($accessAccess)
{
$accessTo = $viewAccess[$viewName.'.access'];
}
2016-01-30 20:28:43 +00:00
// set main access controllers
if ($accessDashboard_add)
{
$dashboard_add = $user->authorise($viewAccess[$viewName.'.dashboard_add'], 'com_###component###');
}
if ($accessDashboard_list)
{
$dashboard_list = $user->authorise($viewAccess[$viewName.'.dashboard_list'], 'com_###component###');
}
2017-12-15 01:10:10 +00:00
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;
2017-12-15 01:10:10 +00:00
$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;
2017-12-15 01:10:10 +00:00
$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;
2017-12-15 01:10:10 +00:00
$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;
2017-12-15 01:10:10 +00:00
$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;
2017-12-15 01:10:10 +00:00
$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;
2016-01-30 20:28:43 +00:00
}
}
return $icons;
}###DASH_MODEL_METHODS###
2016-01-30 20:28:43 +00:00
}