Example #1
0
 function displayDefault()
 {
     global $mainframe, $hgconf;
     //Load pane behavior
     jimport('joomla.html.pane');
     //initialise variables
     $editor =& JFactory::getEditor();
     $document =& JFactory::getDocument();
     $user =& JFactory::getUser();
     $lang =& JFactory::getLanguage();
     $db =& JFactory::getDBO();
     //get vars
     $cid = JRequest::getVar('cid');
     //create the toolbar
     if ($cid) {
         JToolBarHelper::title(JText::_('HG_EDIT_EVENT'), 'event');
     } else {
         JToolBarHelper::title(JText::_('HG_NEW_EVENT'), 'event');
     }
     JToolBarHelper::apply();
     JToolBarHelper::save();
     JToolBarHelper::custom('saveandnew', 'savenew.png', 'savenew.png', 'HG_SAVE_AND_NEW', false);
     JToolBarHelper::cancel();
     //Get data from the model
     $model =& $this->getModel();
     $row =& $this->get('Event');
     $events = hotelguide_events::getEventsTree(0);
     //remove the current category to prevent selection as parent for itself
     foreach ($events as $event) {
         if ($event->id == $row->id) {
             unset($events[$event->id]);
         }
     }
     //fail if checked out not by 'me'
     if ($row->id) {
         if ($model->isCheckedOut($user->get('id'))) {
             JError::raiseWarning('SOME_ERROR_CODE', $row->title . ' ' . JText::_('HG_EDITED_BY_ANOTHER_ADMIN'));
             $mainframe->redirect('index.php?option=com_hotelguide&view=events');
         }
     }
     //clean data
     JFilterOutput::objectHTMLSafe($row, ENT_QUOTES, 'text');
     $Lists['parent_id'] = hotelguide_events::buildeventselect($events, 'parent_id', $row->parent_id, true);
     //assign vars to view
     $this->assignRef('hgconf', $hgconf);
     $this->assignRef('Lists', $Lists);
     $this->assignRef('row', $row);
     $this->assignRef('editor', $editor);
 }