Пример #1
0
 /**
  * Method to display the create / edit event's form.
  * Both views share the same template file.	 
  **/
 function _displayForm($event)
 {
     $mainframe = JFactory::getApplication();
     $my = CFactory::getUser();
     $config = CFactory::getConfig();
     $model = CFactory::getModel('events');
     $categories = $model->getCategories();
     $now = JFactory::getDate();
     $now->setOffset($mainframe->getCfg('offset'));
     jimport('joomla.html.editor');
     $editorType = $config->get('allowhtml') ? $config->get('htmleditor', 'none') : 'none';
     $editor = new JEditor($editorType);
     $totalEventCount = $model->getEventsCreationCount($my->id);
     $event->startdatetime = JRequest::getVar('startdatetime', '00:01', 'POST');
     $event->enddatetime = JRequest::getVar('enddatetime', '23:59', 'POST');
     CFactory::load('helpers', 'time');
     $timezones = CTimeHelper::getTimezoneList();
     CFactory::load('helpers', 'event');
     $helper = CEventHelper::getHandler($event);
     $startDate = $event->getStartDate(false);
     $endDate = $event->getEndDate(false);
     $hours = array();
     $startAmPmSelect = "";
     $endAmPmSelect = "";
     if ($config->get('eventshowampm')) {
         for ($i = 1; $i <= 12; $i++) {
             $hours[] = JHTML::_('select.option', $i, "{$i}");
         }
         // Cannot user ->toFormat('%p') since it is dependent on current locale
         // and would return a null if the system is configured for 24H
         $startAmPm = $startDate->toFormat('%H') >= 12 ? 'PM' : 'AM';
         $endAmPm = $endDate->toFormat('%H') >= 12 ? 'PM' : 'AM';
         $amPmSelect = array();
         $amPmSelect[] = JHTML::_('select.option', 'AM', "am");
         $amPmSelect[] = JHTML::_('select.option', 'PM', "pm");
         $startAmPmSelect = JHTML::_('select.genericlist', $amPmSelect, 'starttime-ampm', array('class' => 'required inputbox'), 'value', 'text', $startAmPm, false);
         $endAmPmSelect = JHTML::_('select.genericlist', $amPmSelect, 'endtime-ampm', array('class' => 'required inputbox'), 'value', 'text', $endAmPm, false);
         $selectedStartHour = intval($startDate->toFormat('%I'));
         $selectedEndHour = intval($endDate->toFormat('%I'));
     } else {
         for ($i = 0; $i <= 23; $i++) {
             $hours[] = JHTML::_('select.option', $i, sprintf("%02d", $i));
         }
         $selectedStartHour = intval($startDate->toFormat('%H'));
         $selectedEndHour = intval($endDate->toFormat('%H'));
     }
     $startHourSelect = JHTML::_('select.genericlist', $hours, 'starttime-hour', array('class' => 'required inputbox'), 'value', 'text', $selectedStartHour, false);
     $endHourSelect = JHTML::_('select.genericlist', $hours, 'endtime-hour', array('class' => 'required inputbox'), 'value', 'text', $selectedEndHour, false);
     $minutes = array();
     $minutes[] = JHTML::_('select.option', 0, "00");
     $minutes[] = JHTML::_('select.option', 15, "15");
     $minutes[] = JHTML::_('select.option', 30, "30");
     $minutes[] = JHTML::_('select.option', 45, "45");
     $startMinSelect = JHTML::_('select.genericlist', $minutes, 'starttime-min', array('class' => 'required inputbox'), 'value', 'text', $startDate->toFormat('%M'), false);
     $endMinSelect = JHTML::_('select.genericlist', $minutes, 'endtime-min', array('class' => 'required inputbox'), 'value', 'text', $endDate->toFormat('%M'), false);
     // Load category tree
     CFactory::load('helpers', 'category');
     $cTree = CCategoryHelper::getCategories($categories);
     $lists['categoryid'] = JHTML::_('select.genericlist', $cTree, 'catid', 'size="1"', 'id', 'nodeText', $event->catid);
     $tmpl = new CTemplate();
     $tmpl->set('startDate', $startDate);
     $tmpl->set('endDate', $endDate);
     $tmpl->set('startHourSelect', $startHourSelect);
     $tmpl->set('endHourSelect', $endHourSelect);
     $tmpl->set('startMinSelect', $startMinSelect);
     $tmpl->set('endMinSelect', $endMinSelect);
     $tmpl->set('startAmPmSelect', $startAmPmSelect);
     $tmpl->set('endAmPmSelect', $endAmPmSelect);
     $tmpl->set('timezones', $timezones);
     $tmpl->set('config', $config);
     $tmpl->set('lists', $lists);
     $tmpl->set('categories', $categories);
     $tmpl->set('event', $event);
     $tmpl->set('editor', $editor);
     $tmpl->set('helper', $helper);
     $tmpl->set('now', $now->toFormat('%Y-%m-%d'));
     $tmpl->set('eventCreated', $totalEventCount);
     $tmpl->set('eventcreatelimit', $config->get('eventcreatelimit'));
     echo $tmpl->fetch('events.forms');
 }
Пример #2
0
 /**
  * Display the form of the event import and the listing of events users can import
  * from the calendar file.
  * */
 public function import($data)
 {
     $events = $data['events'];
     $config = JFactory::getConfig();
     $offset = $config->get('offset');
     if (isset($data['icalParser'])) {
         $parser = $data['icalParser'];
         if (isset($parser->cal['VTIMEZONE']['TZID'])) {
             $offset = $parser->cal['VTIMEZONE']['TZID'];
         }
     }
     $groupId = JRequest::getInt('groupid', 0);
     $groupLink = $groupId > 0 ? '&groupid=' . $groupId : '';
     $saveImportLink = CRoute::_('index.php?option=com_community&view=events&task=saveImport' . $groupLink);
     if (!$this->accessAllowed('registered')) {
         return;
     }
     //$this->showSubmenu();
     /**
      * Opengraph
      */
     CHeadHelper::setType('website', JText::_('COM_COMMUNITY_EVENTS_IMPORT_ICAL'));
     $model = CFactory::getModel('events');
     $categories = $model->getCategories();
     //CFactory::load( 'helpers' , 'event' );
     $event = JTable::getInstance('Event', 'CTable');
     //CFactory::load( 'helpers' , 'time' );
     $timezones = CTimeHelper::getTimezoneList();
     $offsetValue = new DateTime('now', new DateTimeZone($offset));
     $offsetValue = (int) $offsetValue->format('P');
     $tmpl = new CTemplate();
     echo CMiniHeader::showEventMiniHeader($event->id);
     echo $tmpl->set('events', $events)->set('categories', $categories)->set('timezones', $timezones)->set('offset', $offset)->set('saveimportlink', $saveImportLink)->set('offsetValue', $offsetValue)->set('submenu', $this->showSubmenu(false))->set('pageTitle', $groupId ? JText::_('COM_COMMUNITY_EVENTS_IMPORT_GROUP_EVENT') : JText::_('COM_COMMUNITY_IMPORT_EVENTS'))->set('canCreate', CFactory::getUser()->authorise('community.create', 'events'))->fetch('events.import');
 }
Пример #3
0
 /**
  * Retrieve timezone.
  * 
  * @param	int	$offset	The current offset
  * @return	string	The current time zone for the given offset.
  **/
 public static function getTimezone($offset)
 {
     $timezone = CTimeHelper::getTimezoneList();
     return $timezone[$offset];
 }
Пример #4
0
 /**
  * Display the form of the event import and the listing of events users can import
  * from the calendar file.	 
  **/
 public function import($events)
 {
     if (!$this->accessAllowed('registered')) {
         return;
     }
     $document = JFactory::getDocument();
     $config = CFactory::getConfig();
     $document->setTitle(JText::_('COM_COMMUNITY_EVENTS_IMPORT_ICAL'));
     $this->showSubmenu();
     $model = CFactory::getModel('events');
     $categories = $model->getCategories();
     CFactory::load('helpers', 'time');
     $timezones = CTimeHelper::getTimezoneList();
     $tmpl = new CTemplate();
     echo $tmpl->set('events', $events)->set('categories', $categories)->set('timezones', $timezones)->fetch('events.import');
 }