function display() { $app = JFactory::getApplication(); $Itemid = $app->getMenu('site')->getActive()->id; $config = JFactory::getConfig(); $user = JFactory::getUser(); $model =& $this->getModel(); $model->_outPutFormat == 'feed'; $document = JFactory::getDocument(); $document->_itemTags = array(); //Get the active menu item $usersConfig = JComponentHelper::getParams('com_fabrik'); JRequest::setVar('incfilters', 0); $table = $model->getTable(); $model->render(); $params =& $model->getParams(); if ($params->get('rss') == '0') { return ''; } $formModel = $model->getForm(); $form = $formModel->getForm(); $aJoinsToThisKey = $model->getJoinsToThisKey(); /* get headings */ $aTableHeadings = array(); $groupModels = $formModel->getGroupsHiarachy(); $titleEl = $params->get('feed_title'); $dateEl = $params->get('feed_date'); foreach ($groupModels as $groupModel) { $elementModels = $groupModel->getPublishedElements(); foreach ($elementModels as $elementModel) { $element = $elementModel->getElement(); if ($element->id == $titleEl) { $titleEl = $elementModel->getFullName(false, true, false); } if ($element->id == $dateEl) { $dateEl = $elementModel->getFullName(false, true, false); } $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(false, true); $aTableHeadings[$heading]['dbField'] = $element->name; $aTableHeadings[$heading]['key'] = $elParams->get('use_as_fake_key'); // $$$ hugh - adding enclosure stuff for podcasting if ($element->plugin == 'fabrikfileupload') { $aTableHeadings[$heading]['enclosure'] = true; } else { $aTableHeadings[$heading]['enclosure'] = false; } } } } foreach ($aJoinsToThisKey as $element) { $element = $elementModel->getElement(); $elParams = new fabrikParams($element->attribs, JPATH_SITE . '/administrator/components/com_fabrik/xml/element.xml', 'component'); 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'); // $$$ hugh - adding enclosure stuff for podcasting if ($element->plugin == 'fabrikfileupload') { $aTableHeadings[$heading]['enclosure'] = true; } else { $aTableHeadings[$heading]['enclosure'] = false; } } } $w = new FabrikWorker(); $rows = $model->getData(); $document->title = $w->parseMessageForPlaceHolder($table->label, $_REQUEST); $document->description = $w->parseMessageForPlaceHolder($table->introduction); $document->link = JRoute::_('index.php?option=com_fabrik&view=list&listid='.$table->id.'&Itemid='.$Itemid); /* check for a custom css file and include it if it exists*/ $tmpl = JRequest::getVar('layout', $table->template); $csspath = COM_FABRIK_FRONTEND.DS."views".DS."list".DS."tmpl".DS.$tmpl.DS.'feed.css'; if (file_exists($csspath)) { $document->addStyleSheet(COM_FABRIK_LIVESITE."components/com_fabrik/views/table/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 seperate item param $rsstags = array( '<georss:point>' => 'xmlns:georss="http://www.georss.org/georss"' ); foreach ($rows as $group) { foreach ($group as $row) { // strip html from feed item title //$title = html_entity_decode($this->escape( $row->$titleEl)); //get the content $str2 = ''; $str = '<table style="margin-top:10px;padding-top:10px;">'; //used for content not in dl //ok for feed gator you cant have the same item title so we'll take the first value from the table (asume its the pk and use that to append to the item title)' $title = ''; $item = new JFabrikFeedItem(); $enclosures = array(); foreach ($aTableHeadings as $heading=>$dbcolname) { if ($dbcolname['enclosure']) { // $$$ hugh - diddling aorund trying to add enclosures $colName = $dbcolname['colName'] . '_raw'; $enclosure_url = $row->$colName; if (!empty($enclosure_url)) { $enclosure_file = COM_FABRIK_BASE.$enclosure_url; $enclosure_url = COM_FABRIK_LIVESITE . str_replace('\\','/',$enclosure_url); if (file_exists($enclosure_file) and !is_dir($enclosure_file)) { $enclosure_type = ''; if ($enclosure_type = FabrikWorker::getAudioMimeType($enclosure_file)) { $enclosure_size = filesize($enclosure_file); $enclosures[] = array( 'url' => $enclosure_url, 'length' => $enclosure_size, 'type' => $enclosure_type ); // 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']; } $rsscontent = $row->$dbcolname['colName']; $found = false; foreach ($rsstags as $rsstag =>$namespace) { if (strstr($rsscontent, $rsstag)) { $found = true; $rsstag = substr($rsstag, 1, strlen($rsstag)-2); if (!strstr($document->_namespace, $namespace)) { $document->_itemTags[] = $rsstag; $document->_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->$titleEl)) { $title = $row->$titleEl; } $str = $str2 . $str . "</table>"; // url link to article $link = JRoute::_('index.php?option=com_fabrik&view='.$view.'&listid='.$table->id.'&formid='.$form->id.'&rowid='. $row->slug); $guid = COM_FABRIK_LIVESITE . 'index.php?option=com_fabrik&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; 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 = $guid; $item->description = $str; $item->date = $date; // $$$ 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 $document->addItem( $item); } } }
/** * 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); } } }