Exemple #1
0
 /**
  * Get Media
  *
  * @return string
  */
 public function getMedia()
 {
     $itemId = FabrikWorker::itemId();
     $params = $this->getParams();
     $w = $params->get('media_width');
     $h = $params->get('media_height');
     $return = '';
     if ($params->get('media_which_player', 'jw') == 'xspf') {
         $player_type = "Extended";
         $playerUrl = COM_FABRIK_LIVESITE . $this->srcBase . "media/libs/xspf/{$player_type}/xspf_player.swf";
         $playlistUrl = 'index.php?option=com_' . $this->package . '&controller=visualization.media&view=visualization&task=getPlaylist&format=raw&Itemid=' . $itemId . '&visualizationid=' . $this->getId();
         $playlistUrl = urlencode($playlistUrl);
         $return = '<object type="application/x-shockwave-flash" width="400" height="170" data="' . $playerUrl . '?playlist_url=' . $playlistUrl . '">';
         $return .= '<param name="movie" value="xspf_player.swf?playlist_url=' . $playlistUrl . '" />';
         $return .= '</object>';
     } else {
         $return = "<div id='jw_player'></div>";
     }
     return $return;
 }
Exemple #2
0
 /**
  * Create print URL
  *
  * @param   object $formModel form model
  *
  * @since   3.0.6
  *
  * @return  string
  */
 public static function printURL($formModel)
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $form = $formModel->getForm();
     $package = $app->getUserState('com_fabrik.package', 'fabrik');
     $table = $formModel->getTable();
     if ($app->isAdmin()) {
         $url = 'index.php?option=com_' . $package . '&task=details.view&tmpl=component&formid=' . $form->id . '&listid=' . $table->id . '&rowid=' . $formModel->getRowId() . '&iframe=1&print=1';
     } else {
         //$this->pdfURL = 'index.php?option=com_' . $this->package . '&view=details&formid=' . $model->getId() . '&rowid=' . $model->getRowId() . '&format=pdf';
         $url = COM_FABRIK_LIVESITE . 'index.php?option=com_' . $package . '&view=details&tmpl=component&formid=' . $form->id . '&listid=' . $table->id . '&rowid=' . $formModel->getRowId() . '&iframe=1&print=1';
         $url .= '&Itemid=' . FabrikWorker::itemId();
     }
     /* $$$ hugh - @TODO - FIXME - if they were using rowid=-1, we don't need this, as rowid has already been transmogrified
      * to the correct (PK based) rowid.  but how to tell if original rowid was -1???
      */
     if ($input->get('usekey') !== null) {
         $url .= '&usekey=' . $input->get('usekey');
     }
     $url = JRoute::_($url);
     // $$$ rob for some reason JRoute wasn't doing this ???
     //$url            = str_replace('&', '&amp;', $url);
     self::$printURL = $url;
     return self::$printURL;
 }
Exemple #3
0
    /**
     * Execute and display a template script.
     *
     * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
     *
     * @return  mixed  A string if successful, otherwise a JError object.
     */
    public function display($tpl = 'default')
    {
        $app = JFactory::getApplication();
        $package = $app->getUserState('com_fabrik.package', 'fabrik');
        $input = $app->input;
        $j3 = FabrikWorker::j3();
        $Itemid = FabrikWorker::itemId();
        $model = $this->getModel();
        $usersConfig = JComponentHelper::getParams('com_fabrik');
        $id = $input->get('id', $usersConfig->get('visualizationid', $input->get('visualizationid', 0)));
        $model->setId($id);
        $this->row = $model->getVisualization();
        $params = $model->getParams();
        $this->params = $params;
        $this->containerId = $model->getJSRenderContext();
        $this->filters = $this->get('Filters');
        $this->showFilters = $model->showFilters();
        $this->showTitle = $input->getInt('show-title', 1);
        $this->filterFormURL = $this->get('FilterFormURL');
        $calendar = $this->row;
        JHTML::stylesheet('media/com_fabrik/css/list.css');
        $this->canAdd = (bool) $params->get('calendar-read-only', 0) == 1 ? false : $model->getCanAdd();
        $this->requiredFiltersFound = $this->get('RequiredFiltersFound');
        if ($params->get('calendar_show_messages', '1') == '1' && $this->canAdd && $this->requiredFiltersFound) {
            $msg = JText::_('PLG_VISUALIZATION_CALENDAR_DOUBLE_CLICK_TO_ADD');
            $msg .= $model->getDateLimitsMsg();
            $app->enqueueMessage($msg);
        }
        JHTML::stylesheet('media/com_fabrik/css/list.css');
        // Get all list where statements - which are then included in the ajax call to ensure we get the correct data set loaded
        $urlfilters = new stdClass();
        $urlfilters->where = $model->buildQueryWhere();
        $urls = new stdClass();
        // Don't JRoute as its wont load with sef?
        $urls->del = 'index.php?option=com_' . $package . '&controller=visualization.calendar&view=visualization&task=deleteEvent&format=raw&Itemid=' . $Itemid . '&id=' . $id;
        $urls->add = 'index.php?option=com_' . $package . '&view=visualization&format=raw&Itemid=' . $Itemid . '&id=' . $id;
        $user = JFactory::getUser();
        $legend = $params->get('show_calendar_legend', 0) ? $model->getLegend() : '';
        $tpl = $j3 ? 'bootstrap' : 'default';
        $tpl = $params->get('calendar_layout', $j3);
        $options = new stdClass();
        $options->url = $urls;
        $options->dateLimits = $model->getDateLimits();
        $options->deleteables = $model->getDeleteAccess();
        $options->eventLists = $model->getEventLists();
        $options->calendarId = $calendar->id;
        $options->popwiny = $params->get('yoffset', 0);
        $options->urlfilters = $urlfilters;
        $options->canAdd = $this->canAdd;
        $options->showFullDetails = (bool) $params->get('show_full_details', false);
        $options->restFilterStart = FabrikWorker::getMenuOrRequestVar('resetfilters', 0, false, 'request');
        $options->tmpl = $tpl;
        $o = $model->getAddStandardEventFormInfo();
        if ($o != null) {
            $options->listid = $o->id;
        }
        // $$$rob @TODO not sure this is need - it isn't in the timeline viz
        $model->setRequestFilters();
        $options->filters = $model->filters;
        // End not sure
        $options->Itemid = $Itemid;
        $options->show_day = (bool) $params->get('show_day', true);
        $options->show_week = (bool) $params->get('show_week', true);
        $options->days = array(JText::_('SUNDAY'), JText::_('MONDAY'), JText::_('TUESDAY'), JText::_('WEDNESDAY'), JText::_('THURSDAY'), JText::_('FRIDAY'), JText::_('SATURDAY'));
        $options->shortDays = array(JText::_('SUN'), JText::_('MON'), JText::_('TUE'), JText::_('WED'), JText::_('THU'), JText::_('FRI'), JText::_('SAT'));
        $options->months = array(JText::_('JANUARY'), JText::_('FEBRUARY'), JText::_('MARCH'), JText::_('APRIL'), JText::_('MAY'), JText::_('JUNE'), JText::_('JULY'), JText::_('AUGUST'), JText::_('SEPTEMBER'), JText::_('OCTOBER'), JText::_('NOVEMBER'), JText::_('DECEMBER'));
        $options->shortMonths = array(JText::_('JANUARY_SHORT'), JText::_('FEBRUARY_SHORT'), JText::_('MARCH_SHORT'), JText::_('APRIL_SHORT'), JText::_('MAY_SHORT'), JText::_('JUNE_SHORT'), JText::_('JULY_SHORT'), JText::_('AUGUST_SHORT'), JText::_('SEPTEMBER_SHORT'), JText::_('OCTOBER_SHORT'), JText::_('NOVEMBER_SHORT'), JText::_('DECEMBER_SHORT'));
        $options->first_week_day = (int) $params->get('first_week_day', 0);
        $options->monthday = new stdClass();
        $options->monthday->width = (int) $params->get('calendar-monthday-width', 90);
        $options->monthday->height = (int) $params->get('calendar-monthday-height', 80);
        $options->greyscaledweekend = $params->get('greyscaled-week-end', 0) === '1';
        $options->viewType = $params->get('calendar_default_view', 'monthView');
        $options->weekday = new stdClass();
        $options->weekday->width = (int) $params->get('calendar-weekday-width', 90);
        $options->weekday->height = (int) $params->get('calendar-weekday-height', 10);
        $options->open = (int) $params->get('open-hour', 0);
        $options->close = (int) $params->get('close-hour', 24);
        $options->showweekends = (bool) $params->get('calendar-show-weekends', true);
        $options->readonly = (bool) $params->get('calendar-read-only', false);
        $options->timeFormat = $params->get('time_format', '%X');
        $options->readonlyMonth = (bool) $params->get('readonly_monthview', false);
        $options->j3 = FabrikWorker::j3();
        if (FabrikWorker::j3()) {
            $options->buttons = new stdClass();
            $options->buttons->del = '<button class="btn popupDelete" data-task="deleteCalEvent"><i class="icon-delete"></i></button>';
            $options->buttons->edit = '<button class="btn popupEdit" data-task="editCalEvent"><i class="icon-edit"></i></button>';
            $options->buttons->view = '<button class="btn popupView" data-task="viewCalEvent"><i class="icon-eye"></i></button>';
        } else {
            $src = COM_FABRIK_LIVESITE . 'plugins/fabrik_visualization/calendar/views/calendar/tmpl/' . $tpl . '/images/minus-sign.png';
            $options->buttons = '<img src="' . $src . '"
				alt = "del" class="fabrikDeleteEvent" />' . JText::_('PLG_VISUALIZATION_CALENDAR_DELETE');
        }
        $json = json_encode($options);
        JText::script('PLG_VISUALIZATION_CALENDAR_NEXT');
        JText::script('PLG_VISUALIZATION_CALENDAR_PREVIOUS');
        JText::script('PLG_VISUALIZATION_CALENDAR_DAY');
        JText::script('PLG_VISUALIZATION_CALENDAR_WEEK');
        JText::script('PLG_VISUALIZATION_CALENDAR_MONTH');
        JText::script('PLG_VISUALIZATION_CALENDAR_KEY');
        JText::script('PLG_VISUALIZATION_CALENDAR_TODAY');
        JText::script('PLG_VISUALIZATION_CALENDAR_CONF_DELETE');
        JText::script('PLG_VISUALIZATION_CALENDAR_DELETE');
        JText::script('PLG_VISUALIZATION_CALENDAR_VIEW');
        JText::script('PLG_VISUALIZATION_CALENDAR_EDIT');
        JText::script('PLG_VISUALIZATION_CALENDAR_ADD_EDIT_EVENT');
        JText::script('COM_FABRIK_FORM_SAVED');
        JText::script('PLG_VISUALIZATION_CALENDAR_EVENT_START_END');
        JText::script('PLG_VISUALIZATION_CALENDAR_DATE_ADD_TOO_LATE');
        JText::script('PLG_VISUALIZATION_CALENDAR_DATE_ADD_TOO_EARLY');
        $ref = $model->getJSRenderContext();
        $js = array();
        $js[] = "\tvar {$ref} = new fabrikCalendar('{$ref}');";
        $js[] = "\t{$ref}.render({$json});";
        $js[] = "\tFabrik.addBlock('" . $ref . "', {$ref});";
        $js[] = "\t" . $legend . "";
        $js[] = "" . $model->getFilterJs();
        $js = implode("\n", $js);
        $srcs = FabrikHelperHTML::framework();
        $srcs[] = 'media/com_fabrik/js/listfilter.js';
        $srcs[] = 'plugins/fabrik_visualization/calendar/calendar.js';
        FabrikHelperHTML::iniRequireJs($model->getShim());
        FabrikHelperHTML::script($srcs, $js);
        $viewName = $this->getName();
        $this->params = $model->getParams();
        $tpl = $params->get('calendar_layout', $tpl);
        $tmplpath = JPATH_ROOT . '/plugins/fabrik_visualization/calendar/views/calendar/tmpl/' . $tpl;
        $this->_setPath('template', $tmplpath);
        FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/calendar/views/calendar/tmpl/' . $tpl . '/template.css');
        // Adding custom.css, just for the heck of it
        FabrikHelperHTML::stylesheetFromPath('plugins/fabrik_visualization/calendar/views/calendar/tmpl/' . $tpl . '/custom.css');
        return parent::display();
    }
Exemple #4
0
 /**
  * Generic function to redirect
  *
  * @param   object  &$model  form model
  * @param   string  $msg     redirection message to show
  *
  * @return  string  redirect url
  */
 protected function makeRedirect(&$model, $msg = null)
 {
     $app = JFactory::getApplication();
     $package = $app->getUserState('com_fabrik.package', 'fabrik');
     $input = $app->input;
     $formId = $input->getInt('formid');
     $listId = $input->getInt('listid');
     $rowId = $input->getString('rowid', '', 'string');
     if (is_null($msg)) {
         $msg = FText::_('COM_FABRIK_RECORD_ADDED_UPDATED');
     }
     if ($app->isAdmin()) {
         // Admin option is always com_fabrik
         if (array_key_exists('apply', $model->formData)) {
             $url = 'index.php?option=com_fabrik&c=form&task=form&formid=' . $formId . '&listid=' . $listId . '&rowid=' . $rowId;
         } else {
             $url = 'index.php?option=com_fabrik&c=table&task=viewTable&cid[]=' . $model->getTable()->id;
         }
         $this->setRedirect($url, $msg);
     } else {
         if (array_key_exists('apply', $model->formData)) {
             $url = 'index.php?option=com_' . $package . '&c=form&view=form&formid=' . $formId . '&rowid=' . $rowId . '&listid=' . $listId;
         } else {
             if ($this->isMambot) {
                 // Return to the same page
                 $url = FArrayHelper::getValue($_SERVER, 'REQUEST_URI', 'index.php');
             } else {
                 // Return to the page that called the form
                 $url = $input->get('fabrik_referrer', 'index.php', 'string');
             }
             $itemId = FabrikWorker::itemId();
             if ($url == '') {
                 $url = 'index.php?option=com_' . $package . '&Itemid=' . $itemId;
             }
         }
         $config = JFactory::getConfig();
         if ($config->get('sef')) {
             $url = JRoute::_($url);
         }
         $this->setRedirect($url, $msg);
     }
 }
Exemple #5
0
 /**
  * Get the table's forms hidden fields
  *
  * @return  string  hidden fields
  */
 protected function loadTemplateBottom()
 {
     $app = JFactory::getApplication();
     $input = $app->input;
     $Itemid = FabrikWorker::itemId();
     $model = $this->getModel();
     $item = $model->getTable();
     $reffer = str_replace('&', '&amp;', $input->server->get('REQUEST_URI', '', 'string'));
     $reffer = FabrikString::removeQSVar($reffer, 'fabrik_incsessionfilters');
     $this->hiddenFields = array();
     // $$$ rob 15/12/2011 - if in com_content then doing this means you cant delete rows
     $this->hiddenFields[] = '<input type="hidden" name="option" value="' . $input->get('option', 'com_fabrik') . '" />';
     // $$$ rob 28/12/2011 but when using com_content as a value you cant filter!
     // $this->hiddenFields[] = '<input type="hidden" name="option" value="com_fabrik" />';
     $this->hiddenFields[] = '<input type="hidden" name="orderdir" value="' . $input->get('orderdir') . '" />';
     $this->hiddenFields[] = '<input type="hidden" name="orderby" value="' . $input->get('orderby') . '" />';
     // $$$ rob if the content plugin has temporarily set the view to list then get view from origview var, if that doesn't exist
     // revert to view var. Used when showing table in article/blog layouts
     $view = $input->get('origview', $input->get('view', 'list'));
     $this->hiddenFields[] = '<input type="hidden" name="view" value="' . $view . '" />';
     $this->hiddenFields[] = '<input type="hidden" name="listid" value="' . $item->id . '"/>';
     $this->hiddenFields[] = '<input type="hidden" name="listref" value="' . $this->renderContext . '"/>';
     $this->hiddenFields[] = '<input type="hidden" name="Itemid" value="' . $Itemid . '"/>';
     // Removed in favour of using list_{id}_limit dropdown box
     $this->hiddenFields[] = '<input type="hidden" name="fabrik_referrer" value="' . $reffer . '" />';
     $this->hiddenFields[] = JHTML::_('form.token');
     $this->hiddenFields[] = '<input type="hidden" name="format" value="html" />';
     // $packageId = $input->getInt('packageId', 0);
     // $$$ rob testing for ajax table in module
     $packageId = $model->packageId;
     $this->hiddenFields[] = '<input type="hidden" name="packageId" value="' . $packageId . '" />';
     if ($app->isAdmin()) {
         $this->hiddenFields[] = '<input type="hidden" name="task" value="list.view" />';
     } else {
         $this->hiddenFields[] = '<input type="hidden" name="task" value="" />';
     }
     $this->hiddenFields[] = '<input type="hidden" name="fabrik_listplugin_name" value="" />';
     $this->hiddenFields[] = '<input type="hidden" name="fabrik_listplugin_renderOrder" value="" />';
     // $$$ hugh - added this so plugins have somewhere to stuff any random data they need during submit
     $this->hiddenFields[] = '<input type="hidden" name="fabrik_listplugin_options" value="" />';
     $this->hiddenFields[] = '<input type="hidden" name="incfilters" value="1" />';
     // $$$ hugh - testing social profile hash stuff
     if ($input->get('fabrik_social_profile_hash', '') != '') {
         $this->hiddenFields[] = '<input type="hidden" name="fabrik_social_profile_hash" value="' . $input->get('fabrik_social_profile_hash', '', 'string') . '" />';
     }
     $this->hiddenFields = implode("\n", $this->hiddenFields);
 }
Exemple #6
0
 /**
  * Get Js Options
  *
  * @return stdClass
  * @throws Exception
  */
 private function jsOptions()
 {
     $model = $this->getModel();
     $app = JFactory::getApplication();
     $package = $app->getUserState('com_fabrik.package', 'fabrik');
     $params = $model->getParams();
     $Itemid = FabrikWorker::itemId();
     $urls = new stdClass();
     $calendar = $this->row;
     $j3 = FabrikWorker::j3();
     $tpl = $params->get('fullcalendar_layout', $j3);
     // Get all list where statements - which are then included in the ajax call to ensure we get the correct data set loaded
     $urlFilters = new stdClass();
     $urlFilters->where = $model->buildQueryWhere();
     // Don't JRoute as its wont load with sef?
     $urls->del = 'index.php?option=com_' . $package . '&controller=visualization.fullcalendar&view=visualization&task=deleteEvent&format=raw&Itemid=' . $Itemid . '&id=' . $model->getId();
     $urls->add = 'index.php?option=com_' . $package . '&view=visualization&format=raw&Itemid=' . $Itemid . '&id=' . $model->getId();
     $options = new stdClass();
     $options->url = $urls;
     $options->dateLimits = $model->getDateLimits();
     $options->deleteables = $model->getDeleteAccess();
     $options->eventLists = $model->getEventLists();
     $options->calendarId = $calendar->id;
     $options->popwiny = $params->get('yoffset', 0);
     $options->urlfilters = $urlFilters;
     $options->canAdd = $this->canAdd;
     $options->showFullDetails = (bool) $params->get('show_full_details', false);
     $options->restFilterStart = FabrikWorker::getMenuOrRequestVar('resetfilters', 0, false, 'request');
     $options->tmpl = $tpl;
     // $$$rob @TODO not sure this is need - it isn't in the timeline viz
     $model->setRequestFilters();
     $options->filters = $model->filters;
     // End not sure
     $options->Itemid = $Itemid;
     $options->show_day = (bool) $params->get('show_day', true);
     $options->show_week = (bool) $params->get('show_week', true);
     $options->default_view = $params->get('fullcalendar_default_view', 'month');
     $options->add_type = $params->get('add_type', 'both');
     $options->time_format = $params->get('time_format', 'H(:mm)');
     $options->first_week_day = (int) $params->get('first_week_day', 0);
     $options->minDuration = $params->get('minimum_duration', "00:30:00");
     $options->open = $params->get('open-hour', "00:00:00");
     $options->close = $params->get('close-hour', "23:59:59");
     $options->lang = FabrikWorker::getShortLang();
     $options->showweekends = (bool) $params->get('show-weekends', true);
     $options->greyscaledweekend = (bool) $params->get('greyscaled-weekend', false);
     $options->readonly = (bool) $params->get('calendar-read-only', false);
     $options->timeFormat = $params->get('time_format', '%X');
     $options->readonlyMonth = (bool) $params->get('readonly_monthview', false);
     $options->j3 = FabrikWorker::j3();
     $options->calOptions = $params->get('calOptions', '{}');
     $options->startOffset = (int) $params->get('startdate_hour_offset', '0');
     return $options;
 }
Exemple #7
0
 /**
  * Process the plugin, called after form is submitted
  *
  * @return  bool
  */
 public function onLastProcess()
 {
     $formModel = $this->getModel();
     $params = $this->getParams();
     $context = $formModel->getRedirectContext();
     // Get existing session params
     $surl = (array) $this->session->get($context . 'url', array());
     $stitle = (array) $this->session->get($context . 'title', array());
     $smsg = (array) $this->session->get($context . 'msg', array());
     $sshowsystemmsg = (array) $this->session->get($context . 'showsystemmsg', array());
     $this->formModel = $formModel;
     $w = new FabrikWorker();
     $form = $formModel->getForm();
     $this->data = $this->getProcessData();
     $this->data['append_jump_url'] = $params->get('append_jump_url');
     $this->data['save_and_next'] = $params->get('save_and_next', '0');
     $this->data['save_in_session'] = $params->get('save_insession');
     $this->data['jump_page'] = $w->parseMessageForPlaceHolder($params->get('jump_page'), $this->data);
     $this->data['thanks_message'] = $w->parseMessageForPlaceHolder($params->get('thanks_message'), $this->data);
     if (!$this->shouldRedirect($params)) {
         // Clear any session redirects
         unset($surl[$this->renderOrder]);
         unset($stitle[$this->renderOrder]);
         unset($smsg[$this->renderOrder]);
         unset($sshowsystemmsg[$this->renderOrder]);
         $this->session->set($context . 'url', $surl);
         $this->session->set($context . 'title', $stitle);
         $this->session->set($context . 'msg', $smsg);
         $this->session->set($context . 'showsystemmsg', $sshowsystemmsg);
         return true;
     }
     $this->_storeInSession();
     $sshowsystemmsg[$this->renderOrder] = true;
     $this->session->set($context . 'showsystemmsg', $sshowsystemmsg);
     if ($this->data['save_and_next'] === '1') {
         $navIds = $this->getNavIds();
         $next_rowid = $navIds->next == $navIds->last ? '' : '&rowid=' . $navIds->next;
         $itemId = FabrikWorker::itemId();
         if ($this->app->isAdmin()) {
             $url = 'index.php?option=com_' . $this->package . '&task=form.view&formid=' . $form->id . $keyIdentifier;
         } else {
             $url = 'index.php?option=com_' . $this->package . '&view=form&Itemid=' . $itemId . '&formid=' . $form->id . '&listid=' . $formModel->getListModel()->getId();
         }
         $url .= $next_rowid;
         $this->data['jump_page'] = JRoute::_($url);
     }
     if ($this->data['jump_page'] != '') {
         $this->data['jump_page'] = $this->buildJumpPage();
         // 3.0 ajax/module redirect logic handled in form controller not in plugin
         $surl[$this->renderOrder] = $this->data['jump_page'];
         $this->session->set($context . 'url', $surl);
         $this->session->set($context . 'redirect_content_how', $params->get('redirect_content_how', 'popup'));
         $this->session->set($context . 'redirect_content_popup_width', $params->get('redirect_content_popup_width', '300'));
         $this->session->set($context . 'redirect_content_popup_height', $params->get('redirect_content_popup_height', '300'));
         $this->session->set($context . 'redirect_content_popup_x_offset', $params->get('redirect_content_popup_x_offset', '0'));
         $this->session->set($context . 'redirect_content_popup_y_offset', $params->get('redirect_content_popup_y_offset', '0'));
         $this->session->set($context . 'redirect_content_popup_title', $params->get('redirect_content_popup_title', ''));
         $this->session->set($context . 'redirect_content_popup_reset_form', $params->get('redirect_content_popup_reset_form', '1'));
     } else {
         $msg = $this->data['thanks_message'];
         // Redirect not working in admin.
         if (!$this->app->isAdmin()) {
             $sshowsystemmsg[$this->renderOrder] = false;
             $this->session->set($context . 'showsystemmsg', $sshowsystemmsg);
             $stitle[$this->renderOrder] = $form->label;
             $this->session->set($context . 'title', $stitle);
             $surl[$this->renderOrder] = 'index.php?option=com_' . $this->package . '&view=plugin&g=form&plugin=redirect&method=displayThanks&task=pluginAjax';
             $this->session->set($context . 'url', $surl);
         }
     }
     $smsg[$this->renderOrder] = $this->data['thanks_message'];
     // Don't display system message if thanks is empty
     if (FArrayHelper::getValue($this->data, 'thanks_message', '') !== '') {
         $this->session->set($context . 'msg', $smsg);
     }
     return true;
 }
Exemple #8
0
 /**
  * Display the Feed
  *
  * @param   sting $tpl template
  *
  * @return void
  */
 public function display($tpl = null)
 {
     $input = $this->app->input;
     $itemId = FabrikWorker::itemId();
     $model = $this->getModel();
     $model->setOutPutFormat('feed');
     $this->doc->_itemTags = array();
     $table = $model->getTable();
     $model->render();
     $params = $model->getParams();
     if ($params->get('rss') == '0') {
         return '';
     }
     $formModel = $model->getFormModel();
     $form = $formModel->getForm();
     $aJoinsToThisKey = $model->getJoinsToThisKey();
     // Get headings
     $aTableHeadings = array();
     $groupModels = $formModel->getGroupsHiarachy();
     foreach ($groupModels as $groupModel) {
         $elementModels = $groupModel->getPublishedElements();
         foreach ($elementModels as $elementModel) {
             $element = $elementModel->getElement();
             $elParams = $elementModel->getParams();
             if ($elParams->get('show_in_rss_feed') == '1') {
                 $heading = $element->label;
                 if ($elParams->get('show_label_in_rss_feed') == '1') {
                     $aTableHeadings[$heading]['label'] = $heading;
                 } else {
                     $aTableHeadings[$heading]['label'] = '';
                 }
                 $aTableHeadings[$heading]['colName'] = $elementModel->getFullName();
                 $aTableHeadings[$heading]['dbField'] = $element->name;
                 $aTableHeadings[$heading]['key'] = $elParams->get('use_as_fake_key');
             }
         }
     }
     foreach ($aJoinsToThisKey as $element) {
         $element = $elementModel->getElement();
         $elParams = new JRegistry($element->attribs);
         if ($elParams->get('show_in_rss_feed') == '1') {
             $heading = $element->label;
             if ($elParams->get('show_label_in_rss_feed') == '1') {
                 $aTableHeadings[$heading]['label'] = $heading;
             } else {
                 $aTableHeadings[$heading]['label'] = '';
             }
             $aTableHeadings[$heading]['colName'] = $element->db_table_name . "___" . $element->name;
             $aTableHeadings[$heading]['dbField'] = $element->name;
             $aTableHeadings[$heading]['key'] = $elParams->get('use_as_fake_key');
         }
     }
     $w = new FabrikWorker();
     $rows = $model->getData();
     $this->doc->title = $w->parseMessageForPlaceHolder($table->label, $_REQUEST);
     $this->doc->description = htmlspecialchars(trim(strip_tags($w->parseMessageForPlaceHolder($table->introduction, $_REQUEST))));
     $this->doc->link = JRoute::_('index.php?option=com_' . $this->package . '&view=list&listid=' . $table->id . '&Itemid=' . $itemId);
     // Check for a custom css file and include it if it exists
     $tmpl = $input->get('layout', $table->template);
     $cssPath = COM_FABRIK_FRONTEND . '/views/list/tmpl/' . $tmpl . '/feed.css';
     if (file_exists($cssPath)) {
         $this->doc->addStyleSheet(COM_FABRIK_LIVESITE . 'components/com_fabrik/views/list/tmpl/' . $tmpl . '/feed.css');
     }
     $titleEl = $params->get('feed_title');
     $dateColId = (int) $params->get('feed_date', 0);
     $dateColElement = $formModel->getElement($dateColId, true);
     $dateEl = $this->db->qn($dateColElement->getFullName(false, false, false));
     $view = $model->canEdit() ? 'form' : 'details';
     // List of tags to look for in the row data
     // If they are there don't put them in the desc but put them in as a separate item param
     $rssTags = array('<georss:point>' => 'xmlns:georss="http://www.georss.org/georss"');
     foreach ($rows as $group) {
         foreach ($group as $row) {
             // Get the content
             $str2 = '';
             $str = '<table style="margin-top:10px;padding-top:10px;">';
             $title = '';
             $item = new JFeedItem();
             foreach ($aTableHeadings as $heading => $dbColName) {
                 if ($title == '') {
                     // Set a default title
                     $title = $row->{$dbColName}['colName'];
                 }
                 $rssContent = $row->{$dbColName}['colName'];
                 $found = false;
                 foreach ($rssTags as $rssTag => $namespace) {
                     if (strstr($rssContent, $rssTag)) {
                         $found = true;
                         if (!strstr($this->doc->_namespace, $namespace)) {
                             $rssTag = JString::substr($rssTag, 1, JString::strlen($rssTag) - 2);
                             $this->doc->_itemTags[] = $rssTag;
                             $this->doc->_namespace .= $namespace . "\n";
                         }
                         break;
                     }
                 }
                 if ($found) {
                     $item->{$rssTag} = $rssContent;
                 } else {
                     if ($dbColName['label'] == '') {
                         $str2 .= $rssContent . "<br />\n";
                     } else {
                         $str .= "<tr><td>" . $dbColName['label'] . ":</td><td>" . $rssContent . "</td></tr>\n";
                     }
                 }
             }
             if (isset($row->{$titleEl})) {
                 $title = $row->{$titleEl};
             }
             $str = $str2 . $str . "</table>";
             // Url link to article
             $link = JRoute::_('index.php?option=com_' . $this->package . '&view=' . $view . '&listid=' . $table->id . '&formid=' . $form->id . '&rowid=' . $row->__pk_val);
             // Strip html from feed item description text
             $author = @$row->created_by_alias ? @$row->created_by_alias : @$row->author;
             if ($dateEl != '') {
                 $date = $row->{$dateEl} ? date('r', strtotime(@$row->{$dateEl})) : '';
             } else {
                 $date = '';
             }
             // Load individual item creator class
             $item->title = $title;
             $item->link = $link;
             $item->guid = $link;
             $item->description = $str;
             $item->date = $date;
             $item->category = $row->category;
             // Loads item info into rss array
             $this->doc->addItem($item);
         }
     }
 }
Exemple #9
0
 /**
  * Create the form bottom hidden fields
  *
  * @param   object &$form Object containing form view properties
  *
  * @return  void
  */
 protected function _loadTmplBottom(&$form)
 {
     $input = $this->app->input;
     $itemId = FabrikWorker::itemId();
     /** @var FabrikFEModelForm $model */
     $model = $this->getModel();
     $listModel = $model->getListModel();
     $row = JArrayHelper::toObject($model->data);
     $canDelete = $listModel->canDelete($row);
     $params = $model->getParams();
     $task = 'form.process';
     $refer = $input->server->get('HTTP_REFERER', '', 'string');
     // $$$rob - if returning from a failed validation then we should use the fabrik_referrer post var
     $refer = str_replace('&', '&amp;', $input->get('fabrik_referrer', $refer, 'string'));
     $thisRowId = is_array($model->getRowId()) ? implode('|', $model->getRowId()) : $model->getRowId();
     $fields = array();
     $fields[] = '<input type="hidden" name="listid" value="' . $listModel->getId() . '" />';
     $fields[] = '<input type="hidden" name="listref" value="' . $listModel->getId() . '" />';
     $fields[] = '<input type="hidden" name="rowid" value="' . $thisRowId . '" />';
     $fields[] = '<input type="hidden" name="Itemid" value="' . $itemId . '" />';
     $fields[] = '<input type="hidden" name="option" value="com_' . $this->package . '" />';
     $fields[] = '<input type="hidden" name="task" value="' . $task . '" />';
     $fields[] = '<input type="hidden" name="isMambot" value="' . $this->isMambot . '" />';
     $fields[] = '<input type="hidden" name="formid" value="' . $model->get('id') . '" />';
     $fields[] = '<input type="hidden" name="returntoform" value="0" />';
     $fields[] = '<input type="hidden" name="fabrik_referrer" value="' . $refer . '" />';
     $fields[] = '<input type="hidden" name="fabrik_ajax" value="' . (int) $model->isAjax() . '" />';
     $fields[] = '<input type="hidden" name="package" value="' . $this->app->getUserState('com_fabrik.package', 'fabrik') . '" />';
     $fields[] = '<input type="hidden" name="packageId" value="' . $model->packageId . '" />';
     if ($useKey = FabrikWorker::getMenuOrRequestVar('usekey', '')) {
         // $$$rob v's been set from -1 to the actual row id - so ignore usekey not sure if we should comment this out
         // see http://fabrikar.com/forums/showthread.php?t=10297&page=5
         $fields[] = '<input type="hidden" name="usekey" value="' . $useKey . '" />';
         $pk_val = FArrayHelper::getValue($model->data, $listModel->getPrimaryKey(true));
         if (empty($pk_val)) {
             $fields[] = '<input type="hidden" name="usekey_newrecord" value="1" />';
         }
     }
     /** $$$ hugh - testing a fix for pagination issue when submitting a 'search form'.
      * If this is a search form, we need to clear 'limitstart', otherwise ... say we
      * were last on page 4 of the (unfiltered) target table, and the search yields less than 4 pages,
      * we end up with a blank table 'cos the wrong LIMIT's are applied to the query
      */
     $saveInSessions = $params->get('save_insession', '');
     if (is_array($saveInSessions)) {
         foreach ($saveInSessions as $saveInSession) {
             if ($saveInSession == '1') {
                 $fields[] = '<input type="hidden" name="limitstart" value="0" />';
                 break;
             }
         }
     }
     $fields[] = JHTML::_('form.token');
     $resetLabel = FText::_($params->get('reset_button_label'));
     $resetIcon = $params->get('reset_icon', '');
     $copyLabel = FText::_($params->get('copy_button_label'));
     $copyIcon = $params->get('copy_icon', '');
     $applyLabel = FText::_($params->get('apply_button_label'));
     $applyIcon = $params->get('apply_icon', '');
     $deleteLabel = FText::_($params->get('delete_button_label', 'Delete'));
     $deleteIcon = $params->get('delete_icon', '');
     $goBackLabel = FText::_($params->get('goback_button_label'));
     $goBackIcon = $params->get('goback_icon', '');
     $btnLayout = FabrikHelperHTML::getLayout('fabrik-button');
     if ($resetIcon !== '') {
         $resetIcon = FabrikHelperHTML::icon($resetIcon);
         $before = $params->get('reset_icon_location', 'before') == 'before';
         $resetLabel = $before ? $resetIcon . '&nbsp;' . $resetLabel : $resetLabel . '&nbsp;' . $resetIcon;
     }
     $layoutData = (object) array('type' => 'reset', 'class' => 'btn-warning button', 'name' => 'Reset', 'label' => $resetLabel);
     $form->resetButton = $params->get('reset_button', 0) && $this->editable == '1' ? $btnLayout->render($layoutData) : '';
     if ($copyIcon !== '') {
         $copyIcon = FabrikHelperHTML::icon($copyIcon);
         $copyLabel = $params->get('copy_icon_location', 'before') == 'before' ? $copyIcon . '&nbsp;' . $copyLabel : $copyLabel . '&nbsp;' . $copyIcon;
     }
     $layoutData = (object) array('type' => 'submit', 'class' => 'button', 'name' => 'Copy', 'label' => $copyLabel);
     $form->copyButton = $params->get('copy_button', 0) && $this->editable && $model->getRowId() != '' ? $btnLayout->render($layoutData) : '';
     if ($applyIcon !== '') {
         $applyIcon = FabrikHelperHTML::icon($applyIcon);
         $before = $params->get('apply_icon_location', 'before') == 'before';
         $applyLabel = $before ? $applyIcon . '&nbsp;' . $applyLabel : $applyLabel . '&nbsp;' . $applyIcon;
     }
     $layoutData = (object) array('type' => $model->isAjax() ? 'button' : 'submit', 'class' => 'button', 'name' => 'apply', 'label' => $applyLabel);
     $form->applyButton = $params->get('apply_button', 0) && $this->editable ? $btnLayout->render($layoutData) : '';
     if ($deleteIcon !== '') {
         $deleteIcon = FabrikHelperHTML::icon($deleteIcon);
         $before = $params->get('delete_icon_location', 'before') == 'before';
         $deleteLabel = $before ? $deleteIcon . '&nbsp;' . $deleteLabel : $deleteLabel . '&nbsp;' . $deleteIcon;
     }
     $layoutData = (object) array('type' => 'submit', 'class' => 'btn-danger button', 'name' => 'delete', 'label' => $deleteLabel);
     $form->deleteButton = $params->get('delete_button', 0) && $canDelete && $this->editable && $thisRowId != '' ? $btnLayout->render($layoutData) : '';
     if ($goBackIcon !== '') {
         $goBackIcon = FabrikHelperHTML::icon($goBackIcon);
         $before = $params->get('goback_icon_location', 'before') == 'before';
         $goBackLabel = $before ? $goBackIcon . '&nbsp;' . $goBackLabel : $goBackLabel . '&nbsp;' . $goBackIcon;
     }
     $layoutData = (object) array('type' => 'button', 'class' => 'button', 'name' => 'Goback', 'label' => $goBackLabel, 'attributes' => $model->isAjax() ? '' : FabrikWorker::goBackAction());
     $form->gobackButton = $params->get('goback_button', 0) ? $btnLayout->render($layoutData) : '';
     if ($model->isEditable() && $params->get('submit_button', 1)) {
         $submitClass = FabrikString::clean($form->submit_button_label);
         $submitIcon = $params->get('save_icon', '');
         $submitLabel = FText::_($form->submit_button_label);
         if ($submitIcon !== '') {
             $submitIcon = FabrikHelperHTML::icon($submitIcon);
             $before = $params->get('save_icon_location', 'before') == 'before';
             $submitLabel = $before ? $submitIcon . '&nbsp;' . $submitLabel : $submitLabel . '&nbsp;' . $submitIcon;
         }
         $layoutData = (object) array('type' => $model->isAjax() ? 'button' : 'submit', 'class' => 'btn-primary button ' . $submitClass, 'name' => 'Submit', 'label' => $submitLabel);
         $form->submitButton = $btnLayout->render($layoutData);
     } else {
         $form->submitButton = '';
     }
     if ($this->isMultiPage) {
         $layoutData = (object) array('type' => 'button', 'class' => 'fabrikPagePrevious button', 'name' => 'fabrikPagePrevious', 'label' => FabrikHelperHTML::icon('icon-previous', FText::_('COM_FABRIK_PREV')));
         $form->prevButton = $btnLayout->render($layoutData);
         $layoutData = (object) array('type' => 'button', 'class' => 'fabrikPageNext button', 'name' => 'fabrikPageNext', 'label' => FText::_('COM_FABRIK_NEXT') . '&nbsp;' . FabrikHelperHTML::icon('icon-next'));
         $form->nextButton = $btnLayout->render($layoutData);
     } else {
         $form->nextButton = '';
         $form->prevButton = '';
     }
     // $$$ hugh - hide actions section is we're printing, or if not actions selected
     $noButtons = empty($form->nextButton) && empty($form->prevButton) && empty($form->submitButton) && empty($form->gobackButton) && empty($form->deleteButton) && empty($form->applyButton) && empty($form->copyButton) && empty($form->resetButton);
     $this->hasActions = $input->get('print', '0') == '1' || $noButtons ? false : true;
     $format = $model->isAjax() ? 'raw' : 'html';
     $fields[] = '<input type="hidden" name="format" value="' . $format . '" />';
     $groups = $model->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         if ($groupModel->isJoin()) {
             $groupPk = $groupModel->getJoinModel()->getForeignId();
             // Use raw otherwise we inject the actual <input> into the hidden field's value
             $groupPk .= '_raw';
             $groupRowIds = (array) FArrayHelper::getValue($this->data, $groupPk, array());
             $groupRowIds = htmlentities(json_encode($groupRowIds));
             // Used to check against in group process(), when deleting removed repeat groups
             $fields[] = '<input type="hidden" name="fabrik_group_rowids[' . $groupModel->getId() . ']" value="' . $groupRowIds . '" />';
         }
         $group = $groupModel->getGroup();
         $c = $groupModel->repeatTotal;
         // Used for validations
         $fields[] = '<input type="hidden" name="fabrik_repeat_group[' . $group->id . ']" value="' . $c . '" id="fabrik_repeat_group_' . $group->id . '_counter" />';
     }
     // $$$ hugh - testing social_profile_hash stuff
     if ($input->get('fabrik_social_profile_hash', '') != '') {
         $fields[] = '<input type="hidden" name="fabrik_social_profile_hash" value="' . $input->get('fabrik_social_profile_hash', '') . '" id="fabrik_social_profile_hash" />';
     }
     $this->_cryptQueryString($fields);
     $this->_cryptViewOnlyElements($fields);
     $this->hiddenFields = implode("\n", $fields);
 }
Exemple #10
0
 /**
  * Display the Feed
  *
  * @param   sting  $tpl  template
  *
  * @return void
  */
 public function display($tpl = null)
 {
     $input = $this->app->input;
     $itemId = FabrikWorker::itemId();
     $model = $this->getModel();
     $model->setOutPutFormat('feed');
     $this->app->allowCache(true);
     if (!parent::access($model)) {
         exit;
     }
     $this->doc->_itemTags = array();
     // $$$ hugh - modified this so you can enable QS filters on RSS links
     // by setting &incfilters=1
     $input->set('incfilters', $input->getInt('incfilters', 0));
     $table = $model->getTable();
     $model->render();
     $params = $model->getParams();
     if ($params->get('rss') == '0') {
         return '';
     }
     $formModel = $model->getFormModel();
     $form = $formModel->getForm();
     $aJoinsToThisKey = $model->getJoinsToThisKey();
     // Get headings
     $aTableHeadings = array();
     $groupModels = $formModel->getGroupsHiarachy();
     $titleEl = $params->get('feed_title');
     $dateEl = (int) $params->get('feed_date');
     //$imageEl = $formModel->getElement($imageEl, true);
     $titleEl = $formModel->getElement($titleEl, true);
     $dateEl = $formModel->getElement($dateEl, true);
     $titleElName = $titleEl === false ? '' : $titleEl->getFullName(true, false);
     $dateElName = $dateEl === false ? '' : $dateEl->getFullName(true, false);
     $dateElNameRaw = $dateElName . '_raw';
     foreach ($groupModels as $groupModel) {
         $elementModels = $groupModel->getPublishedElements();
         foreach ($elementModels as $elementModel) {
             $element = $elementModel->getElement();
             $elParams = $elementModel->getParams();
             if ($elParams->get('show_in_rss_feed') == '1') {
                 $heading = $element->label;
                 if ($elParams->get('show_label_in_rss_feed') == '1') {
                     $aTableHeadings[$heading]['label'] = $heading;
                 } else {
                     $aTableHeadings[$heading]['label'] = '';
                 }
                 $aTableHeadings[$heading]['colName'] = $elementModel->getFullName();
                 $aTableHeadings[$heading]['dbField'] = $element->name;
                 // $$$ hugh - adding enclosure stuff for podcasting
                 if ($element->plugin == 'fileupload' || $elParams->get('use_as_rss_enclosure', '0') == '1') {
                     $aTableHeadings[$heading]['enclosure'] = true;
                 } else {
                     $aTableHeadings[$heading]['enclosure'] = false;
                 }
             }
         }
     }
     foreach ($aJoinsToThisKey as $element) {
         $element = $elementModel->getElement();
         $elParams = new Registry($element->attribs);
         if ($elParams->get('show_in_rss_feed') == '1') {
             $heading = $element->label;
             if ($elParams->get('show_label_in_rss_feed') == '1') {
                 $aTableHeadings[$heading]['label'] = $heading;
             } else {
                 $aTableHeadings[$heading]['label'] = '';
             }
             $aTableHeadings[$heading]['colName'] = $element->db_table_name . "___" . $element->name;
             $aTableHeadings[$heading]['dbField'] = $element->name;
             // $$$ hugh - adding enclosure stuff for podcasting
             if ($element->plugin == 'fileupload' || $elParams->get('use_as_rss_enclosure', '0') == '1') {
                 $aTableHeadings[$heading]['enclosure'] = true;
             } else {
                 $aTableHeadings[$heading]['enclosure'] = false;
             }
         }
     }
     $w = new FabrikWorker();
     $rows = $model->getData();
     $this->doc->title = htmlspecialchars($w->parseMessageForPlaceHolder($table->label, $_REQUEST), ENT_COMPAT, 'UTF-8');
     $this->doc->description = htmlspecialchars(trim(strip_tags($w->parseMessageForPlaceHolder($table->introduction, $_REQUEST))));
     $this->doc->link = JRoute::_('index.php?option=com_' . $this->package . '&view=list&listid=' . $table->id . '&Itemid=' . $itemId);
     $this->addImage($params);
     // Check for a custom css file and include it if it exists
     $tmpl = $input->get('layout', $table->template);
     $cssPath = COM_FABRIK_FRONTEND . 'views/list/tmpl/' . $tmpl . '/feed.css';
     if (file_exists($cssPath)) {
         $this->doc->addStyleSheet(COM_FABRIK_LIVESITE . 'components/com_fabrik/views/list/tmpl/' . $tmpl . '/feed.css');
     }
     $view = $model->canEdit() ? 'form' : 'details';
     // List of tags to look for in the row data
     // If they are there don't put them in the desc but put them in as a separate item param
     $rssTags = array('<georss:point>' => 'xmlns:georss="http://www.georss.org/georss"');
     foreach ($rows as $group) {
         foreach ($group as $row) {
             // Get the content
             $str2 = '';
             $str = '';
             $tStart = '<table style="margin-top:10px;padding-top:10px;">';
             $title = '';
             $item = new JFabrikFeedItem();
             $enclosures = array();
             foreach ($aTableHeadings as $heading => $dbColName) {
                 if ($dbColName['enclosure']) {
                     // $$$ hugh - diddling around trying to add enclosures
                     $colName = $dbColName['colName'] . '_raw';
                     $enclosureUrl = $row->{$colName};
                     if (!empty($enclosureUrl)) {
                         $remoteFile = false;
                         // Element value should either be a full path, or relative to J! base
                         if (strstr($enclosureUrl, 'http://') && !strstr($enclosureUrl, COM_FABRIK_LIVESITE)) {
                             $enclosureFile = $enclosureUrl;
                             $remoteFile = true;
                         } elseif (strstr($enclosureUrl, COM_FABRIK_LIVESITE)) {
                             $enclosureFile = str_replace(COM_FABRIK_LIVESITE, COM_FABRIK_BASE, $enclosureUrl);
                         } elseif (preg_match('#^' . COM_FABRIK_BASE . "#", $enclosureUrl)) {
                             $enclosureFile = $enclosureUrl;
                             $enclosureUrl = str_replace(COM_FABRIK_BASE, '', $enclosureUrl);
                         } else {
                             $enclosureFile = COM_FABRIK_BASE . $enclosureUrl;
                             $enclosureUrl = COM_FABRIK_LIVESITE . str_replace('\\', '/', $enclosureUrl);
                         }
                         if ($remoteFile || file_exists($enclosureFile) && !is_dir($enclosureFile)) {
                             $enclosureType = '';
                             if ($enclosureType = FabrikWorker::getPodcastMimeType($enclosureFile)) {
                                 $enclosure_size = $this->get_filesize($enclosureFile, $remoteFile);
                                 $enclosures[] = array('url' => $enclosureUrl, 'length' => $enclosure_size, 'type' => $enclosureType);
                                 /**
                                  * No need to insert the URL in the description, as feed readers should
                                  * automagically show 'media' when they see an 'enclosure', so just move on ..
                                  */
                                 continue;
                             }
                         }
                     }
                 }
                 if ($title == '') {
                     // Set a default title
                     $title = $row->{$dbColName}['colName'];
                 }
                 // Rob - was stripping tags - but aren't they valid in the content?
                 $rssContent = $row->{$dbColName}['colName'];
                 $found = false;
                 foreach ($rssTags as $rssTag => $namespace) {
                     if (strstr($rssContent, $rssTag)) {
                         $found = true;
                         $rssTag = JString::substr($rssTag, 1, JString::strlen($rssTag) - 2);
                         if (!strstr($this->doc->_namespace, $namespace)) {
                             $this->doc->_itemTags[] = $rssTag;
                             $this->doc->_namespace .= $namespace . " ";
                         }
                         break;
                     }
                 }
                 if ($found) {
                     $item->{$rssTag} = $rssContent;
                 } else {
                     if ($dbColName['label'] == '') {
                         $str2 .= $rssContent . "<br />\n";
                     } else {
                         $str .= "<tr><td>" . $dbColName['label'] . ":</td><td>" . $rssContent . "</td></tr>\n";
                     }
                 }
             }
             if (isset($row->{$titleElName})) {
                 $title = $row->{$titleElName};
             }
             if (FArrayHelper::getValue($dbColName, 'label') != '') {
                 $str = $tStart . $str . "</table>";
             } else {
                 $str = $str2;
             }
             // Url link to article
             $link = JRoute::_('index.php?option=com_' . $this->package . '&view=' . $view . '&listid=' . $table->id . '&formid=' . $form->id . '&rowid=' . $row->slug);
             $guid = COM_FABRIK_LIVESITE . 'index.php?option=com_' . $this->package . '&view=' . $view . '&listid=' . $table->id . '&formid=' . $form->id . '&rowid=' . $row->slug;
             // Strip html from feed item description text
             $author = @$row->created_by_alias ? @$row->created_by_alias : @$row->author;
             $item->date = isset($row->{$dateElName}) && $row->{$dateElName} ? date('r', strtotime(@$row->{$dateElNameRaw})) : '';
             // Load individual item creator class
             $item->title = $title;
             $item->link = $link;
             $item->guid = $guid;
             $item->description = $str;
             // $$$ hugh - not quite sure where we were expecting $row->category to come from.  Comment out for now.
             // $item->category = $row->category;
             foreach ($enclosures as $enclosure) {
                 $item->setEnclosure($enclosure);
             }
             // Loads item info into rss array
             $res = $this->doc->addItem($item);
         }
     }
 }
Exemple #11
0
 /**
  * Set the List's tab HTML
  *
  * @return  array  Tabs
  */
 public function loadTabs()
 {
     $this->tabs = array();
     $tabs = $this->getTabCategories();
     if (!is_array($tabs) || empty($tabs)) {
         return $this->tabs;
     }
     $package = $this->app->getUserState('com_fabrik.package', 'fabrik');
     $listId = $this->getId();
     $tabsField = $this->getTabField();
     $itemId = FabrikWorker::itemId();
     $uri = JURI::getInstance();
     $urlBase = $uri->toString(array('path'));
     $urlBase .= '?option=com_' . $package . '&';
     if ($this->app->isAdmin()) {
         $urlBase .= 'task=list.view&';
     } else {
         $urlBase .= 'view=list&';
     }
     $urlBase .= 'listid=' . $listId . '&resetfilters=1';
     $urlEquals = $urlBase . '&' . $tabsField . '=%s';
     $urlRange = $urlBase . '&' . $tabsField . '[value][]=%s&' . $tabsField . '[value][]=%s&' . $tabsField . '[condition]=BETWEEN';
     $uri = JURI::getInstance();
     $thisUri = rawurldecode($uri->toString(array('path', 'query')));
     foreach ($tabs as $i => $tabArray) {
         $row = new stdClass();
         list($label, $range) = $tabArray;
         $row->label = $label;
         if (is_null($range)) {
             $row->href = $urlBase;
         } elseif (!is_array($range)) {
             $row->href = sprintf($urlEquals, $range);
         } else {
             list($low, $high) = $range;
             $row->href = sprintf($urlEquals, sprintf($urlRange, $low, $high));
         }
         if ($itemId) {
             $row->href .= '&Itemid=' . $itemId;
         }
         $row->id = 'list_tabs_' . $this->getId() . '_' . $i;
         $row->js = false;
         $row->class = $thisUri == $row->href ? 'active' : '';
         $this->tabs[] = $row;
     }
     return $this->tabs;
 }
Exemple #12
0
 /**
  * Get redirect URL
  *
  * @param   bool  $incSession  Set url in session?
  * @param   bool  $isMambot    Is Mambot
  *
  * @return   array  url: string  Redirect url, baseRedirect (True: default redirect, False: plugin redirect)
  *
  * @since 3.0.6 (was in form controller)
  */
 public function getRedirectURL($incSession = true, $isMambot = false)
 {
     $input = $this->app->input;
     if ($this->app->isAdmin()) {
         // Admin always uses option com_fabrik
         if (array_key_exists('apply', $this->formData)) {
             $url = 'index.php?option=com_fabrik&task=form.view&formid=' . $input->getInt('formid') . '&rowid=' . $input->getString('rowid', '', 'string');
         } else {
             $url = 'index.php?option=com_fabrik&task=list.view&listid=' . $this->getListModel()->getId();
         }
     } else {
         if (array_key_exists('apply', $this->formData)) {
             $url = 'index.php?option=com_' . $this->package . '&view=form&formid=' . $input->getInt('formid') . '&rowid=' . $input->getString('rowid', '', 'string') . '&listid=' . $input->getInt('listid');
         } else {
             if ($isMambot) {
                 // Return to the same page
                 $url = filter_var(ArrayHelper::getValue($_SERVER, 'HTTP_REFERER', 'index.php'), FILTER_SANITIZE_URL);
             } else {
                 // Return to the page that called the form
                 $url = urldecode($input->post->get('fabrik_referrer', 'index.php', 'string'));
             }
             $itemId = (int) FabrikWorker::itemId();
             if ($url == '') {
                 if ($itemId !== 0) {
                     $url = 'index.php?' . http_build_query($this->app->getMenu('site')->getActive()->query) . '&Itemid=' . $itemId;
                 } else {
                     // No menu link so redirect back to list view
                     $url = 'index.php?option=com_' . $this->package . '&view=list&listid=' . $input->getInt('listid');
                 }
             }
         }
         if ($this->config->get('sef')) {
             $url = JRoute::_($url);
         }
     }
     // 3.0 need to distinguish between the default redirect and redirect plugin
     $baseRedirect = true;
     if (!$incSession) {
         return array('url' => $url, 'baseRedirect' => $baseRedirect);
     }
     $formdata = $this->session->get('com_' . $this->package . '.form.data');
     $context = $this->getRedirectContext();
     // If the redirect plug-in has set a url use that in preference to the default url
     $sUrl = $this->session->get($context . 'url', array());
     if (!empty($sUrl)) {
         $baseRedirect = false;
     }
     if (!is_array($sUrl)) {
         $sUrl = array($sUrl);
     }
     if (empty($sUrl)) {
         $sUrl[] = $url;
     }
     $url = array_shift($sUrl);
     $this->session->set($context . 'url', $sUrl);
     // Redirect URL which set prefilters of < were converted to &lt; which then gave mySQL error
     $url = htmlspecialchars_decode($url);
     return array('url' => $url, 'baseRedirect' => $baseRedirect);
 }
Exemple #13
0
 /**
  * Build Pop up form URL
  *
  * @return boolean|string
  */
 protected function popUpFormUrl()
 {
     $app = JFactory::getApplication();
     $package = $app->getUserState('com_fabrik.package', 'fabrik');
     $params = $this->getParams();
     $popupformid = (int) $params->get('databasejoin_popupform');
     if ($popupformid === 0) {
         return false;
     }
     $db = $this->getDb();
     $query = $db->getQuery(true);
     $query->select('id')->from('#__{package}_lists')->where('form_id =' . $popupformid);
     $db->setQuery($query);
     $listid = $db->loadResult();
     $itemId = FabrikWorker::itemId($listid);
     $task = $app->isAdmin() ? 'task=details.view' : 'view=details';
     $url = 'index.php?option=com_' . $package . '&' . $task . '&formid=' . $popupformid . '&listid=' . $listid;
     if (!$app->isAdmin()) {
         $url .= '&Itemid=' . $itemId;
     }
     $url .= '&rowid=';
     return $url;
 }
Exemple #14
0
 /**
  * Query all tables linked to the calendar and return them
  *
  * @return  string	javascript array containing json objects
  */
 public function getEvents()
 {
     $itemId = FabrikWorker::itemId();
     $tzOffset = $this->config->get('offset');
     $tz = new DateTimeZone($tzOffset);
     $w = new FabrikWorker();
     $this->setupEvents();
     $jsEvents = array();
     $input = $this->app->input;
     $where = $input->get('where', array(), 'array');
     foreach ($this->events as $listId => $record) {
         $this_where = FArrayHelper::getValue($where, $listId, '');
         $this_where = html_entity_decode($this_where, ENT_QUOTES);
         /** @var FabrikFEModelList $listModel */
         $listModel = JModelLegacy::getInstance('list', 'FabrikFEModel');
         $listModel->setId($listId);
         if (!$listModel->canView()) {
             continue;
         }
         $table = $listModel->getTable();
         $els = $listModel->getElements();
         $formModel = $listModel->getFormModel();
         foreach ($record as $data) {
             $db = $listModel->getDb();
             $startDate = trim($data['startdate']) !== '' ? FabrikString::safeColName($data['startdate']) : '\'\'';
             if ($data['startdate'] == '') {
                 throw new RuntimeException('No start date selected ', 500);
                 return;
             }
             $startElement = $formModel->getElement($data['startdate']);
             $endDate = trim($data['enddate']) !== '' ? FabrikString::safeColName($data['enddate']) : "''";
             $endElement = trim($data['enddate']) !== '' ? $formModel->getElement($data['enddate']) : $startElement;
             $startLocal = $store_as_local = (bool) $startElement->getParams()->get('date_store_as_local', false);
             $endLocal = $store_as_local = (bool) $endElement->getParams()->get('date_store_as_local', false);
             $label = trim($data['label']) !== '' ? FabrikString::safeColName($data['label']) : "''";
             $customUrl = $data['customUrl'];
             $qLabel = $label;
             if (array_key_exists($qLabel, $els)) {
                 // If db join selected for the label we need to get the label element and not the value
                 if (method_exists($els[$qLabel], 'getJoinLabelColumn')) {
                     $label = $els[$qLabel]->getJoinLabelColumn();
                 } else {
                     $label = FabrikString::safeColName($els[$qLabel]->getOrderByName());
                 }
             }
             $pk = $listModel->getPrimaryKey();
             $query = $db->getQuery(true);
             $query = $listModel->buildQuerySelect('list', $query);
             $status = trim($data['status']) !== '' ? FabrikString::safeColName($data['status']) : "''";
             $query->select($pk . ' AS id, ' . $pk . ' AS rowid, ' . $startDate . ' AS startdate, ' . $endDate . ' AS enddate')->select('"" AS link, ' . $label . ' AS label, ' . $db->q($data['colour']) . ' AS colour, 0 AS formid')->select($status . ' AS status')->order($startDate . ' ASC');
             $query = $listModel->buildQueryJoin($query);
             //$this_where = trim(str_replace('WHERE', '', $this_where));
             $this_where = FabrikString::ltrimiword($this_where, 'WHERE');
             $query = $this_where === '' ? $listModel->buildQueryWhere(true, $query) : $query->where($this_where);
             $db->setQuery($query);
             $formData = $db->loadObjectList();
             if (is_array($formData)) {
                 foreach ($formData as $row) {
                     if ($row->startdate != '') {
                         $defaultURL = 'index.php?option=com_' . $this->package . '&Itemid=' . $itemId . '&view=form&formid=' . $table->form_id . '&rowid=' . $row->id . '&tmpl=component';
                         $thisCustomUrl = $w->parseMessageForPlaceHolder($customUrl, $row);
                         $row->link = $thisCustomUrl !== '' ? $thisCustomUrl : $defaultURL;
                         $row->custom = $customUrl != '';
                         $row->_listid = $table->id;
                         $row->_canDelete = (bool) $listModel->canDelete();
                         $row->_canEdit = (bool) $listModel->canEdit($row);
                         $row->_canView = (bool) $listModel->canViewDetails();
                         //Format local dates toISO8601
                         $myDate = new DateTime($row->startdate);
                         $row->startdate_locale = $myDate->format(DateTime::RFC3339);
                         $myDate = new DateTime($row->enddate);
                         $row->enddate_locale = $myDate->format(DateTime::RFC3339);
                         // Added timezone offset
                         if ($row->startdate !== $db->getNullDate() && $data['startShowTime'] == true) {
                             $date = JFactory::getDate($row->startdate);
                             $row->startdate = $date->format('Y-m-d H:i:s', true);
                             if ($startLocal) {
                                 //Format local dates toISO8601
                                 $myDate = new DateTime($row->startdate);
                                 $row->startdate_locale = $myDate->format(DateTime::RFC3339);
                             } else {
                                 $date->setTimezone($tz);
                                 $row->startdate_locale = $date->toISO8601(true);
                             }
                         }
                         if ($row->enddate !== $db->getNullDate() && (string) $row->enddate !== '') {
                             if ($data['endShowTime'] == true) {
                                 $date = JFactory::getDate($row->enddate);
                                 $row->enddate = $date->format('Y-m-d H:i:d');
                                 if ($endLocal) {
                                     //Format local dates toISO8601
                                     $myDate = new DateTime($row->enddate);
                                     $row->enddate_locale = $myDate->format(DateTime::RFC3339);
                                 } else {
                                     $date->setTimezone($tz);
                                     $row->enddate_locale = $date->toISO8601(true);
                                 }
                             }
                         } else {
                             $row->enddate = $row->startdate;
                             $row->enddate_locale = isset($row->startdate_locale) ? $row->startdate_locale : '';
                         }
                         $jsEvents[$table->id . '_' . $row->id . '_' . $row->startdate] = clone $row;
                     }
                 }
             }
         }
     }
     $addEvent = json_encode($jsEvents);
     return $addEvent;
 }
Exemple #15
0
 /**
  * Create print URL
  *
  * @param   object  $formModel  form model
  *
  * @since   3.0.6
  *
  * @return  string
  */
 public static function printURL($formModel)
 {
     /**
      * Comment this out for now, as it causes issues with multiple forms per page.
      * We could always create a $sig for it, but that would need the info from the form and
      * table models, which are probably the most 'expensive' aprt of this function anyway.
      */
     /*
     if (isset(self::$printURL))
     {
     	return self::$printURL;
     }
     */
     $app = JFactory::getApplication();
     $input = $app->input;
     $form = $formModel->getForm();
     $package = $app->getUserState('com_fabrik.package', 'fabrik');
     $table = $formModel->getTable();
     $url = COM_FABRIK_LIVESITE . 'index.php?option=com_' . $package . '&view=details&tmpl=component&formid=' . $form->id . '&listid=' . $table->id . '&rowid=' . $formModel->getRowId() . '&iframe=1&print=1';
     $url .= '&Itemid=' . FabrikWorker::itemId();
     /* $$$ hugh - @TODO - FIXME - if they were using rowid=-1, we don't need this, as rowid has already been transmogrified
      * to the correct (PK based) rowid.  but how to tell if original rowid was -1???
      */
     if ($input->get('usekey') !== null) {
         $url .= '&usekey=' . $input->get('usekey');
     }
     $url = JRoute::_($url);
     // $$$ rob for some reason JRoute wasn't doing this ???
     $url = str_replace('&', '&amp;', $url);
     self::$printURL = $url;
     return self::$printURL;
 }
Exemple #16
0
 /**
  * Create the form bottom hidden fields
  *
  * @param   object  &$form  Object containing form view properties
  *
  * @return  void
  */
 protected function _loadTmplBottom(&$form)
 {
     $app = JFactory::getApplication();
     $package = $app->getUserState('com_fabrik.package', 'fabrik');
     $input = $app->input;
     $Itemid = FabrikWorker::itemId();
     $model = $this->getModel();
     $listModel = $model->getListModel();
     $row = JArrayHelper::toObject($model->data);
     $canDelete = $listModel->canDelete($row);
     $params = $model->getParams();
     $task = 'form.process';
     $refer = $input->server->get('HTTP_REFERER', '', 'string');
     // $$$rob - if returning from a failed validation then we should use the fabrik_referrer post var
     $refer = str_replace('&', '&amp;', $input->get('fabrik_referrer', $refer, 'string'));
     $this_rowid = is_array($model->getRowId()) ? implode('|', $model->getRowId()) : $model->getRowId();
     $fields = array();
     $fields[] = '<input type="hidden" name="listid" value="' . $listModel->getId() . '" />';
     $fields[] = '<input type="hidden" name="listref" value="' . $listModel->getId() . '" />';
     $fields[] = '<input type="hidden" name="rowid" value="' . $this_rowid . '" />';
     $fields[] = '<input type="hidden" name="Itemid" value="' . $Itemid . '" />';
     $fields[] = '<input type="hidden" name="option" value="com_' . $package . '" />';
     $fields[] = '<input type="hidden" name="task" value="' . $task . '" />';
     $fields[] = '<input type="hidden" name="isMambot" value="' . $this->isMambot . '" />';
     $fields[] = '<input type="hidden" name="formid" value="' . $model->get('id') . '" />';
     $fields[] = '<input type="hidden" name="returntoform" value="0" />';
     $fields[] = '<input type="hidden" name="fabrik_referrer" value="' . $refer . '" />';
     $fields[] = '<input type="hidden" name="fabrik_ajax" value="' . (int) $model->isAjax() . '" />';
     $fields[] = '<input type="hidden" name="package" value="' . $app->getUserState('com_fabrik.package', 'fabrik') . '" />';
     $fields[] = '<input type="hidden" name="packageId" value="' . $model->packageId . '" />';
     if ($usekey = FabrikWorker::getMenuOrRequestVar('usekey', '')) {
         // $$$rob v's been set from -1 to the actual row id - so ignore usekey not sure if we should comment this out
         // see http://fabrikar.com/forums/showthread.php?t=10297&page=5
         $fields[] = '<input type="hidden" name="usekey" value="' . $usekey . '" />';
         $pk_val = JArrayHelper::getValue($model->data, FabrikString::safeColNameToArrayKey($listModel->getTable()->db_primary_key));
         if (empty($pk_val)) {
             $fields[] = '<input type="hidden" name="usekey_newrecord" value="1" />';
         }
     }
     /** $$$ hugh - testing a fix for pagination issue when submitting a 'search form'.
      * If this is a search form, we need to clear 'limitstart', otherwise ... say we
      * were last on page 4 of the (unfiltered) target table, and the search yields less than 4 pages,
      * we end up with a blank table 'cos the wrong LIMIT's are applied to the query
      */
     $save_insessions = $params->get('save_insession', '');
     if (is_array($save_insessions)) {
         foreach ($save_insessions as $save_insession) {
             if ($save_insession == '1') {
                 $fields[] = '<input type="hidden" name="limitstart" value="0" />';
                 break;
             }
         }
     }
     $fields[] = JHTML::_('form.token');
     $resetLabel = JText::_($params->get('reset_button_label'));
     $resetIcon = $params->get('reset_icon', '');
     $copyLabel = JText::_($params->get('copy_button_label'));
     $copyIcon = $params->get('copy_icon', '');
     $applyLabel = JText::_($params->get('apply_button_label'));
     $applyIcon = $params->get('apply_icon', '');
     $deleteLabel = JText::_($params->get('delete_button_label', 'Delete'));
     $deleteIcon = $params->get('delete_icon', '');
     $goBackLabel = JText::_($params->get('goback_button_label'));
     $goBackIcon = $params->get('goback_icon', '');
     if ($resetIcon !== '') {
         $resetIcon = '<i class="' . $resetIcon . '"></i>';
         $before = $params->get('reset_icon_location', 'before') == 'before';
         $resetLabel = $before ? $resetIcon . '&nbsp;' . $resetLabel : $resetLabel . '&nbsp;' . $resetIcon;
     }
     $form->resetButton = $params->get('reset_button', 0) && $this->editable == "1" ? '<button type="reset" class="btn btn-warning button" name="Reset">' . $resetLabel . '</button>' : '';
     if ($copyIcon !== '') {
         $copyIcon = '<i class="' . $copyIcon . '"></i>';
         $copyLabel = $params->get('copy_icon_location', 'before') == 'before' ? $copyIcon . '&nbsp;' . $copyLabel : $copyLabel . '&nbsp;' . $copyIcon;
     }
     $form->copyButton = $params->get('copy_button', 0) && $this->editable && $model->getRowId() != '' ? '<button type="submit" class="btn button" name="Copy">' . $copyLabel . '</button>' : '';
     if ($applyIcon !== '') {
         $applyIcon = '<i class="' . $applyIcon . '"></i>';
         $before = $params->get('apply_icon_location', 'before') == 'before';
         $applyLabel = $before ? $applyIcon . '&nbsp;' . $applyLabel : $applyLabel . '&nbsp;' . $applyIcon;
     }
     $applyButtonType = $model->isAjax() ? 'button' : 'submit';
     $form->applyButton = $params->get('apply_button', 0) && $this->editable ? '<button type="' . $applyButtonType . '" class="btn button" name="apply">' . $applyLabel . '</button>' : '';
     if ($deleteIcon !== '') {
         $deleteIcon = '<i class="' . $deleteIcon . '"></i>';
         $before = $params->get('delete_icon_location', 'before') == 'before';
         $deleteLabel = $before ? $deleteIcon . '&nbsp;' . $deleteLabel : $deleteLabel . '&nbsp;' . $deleteIcon;
     }
     $form->deleteButton = $params->get('delete_button', 0) && $canDelete && $this->editable && $this_rowid != '' ? '<button type="submit" class="btn btn-danger button" name="delete">' . $deleteLabel . '</button>' : '';
     if ($goBackIcon !== '') {
         $goBackIcon = '<i class="' . $goBackIcon . '"></i>';
         $before = $params->get('goback_icon_location', 'before') == 'before';
         $goBackLabel = $before ? $goBackIcon . '&nbsp;' . $goBackLabel : $goBackLabel . '&nbsp;' . $goBackIcon;
     }
     $goBack = $model->isAjax() ? '' : FabrikWorker::goBackAction();
     $form->gobackButton = $params->get('goback_button', 0) ? '<button type="button" class="btn button" name="Goback" ' . $goBack . '>' . $goBackLabel . '</button>' : '';
     if ($model->isEditable() && $params->get('submit_button', 1)) {
         $button = $model->isAjax() ? "button" : "submit";
         $submitClass = FabrikString::clean($form->submit_button_label);
         $submitIcon = $params->get('save_icon', '');
         $submitLabel = JText::_($form->submit_button_label);
         if ($submitIcon !== '') {
             $submitIcon = '<i class="' . $submitIcon . '"></i>';
             $before = $params->get('save_icon_location', 'before') == 'before';
             $submitLabel = $before ? $submitIcon . '&nbsp;' . $submitLabel : $submitLabel . '&nbsp;' . $submitIcon;
         }
         $form->submitButton = '<button type="' . $button . '" class="btn btn-primary button ' . $submitClass . '" name="Submit">' . $submitLabel . '</button>';
     } else {
         $form->submitButton = '';
     }
     if ($this->isMultiPage) {
         $form->prevButton = '<button type="button" class="btn fabrikPagePrevious button" name="fabrikPagePrevious"><i class="icon-previous"></i>&nbsp;' . JText::_('COM_FABRIK_PREV') . '</button>';
         $form->nextButton = '<button type="button" class="btn fabrikPageNext button" name="fabrikPageNext">' . JText::_('COM_FABRIK_NEXT') . '&nbsp;<i class="icon-next"></i></button>';
     } else {
         $form->nextButton = '';
         $form->prevButton = '';
     }
     // $$$ hugh - hide actions section is we're printing, or if not actions selected
     $noButtons = empty($form->nextButton) && empty($form->prevButton) && empty($form->submitButton) && empty($form->gobackButton) && empty($form->deleteButton) && empty($form->applyButton) && empty($form->copyButton) && empty($form->resetButton);
     if ($input->get('print', '0') == '1' || $noButtons) {
         $this->hasActions = false;
     } else {
         $this->hasActions = true;
     }
     $format = $model->isAjax() ? 'raw' : 'html';
     $fields[] = '<input type="hidden" name="format" value="' . $format . '" />';
     $groups = $model->getGroupsHiarachy();
     foreach ($groups as $groupModel) {
         $group = $groupModel->getGroup();
         $c = $groupModel->repeatTotal;
         // Used for validations
         $fields[] = '<input type="hidden" name="fabrik_repeat_group[' . $group->id . ']" value="' . $c . '" id="fabrik_repeat_group_' . $group->id . '_counter" />';
     }
     // $$$ hugh - testing social_profile_hash stuff
     if ($input->get('fabrik_social_profile_hash', '') != '') {
         $fields[] = '<input type="hidden" name="fabrik_social_profile_hash" value="' . $input->get('fabrik_social_profile_hash', '') . '" id="fabrik_social_profile_hash" />';
     }
     $this->_cryptQueryString($fields);
     $this->_cryptViewOnlyElements($fields);
     $this->hiddenFields = implode("\n", $fields);
 }