diff --git a/plugins/rssplugin/KTrss.inc.php b/plugins/rssplugin/KTrss.inc.php index 10fd72e..48b0894 100644 --- a/plugins/rssplugin/KTrss.inc.php +++ b/plugins/rssplugin/KTrss.inc.php @@ -22,10 +22,6 @@ require_once(KT_LIB_DIR . "/documentmanagement/documentcontentversion.inc.php"); require_once(KT_LIB_DIR . "/metadata/fieldset.inc.php"); require_once(KT_LIB_DIR . "/security/Permission.inc"); -// widget includes. -require_once(KT_LIB_DIR . "/widgets/portlet.inc.php"); -require_once(KT_LIB_DIR . "/widgets/fieldsetDisplay.inc.php"); -require_once(KT_LIB_DIR . "/widgets/FieldsetDisplayRegistry.inc.php"); require_once(KT_LIB_DIR . "/actions/documentaction.inc.php"); require_once(KT_LIB_DIR . "/browse/browseutil.inc.php"); @@ -100,7 +96,10 @@ class KTrss{ "LIMIT 1"; $aParams = array($document_id, $iUserId); $aDocumentsInfo = DBUtil::getResultArray(array($sQuery, $aParams)); - $aDocuments[] = $aDocumentsInfo; + $aDocumentsInfo['itemType'] = 'document'; + if($aDocumentsInfo){ + $aDocuments[] = $aDocumentsInfo; + } } } if (PEAR::isError($aDocuments)) { @@ -127,6 +126,7 @@ class KTrss{ "LIMIT 1"; $aParams = array($folder_id, $iUserId); $aFoldersInfo = DBUtil::getResultArray(array($sQuery, $aParams)); + $aFoldersInfo['itemType'] = 'folder'; if($aFoldersInfo){ $aFolders[] = $aFoldersInfo; } @@ -201,41 +201,14 @@ class KTrss{ "".$hostPath."resources/graphics/ktlogo_rss.png\n". "\n"; foreach($aItems as $item){ + if($item['itemType'] == 'folder'){ + $sTypeSelect = 'folder.transactions&fFolderId'; + }elseif($item['itemType'] == 'document'){ + $sTypeSelect = 'document.transactionhistory&fDocumentId'; + } $feed .= "" . "".$item[0]['name']."\n" . - "".$hostPath."view.php?fDocumentId=".$item[0]['id']."\n" . - "".$item[0]['transaction']."\n". - "\n"; - } - $feed .= "\n" . - "\n"; - - return $feed; - } - - // Takes in an array as a parameter and returns rss 2.0 compatible xml - function arrayToXMLSingle($aItems){ - // Build path to host - $aPath = explode('/', trim($_SERVER['PHP_SELF'])); - $hostPath = "http://".$_SERVER['HTTP_HOST']."/".$aPath[1]."/"; - $feed = "\n"; - $feed .= "\n". - "\n" . - "KnowledgeTree RSS\n" . - "(c) 2006 The Jam Warehouse Software (Pty) Ltd. All Rights Reserved - KnowledgeTree Version: OSS 3.3 beta 7\n" . - "".$hostPath."\n" . - "KT-RSS\n" . - "\n". - "KNowledgeTree RSS\n". - "140\n". - "28". - "".$hostPath."knowledgeTree/\n". - "".$hostPath."resources/graphics/ktlogo_rss.png\n". - "\n"; - foreach($aItems as $item){ - $feed .= "" . - "".$item[0]['name']."\n" . - "".$hostPath."view.php?fDocumentId=".$item[0]['id']."\n" . + "".$hostPath."action.php?kt_path_info=ktcore.actions.".$sTypeSelect."=".$item[0]['id']."\n" . "".$item[0]['transaction']."\n". "\n"; } @@ -370,5 +343,36 @@ class KTrss{ return false; } } + + function getRssLinkIcon(){ + // built server path + $sHostPath = "http://".$_SERVER['HTTP_HOST']."/".$GLOBALS['KTRootUrl']."/"; + + // create image + $icon = "RSS"; + + return $icon; + } + + function getRssLink($iItemId, $sItemType){ + $item = strToLower($sItemType); + if($item == 'folder'){ + $sItemParameter = '?folderId'; + }else if($item == 'document'){ + $sItemParameter = '?docId'; + } + + // built server path + $sHostPath = "http://".$_SERVER['HTTP_HOST']; + + // build link + $sLink = $sHostPath.KTBrowseUtil::buildBaseUrl('rss').$sItemParameter.'='.$iItemId; + + return $sLink; + } + + function getImageLink($iItemId, $sItemType){ + return "".KTrss::getRssLinkIcon().""; + } } ?> diff --git a/plugins/rssplugin/RSSDocumentLinkAction.php b/plugins/rssplugin/RSSDocumentLinkAction.php index afbfbc2..97e5a9b 100644 --- a/plugins/rssplugin/RSSDocumentLinkAction.php +++ b/plugins/rssplugin/RSSDocumentLinkAction.php @@ -1,5 +1,5 @@ oDocument; @@ -25,7 +23,26 @@ class RSSDocumentLinkAction extends KTDocumentAction { $iFId = $oDocument->getID(); // return link...there MIGHT be a nicer way of doing this? - return "RSS"; + return "RSS ".KTrss::getImageLink($iFId, 'document'); + } + + function do_main() { + //get document object + $oDocument = $this->oDocument; + + // get document id + $iDId = $oDocument->getID(); + + $oTemplating =& KTTemplating::getSingleton(); + $oTemplate = $oTemplating->loadTemplate('RSSPlugin/rssdocumentaction'); + + $aTemplateData = array( + 'context' => $this, + 'link' => KTrss::getRssLink($iDId, 'document'), + 'linkIcon' => KTrss::getImageLink($iDId, 'document'), + ); + + return $oTemplate->render($aTemplateData); } } ?> \ No newline at end of file diff --git a/plugins/rssplugin/RSSFolderLinkAction.php b/plugins/rssplugin/RSSFolderLinkAction.php index d364cba..7bdf75a 100644 --- a/plugins/rssplugin/RSSFolderLinkAction.php +++ b/plugins/rssplugin/RSSFolderLinkAction.php @@ -8,16 +8,14 @@ require_once(KT_LIB_DIR . '/plugins/plugin.inc.php'); require_once(KT_LIB_DIR . '/plugins/pluginregistry.inc.php'); require_once(KT_LIB_DIR . '/roles/Role.inc'); +require_once(KT_DIR. '/plugins/rssplugin/KTrss.inc.php'); class RSSFolderLinkAction extends KTFolderAction { var $sName = 'ktcore.rss.plugin.folder.link'; var $_sShowPermission = "ktcore.permissions.read"; - var $sDisplayName = "RSS"; + var $sDisplayName = 'RSS'; function getDisplayName() { - // built server path - $hostPath = "http://".$_SERVER['HTTP_HOST']."/".$GLOBALS['KTRootUrl']."/"; - //get folder object $oFolder = $this->oFolder; @@ -25,7 +23,26 @@ class RSSFolderLinkAction extends KTFolderAction { $iFId = $oFolder->getID(); // return link...there MIGHT be a nicer way of doing this? - return "RSS"; + return "RSS ".KTrss::getImageLink($iFId, 'folder'); + } + + function do_main() { + //get folder object + $oFolder = $this->oFolder; + + // get folder id + $iFId = $oFolder->getID(); + + $oTemplating =& KTTemplating::getSingleton(); + $oTemplate = $oTemplating->loadTemplate('RSSPlugin/rssfolderaction'); + + $aTemplateData = array( + 'context' => $this, + 'link' => KTrss::getRssLink($iFId, 'folder'), + 'linkIcon' => KTrss::getImageLink($iFId, 'folder'), + ); + + return $oTemplate->render($aTemplateData); } } ?> \ No newline at end of file diff --git a/plugins/rssplugin/RSSPlugin.php b/plugins/rssplugin/RSSPlugin.php index 400e807..2d5a5df 100644 --- a/plugins/rssplugin/RSSPlugin.php +++ b/plugins/rssplugin/RSSPlugin.php @@ -26,7 +26,7 @@ require_once('RSSDocumentLinkAction.php'); function setup() { $this->registerAction('folderaction', 'RSSFolderLinkAction', 'ktcore.rss.plugin.folder.link', $sFilename = null); - $this->registerAction('documentaction', 'RSSDocumentLinkAction', 'ktcore.rss.document.plugin', $sFilename = null); + $this->registerAction('documentaction', 'RSSDocumentLinkAction', 'ktcore.rss.plugin.document.link', $sFilename = null); $this->registerDashlet('RSSDashlet', 'ktcore.rss.feed.dashlet', 'RSSDashlet.php'); $this->registerPage('managerssfeeds', 'ManageRSSFeedsDispatcher'); diff --git a/plugins/rssplugin/templates/RSSPlugin/dashlet.smarty b/plugins/rssplugin/templates/RSSPlugin/dashlet.smarty index 757f741..ea09c81 100644 --- a/plugins/rssplugin/templates/RSSPlugin/dashlet.smarty +++ b/plugins/rssplugin/templates/RSSPlugin/dashlet.smarty @@ -75,7 +75,7 @@ {$internalrss.items[i].pubDate} - ...full story + ...read more story

{/section} diff --git a/plugins/rssplugin/templates/RSSPlugin/rssdocumentaction.smarty b/plugins/rssplugin/templates/RSSPlugin/rssdocumentaction.smarty new file mode 100644 index 0000000..5c9c55d --- /dev/null +++ b/plugins/rssplugin/templates/RSSPlugin/rssdocumentaction.smarty @@ -0,0 +1,9 @@ +

Document RSS

+

+You can copy the following link into any RSS aggregator to create a feed to the selected document. +

+Another way of quickly accessing a RSS feed for a document of folder is by RSS icon {$linkIcon}, +which you will find in your actions portlet on the left. +

\ No newline at end of file diff --git a/plugins/rssplugin/templates/RSSPlugin/rssfolderaction.smarty b/plugins/rssplugin/templates/RSSPlugin/rssfolderaction.smarty new file mode 100644 index 0000000..9e6c3f4 --- /dev/null +++ b/plugins/rssplugin/templates/RSSPlugin/rssfolderaction.smarty @@ -0,0 +1,9 @@ +

Folder RSS

+

+You can copy the following link into any RSS aggragator to create a feed to the selected folder. +

+Another way of quickly accessing a RSS feed to a document of folder is by RSS icon {$linkIcon}, +which you will find in your actions portlet on the left. +

\ No newline at end of file diff --git a/resources/graphics/rss.gif b/resources/graphics/rss.gif index f434ea9..b0e4adf 100644 --- a/resources/graphics/rss.gif +++ b/resources/graphics/rss.gif