primo commit

This commit is contained in:
2024-12-17 17:34:10 +01:00
commit e650f8df99
16435 changed files with 2451012 additions and 0 deletions

View File

@ -0,0 +1,97 @@
<?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\HTML\HTMLHelper;
use Joomla\CMS\Toolbar\ToolbarButton;
/**
* Holds the logic for attachments manipulation
*
* @package JEM
*/
class JButtonFrontend extends ToolbarButton {
/**
* Button type
*
* @var string
*/
protected $_name = 'Standard';
//Goes inside JButtonFrontend class definition.
public function fetchButton($type = 'Standard', $name = '', $text = '', $task = '', $list = true)
{
$i18n_text = Text::_($text);
$class = $this->fetchIconClass($name);
$doTask = $this->_getCommand($text, $task, $list);
$html = "<a href=\"javascript: void( $doTask);\" onclick=\"$doTask\" class=\"toolbar\">\n";
$html .= "<span class=\"$class\">\n";
$html .= "</span>\n";
$html .= "$i18n_text\n";
$html .= "</a>\n";
return $html;
}
/**
* Get the button CSS Id
*
* @param string $type Unused string.
* @param string $name Name to be used as apart of the id
* @param string $text Button text
* @param string $task The task associated with the button
* @param boolean $list True to allow use of lists
* @param boolean $hideMenu True to hide the menu on click
*
* @return string Button CSS Id
*
*
*/
public function fetchId($type = 'Standard', $name = '', $text = '', $task = '', $list = true, $hideMenu = false)
{
return $this->_parent->getName() . '-' . $name;
}
/**
* Get the JavaScript command for the button
*
* @param string $name The task name as seen by the user
* @param string $task The task used by the application
* @param boolean $list True is requires a list confirmation.
*
* @return string JavaScript command string
*
*
*/
protected function _getCommand($name, $task, $list)
{
HTMLHelper::_('behavior.framework');
$message = Text::_('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
$message = addslashes($message);
if ($list)
{
$cmd = "if (document.adminForm.boxchecked.value==0){alert('$message');}else{ Joomla.submitbutton('$task')}";
}
else
{
$cmd = "Joomla.submitbutton('$task')";
}
return $cmd;
}
}
?>

View File

@ -0,0 +1,24 @@
<?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\Categories\Categories;
/**
* Content Component Category Tree
*/
class JEM2Categories extends Categories
{
public function __construct($options = array())
{
$options['table'] = '#__jem_categories';
$options['extension'] = 'com_jem';
parent::__construct($options);
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,78 @@
<?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\Factory;
class JemMailtoHelper {
public static function addLink($url)
{
$hash = sha1($url);
self::cleanHashes();
$app = Factory::getApplication();
$session = $app->getSession();
$mailto_links = $session->get('com_jem.links', array());
if (!isset($mailto_links[$hash]))
{
$mailto_links[$hash] = new stdClass;
}
$mailto_links[$hash]->link = $url;
$mailto_links[$hash]->expiry = time();
$session->set('com_jem.links', $mailto_links);
return $hash;
}
public static function cleanHashes($lifetime = 1440)
{
// Flag for if we've cleaned on this cycle
static $cleaned = false;
if (!$cleaned)
{
$past = time() - $lifetime;
$app = Factory::getApplication();
$session = $app->getSession();
$mailto_links = $session->get('com_jem.links', array());
foreach ($mailto_links as $index => $link)
{
if ($link->expiry < $past)
{
unset($mailto_links[$index]);
}
}
$session->set('com_jem.links', $mailto_links);
$cleaned = true;
}
}
public static function validateHash($hash)
{
$retval = false;
$app = Factory::getApplication();
$session = $app->getSession();
self::cleanHashes();
$mailto_links = $session->get('com_jem.links', array());
if (isset($mailto_links[$hash]))
{
$retval = $mailto_links[$hash]->link;
}
return $retval;
}
}
?>

View File

@ -0,0 +1,318 @@
<?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\Factory;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Log\Log;
require_once(JPATH_SITE.'/components/com_jem/helpers/helper.php');
require_once(JPATH_SITE.'/components/com_jem/classes/categories.class.php');
/**
* JEM Component Route Helper
* based on Joomla ContentHelperRoute
*
* @static
* @package JEM
*
*/
abstract class JEMHelperRoute
{
protected static $lookup;
const ARTIFICALID = 0;
/**
* Determines an JEM Link
*
* @param int The id of an JEM item
* @param string The view
* @param string The category of the item
* @deprecated Use specific Route methods instead!
*
* @return string determined Link
*/
public static function getRoute($id, $view = 'event', $category = null)
{
// Deprecation warning.
Log::add('JEMHelperRoute::getRoute() is deprecated, use specific route methods instead.', Log::WARNING, 'deprecated');
$needles = array(
$view => array((int) $id)
);
if ($item = self::_findItem($needles)) {
$link = 'index.php?Itemid='.$item;
}
else {
// Create the link
$link = 'index.php?option=com_jem&view='.$view.'&id='. $id;
// Add category, if available
if(!is_null($category)) {
$link .= '&catid='.$category;
}
if ($item = self::_findItem($needles)) {
$link .= '&Itemid='.$item;
}
elseif ($item = self::_findItem()) {
$link .= '&Itemid='.$item;
}
}
return $link;
}
public static function getCategoryRoute($id, $task = '')
{
$settings = JEMHelper::globalattribs();
$defaultItemid = $settings->get('default_Itemid');
$needles = array(
'category' => array((int) $id)
);
// Create the link
$link = 'index.php?option=com_jem&view=category&id='. $id;
// If no category view works try categories
$needles['categories'] = array(self::ARTIFICALID);
$category = new JEMCategories($id);
if($category) {
$needles['categories'] = array_reverse($category->getPath());
}
if (!empty($task)) {
$link .= '&task='.$task;
}
if ($item = self::_findItem($needles)) {
$link .= '&Itemid='.$item;
}
elseif ($item = self::_findItem()) {
if (isset($defaultItemid))
{
$link .= '&Itemid='.$defaultItemid;
}
}
return $link;
}
public static function getEventRoute($id, $catid = null)
{
$settings = JEMHelper::globalattribs();
$defaultItemid = $settings->get('default_Itemid');
$needles = array(
'event' => array((int) $id)
);
// Create the link
$link = 'index.php?option=com_jem&view=event&id='. $id;
// Add category, if available
if(!is_null($catid)) {
// TODO
//$needles['categories'] = $needles['category'];
$link .= '&catid='.$catid;
}
if ($item = self::_findItem($needles)) {
$link .= '&Itemid='.$item;
}
elseif ($item = self::_findItem()) {
// $link .= '&Itemid='.$item;
if (isset($defaultItemid))
{
$link .= '&Itemid='.$defaultItemid;
}
}
return $link;
}
public static function getVenueRoute($id)
{
$settings = JEMHelper::globalattribs();
$defaultItemid = $settings->get('default_Itemid');
$needles = array(
'venue' => array((int) $id)
);
// Create the link
$link = 'index.php?option=com_jem&view=venue&id='. $id;
// If no venue view works try venues
$needles['venues'] = array(self::ARTIFICALID);
if ($item = self::_findItem($needles)) {
$link .= '&Itemid='.$item;
}
elseif ($item = self::_findItem()) {
if (isset($defaultItemid))
{
$link .= '&Itemid='.$defaultItemid;
}
}
return $link;
}
protected static function getRouteWithoutId($my)
{
$settings = JEMHelper::globalattribs();
$defaultItemid = $settings->get('default_Itemid');
$needles = array();
$needles[$my] = array(self::ARTIFICALID);
// Create the link
$link = 'index.php?option=com_jem&view='.$my;
if ($item = self::_findItem($needles)) {
$link .= '&Itemid='.$item;
}
elseif ($item = self::_findItem()) {
if (isset($defaultItemid))
{
$link .= '&Itemid='.$defaultItemid;
} else {
$link .= '&Itemid='.$item;
}
}
return $link;
}
public static function getMyAttendancesRoute()
{
return self::getRouteWithoutId('myattendances');
}
public static function getMyEventsRoute()
{
return self::getRouteWithoutId('myevents');
}
public static function getMyVenuesRoute()
{
return self::getRouteWithoutId('myvenues');
}
/**
* Determines the Itemid
*
* searches if a menuitem for this item exists
* if not the active menuitem will be returned
*
* @param array The id and view
*
*
* @return int Itemid
*/
protected static function _findItem($needles = null)
{
$app = Factory::getApplication();
$menus = $app->getMenu('site');
// Prepare the reverse lookup array.
if (self::$lookup === null) {
self::$lookup = array();
$component = ComponentHelper::getComponent('com_jem');
$items = $menus->getItems('component_id', $component->id);
if ($items) {
foreach ($items as $item)
{
if (isset($item->query) && isset($item->query['view'])) {
if (isset($item->query['layout']) && ($item->query['layout'] == 'calendar')) {
continue; // skip calendars
}
$view = $item->query['view'];
if (!isset(self::$lookup[$view])) {
self::$lookup[$view] = array();
}
if (isset($item->query['id'])) {
self::$lookup[$view][$item->query['id']] = $item->id;
}
// Some views have no ID, but we have to set one
else {
self::$lookup[$view][self::ARTIFICALID] = $item->id;
}
}
}
}
}
if ($needles) {
foreach ($needles as $view => $ids)
{
if (isset(self::$lookup[$view])) {
foreach($ids as $id)
{
if (isset(self::$lookup[$view][(int)$id])) {
// TODO: Check on access. See commented code below
return self::$lookup[$view][(int)$id];
}
}
}
}
}
else {
$active = $menus->getActive();
if ($active) {
return $active->id;
}
}
return null;
// $user = JemFactory::getUser();
// //false if there exists no menu item at all
// if (!$items) {
// return false;
// } else {
// //Not needed currently but kept because of a possible hierarchic link structure in future
// foreach($needles as $needle => $id)
// {
// foreach($items as $item)
// {
// if (($item->query['view'] == $needle) && ($item->query['id'] == $id)) {
// return $item;
// }
// }
// /*
// //no menuitem exists -> return first possible match
// foreach($items as $item)
// {
// if ($item->published == 1 && $item->access <= $gid) {
// return $item;
// }
// }
// */
// }
// }
// return false;
}
}
?>