function template_display_my_feed(&$feed_row) { global $image_path, $even_bg, $sugar_config, $mod_strings; if (!defined('DOMIT_RSS_INCLUDE_PATH')) { define('DOMIT_RSS_INCLUDE_PATH', "include/domit_rss/"); } require_once DOMIT_RSS_INCLUDE_PATH . 'xml_domit_rss.php'; $rssdoc = new xml_domit_rss_document($feed_row['url'], 'cache/feeds/', $sugar_config['rss_cache_time']); $content = ''; $currChannel = $rssdoc->getChannel(0); // $channel_desc = $currChannel->getDescription(); if (!method_exists($currChannel, 'getTitle')) { print $mod_strings['LBL_FEED_NOT_AVAILABLE']; // This section of the code fetches the filename of the cache required to delete and refresh require_once DOMIT_RSS_INCLUDE_PATH . 'php_text_cache.php'; $cache = new php_text_cache('cache/feeds/', $sugar_config['rss_cache_time']); $deletecache = $cache->getCacheFileName($feed_row['url']); if (file_exists($deletecache)) { unlink($deletecache); } print "<br><a href='index.php?module=Feeds&action=index&return_module=Feeds&delete_cache='>" . $mod_strings['LBL_REFRESH_CACHE'] . "</a>"; return; } if (method_exists($currChannel, 'getLastBuildDate')) { $last_build_date = $currChannel->getLastBuildDate(); } $img_html = ''; ?> <table width="100%" cellspacing="0" cellpadding="0" border="0"> <tr> <td align="right"><nobr> <a href="index.php?return_action=<?php echo $_REQUEST['action']; ?> &return_module=Feeds&action=MoveUp&module=Feeds&record=<?php echo $feed_row['id']; ?> "><?php echo get_image($image_path . "uparrow", 'border="0" align="absmiddle" alt="Move Up"'); ?> </a> <a href="index.php?return_action=<?php echo $_REQUEST['action']; ?> &return_module=Feeds&action=MoveDown&module=Feeds&record=<?php echo $feed_row['id']; ?> "><?php echo get_image($image_path . "downarrow", 'border="0" align="absmiddle" alt="Move Down"'); ?> </a> <a href="index.php?return_action=<?php echo $_REQUEST['action']; ?> &return_module=Feeds&action=DeleteFavorite&module=Feeds&record=<?php echo $feed_row['id']; ?> " class="listViewTdToolsS1"><?php echo get_image($image_path . "delete", 'border="0" align="absmiddle" alt="delete from favorites"'); ?> </a> </nobr></td> </tr> </table> <table cellpadding="0" cellspacing="0" width="100%" border="0" class="listView"> <tr height="20"><td scope="col" width="100%" class="listViewThS1"><a href="index.php?action=DetailView&module=Feeds&record=<?php echo $feed_row['id']; ?> " class="listViewThLinkS1"><?php echo $currChannel->getTitle(); ?> </a> - <a target="_new" href="<?php echo $currChannel->getLink(); ?> " class="listViewThLinkS1">(<?php echo $mod_strings['LBL_VISIT_WEBSITE']; ?> )</a> <?php if (!empty($last_build_date)) { echo $mod_strings['LBL_LAST_UPDATED']; ?> : <?php echo $last_build_date; } ?> </td> </tr> <tr> <td scope="col" bgcolor="<?php echo $even_bg; ?> " class="evenListRowS1" colspan="10"> <?php //get total number of items //$totalItems = $currChannel->getItemCount(); $totalItems = 5; $topitem = $currChannel->getItem(0); if (!isset($topitem)) { ?> No content <?php } else { //loop through each item for ($j = 0; $j < $totalItems; $j++) { //get reference to current item $currItem = $currChannel->getItem($j); if (!isset($currItem)) { continue; } $item_link = $currItem->getLink(); $item_title = $currItem->getTitle(); $item_date = $currItem->getPubDate(); //$item_desc = $currItem->getDescription(); ?> <li> <a target="_new" href="<?php echo $currItem->getLink(); ?> " class="listViewTdLinkS1"><?php echo $currItem->getTitle(); ?> </a> <span class="rssItemDate"><?php echo $item_date; ?> </span> <?php } } ?> </td></tr> </table> <?php }
public static function showNewsfeeds(&$newsfeed, $LitePath, $cacheDir, &$params) { ?> <table width="100%" class="contentpane<?php echo $params->get('pageclass_sfx'); ?> "> <?php if ($params->get('header')) { ?> <tr> <td class="componentheading<?php echo $params->get('pageclass_sfx'); ?> " colspan="2"> <?php echo $params->get('header'); ?> </td> </tr> <?php } // full RSS parser used to access image information $rssDoc = new xml_domit_rss_document(); $rssDoc->setRSSTimeout(5); $rssDoc->useCacheLite(true, $LitePath, $cacheDir, $newsfeed->cache_time); $success = $rssDoc->loadRSS($newsfeed->link); if ($success) { $totalChannels = $rssDoc->getChannelCount(); for ($i = 0; $i < $totalChannels; $i++) { $currChannel =& $rssDoc->getChannel($i); $elements = $currChannel->getElementList(); $descrip = 0; $iUrl = 0; foreach ($elements as $element) { //image handling if ($element == 'image') { $image =& $currChannel->getElement(DOMIT_RSS_ELEMENT_IMAGE); $iUrl = $image->getUrl(); $iTitle = $image->getTitle(); } if ($element == 'description') { $descrip = 1; // hide com_rss descrip in 4.5.0 feeds if ($currChannel->getDescription() == 'com_rss') { $descrip = 0; } } } $feed_title = $currChannel->getTitle(); $feed_title = mosCommonHTML::newsfeedEncoding($rssDoc, $feed_title); ?> <tr> <td class="contentheading<?php echo $params->get('pageclass_sfx'); ?> "> <a href="<?php echo ampReplace($currChannel->getLink()); ?> " target="_blank"> <?php echo $feed_title; ?> </a> </td> </tr> <?php // feed description if ($descrip && $params->get('feed_descr')) { $feed_descrip = $currChannel->getDescription(); $feed_descrip = mosCommonHTML::newsfeedEncoding($rssDoc, $feed_descrip); ?> <tr> <td> <?php echo $feed_descrip; ?> <br /> <br /> </td> </tr> <?php } // feed image if ($iUrl && $params->get('feed_image')) { ?> <tr> <td> <img src="<?php echo $iUrl; ?> " alt="<?php echo $iTitle; ?> " /> </td> </tr> <?php } $actualItems = $currChannel->getItemCount(); $setItems = $newsfeed->numarticles; if ($setItems > $actualItems) { $totalItems = $actualItems; } else { $totalItems = $setItems; } ?> <tr> <td> <ul> <?php for ($j = 0; $j < $totalItems; $j++) { $currItem =& $currChannel->getItem($j); $item_title = $currItem->getTitle(); $item_title = mosCommonHTML::newsfeedEncoding($rssDoc, $item_title); ?> <li> <?php // START fix for RSS enclosure tag url not showing if ($currItem->getLink()) { ?> <a href="<?php echo ampReplace($currItem->getLink()); ?> " target="_blank"> <?php echo $item_title; ?> </a> <?php } else { if ($currItem->getEnclosure()) { $enclosure = $currItem->getEnclosure(); $eUrl = $enclosure->getUrl(); ?> <a href="<?php echo ampReplace($eUrl); ?> " target="_blank"> <?php echo $item_title; ?> </a> <?php } else { if ($currItem->getEnclosure() && $currItem->getLink()) { $enclosure = $currItem->getEnclosure(); $eUrl = $enclosure->getUrl(); ?> <a href="<?php echo ampReplace($currItem->getLink()); ?> " target="_blank"> <?php echo $item_title; ?> </a> <br /> Link: <a href="<?php echo $eUrl; ?> " target="_blank"> <?php echo ampReplace($eUrl); ?> </a> <?php } } } // END fix for RSS enclosure tag url not showing // item description if ($params->get('item_descr')) { $text = $currItem->getDescription(); $text = mosCommonHTML::newsfeedEncoding($rssDoc, $text); $num = $params->get('word_count'); // word limit check if ($num) { $texts = explode(' ', $text); $count = count($texts); if ($count > $num) { $text = ''; for ($i = 0; $i < $num; $i++) { $text .= ' ' . $texts[$i]; } $text .= '...'; } } ?> <br /> <?php echo $text; ?> <br /> <br /> <?php } ?> </li> <?php } ?> </ul> </td> </tr> <tr> <td> <br /> </td> </tr> <?php } } ?> </table> <?php // displays back button mosHTML::BackButton($params); }
public static function modoutput_feed(&$module, &$params, $moduleclass_sfx) { global $mosConfig_absolute_path, $mosConfig_cachepath; // check if cache directory is writeable $cacheDir = $mosConfig_cachepath . '/'; if (!is_writable($cacheDir)) { $module->content = 'Cache Directory Unwriteable'; return; } $rssurl = $params->get('rssurl'); $rssitems = $params->get('rssitems', 5); $rssdesc = $params->get('rssdesc', 1); $rssimage = $params->get('rssimage', 1); $rssitemdesc = $params->get('rssitemdesc', 1); $words = $params->def('word_count', 0); $rsstitle = $params->get('rsstitle', 1); $rsscache = $params->get('rsscache', 3600); $contentBuffer = ''; $LitePath = $mosConfig_absolute_path . '/includes/Cache/Lite.php'; require_once $mosConfig_absolute_path . '/includes/domit/xml_domit_rss.php'; $rssDoc = new xml_domit_rss_document(); $rssDoc->setRSSTimeout(2); $rssDoc->useCacheLite(true, $LitePath, $cacheDir, $rsscache); $success = $rssDoc->loadRSS($rssurl); if ($success) { $content_buffer = ''; $totalChannels = $rssDoc->getChannelCount(); for ($i = 0; $i < $totalChannels; $i++) { $currChannel =& $rssDoc->getChannel($i); $elements = $currChannel->getElementList(); $iUrl = 0; foreach ($elements as $element) { //image handling if ($element == 'image') { $image =& $currChannel->getElement(DOMIT_RSS_ELEMENT_IMAGE); $iUrl = $image->getUrl(); $iTitle = $image->getTitle(); } } // feed title $content_buffer = '<table cellpadding="0" cellspacing="0" class="moduletable' . $moduleclass_sfx . '">' . "\n"; if ($currChannel->getTitle() && $rsstitle) { $feed_title = $currChannel->getTitle(); $feed_title = mosCommonHTML::newsfeedEncoding($rssDoc, $feed_title); $content_buffer .= "<tr>\n"; $content_buffer .= "\t<td>\n"; $content_buffer .= "\t\t<strong>\n"; $content_buffer .= "\t\t<a href=\"" . ampReplace($currChannel->getLink()) . "\" target=\"_blank\">\n"; $content_buffer .= $feed_title . "</a>\n"; $content_buffer .= "\t\t</strong>\n"; $content_buffer .= "\t</td>\n"; $content_buffer .= "</tr>\n"; } // feed description if ($rssdesc) { $feed_descrip = $currChannel->getDescription(); $feed_descrip = mosCommonHTML::newsfeedEncoding($rssDoc, $feed_descrip); $content_buffer .= "<tr>\n"; $content_buffer .= "\t<td>\n"; $content_buffer .= $feed_descrip; $content_buffer .= "\t</td>\n"; $content_buffer .= "</tr>\n"; } // feed image if ($rssimage && $iUrl) { $content_buffer .= "<tr>\n"; $content_buffer .= "\t<td align=\"center\">\n"; $content_buffer .= "\t\t<image src=\"" . $iUrl . "\" alt=\"" . @$iTitle . "\"/>\n"; $content_buffer .= "\t</td>\n"; $content_buffer .= "</tr>\n"; } $actualItems = $currChannel->getItemCount(); $setItems = $rssitems; if ($setItems > $actualItems) { $totalItems = $actualItems; } else { $totalItems = $setItems; } $content_buffer .= "<tr>\n"; $content_buffer .= "\t<td>\n"; $content_buffer .= "\t\t<ul class=\"newsfeed" . $moduleclass_sfx . "\">\n"; for ($j = 0; $j < $totalItems; $j++) { $currItem =& $currChannel->getItem($j); // item title $item_title = $currItem->getTitle(); $item_title = mosCommonHTML::newsfeedEncoding($rssDoc, $item_title); // START fix for RSS enclosure tag url not showing $content_buffer .= "<li class=\"newsfeed" . $moduleclass_sfx . "\">\n"; $content_buffer .= "\t<strong>\n"; if ($currItem->getLink()) { $content_buffer .= " <a href=\"" . ampReplace($currItem->getLink()) . "\" target=\"_blank\">\n"; $content_buffer .= " " . $item_title . "</a>\n"; } else { if ($currItem->getEnclosure()) { $enclosure = $currItem->getEnclosure(); $eUrl = $enclosure->getUrl(); $content_buffer .= " <a href=\"" . ampReplace($eUrl) . "\" target=\"_blank\">\n"; $content_buffer .= " " . $item_title . "</a>\n"; } else { if ($currItem->getEnclosure() && $currItem->getLink()) { $enclosure = $currItem->getEnclosure(); $eUrl = $enclosure->getUrl(); $content_buffer .= " <a href=\"" . ampReplace($currItem->getLink()) . "\" target=\"_blank\">\n"; $content_buffer .= " " . $item_title . "</a><br/>\n"; $content_buffer .= " <a href=\"" . ampReplace($eUrl) . "\" target=\"_blank\"><u>Download</u></a>\n"; } } } $content_buffer .= "\t</strong>\n"; // END fix for RSS enclosure tag url not showing // item description if ($rssitemdesc) { // item description $text = $currItem->getDescription(); $text = mosCommonHTML::newsfeedEncoding($rssDoc, $text); // word limit check if ($words) { $texts = explode(' ', $text); $count = count($texts); if ($count > $words) { $text = ''; for ($i = 0; $i < $words; $i++) { $text .= ' ' . $texts[$i]; } $text .= '...'; } } $content_buffer .= " <div>\n"; $content_buffer .= " " . $text; $content_buffer .= "\t\t</div>\n"; } $content_buffer .= "</li>\n"; } $content_buffer .= " </ul>\n"; $content_buffer .= "\t</td>\n"; $content_buffer .= "</tr>\n"; $content_buffer .= "</table>\n"; } $module->content = $content_buffer; } }
function display_feed() { global $mod_strings; $rssurl = $this->url; if (!defined('DOMIT_RSS_INCLUDE_PATH')) { define('DOMIT_RSS_INCLUDE_PATH', "include/domit_rss/"); } require_once DOMIT_RSS_INCLUDE_PATH . 'xml_domit_rss.php'; $rssdoc = new xml_domit_rss_document($rssurl, $GLOBALS['sugar_config']['cache_dir'] . 'feeds/', 3600); $content = ''; $currChannel = $rssdoc->getChannel(0); if (!method_exists($currChannel, 'getTitle')) { print $mod_strings['LBL_FEED_NOT_AVAILABLE'] . "<BR><BR>"; return; } $channel_link = $currChannel->getLink(); $channel_title = $currChannel->getTitle(); $channel_desc = $currChannel->getDescription(); $img_html = ''; if ($currChannel->hasElement('image')) { $img_element = $currChannel->getElement('image'); $img_src = $img_element->getUrl(); $img_width = $img_element->getWidth(); $img_height = $img_element->getHeight(); $img_title = $img_element->getTitle(); $img_html = "<td width=\"1%\" class=\"rssimg\" bgcolor=\"black\"><a href=\"{$channel_link}\"><img title=\"{$img_title}\" height=\"{$img_height}\" width=\"{$img_width}\" src=\"{$img_src}\" border=\"0\"/></a></td>\n"; } $url = $this->url; $content = <<<EOQ <style type="text/css"> .modtitle { font-family:arial,sans-serif; font-weight:bold; font-size:12pt; color:#000000 } </style> <table class="mod" id="2:0" border=0 cellpadding=0 cellspacing=0 width=100%> <tr> <td bgcolor=aaaaaa> <table border=0 cellpadding=2 cellspacing=0 width=100%> <tr> <td class="modtitle" width="98%"><a href="{$channel_link}">{$channel_title}</a></td> {$img_html} </tr> </table> </td> </tr> <tr> <td> <table border=0 cellpadding=3 cellspacing=0 width=100%> <tr> <td> <style type="text/css"> .itemtitle { font-family:arial,sans-serif; font-weight:bold; font-size:10pt; color:#000000 } .itemdate { font-family:arial,sans-serif; font-weight:normal; font-size:8pt; color:#999999 } .itemdesc { font-family:times,serif; font-weight:normal; font-size:10pt; color:#000000 } </style> <table cellpadding=4 cellspacing=0> EOQ; //get total number of channels //$totalChannels = $rssdoc->getChannelCount(); //get total number of items $totalItems = $currChannel->getItemCount(); //loop through each item for ($j = 0; $j < $totalItems; $j++) { //get reference to current item $currItem = $currChannel->getItem($j); $item_link = $currItem->getLink(); $item_title = $currItem->getTitle(); $item_date = $currItem->getPubDate(); $item_desc = $currItem->getDescription(); //echo item info $content .= "<tr><td align=top></td><td>\n"; $content .= "<table cellpadding=0 cellspacing=2><tr>\n"; $content .= "<td class=\"itemtitle\"><a target=\"_new\" href=\"{$item_link}\">{$item_title}</a></td>\n"; $content .= "</tr>\n"; $content .= "<tr><td class=\"itemdate\">{$item_date}</td></tr>\n"; $content .= "<tr><td class=\"itemdesc\">{$item_desc}</td></tr>\n"; $content .= "</table>\n"; $content .= "</td></tr>\n"; } $content .= "</table> </td> </tr> </table>\n"; $content .= "</td> </tr> </table>\n"; return $content; }
function template_display_my_feed(&$feed_row) { global $sugar_config, $mod_strings, $current_user; $out = ""; if (!defined('DOMIT_RSS_INCLUDE_PATH')) { define('DOMIT_RSS_INCLUDE_PATH', "include/domit_rss/"); } require_once DOMIT_RSS_INCLUDE_PATH . 'xml_domit_rss.php'; $rssdoc = new xml_domit_rss_document($feed_row['url'], $GLOBALS['sugar_config']['cache_dir'] . 'feeds/', $sugar_config['rss_cache_time']); $content = ''; $currChannel = $rssdoc->getChannel(0); if (!method_exists($currChannel, 'getTitle')) { $out .= $mod_strings['LBL_FEED_NOT_AVAILABLE']; // This section of the code fetches the filename of the cache required to delete and refresh $cache = new php_text_cache($GLOBALS['sugar_config']['cache_dir'] . 'feeds/', $sugar_config['rss_cache_time']); $deletecache = $cache->getCacheFileName($feed_row['url']); if (file_exists($deletecache)) { unlink($deletecache); } echo "<br><a href='index.php?module=Feeds&action=index&return_module=Feeds&delete_cache='>" . $mod_strings['LBL_REFRESH_CACHE'] . "</a>"; return; } if (method_exists($currChannel, 'getLastBuildDate')) { $last_build_date = $currChannel->getLastBuildDate(); if (!empty($last_build_date)) { $user_preference_format = $current_user->getUserDateTimePreferences(); $last_build_date = Date($user_preference_format['date'] . ' ' . $user_preference_format['time'], strtotime($last_build_date)); } } $img_html = ''; $baseURL = "index.php?return_action={$_REQUEST['action']}&return_module=Feeds&module=Feeds&record={$feed_row['id']}&action="; $up = SugarThemeRegistry::current()->getImage("uparrow", 'border="0" align="absmiddle" alt="' . $mod_strings['LBL_MOVE_UP'] . '"'); $down = SugarThemeRegistry::current()->getImage("downarrow", 'border="0" align="absmiddle" alt="' . $mod_strings['LBL_MOVE_DOWN'] . '"'); $del = SugarThemeRegistry::current()->getImage("delete", 'border="0" align="absmiddle" alt="' . $mod_strings['LBL_DELETE_FAV_BUTTON_LABEL'] . '"'); $title = $currChannel->getTitle(); $link = $currChannel->getLink(); $buildDate = empty($last_build_date) ? "" : $mod_strings['LBL_LAST_UPDATED'] . ": " . $last_build_date; $out .= <<<eoq \t\t<table width="100%" cellspacing="0" cellpadding="0" border="0"> \t\t\t<tr> \t\t\t\t<td align="right"> \t\t\t\t\t<nobr> \t\t\t\t\t<a href="{$baseURL}MoveUp">{$up}</a> \t\t\t\t\t<a href="{$baseURL}MoveDown">{$down}</a> \t\t\t\t\t<a href="{$baseURL}DeleteFavorite" class="listViewTdToolsS1">{$del}</a> \t\t\t\t\t</nobr> \t\t\t\t</td> \t\t\t</tr> \t\t</table> \t\t<table cellpadding="0" cellspacing="0" width="100%" border="0" class="list view"> \t\t\t<tr height="20"> \t\t\t\t<td scope="col" width="100%" > \t\t\t\t\t<a href="index.php?action=DetailView&module=Feeds&record={$feed_row['id']}" class="listViewThLinkS1">{$title}</a> - \t\t\t\t\t<a target="_new" href="{$link}" class="listViewThLinkS1">( {$mod_strings['LBL_VISIT_WEBSITE']} )</a> \t\t\t\t\t {$buildDate} \t\t\t\t</td> \t\t\t</tr> \t\t\t<tr class="evenListRowS1"> \t\t\t\t<td scope="col" colspan="10"> eoq; $totalItems = 5; $topitem = $currChannel->getItem(0); if (!isset($topitem)) { $out .= "No content"; } else { //loop through each item for ($j = 0; $j < $totalItems; $j++) { //get reference to current item $currItem = $currChannel->getItem($j); if (!isset($currItem)) { continue; } $item_link = $currItem->getLink(); $item_title = strip_tags($currItem->getTitle()); $item_date = $currItem->getPubDate(); if (!empty($item_date)) { $user_preference_format = $current_user->getUserDateTimePreferences(); $item_date = Date($user_preference_format['date'] . ' ' . $user_preference_format['time'], strtotime($item_date)); } $out .= <<<eoq \t\t\t\t<li><a target="_new" href="{$item_link}" >{$item_title}</a> <span class="rssItemDate">{$item_date}</span> eoq; } } $out .= "</td></tr></table>"; echo $out; }