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,56 @@
<?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('JPATH_PLATFORM') or die;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Form\Field\CalendarField;
/**
* Form Field class for JEM needs.
*
* Advances CalendarField for better country-specific date format support.
*
* @since 2.2.3
*/
class JFormFieldCalendarJem extends CalendarField
{
/**
* The form field type.
*
* @var string
*/
protected $type = 'CalendarJem';
/**
* Method to get the data to be passed to the layout for rendering.
*
* @return array
*/
protected function getLayoutData()
{
$data = parent::getLayoutData();
if (!empty($this->hint)) {
return $data;
}
// add hint regarding date/time format accepted in edit field
$exampleTimestamp = strtotime("12/31/2017 23:59");
$date_format = str_replace("%","",$this->format);
$hint = Text::sprintf('COM_JEM_DATEFIELD_HINT', date($date_format, $exampleTimestamp));
$extraData = array(
'hint' => $hint,
);
return array_merge($data, $extraData);
}
}

View File

@ -0,0 +1,195 @@
<?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('JPATH_BASE') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Form\FormHelper;
use Joomla\CMS\HTML\HTMLHelper;
FormHelper::loadFieldClass('list');
require_once __DIR__ . '/../../helpers/helper.php';
/**
* CatOptions Field class.
*/
class JFormFieldCatOptions extends ListField
{
/**
* The category options field type.
*/
protected $type = 'CatOptions';
/**
* Create Input
* @see JFormField::getInput()
*/
public function getInput()
{
$attr = '';
// Initialize field attributes.
$attr .= !empty($this->class) ? ' class="' . $this->class . '"' : '';
$attr .= !empty($this->size) ? ' size="' . $this->size . '"' : '';
$attr .= $this->multiple ? ' multiple' : '';
$attr .= $this->required ? ' required aria-required="true"' : '';
// To avoid user's confusion, readonly="true" should imply disabled="true".
if ((string) $this->readonly == '1' || (string) $this->readonly == 'true' || (string) $this->disabled == '1'|| (string) $this->disabled == 'true')
{
$attr .= ' disabled="disabled"';
}
// Initialize JavaScript field attributes.
$attr .= $this->onchange ? ' onchange="' . $this->onchange . '"' : '';
// Output
$currentid = Factory::getApplication()->input->getInt('a_id');
if (!$currentid) { // special case: new event as copy of another one
$currentid = Factory::getApplication()->input->getInt('from_id');
}
// Get the field options.
$options = (array) $this->getOptions();
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('DISTINCT catid');
$query->from('#__jem_cats_event_relations');
$query->where('itemid = '. $db->quote($currentid));
$db->setQuery($query);
$selectedcats = $db->loadColumn();
// On new event we may have a category preferred to select.
if (empty($selectedcats) && !empty($this->element['prefer'])) {
$selectedcats = (array)$this->element['prefer'];
}
// Create a read-only list (no name) with a hidden input to store the value.
if ((string) $this->readonly == '1' || (string) $this->readonly == 'true')
{
$html[] = HTMLHelper::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $selectedcats,$this->id);
$html[] = '<input type="hidden" name="' . $this->name . '" value="' . htmlspecialchars($selectedcats, ENT_COMPAT, 'UTF-8') . '"/>';
}
else
// Create a regular list.
{
$html[] = HTMLHelper::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $selectedcats,$this->id);
}
return implode($html);
}
/**
* Retrieve Options
* @see ListField::getOptions()
*/
protected function getOptions()
{
$currentid = Factory::getApplication()->input->getInt('a_id');
$options = self::getCategories($currentid);
$options = array_values($options);
// Pad the option text with spaces using depth level as a multiplier
# the level has to be decreased as we are having a (invisible) root
# treename is generated by the function so let's use that one instead of the Joomla way
for ($i = 0, $n = count($options); $i < $n; $i++)
{
/*
if ($options[$i]->published == 1)
{
$options[$i]->text = str_repeat('- ', ($options[$i]->level - 1)) . $options[$i]->text;
}
else
{
$options[$i]->text = str_repeat('- ', ($options[$i]->level - 1)) . '[' . $options[$i]->text . ']';
}
*/
$options[$i]->text = $options[$i]->treename;
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
/**
* logic to get the categories
*
* @access public
* @return void
*/
public function getCategories($id)
{
$db = Factory::getContainer()->get('DatabaseDriver');
$user = JemFactory::getUser();
$userid = (int) $user->get('id');
if (empty($id)) {
// for new events also show all categories user is allowed to see, disable non-useable categories
// (to show same list in both cases, and allow "unusable" parents for structuring)
$mitems = $user->getJemCategories('add', 'event', array('use_disable' => true));
} else {
$query = $db->getQuery(true);
$query = 'SELECT COUNT(*)'
. ' FROM #__jem_events AS e'
. ' WHERE e.id = ' . $db->quote($id)
. ' AND e.created_by = ' . $db->quote($userid);
$db->setQuery($query);
$owner = $db->loadResult();
// on edit show all categories user is allowed to see, disable non-useable categories
$mitems = $user->getJemCategories(array('add', 'edit'), 'event', array('use_disable' => true, 'owner' => $owner));
}
if (!$mitems)
{
$mitems = array();
$children = array();
$parentid = 0;
}
else
{
$children = array();
// First pass - collect children
foreach ($mitems as $v)
{
$v->value = $v->id;
$v->text = $v->catname;
$pt = $v->parent_id;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$children[$pt] = $list;
}
// list childs of "root" which has no parent and normally id 1
$parentid = intval(@isset($children[0][0]->id) ? $children[0][0]->id : 1);
}
//get list of the items
$list = JemCategories::treerecurse($parentid, '', array(), $children, 9999, 0, 0);
// append orphaned categories
if (count($mitems) > count($list)) {
foreach ($children as $k => $v) {
if (($k > 1) && !array_key_exists($k, $list)) {
$list = JemCategories::treerecurse($k, '?&nbsp;', $list, $children, 999, 0, 0);
}
}
}
return $list;
}
}

View File

@ -0,0 +1,34 @@
<?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('JPATH_BASE') or die;
use Joomla\CMS\Form\Field\ListField;
use Joomla\CMS\Form\FormHelper;
FormHelper::loadFieldClass('list');
/**
* CountryOptions Field class
*/
class JFormFieldCountryOptions extends ListField
{
/**
* The form field type.
*/
protected $type = 'CountryOptions';
/**
* Method to get the Country options.
*/
public function getOptions()
{
return JemHelper::getCountryOptions();
}
}

View File

@ -0,0 +1,40 @@
<?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('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
/**
* Endtime Field class.
*
*
*/
class JFormFieldEndtime extends FormField
{
/**
* The form field type.
*
*/
protected $type = 'Endtime';
public function getInput()
{
$endhours = JEMHelper::buildtimeselect(23, 'endhours', substr( $this->value, 0, 2 ));
$endminutes = JEMHelper::buildtimeselect(59, 'endminutes', substr($this->value, 3, 2 ));
$var2 = $endhours.$endminutes;
return $var2;
}
}

View File

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

View File

@ -0,0 +1,110 @@
<?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\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Form\FormField;
/**
* Contact select
*/
class JFormFieldModal_Contact extends FormField
{
/**
* field type
* @var string
*/
protected $type = 'Modal_Contact';
/**
* Method to get the field input markup
*/
protected function getInput()
{
$app = Factory::getApplication();
$document = $app->getDocument();
$wa = $document->getWebAssetManager();
// Build the script
$script = array();
$script[] = ' function jSelectContact_'.$this->id.'(id, name, object) {';
$script[] = ' document.getElementById("'.$this->id.'_id").value = id;';
$script[] = ' document.getElementById("'.$this->id.'_name").value = name;';
// $script[] = ' SqueezeBox.close();';
$script[] = ' $("#contact-modal").modal("hide");';
$script[] = ' }';
// Add to document head
$wa->addInlineScript(implode("\n", $script));
// Setup variables for display
$html = array();
$link = 'index.php?option=com_jem&amp;view=editevent&amp;layout=choosecontact&amp;tmpl=component&amp;function=jSelectContact_'.$this->id;
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('name');
$query->from('#__contact_details');
$query->where(array('id='.(int)$this->value));
$db->setQuery($query);
try
{
$contact = $db->loadResult();
}
catch (RuntimeException $e)
{
$app->enqueueMessage($e->getMessage(), 'warning');
}
if (empty($contact)) {
$contact = Text::_('COM_JEM_SELECT_CONTACT');
}
$contact = htmlspecialchars($contact, ENT_QUOTES, 'UTF-8');
// The current contact input field
$html[] = ' <input type="text" id="'.$this->id.'_name" class="form-control readonly inputbox valid form-control-success" value="'.$contact.'" style="display:inline-block;" disabled="disabled" size="35" />';
// The contact select button
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
'contact-modal',
array(
'url' => $link.'&amp;'.Session::getFormToken().'=1',
'title' => Text::_('COM_JEM_SELECT'),
'width' => '800px',
'height' => '450px',
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('COM_JEM_CLOSE') . '</button>'
)
);
$html[] ='<button type="button" class="btn btn-success button-select" data-bs-toggle="modal" data-bs-target="#contact-modal">'.Text::_('COM_JEM_SELECT').'</button>';
// The active contact id field
if (0 == (int)$this->value) {
$value = '';
} else {
$value = (int)$this->value;
}
// class='required' for client side validation
$class = '';
if ($this->required) {
$class = ' class="required modal-value"';
}
$html[] = '<input type="hidden" id="'.$this->id.'_id"'.$class.' name="'.$this->name.'" value="'.$value.'" />';
return implode("\n", $html);
}
}
?>

View File

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

View File

@ -0,0 +1,124 @@
<?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\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Session\Session;
/**
* Contact select
*/
class JFormFieldModal_Users extends FormField
{
/**
* field type
* @var string
*/
protected $type = 'Modal_Users';
/**
* Method to get the field input markup
*/
protected function getInput()
{
$app = Factory::getApplication();
$document = $app->getDocument();
$wa = $document->getWebAssetManager();
// Build the script
$script = array();
$script[] = ' function jSelectUsers_'.$this->id.'(ids, count, object) {';
$script[] = ' document.getElementById("'.$this->id.'_ids").value = ids;';
$script[] = ' document.getElementById("'.$this->id.'_count").value = count;';
// $script[] = ' SqueezeBox.close();';
$script[] = ' $("#user-modal").modal("hide");';
$script[] = ' }';
// Add to document head
$wa->addInlineScript(implode("\n", $script));
// Setup variables for display
$html = array();
$eventid = isset($this->element['eventid']) ? (int)$this->element['eventid'] : 0;
$link = 'index.php?option=com_jem&amp;view=editevent&amp;layout=chooseusers&amp;tmpl=component&amp;function=jSelectUsers_'.$this->id.'&amp;a_id='.$eventid;
// we expect a list of unique, non-zero numbers
$ids = explode(',', $this->value);
array_walk($ids, function(&$v, $k){$v = (int)$v;});
$ids = array_filter($ids);
$ids = array_unique($ids);
$idlist = implode(',', $ids);
if (!empty($idlist)) {
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('COUNT(id)');
$query->from('#__users');
$query->where('id IN ('.$idlist.')');
$db->setQuery($query);
// if ($error = $db->getErrorMsg()) {
// \Joomla\CMS\Factory::getApplication()->enqueueMessage($error, 'warning');
// }
try
{
$count = (int)$db->loadResult();
}
catch (RuntimeException $e)
{
\Joomla\CMS\Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning');
}
} else {
$count = 0;
}
// if (empty($count)) {
// $count = Text::_('COM_JEM_SELECT_USERS');
// }
// $count = htmlspecialchars($count, ENT_QUOTES, 'UTF-8');
// The current contact input field
$html[] = ' <input type="text" id="'.$this->id.'_count" value="'.$count.'" disabled="disabled" size="4" />';
// The contact select button
// $html[] = ' <a class="flyermodal" title="'.Text::_('COM_JEM_SELECT').'" href="'.$link.'&amp;'.Session::getFormToken().'=1" rel="{handler: \'iframe\', size: {x:800, y:450}}">'.
// Text::_('COM_JEM_SELECT').'</a>';
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
'user-modal',
array(
'url' => $link.'&amp;'.Session::getFormToken().'=1',
'title' => Text::_('COM_JEM_SELECT'),
'width' => '800px',
'height' => '450px',
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('COM_JEM_CLOSE') . '</button>'
)
);
$html[] ='<button type="button" class="btn btn-link" data-bs-dismiss="modal" data-bs-toggle="modal" data-bs-target="#user-modal">'.Text::_('COM_JEM_SELECT').'
</button>';
// class='required' for client side validation
$class = '';
if ($this->required) {
$class = ' class="required modal-value"';
}
$html[] = '<input type="hidden" id="'.$this->id.'_ids"'.$class.' name="'.$this->name.'" value="'.$idlist.'" />';
$html[] = '<input type="hidden" id="'.$this->id.'_evid"'.$class.' value="'.$eventid.'" />';
return implode("\n", $html);
}
}
?>

View File

@ -0,0 +1,120 @@
<?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\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
use Joomla\CMS\Session\Session;
use Joomla\CMS\Form\FormField;
use Joomla\CMS\Uri\Uri;
/**
* Venue Select
*/
class JFormFieldModal_Venue extends FormField
{
/**
* field type
* @var string
*/
protected $type = 'Modal_Venue';
/**
* Method to get the field input markup
*/
protected function getInput()
{
$app = Factory::getApplication();
$document = $app->getDocument();
$wa = $document->getWebAssetManager();
// Build the script
$script = array();
$script[] = ' function jSelectVenue_'.$this->id.'(id, venue, object) {';
$script[] = ' document.getElementById("'.$this->id.'_id").value = id;';
$script[] = ' document.getElementById("'.$this->id.'_name").value = venue;';
// $script[] = ' SqueezeBox.close();';
$script[] = ' $("#venue-modal").modal("hide");';
$script[] = ' }';
// Add to document head
$wa->addInlineScript(implode("\n", $script));
// Setup variables for display
$html = array();
$link = Uri::base() . 'index.php?option=com_jem&amp;view=editevent&amp;layout=choosevenue&amp;tmpl=component&amp;function=jSelectVenue_'.$this->id;
$db = Factory::getContainer()->get('DatabaseDriver');
$query = $db->getQuery(true);
$query->select('venue');
$query->from('#__jem_venues');
$query->where(array('id='.(int)$this->value));
$db->setQuery($query);
// if ($error = $db->getErrorMsg()) {
// \Joomla\CMS\Factory::getApplication()->enqueueMessage($error, 'warning');
// }
try
{
$venue = $db->loadResult();
}
catch (RuntimeException $e)
{
\Joomla\CMS\Factory::getApplication()->enqueueMessage($e->getMessage(), 'warning');
}
if (empty($venue)) {
$venue = Text::_('COM_JEM_SELECT_VENUE');
}
$venue = htmlspecialchars($venue, ENT_QUOTES, 'UTF-8');
// The current venue input field
$html[] = ' <input type="text" id="'.$this->id.'_name" value="'.$venue.'" disabled="disabled" size="35" />';
// The venue select button
// $html[] = ' <a class="flyermodal" title="'.Text::_('COM_JEM_SELECT').'" href="'.$link.'&amp;'.Session::getFormToken().'=1" rel="{handler: \'iframe\', size: {x:800, y:450}}">'.
// Text::_('COM_JEM_SELECT').'</a>';
$html[] = HTMLHelper::_(
'bootstrap.renderModal',
'venue-modal',
array(
'url' => $link.'&amp;'.Session::getFormToken().'=1',
'title' => Text::_('COM_JEM_SELECT'),
'width' => '800px',
'height' => '450px',
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">' . Text::_('COM_JEM_CLOSE') . '</button>'
)
);
$html[] ='<button type="button" class="btn btn-link" data-bs-dismiss="modal" data-bs-toggle="modal" data-bs-target="#venue-modal">'.Text::_('COM_JEM_SELECT').'
</button>';
// The active venue id field
if (0 == (int)$this->value) {
$value = '';
} else {
$value = (int)$this->value;
}
// class='required' for client side validation
$class = '';
if ($this->required) {
$class = ' class="required modal-value"';
}
$html[] = '<input type="hidden" id="'.$this->id.'_id"'.$class.' name="'.$this->name.'" value="'.$value.'" />';
return implode("\n", $html);
}
}
?>

View File

@ -0,0 +1,41 @@
<?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('JPATH_BASE') or die;
use Joomla\CMS\Form\FormField;
/**
* CountryOptions Field class.
*
*
*/
class JFormFieldStarttime extends FormField
{
/**
* The form field type.
*
*/
protected $type = 'Starttime';
public function getInput()
{
$starthours = JEMHelper::buildtimeselect(23, 'starthours', substr( $this->value, 0, 2 ));
$startminutes = JEMHelper::buildtimeselect(59, 'startminutes', substr($this->value, 3, 2 ));
$var2 = $starthours.$startminutes;
return $var2;
}
}