/**
  * Shows the form
  *
  * @param   string  $tpl  - The tmpl
  *
  * @return  bool|mixed|object
  */
 public function display($tpl = null)
 {
     $booking_id = JFactory::getApplication()->input->get('booking_id', 0);
     $user = JFactory::getUser();
     $model = $this->getModel();
     if (empty($booking_id)) {
         JError::raiseError('404', "COM_MATUKIO_NO_ID");
     }
     $booking = $model->getBooking($booking_id);
     $event = $model->getEvent($booking->semid);
     MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_EVENTS'), JRoute::_("index.php?option=com_matukio&view=eventlist"));
     MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_EVENT_PAYPAL_PAYMENT'), "");
     $net_amount = $booking->payment_brutto;
     $tax_amount = 0;
     $successurl = JURI::base() . substr(JRoute::_("index.php?option=com_matukio&view=callback&booking_id=" . $booking_id), strlen(JURI::base(true)) + 1);
     $cancelreturn = JURI::base() . substr(JRoute::_("index.php?option=com_matukio&view=callback&task=cancel&booking_id=" . $booking_id . "&return=1"), strlen(JURI::base(true)) + 1);
     $item_number = $booking->nrbooked;
     $this->event = $event;
     $this->user = $user;
     $this->booking = $booking;
     $this->merchant_address = MatukioHelperSettings::getSettings("paypal_address", '*****@*****.**');
     $this->currency = MatukioHelperSettings::getSettings("paypal_currency", 'EUR');
     $this->success_url = $successurl;
     $this->cancel_url = $cancelreturn;
     $this->item_number = $item_number;
     $this->net_amount = $net_amount;
     $this->tax_amount = $tax_amount;
     parent::display($tpl);
 }
 /**
  * Displays the form
  *
  * @param   string  $tpl  - The template
  *
  * @throws  Exception
  * @return  mixed|void
  */
 public function display($tpl = null)
 {
     $cid = JFactory::getApplication()->input->getInt('cid', 0);
     $user = JFactory::getUser();
     // Booking id!!
     $uid = JFactory::getApplication()->input->getInt('uid', 0);
     $uuid = JFactory::getApplication()->input->get('uuid', 0);
     if (empty($cid)) {
         throw new Exception(JText::_("COM_MATUKIO_NO_ID"), 404);
     }
     // Load event (use model function)
     $emodel = JModelLegacy::getInstance('Event', 'MatukioModel');
     $event = $emodel->getItem($cid);
     $booking = null;
     if (!empty($uuid)) {
         $model = JModelLegacy::getInstance('Booking', 'MatukioModel');
         $booking = $model->getBooking($uuid);
         if (empty($booking)) {
             throw new Exception(JText::_("COM_MATUKIO_NO_BOOKING_FOUND"), 404);
         }
         $uid = $booking->id;
     }
     // With Payment Step or without?
     $steps = 3;
     if (empty($event->fees)) {
         $steps = 2;
     }
     $fields_p1 = MatukioHelperUtilsBooking::getBookingFields(1);
     $fields_p2 = MatukioHelperUtilsBooking::getBookingFields(2);
     $fields_p3 = MatukioHelperUtilsBooking::getBookingFields(3);
     // MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_EVENTS'), JRoute::_("index.php?option=com_matukio&view=eventlist"));
     // Add event to breadcrumb :)
     MatukioHelperUtilsBasic::expandPathway(JTEXT::_($event->title), JRoute::_("index.php?option=com_matukio&view=event&id=" . $cid));
     MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_EVENT_BOOKING'), "");
     $dispatcher = JDispatcher::getInstance();
     JPluginHelper::importPlugin("payment");
     $gateways = $dispatcher->trigger('onTP_GetInfo', array(MatukioHelperPayment::$matukio_payment_plugins));
     $payment = array();
     foreach ($gateways as $gway) {
         $payment[] = array("name" => $gway->id, "title" => $gway->name);
     }
     if (empty($payment)) {
         // If no payment plugins enabled then set Steps to 2 :)
         $steps = 2;
     }
     $this->gateways = $gateways;
     $this->event = $event;
     $this->uid = $uid;
     $this->uuid = $uuid;
     $this->booking = $booking;
     $this->user = $user;
     $this->steps = $steps;
     $this->payment = $payment;
     $this->fields_p1 = $fields_p1;
     $this->fields_p2 = $fields_p2;
     $this->fields_p3 = $fields_p3;
     parent::display($tpl);
 }
 public function display($tpl = NULL)
 {
     $booking_id = JFactory::getApplication()->input->get('booking_id', 0);
     $user = JFactory::getUser();
     $model = $this->getModel();
     $return = JFactory::getApplication()->input->get('return', 0);
     if (empty($booking_id)) {
         JError::raiseError('404', "COM_MATUKIO_NO_ID");
         return;
     }
     $booking = $model->getBooking($booking_id);
     $event = $model->getEvent($booking->semid);
     if ($return != 1) {
         $dispatcher = JDispatcher::getInstance();
         $results = $dispatcher->trigger('onAfterPaidBooking', $booking, $event);
     }
     MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_EVENTS'), JRoute::_("index.php?option=com_matukio"));
     MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_EVENT_PAYPAL_PAYMENT'), "");
     $this->event = $event;
     $this->user = $user;
     $this->booking = $booking;
     parent::display($tpl);
 }
 /**
  * Displays the form
  *
  * @param null $tpl
  *
  * @return mixed|void
  */
 public function display($tpl = null)
 {
     $catid = JFactory::getApplication()->input->get('catid', array(), '', 'array');
     $user = JFactory::getUser();
     $ue_title = "COM_MATUKIO_UPCOMING_EVENTS";
     $dispatcher = JDispatcher::getInstance();
     $params = JComponentHelper::getParams('com_matukio');
     $menuitemid = JFactory::getApplication()->input->get('Itemid');
     if ($menuitemid) {
         $site = new JSite();
         $menu = $site->getMenu();
         $menuparams = $menu->getParams($menuitemid);
         $params->merge($menuparams);
     }
     if (empty($catid)) {
         $catid = $params->get('catid', 0);
     }
     $ue_title = $params->get('title', 'COM_MATUKIO_UPCOMING_EVENTS');
     $number = $params->get('number', 10);
     $orderby = $params->get('orderby', 'begin ASC');
     $model = $this->getModel();
     $events = $model->getEvents($catid, $number, $orderby);
     MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_UPCOMING_EVENTS'), "");
     JPluginHelper::importPlugin('content');
     foreach ($events as $key => $event) {
         $events[$key]->jevent = new stdClass();
         $results = $dispatcher->trigger('onContentAfterButton', array('com_matukio.upcomingevent', &$event, &$params, 0));
         $events[$key]->jevent->afterDisplayButton = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_matukio.upcomingevent', &$event, &$params, 0));
         $events[$key]->jevent->afterDisplayContent = trim(implode("\n", $results));
     }
     $this->catid = $catid;
     $this->events = $events;
     $this->user = $user;
     $this->title = $ue_title;
     parent::display($tpl);
 }
 /**
  * Displays the form
  *
  * @param   string  $tpl  - The tmpl
  *
  * @return  mixed|object
  */
 public function display($tpl = null)
 {
     $params = JComponentHelper::getParams('com_matukio');
     $menuitemid = JFactory::getApplication()->input->get('Itemid');
     if ($menuitemid) {
         $site = new JSite();
         $menu = $site->getMenu();
         $menuparams = $menu->getParams($menuitemid);
         $params->merge($menuparams);
     }
     // Hardcode in Dirk's matukio-mvc.php task
     $art = JFactory::getApplication()->input->getInt('art', 0);
     $order_by = $params->get("orderby", "a.begin");
     $database = JFactory::getDBO();
     $dateid = JFactory::getApplication()->input->getInt('dateid', 1);
     $catid = JFactory::getApplication()->input->getInt('catid', 0);
     $uuid = JFactory::getApplication()->input->get('uuid', '', 'string');
     if (empty($catid)) {
         $catid = $params->get('startcat', 0);
     }
     $search = JFactory::getApplication()->input->get('search', '', 'string');
     $search = str_replace("'", "", $search);
     $search = str_replace("\"", "", $search);
     $limit = JFactory::getApplication()->input->getInt('limit', MatukioHelperSettings::getSettings('event_showanzahl', 10));
     $limitstart = JFactory::getApplication()->input->getInt('limitstart', 0);
     $my = JFactory::getuser();
     $groups = implode(',', $my->getAuthorisedViewLevels());
     if ($art == 1) {
         if ($my->id == 0 && empty($uuid)) {
             JError::raiseError("403", JTEXT::_('COM_MATUKIO_NOT_LOGGED_IN'));
         }
     }
     // Check if user is logged in and allowed to edit his OWN events
     if ($art == 2) {
         if (!JFactory::getUser()->authorise('core.edit.own', 'com_matukio')) {
             return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     }
     switch ($art) {
         default:
         case "0":
             $navioben = explode(" ", MatukioHelperSettings::getSettings('frontend_topnavshowmodules', 'SEM_NUMBER SEM_SEARCH SEM_CATEGORIES SEM_RESET'));
             break;
         case "1":
             $navioben = explode(" ", MatukioHelperSettings::getSettings('frontend_topnavbookingmodules', 'SEM_NUMBER SEM_SEARCH SEM_TYPES SEM_RESET'));
             break;
         case "2":
             $navioben = explode(" ", MatukioHelperSettings::getSettings('frontend_topnavoffermodules', 'SEM_NUMBER SEM_SEARCH SEM_TYPES SEM_RESET'));
             break;
     }
     // Old event form
     if ($this->getLayout() != "modern" || $my->id == 0) {
         $ret = MatukioHelperUtilsEvents::getEventList($art, $search, $dateid, $catid, $order_by, $my, $navioben, $limitstart, $limit, "old");
         $events = $ret[0];
         $total = $ret[1];
         switch ($art) {
             case "0":
                 $anztyp = array(JTEXT::_('COM_MATUKIO_EVENTS'), 0);
                 break;
             case "1":
                 // Show booked events
                 $anztyp = array(JTEXT::_('COM_MATUKIO_MY_BOOKINGS'), 1);
                 break;
             case "2":
                 // Show offered events
                 $anztyp = array(JTEXT::_('COM_MATUKIO_MY_OFFERS'), 2);
                 break;
         }
         $pageNav = MatukioHelperUtilsEvents::cleanSiteNavigation($total, $limit, $limitstart);
         $this->rows = $events;
         $this->pageNav = $pageNav;
     }
     // Modern Layout - merge that someday :/
     if ($this->getLayout() == "modern") {
         // Tabs
         if ($my->id > 0) {
             // Just set it to the default
             $anztyp = array(JTEXT::_('COM_MATUKIO_EVENTS'), 0);
             // Normal events view
             $ret = MatukioHelperUtilsEvents::getEventList(0, $search, $dateid, $catid, $order_by, $my, $navioben, $limitstart, $limit, "modern");
             $allEvents = $ret[0];
             $total = $ret[1];
             $this->pageNavAllEvents = MatukioHelperUtilsEvents::cleanSiteNavigation($total, $limit, $limitstart);
             $this->allEvents = $allEvents;
             // My Bookings
             $bookedEvents = MatukioHelperUtilsEvents::getEventList(1, $search, $dateid, $catid, $order_by, $my, $navioben, 0, 1000, "modern");
             $this->mybookedEvents = $bookedEvents[0];
             // My offers
             if (JFactory::getUser()->authorise('core.edit.own', 'com_matukio')) {
                 $editEvents = MatukioHelperUtilsEvents::getEventList(2, $search, $dateid, $catid, $order_by, $my, $navioben, 0, 1000, "modern");
                 $this->myofferEvents = $editEvents[0];
             }
         } else {
             // Not logged in user - we can take rows from above
             $this->allEvents = $events;
             $this->pageNavAllEvents = $pageNav;
         }
     }
     // Kursauswahl erstellen
     $allekurse = array();
     $allekurse[] = JHTML::_('select.option', '0', JTEXT::_('COM_MATUKIO_ALL_EVENTS'));
     $allekurse[] = JHTML::_('select.option', '1', JTEXT::_('COM_MATUKIO_CURRENT_EVENTS'));
     $allekurse[] = JHTML::_('select.option', '2', JTEXT::_('COM_MATUKIO_OLD_EVENTS'));
     $selectclass = $this->getLayout() == "modern" ? "mat_inputbox" : "sem_inputbox22";
     $datelist = JHTML::_('select.genericlist', $allekurse, "dateid", "class=\"" . $selectclass . " chzn-single\" size=\"1\"\r\n                onchange=\"changeStatus();\"", "value", "text", $dateid);
     $categories[] = JHTML::_('select.option', '0', JTEXT::_('COM_MATUKIO_ALL_CATS'));
     $database->setQuery("SELECT id AS value, title AS text FROM #__categories WHERE extension='" . JFactory::getApplication()->input->get('option') . "' AND access in (" . $groups . ") AND published = 1 ORDER BY lft");
     $categs = array_merge($categories, (array) $database->loadObjectList());
     $clist = JHTML::_('select.genericlist', $categs, "catid", "class=\"" . $selectclass . " chzn-single\" size=\"1\"\r\n                onchange=\"changeCategoryEventlist();\" style=\"width: 180px;\"", "value", "text", $catid);
     $listen = array($datelist, $dateid, $clist, $catid);
     // Navigationspfad erweitern
     MatukioHelperUtilsBasic::expandPathway($anztyp[0], JRoute::_("index.php?option=com_matukio&view=eventlist"));
     $ue_title = $params->get('title', 'COM_MATUKIO_EVENTS_OVERVIEW');
     $this->art = $art;
     $this->search = $search;
     $this->limit = $limit;
     $this->limitstart = $limitstart;
     $this->total = $total;
     $this->datelist = $datelist;
     $this->dateid = $dateid;
     $this->clist = $clist;
     $this->catid = $catid;
     $this->title = $ue_title;
     $this->order_by = $order_by;
     parent::display($tpl);
 }
 /**
  * Displays the event form
  *
  * @param   string  $tpl  - The template
  *
  * @throws  Exception
  * @return  void
  */
 public function display($tpl = null)
 {
     $input = JFactory::getApplication()->input;
     $model = $this->getModel();
     $art = $input->getInt('art', 0);
     $database = JFactory::getDBO();
     $dateid = $input->getInt('dateid', 1);
     // Event id
     $cid = $input->getInt('id', 0);
     // Booking id!!
     $uid = $input->getInt('uid', 0);
     $uuid = $input->get('uuid', '');
     $dispatcher = JDispatcher::getInstance();
     $booking = "";
     $user = JFactory::getUser();
     if ($art == 1) {
         // Updated 2.2.4 to show the cancel booking button if logged in!
         $booking = MatukioHelperUtilsBooking::getBooking($uid, $cid);
     }
     // Fix if uid / booking not found or booking as not registered user
     if (empty($booking)) {
         $art = 0;
     }
     // Category id
     $catid = $input->getInt('catid', 0);
     $search = $input->get('search', '', 'string');
     $limit = $input->getInt('limit', 5);
     // TODO Pagination should be updated to Joomla Framework
     $limitstart = $input->getInt('limitstart', 0);
     $params = JComponentHelper::getParams('com_matukio');
     $menuitemid = $input->get('Itemid');
     if ($menuitemid) {
         $site = new JSite();
         $menu = $site->getMenu();
         $menuparams = $menu->getParams($menuitemid);
         $params->merge($menuparams);
     }
     $menu_cid = $params->get('eventId', 0);
     if (empty($cid)) {
         if (empty($menu_cid)) {
             JError::raiseError('404', JTEXT::_("COM_MATUKIO_NO_ID"));
         } else {
             $cid = $menu_cid;
         }
     }
     $row = $model->getItem($cid, true);
     if ($art == 3) {
         if ($uid > 0) {
             $database->setQuery("SELECT * FROM #__matukio_bookings WHERE id='" . $uid . "'");
             $temp = $database->loadObjectList();
             $userid = $temp[0]->userid;
             if ($userid == 0) {
                 $uid = $uid * -1;
             } else {
                 $uid = $userid;
             }
         }
     } else {
         if ($uid > 0) {
             $database->setQuery("SELECT * FROM #__matukio_bookings WHERE id='{$uid}'");
             $temp = $database->loadObjectList();
             if ($temp[0]->userid != 0 || $art != 1) {
                 $uid = $temp[0]->userid;
             } else {
                 $uid = $uid * -1;
             }
         }
     }
     if ($art == 0) {
         // Hits erhoehen
         $database->setQuery("UPDATE #__matukio_recurring SET hits=hits+1 WHERE id='{$cid}'");
         if (!$database->execute()) {
             throw new Exception("COM_MATUKIO_ERROR_ADDING_HIT" . ":" . $row->getError());
         }
         // Ausgabe des Kurses
         // MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_EVENTS'), JRoute::_("index.php?option=com_matukio"));
     } elseif ($art == 1 or $art == 2) {
         if ($user->id > 0) {
             MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_MY_BOOKINGS'), JRoute::_("index.php?option=com_matukio&view=eventlist&art=1"));
         }
     } else {
         MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_MY_OFFERS'), JRoute::_("index.php?option=com_matukio&view=eventlist&art=2"));
     }
     // Add category link to breadcrumb
     MatukioHelperUtilsBasic::expandPathway($row->category, JRoute::_("index.php?option=com_matukio&view=eventlist&art=" . $art . "&catid=" . $row->catid . ":" . JFilterOutput::stringURLSafe($row->category)));
     // Add event to breadcrumb
     MatukioHelperUtilsBasic::expandPathway($row->title, "");
     $ueberschrift = array(JTEXT::_('COM_MATUKIO_DESCRIPTION'), $row->shortdesc);
     if (empty($row)) {
         JError::raiseError('404', JTEXT::_("COM_MATUKIO_NO_ID"));
         return;
     }
     $locobj = null;
     if ($row->place_id > 0) {
         $locobj = MatukioHelperUtilsEvents::getLocation($row->place_id);
     }
     $title = JFactory::getDocument()->getTitle();
     JFactory::getDocument()->setTitle($title . " - " . JText::_($row->title));
     JPluginHelper::importPlugin('content');
     $this->jevent = new stdClass();
     $results = $dispatcher->trigger('onContentAfterDisplay', array('com_matukio.event', &$row, &$params, 0));
     $this->jevent->afterDisplayContent = trim(implode("\n", $results));
     $this->id = $cid;
     $this->art = $art;
     $this->event = $row;
     $this->uid = $uid;
     $this->uuid = $uuid;
     $this->search = $search;
     $this->catid = $catid;
     $this->limit = $limit;
     $this->limitstart = $limitstart;
     $this->dateid = $dateid;
     $this->ueberschrift = $ueberschrift;
     $this->booking = $booking;
     $this->user = $user;
     $this->location = $locobj;
     parent::display($tpl);
 }
 /**
  * Shows the form
  *
  * @param   string  $tpl  - The tmpl
  *
  * @return  bool|mixed|object
  */
 public function display($tpl = null)
 {
     $art = JFactory::getApplication()->input->getInt('art', 0);
     $cid = JFactory::getApplication()->input->getInt('cid', 0);
     if (empty($cid)) {
         JError::raiseError('404', "COM_MATUKIO_NO_ID");
     }
     $database = JFactory::getDBO();
     $dateid = JFactory::getApplication()->input->getInt('dateid', 1);
     $catid = JFactory::getApplication()->input->getInt('catid', 0);
     $search = JFactory::getApplication()->input->get('search', '');
     $limit = JFactory::getApplication()->input->getInt('limit', 5);
     $limitstart = JFactory::getApplication()->input->getInt('limitstart', 0);
     $user = JFactory::getUser();
     // Load event (use model function)
     $emodel = JModelLegacy::getInstance('Event', 'MatukioModel');
     $kurs = $emodel->getItem($cid);
     if ($art == 0) {
         $anztyp = array(JTEXT::_('COM_MATUKIO_EVENTS'), 0);
     } elseif ($art == 1) {
         $anztyp = array(JTEXT::_('COM_MATUKIO_MY_BOOKINGS'), 1);
     } elseif ($art == 2) {
         $anztyp = array(JTEXT::_('COM_MATUKIO_MY_OFFERS'), 2);
     } elseif ($art == 3) {
         $anztyp = array(JTEXT::_('COM_MATUKIO_MY_OFFERS'), 3);
     }
     if ($art == 0) {
         if (!(MatukioHelperSettings::getSettings('frontend_userviewteilnehmer', 0) == 2 and $user->id > 0 or MatukioHelperSettings::getSettings('frontend_userviewteilnehmer', 0) == 1)) {
             return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     }
     if ($art == 1) {
         if (!(MatukioHelperSettings::getSettings('frontend_userviewteilnehmer', 0) == 2 and $user->id > 0 or MatukioHelperSettings::getSettings('frontend_userviewteilnehmer', 0) == 1)) {
             return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     }
     if ($art == 2) {
         if ($kurs->publisher == JFactory::getUser()->id) {
             if (!JFactory::getUser()->authorise('core.edit.own', 'com_matukio')) {
                 return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
             }
         } else {
             if (!JFactory::getUser()->authorise('core.edit', 'com_matukio')) {
                 return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
             }
         }
     }
     $fstatus = JFactory::getApplication()->input->get("filter_status", 'activeandpending');
     $status = "AND (a.status = '1' OR a.status = '0')";
     if (!empty($fstatus)) {
         switch ($fstatus) {
             case "pending":
                 // 0 is active in Seminar :(
                 $status = "AND a.status = '0'";
                 break;
             case "active":
                 $status = "AND a.status = '1'";
                 break;
             case 'activeandpending':
                 $status = "AND (a.status = '1' OR a.status = '0')";
                 break;
             case "waitlist":
                 $status = "AND a.status = '2'";
                 break;
             case "archived":
                 $status = "AND a.status = '3'";
                 break;
             case "deleted":
                 $status = "AND a.status = '4'";
                 break;
             case "paid":
                 $status = "AND a.paid = '1'";
                 break;
             case "unpaid":
                 $status = "AND a.paid = '0'";
                 break;
             case "all":
                 $status = "";
                 break;
         }
     }
     $this->filterStatus = $fstatus;
     $database->setQuery("SELECT a.*, cc.*, a.id AS sid, a.name AS aname, a.email AS aemail FROM #__matukio_bookings\r\n                AS a LEFT JOIN #__users AS cc ON cc.id = a.userid WHERE a.semid = '" . $kurs->id . " '\r\n                " . $status . " ORDER BY a.id");
     $rows = $database->loadObjectList();
     if ($database->getErrorNum()) {
         echo $database->stderr();
         return false;
     }
     MatukioHelperUtilsBasic::expandPathway($anztyp[0], JRoute::_("index.php?option=com_matukio&art=" . $art));
     MatukioHelperUtilsBasic::expandPathway($kurs->title, "");
     $this->rows = $rows;
     $this->art = $art;
     $this->search = $search;
     $this->limit = $limit;
     $this->limitstart = $limitstart;
     $this->kurs = $kurs;
     $this->catid = $catid;
     $this->dateid = $dateid;
     parent::display($tpl);
 }
 /**
  * Displays the form
  *
  * @param   string  $tpl  - The template
  *
  * @return  mixed|object
  */
 public function display($tpl = null)
 {
     $my = JFactory::getuser();
     $dateid = JFactory::getApplication()->input->getInt('dateid', 1);
     $catid = JFactory::getApplication()->input->getInt('catid', 0);
     $params = JComponentHelper::getParams('com_matukio');
     $menuitemid = JFactory::getApplication()->input->get('Itemid');
     if ($menuitemid) {
         $site = new JSite();
         $menu = $site->getMenu();
         $menuparams = $menu->getParams($menuitemid);
         $params->merge($menuparams);
     }
     if (empty($catid)) {
         $catid = $params->get('catid', 0);
     }
     $search = JFactory::getApplication()->input->get('search', '', 'string');
     $limit = JFactory::getApplication()->input->getInt('limit', 5);
     $limitstart = JFactory::getApplication()->input->getInt('limitstart', 0);
     $vorlage = JFactory::getApplication()->input->getInt('vorlage', 0);
     $cid = JFactory::getApplication()->input->getInt('cid', 0);
     if (empty($cid)) {
         // Access check for creating new event
         if (!JFactory::getUser()->authorise('core.create', 'com_matukio')) {
             return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     } else {
         // Access check for editing this event
         if (!JFactory::getUser()->authorise('core.edit.own', 'com_matukio')) {
             return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
         }
     }
     $row = null;
     // Load event
     $row = MatukioHelperUtilsEvents::getEventEditTemplate($cid);
     // Ist es eine Vorlage
     if ($vorlage > 0) {
         $row->id = "";
         $row->pattern = "";
     }
     if ($cid < 1) {
         $row->publisher = $my->id;
         $row->semnum = MatukioHelperUtilsEvents::createNewEventNumber(date('Y'));
     }
     $row->vorlage = $vorlage;
     // New Event
     if (empty($row->begin) || $row->begin == "0000-00-00 00:00:00") {
         $row->begin = date("Y-m-d 14:00:00");
         $row->end = date("Y-m-d 17:00:00");
         $row->booked = date("Y-m-d 12:00:00");
     }
     $zeit = explode(" ", $row->begin);
     $row->begin_date = $zeit[0];
     $zeit = explode(":", $zeit[1]);
     $row->begin_hour = $zeit[0];
     $row->begin_minute = $zeit[1];
     $zeit = explode(" ", $row->end);
     $row->end_date = $zeit[0];
     $zeit = explode(":", $zeit[1]);
     $row->end_hour = $zeit[0];
     $row->end_minute = $zeit[1];
     $zeit = explode(" ", $row->booked);
     $row->booked_date = $zeit[0];
     $zeit = explode(":", $zeit[1]);
     $row->booked_hour = $zeit[0];
     $row->booked_minute = $zeit[1];
     // MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_MY_OFFERS'), "index.php?option=com_matukio&view=myevents");
     if ($cid) {
         MatukioHelperUtilsBasic::expandPathway($row->title, "");
     } else {
         MatukioHelperUtilsBasic::expandPathway(JTEXT::_('COM_MATUKIO_NEW_EVENT'), "");
     }
     $this->event = $row;
     $this->search = $search;
     $this->catid = $catid;
     $this->limit = $limit;
     $this->limitstart = $limitstart;
     $this->dateid = $dateid;
     parent::display($tpl);
 }