primo commit
This commit is contained in:
169
administrator/components/com_jem/helpers/helper.php
Normal file
169
administrator/components/com_jem/helpers/helper.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Access\Access;
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\HTML\Helpers\Sidebar;
|
||||
|
||||
require_once(JPATH_SITE.'/components/com_jem/factory.php');
|
||||
|
||||
|
||||
// class JemSidebarHelper extends HTMLHelperSidebar
|
||||
class JemSidebarHelper extends Sidebar
|
||||
|
||||
{
|
||||
public static function render()
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
public static function getEntries()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper: Backend
|
||||
*/
|
||||
class JemHelperBackend
|
||||
{
|
||||
|
||||
public static $extension = 'com_jem';
|
||||
|
||||
/**
|
||||
* Configure the Linkbar.
|
||||
*
|
||||
* @param string The name of the active view.
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
*/
|
||||
public static function addSubmenu($vName)
|
||||
{
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_SUBMENU_MAIN'),
|
||||
'index.php?option=com_jem&view=main',
|
||||
$vName == 'main'
|
||||
);
|
||||
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_EVENTS'),
|
||||
'index.php?option=com_jem&view=events',
|
||||
$vName == 'events'
|
||||
);
|
||||
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_VENUES'),
|
||||
'index.php?option=com_jem&view=venues',
|
||||
$vName == 'venues'
|
||||
);
|
||||
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_CATEGORIES'),
|
||||
'index.php?option=com_jem&view=categories',
|
||||
$vName == 'categories'
|
||||
);
|
||||
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_GROUPS'),
|
||||
'index.php?option=com_jem&view=groups',
|
||||
$vName == 'groups'
|
||||
);
|
||||
|
||||
if (JemFactory::getUser()->authorise('core.manage', 'com_jem')) {
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_SETTINGS_TITLE'),
|
||||
'index.php?option=com_jem&view=settings',
|
||||
$vName == 'settings'
|
||||
);
|
||||
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_HOUSEKEEPING'),
|
||||
'index.php?option=com_jem&view=housekeeping',
|
||||
$vName == 'housekeeping'
|
||||
);
|
||||
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_UPDATECHECK_TITLE'),
|
||||
'index.php?option=com_jem&view=updatecheck',
|
||||
$vName == 'updatecheck'
|
||||
);
|
||||
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_IMPORT_DATA'),
|
||||
'index.php?option=com_jem&view=import',
|
||||
$vName == 'import'
|
||||
);
|
||||
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_EXPORT_DATA'),
|
||||
'index.php?option=com_jem&view=export',
|
||||
$vName == 'export'
|
||||
);
|
||||
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_CSSMANAGER_TITLE'),
|
||||
'index.php?option=com_jem&view=cssmanager',
|
||||
$vName == 'cssmanager'
|
||||
);
|
||||
}
|
||||
|
||||
JemSidebarHelper::addEntry(
|
||||
Text::_('COM_JEM_HELP'),
|
||||
'index.php?option=com_jem&view=help',
|
||||
$vName == 'help'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of the actions that can be performed.
|
||||
*
|
||||
* @param int The category ID.
|
||||
*
|
||||
* @return CMSObject
|
||||
*/
|
||||
public static function getActions($categoryId = 0)
|
||||
{
|
||||
$user = JemFactory::getUser();
|
||||
$result = new CMSObject;;
|
||||
|
||||
if (empty($categoryId)) {
|
||||
$assetName = 'com_jem';
|
||||
$level = 'component';
|
||||
} else {
|
||||
$assetName = 'com_jem.category.'.(int) $categoryId;
|
||||
$level = 'category';
|
||||
}
|
||||
|
||||
// $actions = Access::getActions('com_jem', $level);
|
||||
$actions = Access::getActionsFromFile(JPATH_ADMINISTRATOR.'/components/com_jem/access.xml',"/access/section[@name='".$level."']/");
|
||||
|
||||
foreach ($actions as $action) {
|
||||
$result->set($action->name, $user->authorise($action->name, $assetName));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function getCountryOptions()
|
||||
{
|
||||
$options = array();
|
||||
$options = array_merge(JEMHelperCountries::getCountryOptions(),$options);
|
||||
|
||||
array_unshift($options, HTMLHelper::_('select.option', '0', Text::_('COM_JEM_SELECT_COUNTRY')));
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
}
|
||||
1
administrator/components/com_jem/helpers/html/index.html
Normal file
1
administrator/components/com_jem/helpers/html/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
||||
284
administrator/components/com_jem/helpers/html/jemhtml.php
Normal file
284
administrator/components/com_jem/helpers/html/jemhtml.php
Normal file
@ -0,0 +1,284 @@
|
||||
<?php
|
||||
/**
|
||||
* @package JEM
|
||||
* @copyright (C) 2013-2024 joomlaeventmanager.net
|
||||
* @copyright (C) 2005-2009 Christoph Lukes
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0 GNU/GPL
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\HTML\HTMLHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
use Joomla\CMS\Log\Log;
|
||||
use Joomla\Utilities\ArrayHelper;
|
||||
|
||||
/**
|
||||
* HTMLHelper Class
|
||||
*/
|
||||
// abstract class HTMLHelperJemHtml
|
||||
class JemHtml
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param int $i
|
||||
* @param int $value state value
|
||||
*/
|
||||
static public function featured($i, $value = 0, $canChange = true)
|
||||
{
|
||||
// Array of image, iconfont, task, title, action
|
||||
$states = array(
|
||||
0 => array(
|
||||
'disabled.png',
|
||||
// 'fa-star-o', //'fa-circle-o',
|
||||
'fas fa-star', //'fa-circle-o',
|
||||
'events.featured',
|
||||
'COM_JEM_EVENTS_UNFEATURED',
|
||||
'COM_JEM_EVENTS_TOGGLE_TO_FEATURE'
|
||||
),
|
||||
1 => array(
|
||||
'featured.png',
|
||||
'fa-star', //'fa-circle',
|
||||
'events.unfeatured',
|
||||
'COM_JEM_EVENTS_FEATURED',
|
||||
'COM_JEM_EVENTS_TOGGLE_TO_UNFEATURE'
|
||||
)
|
||||
);
|
||||
$state = ArrayHelper::getValue($states, (int)$value, $states[1]);
|
||||
$no_iconfont = (bool)Factory::getApplication()->isClient('administrator'); // requires font and css loaded which isn't yet on backend
|
||||
$html = HTMLHelper::_('jemhtml.icon', 'com_jem/'.$state[0], 'fa fa-fw fa-lg '.$state[1].' jem-featured-'.$state[1], $state[3], null, $no_iconfont);
|
||||
if ($canChange) {
|
||||
$html = '<a href="#" onclick="return Joomla.listItemTask(\'cb' . $i . '\',\'' . $state[2] . '\')" title="' . Text::_($state[4]) . '">' . $html . '</a>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $i
|
||||
* @param int $value state value
|
||||
* @deprecated since version 2.1.7
|
||||
*/
|
||||
static public function toggleStatus($i, $value = 0, $canChange = true)
|
||||
|
||||
{
|
||||
if (class_exists('JemHelper')) {
|
||||
JemHelper::addLogEntry('Use of this function is deprecated. Use JemHekper::toggleAttendanceStatus() instead.', __METHOD__, Log::WARNING);
|
||||
}
|
||||
|
||||
// Array of image, iconfont, task, title, action
|
||||
$states = array(
|
||||
0 => array(
|
||||
'tick.png',
|
||||
'fa-check-circle',
|
||||
'attendees.OnWaitinglist',
|
||||
'COM_JEM_ATTENDING',
|
||||
'COM_JEM_ATTENDING'
|
||||
),
|
||||
1 => array(
|
||||
'publish_y.png',
|
||||
'fa-hourglass-half', //'fa-exclamation-circle',
|
||||
'attendees.OffWaitinglist',
|
||||
'COM_JEM_ON_WAITINGLIST',
|
||||
'COM_JEM_ON_WAITINGLIST'
|
||||
)
|
||||
);
|
||||
$state = ArrayHelper::getValue($states, (int)$value, $states[1]);
|
||||
$no_iconfont = (bool)Factory::getApplication()->isClient('administrator'); // requires font and css loaded which isn't yet on backend
|
||||
$html = HTMLHelper::_('jemhtml.icon', 'com_jem/'.$state[0], 'fa fa-fw fa-lg '.$state[1].' jem-attendance-status-'.$state[1], $state[3], null, $no_iconfont);
|
||||
if ($canChange) {
|
||||
$html = '<a href="#" onclick="return Joomla.listItemTask(\'cb' . $i . '\',\'' . $state[2] . '\')" title="' . Text::_($state[4]) . '">' . $html . '</a>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns text of attendance status, maybe incl. hint to toggle this status.
|
||||
*
|
||||
* @param int $i registration record id
|
||||
* @param int $value status value
|
||||
* @param bool $canChange current user is allowed to modify the status
|
||||
* @param bool $print if true show icon AND text for printing
|
||||
* @return string The html snippet.
|
||||
*/
|
||||
static public function getAttendanceStatusText($i, $value = 0, $canChange = true, $print = false)
|
||||
|
||||
{
|
||||
// Array of image, iconfont, task, alt-text, alt-text edit, tooltip
|
||||
$states = array(
|
||||
-99 => array( // fallback on wrong status value
|
||||
'disabled.png',
|
||||
'fa-circle-o',
|
||||
'',
|
||||
'COM_JEM_STATUS_UNKNOWN',
|
||||
'COM_JEM_STATUS_UNKNOWN',
|
||||
'COM_JEM_ATTENDEES_STATUS_UNKNOWN'
|
||||
),
|
||||
-1 => array( // not attending, no toggle
|
||||
'publish_r.png',
|
||||
'fa-times-circle',
|
||||
'',
|
||||
'COM_JEM_NOT_ATTENDING',
|
||||
'COM_JEM_NOT_ATTENDING',
|
||||
'COM_JEM_ATTENDEES_NOT_ATTENDING'
|
||||
),
|
||||
0 => array( // invited, no toggle
|
||||
'invited.png',
|
||||
'fa-question-circle',
|
||||
'',
|
||||
'COM_JEM_INVITED',
|
||||
'COM_JEM_INVITED',
|
||||
'COM_JEM_ATTENDEES_INVITED'
|
||||
),
|
||||
1 => array( // attending, toggle: waiting list
|
||||
'tick.png',
|
||||
'fa-check-circle',
|
||||
'attendees.OnWaitinglist',
|
||||
'COM_JEM_ATTENDING',
|
||||
'COM_JEM_ATTENDING_MOVE_TO_WAITINGLIST',
|
||||
'COM_JEM_ATTENDEES_ATTENDING'
|
||||
),
|
||||
2 => array( // on waiting list, toggle: list of attendees
|
||||
'publish_y.png',
|
||||
'fa-hourglass-half', //'fa-exclamation-circle',
|
||||
'attendees.OffWaitinglist',
|
||||
'COM_JEM_ON_WAITINGLIST',
|
||||
'COM_JEM_ON_WAITINGLIST_MOVE_TO_ATTENDING',
|
||||
'COM_JEM_ATTENDEES_ON_WAITINGLIST'
|
||||
)
|
||||
);
|
||||
|
||||
$state = ArrayHelper::getValue($states, (int)$value, $states[-99]);
|
||||
|
||||
if ($print) {
|
||||
$result = Text::_($state[5]);
|
||||
} else {
|
||||
$result = Text::_($state[$canChange ? 4 : 3]);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates html code to show attendance status, maybe incl. link to toggle this status.
|
||||
*
|
||||
* @param int $i registration record id
|
||||
* @param int $value status value
|
||||
* @param bool $canChange current user is allowed to modify the status
|
||||
* @param bool $print if true show icon AND text for printing
|
||||
* @return string The html snippet.
|
||||
*/
|
||||
static public function toggleAttendanceStatus($i, $value = 0, $canChange = true, $print = false)
|
||||
|
||||
{
|
||||
// Array of image, iconfont, task, alt-text, alt-text edit, tooltip
|
||||
$states = array(
|
||||
-99 => array( // fallback on wrong status value
|
||||
'disabled.png',
|
||||
'fa-circle',
|
||||
'',
|
||||
'COM_JEM_STATUS_UNKNOWN',
|
||||
'COM_JEM_STATUS_UNKNOWN',
|
||||
'COM_JEM_ATTENDEES_STATUS_UNKNOWN'
|
||||
),
|
||||
-1 => array( // not attending, no toggle
|
||||
'publish_r.png',
|
||||
'fa-times-circle',
|
||||
'',
|
||||
'COM_JEM_NOT_ATTENDING',
|
||||
'COM_JEM_NOT_ATTENDING',
|
||||
'COM_JEM_ATTENDEES_NOT_ATTENDING'
|
||||
),
|
||||
0 => array( // invited, no toggle
|
||||
'invited.png',
|
||||
'fa-question-circle',
|
||||
'',
|
||||
'COM_JEM_INVITED',
|
||||
'COM_JEM_INVITED',
|
||||
'COM_JEM_ATTENDEES_INVITED'
|
||||
),
|
||||
1 => array( // attending, toggle: waiting list
|
||||
'tick.png',
|
||||
'fa-check-circle',
|
||||
'attendees.OnWaitinglist',
|
||||
'COM_JEM_ATTENDING',
|
||||
'COM_JEM_ATTENDING_MOVE_TO_WAITINGLIST',
|
||||
'COM_JEM_ATTENDEES_ATTENDING'
|
||||
),
|
||||
2 => array( // on waiting list, toggle: list of attendees
|
||||
'publish_y.png',
|
||||
'fa-hourglass-half', //fa-exclamation-circle',
|
||||
'attendees.OffWaitinglist',
|
||||
'COM_JEM_ON_WAITINGLIST',
|
||||
'COM_JEM_ON_WAITINGLIST_MOVE_TO_ATTENDING',
|
||||
'COM_JEM_ATTENDEES_ON_WAITINGLIST'
|
||||
)
|
||||
);
|
||||
|
||||
$backend = (bool)Factory::getApplication()->isClient('administrator');
|
||||
$state = ArrayHelper::getValue($states, (int)$value, $states[-99]);
|
||||
HTMLHelper::_('bootstrap.tooltip');
|
||||
$attr = 'class="hasTooltip" data-bs-toggle="tooltip" title="'.HTMLHelper::tooltipText(Text::_('COM_JEM_STATUS'), $canChange ? Text::_($state[4]) : str_replace(" ", " ",Text::_($state[3])), 0).'"';
|
||||
|
||||
if ($print) {
|
||||
$html = jemhtml::icon('com_jem/'.$state[0], 'fa fa-fw fa-lg '.$state[1].' jem-attendance-status-'.$state[1], $state[3], 'class="icon-inline-left"', $backend);
|
||||
$html .= Text::_($state[5]);
|
||||
} elseif ($canChange && !empty($state[2])) {
|
||||
$html = jemhtml::icon('com_jem/'.$state[0], 'fa fa-fw fa-lg '.$state[1].' jem-attendance-status-'.$state[1], $state[3], null, $backend);
|
||||
if ($backend) {
|
||||
$attr .= ' onclick="return Joomla.listItemTask(\'cb' . $i . '\',\'' . $state[2] . '\')"';
|
||||
$url = '#';
|
||||
} else {
|
||||
$url = Route::_('index.php?option=com_jem&view=attendees&task=attendees.attendeetoggle&id='.$i.'&'.Session::getFormToken().'=1');
|
||||
}
|
||||
$html = HTMLHelper::_('link', $url, $html, $attr);
|
||||
} else {
|
||||
$html = jemhtml::icon('com_jem/'.$state[0], 'fa fa-fw fa-lg '.$state[1].' jem-attendance-status-'.$state[1], $state[3], $attr, $backend);
|
||||
}
|
||||
//-------------start added for tooltips initialize-----------
|
||||
$html .= '<script>
|
||||
jQuery(document).ready(function(){
|
||||
var tooltipTriggerList = [].slice.call(document.querySelectorAll(\'[data-bs-toggle="tooltip"]\'))
|
||||
var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) {
|
||||
return new bootstrap.Tooltip(tooltipTriggerEl,{html:true})
|
||||
})
|
||||
});
|
||||
</script>';
|
||||
//-------------end added for tooltips initialize-----------
|
||||
return $html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates html code to show an icon, using image or icon font depending on configuration.
|
||||
* Call HTMLHelper::_('jemhtml.icon', $image, $icon, $alt, $attribs, $no_iconfont, $relative)
|
||||
*
|
||||
* @param string $value status value
|
||||
* @param string $image The relative or absolute URL to use for the `<img>` src attribute.
|
||||
* @param string $icon The CSS class(es) to specify the icon in case icon font will be used.
|
||||
* @param string $alt The alt text.
|
||||
* @param array|string $attribs Attributes to be added to the `<img>` or `<span>` element
|
||||
* @param boolean $no_iconfont Flag if configuration should be ignored and images should be used always (e.g. on backend).
|
||||
* @param boolean $relative Flag if the path to the file is relative to the /media folder (and searches in template).
|
||||
* @return string The html snippet.
|
||||
*/
|
||||
static public function icon($image, $icon, $alt, $attribs = null, $no_iconfont = false, $relative = true)
|
||||
{
|
||||
$useiconfont = !$no_iconfont && (JemHelper::config()->useiconfont == 1);
|
||||
|
||||
if (!$useiconfont) {
|
||||
$html = HTMLHelper::_('image', $image, Text::_($alt), $attribs, $relative);
|
||||
} elseif (!empty($attribs)) {
|
||||
$html = '<span ' . trim((is_array($attribs) ? ArrayHelper::toString($attribs) : $attribs)) . '><i class="' . $icon . '"></i></span>';
|
||||
} else {
|
||||
$html = '<i class="'.$icon.'" aria-hidden="true"></i>';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
1
administrator/components/com_jem/helpers/index.html
Normal file
1
administrator/components/com_jem/helpers/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
||||
Reference in New Issue
Block a user