Commit f50b36497e805035c0f893abb350bd940ba5cb30
1 parent
409bccdf
KTS-1556
"Implement RSS feed system" Implemented. Reviewed By: Kevin, Conrad git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@6166 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
12 changed files
with
1141 additions
and
0 deletions
plugins/rssplugin/KTrss.inc.php
0 โ 100644
| 1 | +<?php | ||
| 2 | +/* | ||
| 3 | + * Created on 08 Jan 2007 | ||
| 4 | + * | ||
| 5 | + * To change the template for this generated file go to | ||
| 6 | + * Window - Preferences - PHPeclipse - PHP - Code Templates | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +class KTrss extends KTEntity { | ||
| 10 | + // Gets a listing of external feeds for user | ||
| 11 | + function getExternalFeedsList($iUserId){ | ||
| 12 | + $sQuery = "SELECT id, url, title FROM plugin_rss WHERE user_id = ?"; | ||
| 13 | + $aParams = array($iUserId); | ||
| 14 | + $aFeeds = DBUtil::getResultArray(array($sQuery, $aParams)); | ||
| 15 | + | ||
| 16 | + if (PEAR::isError($aFeeds)) { | ||
| 17 | + // XXX: log error | ||
| 18 | + return false; | ||
| 19 | + } | ||
| 20 | + if ($aFeeds) { | ||
| 21 | + return $aFeeds; | ||
| 22 | + } | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + // Gets full listing of data of documents and folders subscribed to | ||
| 26 | + function getInternalFeed($iUserId){ | ||
| 27 | + $aFullList = array_merge(KTrss::getDocuments($iUserId), KTrss::getFolders($iUserId)); | ||
| 28 | + if($aFullList){ | ||
| 29 | + $internalFeed = KTrss::arrayToXML($aFullList); | ||
| 30 | + $response = rss2arrayBlock($internalFeed); | ||
| 31 | + } | ||
| 32 | + return $response; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + // Get list of document subscriptions | ||
| 36 | + function getDocumentList($iUserId){ | ||
| 37 | + $sQuery = "SELECT document_id as id FROM document_subscriptions WHERE user_id = ?"; | ||
| 38 | + $aParams = array($iUserId); | ||
| 39 | + $aDocumentList = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id'); | ||
| 40 | + | ||
| 41 | + if (PEAR::isError($aDocumentList)) { | ||
| 42 | + // XXX: log error | ||
| 43 | + return false; | ||
| 44 | + } | ||
| 45 | + if($aDocumentList){ | ||
| 46 | + return $aDocumentList; | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + // Get list of folder subscriptions | ||
| 51 | + function getFolderList($iUserId){ | ||
| 52 | + $sQuery = "SELECT folder_id as id FROM folder_subscriptions WHERE user_id = ?"; | ||
| 53 | + $aParams = array($iUserId); | ||
| 54 | + $aFolderList = DBUtil::getResultArrayKey(array($sQuery, $aParams), 'id'); | ||
| 55 | + | ||
| 56 | + if (PEAR::isError($aFolderList)) { | ||
| 57 | + // XXX: log error | ||
| 58 | + return false; | ||
| 59 | + } | ||
| 60 | + if ($aFolderList) { | ||
| 61 | + return $aFolderList; | ||
| 62 | + } | ||
| 63 | + } | ||
| 64 | + | ||
| 65 | + // Get data for all documents subscribed to | ||
| 66 | + function getDocuments($iUserId){ | ||
| 67 | + $aDList = KTrss::getDocumentList($iUserId); | ||
| 68 | + if($aDList){ | ||
| 69 | + foreach($aDList as $document_id){ | ||
| 70 | + $sQuery = "SELECT dt.document_id AS id, dt.datetime AS date, dt.comment AS transaction, dmv.name AS name " . | ||
| 71 | + "FROM document_metadata_version AS dmv, document_subscriptions AS ds, document_transactions AS dt " . | ||
| 72 | + "WHERE dmv.document_id = ds.document_id " . | ||
| 73 | + "AND dt.document_id = ds.document_id " . | ||
| 74 | + "AND ds.document_id = ? " . | ||
| 75 | + "AND ds.user_id = ? " . | ||
| 76 | + "ORDER BY date DESC " . | ||
| 77 | + "LIMIT 1"; | ||
| 78 | + $aParams = array($document_id, $iUserId); | ||
| 79 | + $aDocumentsInfo = DBUtil::getResultArray(array($sQuery, $aParams)); | ||
| 80 | + $aDocuments[] = $aDocumentsInfo; | ||
| 81 | + } | ||
| 82 | + } | ||
| 83 | + if (PEAR::isError($aDocuments)) { | ||
| 84 | + // XXX: log error | ||
| 85 | + return false; | ||
| 86 | + } | ||
| 87 | + if ($aDocuments) { | ||
| 88 | + return $aDocuments; | ||
| 89 | + } | ||
| 90 | + } | ||
| 91 | + | ||
| 92 | + // Get data for all folders subscribed to | ||
| 93 | + function getFolders($iUserId){ | ||
| 94 | + $aFList = KTrss::getFolderList($iUserId); | ||
| 95 | + if($aFList){ | ||
| 96 | + foreach($aFList as $folder_id){ | ||
| 97 | + $sQuery = "SELECT ft.folder_id AS id, ft.datetime AS date, ft.comment AS transaction, f.name AS name " . | ||
| 98 | + "FROM folders AS f, folder_subscriptions AS fs, folder_transactions AS ft " . | ||
| 99 | + "WHERE f.id = fs.folder_id " . | ||
| 100 | + "AND ft.folder_id = fs.folder_id " . | ||
| 101 | + "AND fs.folder_id = ? " . | ||
| 102 | + "AND fs.user_id = ? " . | ||
| 103 | + "ORDER BY date DESC " . | ||
| 104 | + "LIMIT 1"; | ||
| 105 | + $aParams = array($folder_id, $iUserId); | ||
| 106 | + $aFoldersInfo = DBUtil::getResultArray(array($sQuery, $aParams)); | ||
| 107 | + if($aFoldersInfo){ | ||
| 108 | + $aFolders[] = $aFoldersInfo; | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + } | ||
| 112 | + } | ||
| 113 | + if (PEAR::isError($aFolders)) { | ||
| 114 | + // XXX: log error | ||
| 115 | + return false; | ||
| 116 | + } | ||
| 117 | + if ($aFolders){ | ||
| 118 | + return $aFolders; | ||
| 119 | + } | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + // Takes in an array as a parameter and returns rss2.0 compatible xml | ||
| 123 | + function arrayToXML($aItems){ | ||
| 124 | + // Build path to host | ||
| 125 | + $aPath = explode('/', trim($_SERVER['PHP_SELF'])); | ||
| 126 | + $hostPath = "http://".$_SERVER['HTTP_HOST']."/".$aPath[1]."/"; | ||
| 127 | + $feed = "<?xml version=\"1.0\"?>"; | ||
| 128 | + $feed .= "<rss version=\"2.0\">". | ||
| 129 | + "<channel>" . | ||
| 130 | + "<title>KnowledgeTree RSS</title>" . | ||
| 131 | + "<copyright>(c) 2006 The Jam Warehouse Software (Pty) Ltd. All Rights Reserved - KnowledgeTree Version: OSS 3.3 beta 7</copyright>" . | ||
| 132 | + "<link>".$hostPath."</link>" . | ||
| 133 | + "<description>KT-RSS</description>" . | ||
| 134 | + "<image>". | ||
| 135 | + "<title>KNowledgeTree RSS</title>". | ||
| 136 | + "<width>140</width>". | ||
| 137 | + "<height>28</height>". | ||
| 138 | + "<link>".$hostPath."knowledgeTree/</link>". | ||
| 139 | + "<url>".$hostPath."resources/graphics/ktlogo_rss.png</url>". | ||
| 140 | + "</image>"; | ||
| 141 | + foreach($aItems as $item){ | ||
| 142 | + $feed .= "<item>" . | ||
| 143 | + "<title>".$item[0]['name']."</title>" . | ||
| 144 | + "<link>".$hostPath."view.php?fDocumentId=".$item[0]['id']."</link>" . | ||
| 145 | + "<description>".$item[0]['transaction']."</description>". | ||
| 146 | + "</item>"; | ||
| 147 | + } | ||
| 148 | + $feed .= "</channel>" . | ||
| 149 | + "</rss>"; | ||
| 150 | + | ||
| 151 | + return $feed; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + // Delete feed function | ||
| 155 | + function deleteFeed($iFeedId){ | ||
| 156 | + $res = DBUtil::autoDelete('plugin_rss', $iFeedId); | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + // Get title for external feed | ||
| 160 | + function getExternalFeedTitle($iFeedId){ | ||
| 161 | + $sQuery = "SELECT title FROM plugin_rss WHERE id = ?"; | ||
| 162 | + $aParams = array($iFeedId); | ||
| 163 | + $sFeedTitle = DBUtil::getOneResultKey(array($sQuery, $aParams), 'title'); | ||
| 164 | + | ||
| 165 | + if (PEAR::isError($sFeedTitle)) { | ||
| 166 | + // XXX: log error | ||
| 167 | + return false; | ||
| 168 | + } | ||
| 169 | + if ($sFeedTitle) { | ||
| 170 | + return $sFeedTitle; | ||
| 171 | + } | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + // Get url for external feed | ||
| 175 | + function getExternalFeedUrl($iFeedId){ | ||
| 176 | + $sQuery = "SELECT url FROM plugin_rss WHERE id = ?"; | ||
| 177 | + $aParams = array($iFeedId); | ||
| 178 | + $sFeedUrl = DBUtil::getOneResultKey(array($sQuery, $aParams), 'url'); | ||
| 179 | + | ||
| 180 | + if (PEAR::isError($sFeedUrl)) { | ||
| 181 | + // XXX: log error | ||
| 182 | + return false; | ||
| 183 | + } | ||
| 184 | + if ($sFeedUrl) { | ||
| 185 | + return $sFeedUrl; | ||
| 186 | + } | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + // Update external feed data | ||
| 190 | + function updateFeed($iFeedId, $sFeedTitle, $sFeedUrl){ | ||
| 191 | + $sQuery = "UPDATE plugin_rss SET title=?, url=? WHERE id=?"; | ||
| 192 | + $aParams = array($sFeedTitle, $sFeedUrl, $iFeedId); | ||
| 193 | + $res = DBUtil::runQuery(array($sQuery, $aParams)); | ||
| 194 | + | ||
| 195 | + return $res; | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + // Create new external feed | ||
| 199 | + function createFeed($sFeedTitle, $sFeedUrl, $iUserId){ | ||
| 200 | + $aParams = array( | ||
| 201 | + 'user_id' => $iUserId, | ||
| 202 | + 'url' => $sFeedUrl, | ||
| 203 | + 'title' => $sFeedTitle, | ||
| 204 | + ); | ||
| 205 | + $res = DBUtil::autoInsert('plugin_rss', $aParams); | ||
| 206 | + | ||
| 207 | + return $res; | ||
| 208 | + } | ||
| 209 | +} | ||
| 210 | +?> |
plugins/rssplugin/RSSDashlet.php
0 โ 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * $Id: TestDashlet.php,v 1.3 2006/02/28 16:53:49 nbm Exp $ | ||
| 5 | + * | ||
| 6 | + * Copyright (c) 2006 Jam Warehouse http://www.jamwarehouse.com | ||
| 7 | + * | ||
| 8 | + * This program is free software; you can redistribute it and/or modify | ||
| 9 | + * it under the terms of the GNU General Public License as published by | ||
| 10 | + * the Free Software Foundation; using version 2 of the License. | ||
| 11 | + * | ||
| 12 | + * This program is distributed in the hope that it will be useful, | ||
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | + * GNU General Public License for more details. | ||
| 16 | + * | ||
| 17 | + * You should have received a copy of the GNU General Public License | ||
| 18 | + * along with this program; if not, write to the Free Software | ||
| 19 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | + * | ||
| 21 | + * ------------------------------------------------------------------------- | ||
| 22 | + * | ||
| 23 | + * You can contact the copyright owner regarding licensing via the contact | ||
| 24 | + * details that can be found on the KnowledgeTree web site: | ||
| 25 | + * | ||
| 26 | + * http://www.ktdms.com/ | ||
| 27 | + */ | ||
| 28 | + | ||
| 29 | + | ||
| 30 | +require_once(KT_LIB_DIR . '/browse/browseutil.inc.php'); | ||
| 31 | +require_once(KT_DIR. '/plugins/rssplugin/rss2array.inc.php'); | ||
| 32 | +require_once(KT_DIR. '/plugins/rssplugin/KTrss.inc.php'); | ||
| 33 | + | ||
| 34 | +class RSSDashlet extends KTBaseDashlet { | ||
| 35 | + var $oUser; | ||
| 36 | + | ||
| 37 | + function RSSDashlet(){ | ||
| 38 | + $this->sTitle = _kt('RSS Feeds'); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + function is_active($oUser) { | ||
| 42 | + $this->oUser = $oUser; | ||
| 43 | + return true; | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + function render() { | ||
| 47 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 48 | + $oTemplate = $oTemplating->loadTemplate('RSSPlugin/dashlet'); | ||
| 49 | + | ||
| 50 | + $iUId = $this->oUser->getId(); | ||
| 51 | + | ||
| 52 | + // Get internal Feed | ||
| 53 | + $aInternalRSS = KTrss::getInternalFeed($iUId); | ||
| 54 | + | ||
| 55 | + // Get count of all items in feed | ||
| 56 | + $iCountItems = count($aInternalRSS[items]); | ||
| 57 | + | ||
| 58 | + // Get listing of external feeds | ||
| 59 | + $aExternalFeedsList = KTrss::getExternalFeedsList($iUId); | ||
| 60 | + | ||
| 61 | + // Create action for external feed management to be linked to inside of dashlet | ||
| 62 | + $action = array("name" => _kt("Manage External RSS Feeds"), "url" => $this->oPlugin->getPagePath('managerssfeeds')); | ||
| 63 | + | ||
| 64 | + // Prepare template data | ||
| 65 | + $aTemplateData = array( | ||
| 66 | + 'context' => $this, | ||
| 67 | + 'internalrss' => $aInternalRSS, | ||
| 68 | + 'itemcount' => $iCountItems, | ||
| 69 | + 'feedlist' => $aExternalFeedsList, | ||
| 70 | + 'user' => $iUId, | ||
| 71 | + 'action' => $action, | ||
| 72 | + ); | ||
| 73 | + | ||
| 74 | + return $oTemplate->render($aTemplateData); | ||
| 75 | + } | ||
| 76 | +} | ||
| 77 | +?> |
plugins/rssplugin/RSSPlugin.php
0 โ 100644
| 1 | +<?php | ||
| 2 | +/* | ||
| 3 | + * Created on 03 Jan 2007 | ||
| 4 | + * | ||
| 5 | + * To change the template for this generated file go to | ||
| 6 | + * Window - Preferences - PHPeclipse - PHP - Code Templates | ||
| 7 | + */ | ||
| 8 | + | ||
| 9 | +require_once(KT_LIB_DIR . "/plugins/plugin.inc.php"); | ||
| 10 | +require_once(KT_LIB_DIR . "/plugins/pluginregistry.inc.php"); | ||
| 11 | +require_once('manageRSSFeeds.php'); | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + class RSSPlugin extends KTPlugin | ||
| 15 | + { | ||
| 16 | + | ||
| 17 | + var $sNamespace = 'ktcore.rss.plugin'; | ||
| 18 | + | ||
| 19 | + function RSSPlugin($sFilename = null) { | ||
| 20 | + $res = parent::KTPlugin($sFilename); | ||
| 21 | + $this->sFriendlyName = _kt('RSS Plugin'); | ||
| 22 | + return $res; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + function setup() { | ||
| 26 | + $this->registerDashlet('RSSDashlet', 'ktcore.rss.feed.dashlet', 'RSSDashlet.php'); | ||
| 27 | + $this->registerPage('managerssfeeds', 'ManageRSSFeedsDispatcher'); | ||
| 28 | + | ||
| 29 | + require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | ||
| 30 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 31 | + $oTemplating->addLocation('RSS Plugin', '/plugins/rssplugin/templates'); | ||
| 32 | + } | ||
| 33 | + } | ||
| 34 | +$oPluginRegistry =& KTPluginRegistry::getSingleton(); | ||
| 35 | +$oPluginRegistry->registerPlugin('RSSPlugin', 'ktcore.rss.plugin', __FILE__); | ||
| 36 | +?> |
plugins/rssplugin/js/update.js
0 โ 100644
| 1 | +function loadFeed(){ | ||
| 2 | + xmlHttp=GetXmlHttpObject(); | ||
| 3 | + if (xmlHttp===null){ | ||
| 4 | + alert ("Browser does not support HTTP Request"); | ||
| 5 | + return; | ||
| 6 | + } | ||
| 7 | + var feed = document.nullForm.feedSelect.options[document.nullForm.feedSelect.options.selectedIndex].value; | ||
| 8 | + | ||
| 9 | + var url="../calculator.php"; | ||
| 10 | + url=url+"?incomplete=yes"; | ||
| 11 | + url=url+"&sid="+Math.random(); | ||
| 12 | + xmlHttp.onreadystatechange=stateChanged; | ||
| 13 | + xmlHttp.open("GET",url,true); | ||
| 14 | + xmlHttp.send(null); | ||
| 15 | +} | ||
| 16 | + | ||
| 17 | +function stateChanged(){ | ||
| 18 | + if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ | ||
| 19 | + document.getElementById("output").innerHTML=xmlHttp.responseText; | ||
| 20 | + } | ||
| 21 | +} | ||
| 22 | + | ||
| 23 | +function GetXmlHttpObject(){ | ||
| 24 | + var objXMLHttp=null; | ||
| 25 | + if (window.XMLHttpRequest){ | ||
| 26 | + objXMLHttp=new XMLHttpRequest(); | ||
| 27 | + }else if (window.ActiveXObject){ | ||
| 28 | + objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP"); | ||
| 29 | + } | ||
| 30 | + return objXMLHttp; | ||
| 31 | +} | ||
| 0 | \ No newline at end of file | 32 | \ No newline at end of file |
plugins/rssplugin/loadFeed.inc.php
0 โ 100644
| 1 | +<?php | ||
| 2 | +/* | ||
| 3 | + * Created on 10 Jan 2007 | ||
| 4 | + * | ||
| 5 | + * To change the template for this generated file go to | ||
| 6 | + * Window - Preferences - PHPeclipse - PHP - Code Templates | ||
| 7 | + */ | ||
| 8 | + require_once('../../config/dmsDefaults.php'); | ||
| 9 | + require_once(KT_DIR. '/plugins/rssplugin/rss2array.inc.php'); | ||
| 10 | + require_once(KT_DIR. '/plugins/rssplugin/KTrss.inc.php'); | ||
| 11 | + | ||
| 12 | + $feed = $_GET["feed"]; | ||
| 13 | + $user = $_GET["user"]; | ||
| 14 | + | ||
| 15 | + // Check if the feed matches a url | ||
| 16 | + if(!preg_match("/^http:\/\/([^\/]+)(.*)$/", $feed, $matches)){ | ||
| 17 | + // If not, it is an internal feed | ||
| 18 | + $aRSSArray = KTrss::getInternalFeed($user); | ||
| 19 | + }else{ | ||
| 20 | + // If it is a url, it is an external feed | ||
| 21 | + $aRSSArray = rss2array($feed); | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + // Prepare response data to be passed back to page | ||
| 25 | + $reposonse = "<h3>".$aRSSArray[channel][title]."</h3>" . | ||
| 26 | + "<div class='outerContainer' id='outerContainer'>" . | ||
| 27 | + "<table width='80%'>"; | ||
| 28 | + for($i=0;$i<count($aRSSArray[items]);$i++){ | ||
| 29 | + $reposonse .= "<tr> | ||
| 30 | + <td colspan='2'><strong>".$aRSSArray[items][$i][title]."<strong></td> | ||
| 31 | + </tr> | ||
| 32 | + <tr> | ||
| 33 | + <td>".$aRSSArray[items][$i][description]."</td> | ||
| 34 | + <td>".$aRSSArray[items][$i][pubDate]."</td> | ||
| 35 | + </tr> | ||
| 36 | + <tr> | ||
| 37 | + <td colspan='2'><a href='".$aRSSArray[items][$i][link]."' target='_blank'>... read more</a></td> | ||
| 38 | + </tr> | ||
| 39 | + <tr><td colspan='2'><hr><br></td></tr>"; | ||
| 40 | + } | ||
| 41 | + $reposonse .= "</table></div>"; | ||
| 42 | + | ||
| 43 | + echo $reposonse; | ||
| 44 | +?> |
plugins/rssplugin/manageRSSFeeds.php
0 โ 100644
| 1 | +<?php | ||
| 2 | + | ||
| 3 | +/** | ||
| 4 | + * $Id: manageHelp.php,v 1.6 2006/02/28 16:53:50 nbm Exp $ | ||
| 5 | + * | ||
| 6 | + * Copyright (c) 2006 Jam Warehouse http://www.jamwarehouse.com | ||
| 7 | + * | ||
| 8 | + * This program is free software; you can redistribute it and/or modify | ||
| 9 | + * it under the terms of the GNU General Public License as published by | ||
| 10 | + * the Free Software Foundation; using version 2 of the License. | ||
| 11 | + * | ||
| 12 | + * This program is distributed in the hope that it will be useful, | ||
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 15 | + * GNU General Public License for more details. | ||
| 16 | + * | ||
| 17 | + * You should have received a copy of the GNU General Public License | ||
| 18 | + * along with this program; if not, write to the Free Software | ||
| 19 | + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
| 20 | + * | ||
| 21 | + * ------------------------------------------------------------------------- | ||
| 22 | + * | ||
| 23 | + * You can contact the copyright owner regarding licensing via the contact | ||
| 24 | + * details that can be found on the KnowledgeTree web site: | ||
| 25 | + * | ||
| 26 | + * http://www.ktdms.com/ | ||
| 27 | + */ | ||
| 28 | + | ||
| 29 | + | ||
| 30 | +require_once(KT_LIB_DIR . "/templating/templating.inc.php"); | ||
| 31 | +require_once(KT_LIB_DIR . "/util/ktutil.inc"); | ||
| 32 | +require_once(KT_LIB_DIR . "/dispatcher.inc.php"); | ||
| 33 | +require_once(KT_LIB_DIR . "/templating/kt3template.inc.php"); | ||
| 34 | +require_once(KT_DIR. '/plugins/rssplugin/KTrss.inc.php'); | ||
| 35 | + | ||
| 36 | +class ManageRSSFeedsDispatcher extends KTStandardDispatcher { | ||
| 37 | + | ||
| 38 | + function do_main() { | ||
| 39 | + // This line adds your page to the breadcrumbs list at the top | ||
| 40 | + $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Manage External RSS Feeds','rssplugin')); | ||
| 41 | + $iUId = $this->oUser->getId(); | ||
| 42 | + | ||
| 43 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 44 | + $oTemplate = $oTemplating->loadTemplate('RSSPlugin/managerssfeeds'); | ||
| 45 | + | ||
| 46 | + $aFeedsList = array(); | ||
| 47 | + $aFeedsList = KTrss::getExternalFeedsList($iUId); | ||
| 48 | + | ||
| 49 | + $aTemplateData = array( | ||
| 50 | + 'context' => $this, | ||
| 51 | + 'feedlist' => $aFeedsList, | ||
| 52 | + ); | ||
| 53 | + | ||
| 54 | + return $oTemplate->render($aTemplateData); | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + // Delete feed function | ||
| 58 | + function do_deleteFeed(){ | ||
| 59 | + $iFeedId = KTUtil::arrayGet($_REQUEST, 'feed_id'); | ||
| 60 | + | ||
| 61 | + $res = KTrss::deleteFeed($iFeedId); | ||
| 62 | + | ||
| 63 | + if (PEAR::isError($res)) { | ||
| 64 | + $this->errorRedirectToMain(sprintf(_kt('Unable to delete item: %s','rssplugin'), $res->getMessage())); | ||
| 65 | + } | ||
| 66 | + else{ | ||
| 67 | + $this->successRedirectToMain(sprintf(_kt('RSS feed deleted','rssplugin'))); | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + // Edit feed function | ||
| 72 | + function do_editFeed(){ | ||
| 73 | + $iFeedId = KTUtil::arrayGet($_REQUEST, 'feed_id'); | ||
| 74 | + | ||
| 75 | + $add_fields = array(); | ||
| 76 | + $add_fields[] = new KTStringWidget(_kt('Title','rssplugin'),_kt('The title of the RSS feed','rssplugin'), 'title', KTrss::getExternalFeedTitle($iFeedId), $this->oPage, true, null, null); | ||
| 77 | + $add_fields[] = new KTStringWidget(_kt('URL','rssplugin'),_kt('The url of the RSS feed','rssplugin'), 'url', KTrss::getExternalFeedUrl($iFeedId), $this->oPage, false, null, null); | ||
| 78 | + | ||
| 79 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 80 | + $oTemplate = $oTemplating->loadTemplate("RSSPlugin/editfeed"); | ||
| 81 | + $aTemplateData = array( | ||
| 82 | + "context" => &$this, | ||
| 83 | + "add_fields" => $add_fields, | ||
| 84 | + "feed_id" => $iFeedId, | ||
| 85 | + ); | ||
| 86 | + return $oTemplate->render($aTemplateData); | ||
| 87 | + | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + // Update feed function on post | ||
| 91 | + function do_updateFeed(){ | ||
| 92 | + $iFeedId = KTUtil::arrayGet($_REQUEST, 'feed_id'); | ||
| 93 | + | ||
| 94 | + $aErrorOptions = array( | ||
| 95 | + 'redirect_to' => array('editFeed', sprintf('feed_id=%s', $iFeedId)) | ||
| 96 | + ); | ||
| 97 | + | ||
| 98 | + $sTitle = $this->oValidator->validateString( | ||
| 99 | + KTUtil::arrayGet($_REQUEST, 'title'), | ||
| 100 | + KTUtil::meldOptions($aErrorOptions, array('message' => _kt("You must provide a title",'rssplugin'))) | ||
| 101 | + ); | ||
| 102 | + | ||
| 103 | + $sUrl =KTUtil::arrayGet($_REQUEST, 'url'); | ||
| 104 | + | ||
| 105 | + $res = KTrss::updateFeed($iFeedId, $sTitle, $sUrl); | ||
| 106 | + | ||
| 107 | + if (PEAR::isError($res)) { | ||
| 108 | + $this->errorRedirectToMain(sprintf(_kt('Unable to delete item: %s','rssplugin'), $res->getMessage())); | ||
| 109 | + } | ||
| 110 | + else{ | ||
| 111 | + $this->successRedirectToMain(sprintf(_kt('Updated news item.','rssplugin'))); | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + | ||
| 115 | + // Add feed function | ||
| 116 | + function do_addFeed(){ | ||
| 117 | + $this->aBreadcrumbs[] = array('url' => $_SERVER['PHP_SELF'], 'name' => _kt('Manage RSS Feeds')); | ||
| 118 | + $this->oPage->setBreadcrumbDetails(_kt("Create a new RSS feed",'rssplugin')); | ||
| 119 | + $this->oPage->setTitle(_kt("Create a link to a new RSS feed",'rssplugin')); | ||
| 120 | + | ||
| 121 | + $add_fields = array(); | ||
| 122 | + $add_fields[] = new KTStringWidget(_kt('Title','rssplugin'),_kt('The title of rss feed','rssplugin'), 'title', null, $this->oPage, true, null, null); | ||
| 123 | + | ||
| 124 | + $add_fields[] = new KTStringWidget(_kt('URL','rssplugin'),_kt('The url to the rss feed','rssplugin'), 'url', null, $this->oPage, false, null, null); | ||
| 125 | + | ||
| 126 | + $oTemplating =& KTTemplating::getSingleton(); | ||
| 127 | + $oTemplate = $oTemplating->loadTemplate("RSSPlugin/addfeed"); | ||
| 128 | + $aTemplateData = array( | ||
| 129 | + "context" => &$this, | ||
| 130 | + "add_fields" => $add_fields, | ||
| 131 | + ); | ||
| 132 | + return $oTemplate->render($aTemplateData); | ||
| 133 | + | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + // Create feed on post | ||
| 137 | + function do_createFeed() { | ||
| 138 | + $iFeedId = KTUtil::arrayGet($_REQUEST, 'feed_id'); | ||
| 139 | + // use the validator object | ||
| 140 | + $aErrorOptions = array('redirect_to' => array('addFeed'), 'message' => _kt('You must specify a title for the rss feed.','newsdashletplugin')); | ||
| 141 | + $sTitle = $this->oValidator->validateString(KTUtil::arrayGet($_REQUEST, 'title'), $aErrorOptions); | ||
| 142 | + | ||
| 143 | + $sUrl = KTUtil::arrayGet($_REQUEST, 'url'); | ||
| 144 | + $res = KTrss::createFeed($sTitle, $sUrl, $this->oUser->getId()); | ||
| 145 | + | ||
| 146 | + if (PEAR::isError($res)) { | ||
| 147 | + $this->errorRedirectToMain(sprintf(_kt('Unable to create feed: %s','rssplugin'), $res->getMessage())); | ||
| 148 | + } | ||
| 149 | + else{ | ||
| 150 | + $this->successRedirectToMain(sprintf(_kt('Created new rss feed','rssplugin') . ': "' . KTrss::getExternalFeedTitle($iFeedId)) . '"'); | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | +} | ||
| 154 | + | ||
| 155 | +?> |
plugins/rssplugin/rss2array.inc.php
0 โ 100644
| 1 | +<? | ||
| 2 | + | ||
| 3 | + # | ||
| 4 | + # rss2array | ||
| 5 | + # | ||
| 6 | + # example usage: | ||
| 7 | + # | ||
| 8 | + # require("inc.rss2array.php"); | ||
| 9 | + # $rss_array = rss2array("http://news.bbc.co.uk/rss/newsonline_world_edition/front_page/rss.xml"); | ||
| 10 | + # print "<pre>"; | ||
| 11 | + # print_r($rss_array); | ||
| 12 | + # print "</pre>"; | ||
| 13 | + # | ||
| 14 | + # author: dan@freelancers.net | ||
| 15 | + # | ||
| 16 | + | ||
| 17 | + # | ||
| 18 | + # global vars | ||
| 19 | + # | ||
| 20 | + | ||
| 21 | + global $rss2array_globals; | ||
| 22 | + | ||
| 23 | + # | ||
| 24 | + # fetch_feed | ||
| 25 | + # | ||
| 26 | + | ||
| 27 | + function rss2array($url){ | ||
| 28 | + | ||
| 29 | + global $rss2array_globals; | ||
| 30 | + | ||
| 31 | + # | ||
| 32 | + # empty our global array | ||
| 33 | + # | ||
| 34 | + | ||
| 35 | + $rss2array_globals = array(); | ||
| 36 | + | ||
| 37 | + # | ||
| 38 | + # if the URL looks ok | ||
| 39 | + # | ||
| 40 | + | ||
| 41 | + if(preg_match("/^http:\/\/([^\/]+)(.*)$/", $url, $matches)){ | ||
| 42 | + | ||
| 43 | + $host = $matches[1]; | ||
| 44 | + $uri = $matches[2]; | ||
| 45 | + | ||
| 46 | + $request = "GET $uri HTTP/1.0\r\n"; | ||
| 47 | + $request .= "Host: $host\r\n"; | ||
| 48 | + $request .= "User-Agent: RSSMix/0.1 http://www.rssmix.com\r\n"; | ||
| 49 | + $request .= "Connection: close\r\n\r\n"; | ||
| 50 | + | ||
| 51 | + # | ||
| 52 | + # open the connection | ||
| 53 | + # | ||
| 54 | + | ||
| 55 | + if($http = fsockopen($host, 80, $errno, $errstr, 5)){ | ||
| 56 | + | ||
| 57 | + # | ||
| 58 | + # make the request | ||
| 59 | + # | ||
| 60 | + | ||
| 61 | + fwrite($http, $request); | ||
| 62 | + | ||
| 63 | + # | ||
| 64 | + # read in for max 5 seconds | ||
| 65 | + # | ||
| 66 | + | ||
| 67 | + $timeout = time() + 5; | ||
| 68 | + | ||
| 69 | + while(time() < $timeout && !feof($http)) { | ||
| 70 | + | ||
| 71 | + $response .= fgets($http, 4096); | ||
| 72 | + | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + # | ||
| 76 | + # split on two newlines | ||
| 77 | + # | ||
| 78 | + | ||
| 79 | + list($header, $xml) = preg_split("/\r?\n\r?\n/", $response, 2); | ||
| 80 | + | ||
| 81 | + # | ||
| 82 | + # get the status | ||
| 83 | + # | ||
| 84 | + | ||
| 85 | + if(preg_match("/^HTTP\/[0-9\.]+\s+(\d+)\s+/", $header, $matches)){ | ||
| 86 | + | ||
| 87 | + $status = $matches[1]; | ||
| 88 | + | ||
| 89 | + # | ||
| 90 | + # if 200 OK | ||
| 91 | + # | ||
| 92 | + | ||
| 93 | + if($status == 200){ | ||
| 94 | + | ||
| 95 | + # | ||
| 96 | + # create the parser | ||
| 97 | + # | ||
| 98 | + | ||
| 99 | + $xml_parser = xml_parser_create(); | ||
| 100 | + | ||
| 101 | + xml_set_element_handler($xml_parser, "startElement", "endElement"); | ||
| 102 | + xml_set_character_data_handler($xml_parser, "characterData"); | ||
| 103 | + | ||
| 104 | + # | ||
| 105 | + # parse! | ||
| 106 | + # | ||
| 107 | + | ||
| 108 | + xml_parse($xml_parser, trim($xml), true) or $rss2array_globals[errors][] = xml_error_string(xml_get_error_code($xml_parser)) . " at line " . xml_get_current_line_number($xml_parser); | ||
| 109 | + | ||
| 110 | + # | ||
| 111 | + # free parser | ||
| 112 | + # | ||
| 113 | + | ||
| 114 | + xml_parser_free($xml_parser); | ||
| 115 | + | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + else { | ||
| 119 | + | ||
| 120 | + $rss2array_globals[errors][] = "Can't get feed: HTTP status code $status"; | ||
| 121 | + | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + # | ||
| 127 | + # Can't get status from header | ||
| 128 | + # | ||
| 129 | + | ||
| 130 | + else { | ||
| 131 | + | ||
| 132 | + $rss2array_globals[errors][] = "Can't get status from header"; | ||
| 133 | + | ||
| 134 | + } | ||
| 135 | + | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + # | ||
| 139 | + # Can't connect to host | ||
| 140 | + # | ||
| 141 | + | ||
| 142 | + else { | ||
| 143 | + | ||
| 144 | + $rss2array_globals[errors][] = "Can't connect to $host"; | ||
| 145 | + | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + # | ||
| 151 | + # Feed url looks wrong | ||
| 152 | + # | ||
| 153 | + | ||
| 154 | + else { | ||
| 155 | + | ||
| 156 | + $rss2array_globals[errors][] = "Invalid url: $url"; | ||
| 157 | + | ||
| 158 | + } | ||
| 159 | + | ||
| 160 | + # | ||
| 161 | + # unset all the working vars | ||
| 162 | + # | ||
| 163 | + | ||
| 164 | + unset($rss2array_globals[channel_title]); | ||
| 165 | + | ||
| 166 | + unset($rss2array_globals[inside_rdf]); | ||
| 167 | + unset($rss2array_globals[inside_rss]); | ||
| 168 | + unset($rss2array_globals[inside_channel]); | ||
| 169 | + unset($rss2array_globals[inside_item]); | ||
| 170 | + | ||
| 171 | + unset($rss2array_globals[current_tag]); | ||
| 172 | + unset($rss2array_globals[current_title]); | ||
| 173 | + unset($rss2array_globals[current_link]); | ||
| 174 | + unset($rss2array_globals[current_description]); | ||
| 175 | + | ||
| 176 | + return $rss2array_globals; | ||
| 177 | + | ||
| 178 | + } | ||
| 179 | + | ||
| 180 | + function rss2arrayBlock($xml){ | ||
| 181 | + | ||
| 182 | + global $rss2array_globals; | ||
| 183 | + | ||
| 184 | + # | ||
| 185 | + # empty our global array | ||
| 186 | + # | ||
| 187 | + | ||
| 188 | + $rss2array_globals = array(); | ||
| 189 | + | ||
| 190 | + | ||
| 191 | + # | ||
| 192 | + # create the parser | ||
| 193 | + # | ||
| 194 | + | ||
| 195 | + $xml_parser = xml_parser_create(); | ||
| 196 | + | ||
| 197 | + xml_set_element_handler($xml_parser, "startElement", "endElement"); | ||
| 198 | + xml_set_character_data_handler($xml_parser, "characterData"); | ||
| 199 | + | ||
| 200 | + # | ||
| 201 | + # parse! | ||
| 202 | + # | ||
| 203 | + | ||
| 204 | + xml_parse($xml_parser, trim($xml), true) or $rss2array_globals[errors][] = xml_error_string(xml_get_error_code($xml_parser)) . " at line " . xml_get_current_line_number($xml_parser); | ||
| 205 | + | ||
| 206 | + # | ||
| 207 | + # free parser | ||
| 208 | + # | ||
| 209 | + | ||
| 210 | + xml_parser_free($xml_parser); | ||
| 211 | + | ||
| 212 | + | ||
| 213 | + # | ||
| 214 | + # unset all the working vars | ||
| 215 | + # | ||
| 216 | + | ||
| 217 | + unset($rss2array_globals[channel_title]); | ||
| 218 | + | ||
| 219 | + unset($rss2array_globals[inside_rdf]); | ||
| 220 | + unset($rss2array_globals[inside_rss]); | ||
| 221 | + unset($rss2array_globals[inside_channel]); | ||
| 222 | + unset($rss2array_globals[inside_item]); | ||
| 223 | + | ||
| 224 | + unset($rss2array_globals[current_tag]); | ||
| 225 | + unset($rss2array_globals[current_title]); | ||
| 226 | + unset($rss2array_globals[current_link]); | ||
| 227 | + unset($rss2array_globals[current_description]); | ||
| 228 | + | ||
| 229 | + return $rss2array_globals; | ||
| 230 | + | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | + # | ||
| 234 | + # this function will be called everytime a tag starts | ||
| 235 | + # | ||
| 236 | + | ||
| 237 | + function startElement($parser, $name, $attrs){ | ||
| 238 | + | ||
| 239 | + global $rss2array_globals; | ||
| 240 | + | ||
| 241 | + $rss2array_globals[current_tag] = $name; | ||
| 242 | + | ||
| 243 | + if($name == "RSS"){ | ||
| 244 | + | ||
| 245 | + $rss2array_globals[inside_rss] = true; | ||
| 246 | + | ||
| 247 | + } | ||
| 248 | + | ||
| 249 | + elseif($name == "RDF:RDF"){ | ||
| 250 | + | ||
| 251 | + $rss2array_globals[inside_rdf] = true; | ||
| 252 | + | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + elseif($name == "CHANNEL"){ | ||
| 256 | + | ||
| 257 | + $rss2array_globals[inside_channel] = true; | ||
| 258 | + $rss2array_globals[channel_title] = ""; | ||
| 259 | + | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + elseif(($rss2array_globals[inside_rss] and $rss2array_globals[inside_channel]) or $rss2array_globals[inside_rdf]){ | ||
| 263 | + | ||
| 264 | + if($name == "ITEM"){ | ||
| 265 | + | ||
| 266 | + $rss2array_globals[inside_item] = true; | ||
| 267 | + | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + elseif($name == "IMAGE"){ | ||
| 271 | + | ||
| 272 | + $rss2array_globals[inside_image] = true; | ||
| 273 | + | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + } | ||
| 279 | + | ||
| 280 | + # | ||
| 281 | + # this function will be called everytime there is a string between two tags | ||
| 282 | + # | ||
| 283 | + | ||
| 284 | + function characterData($parser, $data){ | ||
| 285 | + | ||
| 286 | + global $rss2array_globals; | ||
| 287 | + | ||
| 288 | + if($rss2array_globals[inside_item]){ | ||
| 289 | + | ||
| 290 | + switch($rss2array_globals[current_tag]){ | ||
| 291 | + | ||
| 292 | + case "TITLE": | ||
| 293 | + $rss2array_globals[current_title] .= $data; | ||
| 294 | + break; | ||
| 295 | + case "DESCRIPTION": | ||
| 296 | + $rss2array_globals[current_description] .= $data; | ||
| 297 | + break; | ||
| 298 | + case "LINK": | ||
| 299 | + $rss2array_globals[current_link] .= $data; | ||
| 300 | + break; | ||
| 301 | + | ||
| 302 | + } | ||
| 303 | + | ||
| 304 | + } | ||
| 305 | + | ||
| 306 | + elseif($rss2array_globals[inside_image]){ | ||
| 307 | + | ||
| 308 | + } | ||
| 309 | + | ||
| 310 | + elseif($rss2array_globals[inside_channel]){ | ||
| 311 | + | ||
| 312 | + switch($rss2array_globals[current_tag]){ | ||
| 313 | + | ||
| 314 | + case "TITLE": | ||
| 315 | + $rss2array_globals[channel_title] .= $data; | ||
| 316 | + break; | ||
| 317 | + | ||
| 318 | + } | ||
| 319 | + | ||
| 320 | + } | ||
| 321 | + | ||
| 322 | + } | ||
| 323 | + | ||
| 324 | + # | ||
| 325 | + # this function will be called everytime a tag ends | ||
| 326 | + # | ||
| 327 | + | ||
| 328 | + function endElement($parser, $name){ | ||
| 329 | + | ||
| 330 | + global $rss2array_globals; | ||
| 331 | + | ||
| 332 | + # | ||
| 333 | + # end of item, add complete item to array | ||
| 334 | + # | ||
| 335 | + | ||
| 336 | + if($name == "ITEM"){ | ||
| 337 | + | ||
| 338 | + $rss2array_globals[items][] = array(title => trim($rss2array_globals[current_title]), link => trim($rss2array_globals[current_link]), description => trim($rss2array_globals[current_description])); | ||
| 339 | + | ||
| 340 | + # | ||
| 341 | + # reset these vars for next loop | ||
| 342 | + # | ||
| 343 | + | ||
| 344 | + $rss2array_globals[current_title] = ""; | ||
| 345 | + $rss2array_globals[current_description] = ""; | ||
| 346 | + $rss2array_globals[current_link] = ""; | ||
| 347 | + | ||
| 348 | + $rss2array_globals[inside_item] = false; | ||
| 349 | + | ||
| 350 | + } | ||
| 351 | + | ||
| 352 | + elseif($name == "RSS"){ | ||
| 353 | + | ||
| 354 | + $rss2array_globals[inside_rss] = false; | ||
| 355 | + | ||
| 356 | + } | ||
| 357 | + | ||
| 358 | + elseif($name == "RDF:RDF"){ | ||
| 359 | + | ||
| 360 | + $rss2array_globals[inside_rdf] = false; | ||
| 361 | + | ||
| 362 | + } | ||
| 363 | + | ||
| 364 | + elseif($name == "CHANNEL"){ | ||
| 365 | + | ||
| 366 | + $rss2array_globals[channel][title] = trim($rss2array_globals[channel_title]); | ||
| 367 | + | ||
| 368 | + $rss2array_globals[inside_channel] = false; | ||
| 369 | + | ||
| 370 | + } | ||
| 371 | + | ||
| 372 | + elseif($name == "IMAGE"){ | ||
| 373 | + | ||
| 374 | + $rss2array_globals[inside_image] = false; | ||
| 375 | + | ||
| 376 | + } | ||
| 377 | + | ||
| 378 | + } | ||
| 379 | + | ||
| 380 | +?> | ||
| 0 | \ No newline at end of file | 381 | \ No newline at end of file |
plugins/rssplugin/templates/RSSPlugin/addfeed.smarty
0 โ 100644
| 1 | +{$context->oPage->requireJSResource("thirdpartyjs/tinymce/jscripts/tiny_mce/tiny_mce.js")} | ||
| 2 | +{capture assign=sJS} | ||
| 3 | +{literal} | ||
| 4 | +tinyMCE.init({ | ||
| 5 | + mode : "textareas", | ||
| 6 | + theme : "simple", | ||
| 7 | +}); | ||
| 8 | +{/literal} | ||
| 9 | +{/capture} | ||
| 10 | +{$context->oPage->requireJSStandalone($sJS)} | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +<h2>{i18n}New RSS Feed{/i18n}</h2> | ||
| 15 | + | ||
| 16 | +<p class="descriptiveText">{i18n}Create a rss feed which will be displayed on the dashboard{/i18n}</p> | ||
| 17 | + | ||
| 18 | + <form action="{$smarty.server.PHP_SELF}" method="POST"> | ||
| 19 | + <input type="hidden" name="action" value="createFeed" /> | ||
| 20 | + <fieldset> | ||
| 21 | + <legend>{i18n}Create a new rss feed{/i18n}</legend> | ||
| 22 | + {foreach item=oWidget from=$add_fields} | ||
| 23 | + {$oWidget->render()} | ||
| 24 | + {/foreach} | ||
| 25 | + <div class="form_actions"> | ||
| 26 | + <input type="submit" value="{i18n}Create{/i18n}" /> | ||
| 27 | + <input type="submit" name="kt_cancel[]" value="{i18n}Cancel{/i18n}" /> | ||
| 28 | + </div> | ||
| 29 | + </fieldset> | ||
| 30 | + </form> | ||
| 31 | + | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + |
plugins/rssplugin/templates/RSSPlugin/dashlet.smarty
0 โ 100644
| 1 | +<div> | ||
| 2 | + {literal} | ||
| 3 | + <script> | ||
| 4 | + var currloc = location.pathname.substring(0,location.pathname.lastIndexOf('/')+1); | ||
| 5 | + // Loadfeed function that is called by event | ||
| 6 | + function loadFeed(){ | ||
| 7 | + xmlHttp=GetXmlHttpObject(); | ||
| 8 | + if (xmlHttp===null){ | ||
| 9 | + alert ("Browser does not support HTTP Request"); | ||
| 10 | + return; | ||
| 11 | + } | ||
| 12 | + var feed = document.nullForm.feedSelect.options[document.nullForm.feedSelect.options.selectedIndex].value; | ||
| 13 | + // First check if there is a feed - in the event the 'Select feed' option was selected | ||
| 14 | + if(feed !== 'null'){ | ||
| 15 | + var url=currloc+"plugins/rssplugin/loadFeed.inc.php"; | ||
| 16 | + url=url+"?feed="+feed; | ||
| 17 | + url=url+"&user="+{/literal}{$user}{literal}; | ||
| 18 | + url=url+"&sid="+Math.random(); | ||
| 19 | + xmlHttp.onreadystatechange=stateChanged; | ||
| 20 | + xmlHttp.open("GET",url,true); | ||
| 21 | + xmlHttp.send(null); | ||
| 22 | + } | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + function stateChanged(){ | ||
| 26 | + if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete"){ | ||
| 27 | + document.getElementById("rssBlock").innerHTML=xmlHttp.responseText; | ||
| 28 | + }else{ | ||
| 29 | + document.getElementById("rssBlock").innerHTML="Loading feed..."; | ||
| 30 | + } | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + function GetXmlHttpObject(){ | ||
| 34 | + var objXMLHttp=null; | ||
| 35 | + if (window.XMLHttpRequest){ | ||
| 36 | + objXMLHttp=new XMLHttpRequest(); | ||
| 37 | + }else if (window.ActiveXObject){ | ||
| 38 | + objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP"); | ||
| 39 | + } | ||
| 40 | + return objXMLHttp; | ||
| 41 | + } | ||
| 42 | + </script> | ||
| 43 | + {/literal} | ||
| 44 | + {if $internalrss or $feedlist} | ||
| 45 | + <form name='nullForm' id='nullForm' action=''> | ||
| 46 | + <select id='feedSelect' name='feedSelect' onchange='loadFeed()'> | ||
| 47 | + {if $internalrss} | ||
| 48 | + <option selected='selected' value='{$internalrss}'>KnowledgeTree RSS</option> | ||
| 49 | + {else} | ||
| 50 | + <option selected='selected' value='null'>Select External RSS Feed</option> | ||
| 51 | + {/if} | ||
| 52 | + {if $feedlist} | ||
| 53 | + {section name=feed loop=$feedlist} | ||
| 54 | + <option value='{$feedlist[feed].url}'>{$feedlist[feed].title}</option> | ||
| 55 | + {/section} | ||
| 56 | + {/if} | ||
| 57 | + </select> | ||
| 58 | + {if ($action.url)}<a href="{$action.url}" | ||
| 59 | +{if $action.description}title="{$action.description}"{/if} | ||
| 60 | + >{$action.name}</a>{else}{$action.name}{/if} | ||
| 61 | + </form> | ||
| 62 | + {/if} | ||
| 63 | +</div> | ||
| 64 | +<div id="rssBlock"> | ||
| 65 | + {if ($internalrss)} | ||
| 66 | + <h3>{$internalrss.channel.title}</h3> | ||
| 67 | + <div class='outerContainer' id='outerContainer'> | ||
| 68 | + <table width='80%'> | ||
| 69 | + {section name=i start=0 loop=$itemcount} | ||
| 70 | + <tr> | ||
| 71 | + <td colspan='2'><strong>{$internalrss.items[i].title}<strong></td> | ||
| 72 | + </tr> | ||
| 73 | + <tr> | ||
| 74 | + <td>{$internalrss.items[i].description}</td> | ||
| 75 | + <td>{$internalrss.items[i].pubDate}</td> | ||
| 76 | + </tr> | ||
| 77 | + <tr> | ||
| 78 | + <td colspan='2'><a href='{$internalrss.items[i].link}'>...full story</a></td> | ||
| 79 | + </tr> | ||
| 80 | + <tr><td colspan='2'><hr><br></td></tr> | ||
| 81 | + {/section} | ||
| 82 | + </table> | ||
| 83 | + </div> | ||
| 84 | + {else} | ||
| 85 | + {if !$feedlist} | ||
| 86 | + {if ($action.url)}<a href="{$action.url}" | ||
| 87 | + {if $action.description}title="{$action.description}"{/if}>{$action.name}</a><br>{else}{$action.name} | ||
| 88 | + {/if} | ||
| 89 | + {/if} | ||
| 90 | + <br>No internal {if !$feedlist}or external {/if}feeds available. | ||
| 91 | + <br> | ||
| 92 | + <br> | ||
| 93 | + {/if} | ||
| 94 | +</div> | ||
| 95 | + | ||
| 96 | + | ||
| 97 | + | ||
| 98 | + | ||
| 99 | + | ||
| 100 | + |
plugins/rssplugin/templates/RSSPlugin/editfeed.smarty
0 โ 100644
| 1 | +{$context->oPage->requireJSResource("thirdpartyjs/tinymce/jscripts/tiny_mce/tiny_mce.js")} | ||
| 2 | +{capture assign=sJS} | ||
| 3 | +{literal} | ||
| 4 | +tinyMCE.init({ | ||
| 5 | + mode : "textareas", | ||
| 6 | + theme : "simple", | ||
| 7 | +}); | ||
| 8 | +{/literal} | ||
| 9 | +{/capture} | ||
| 10 | +{$context->oPage->requireJSStandalone($sJS)} | ||
| 11 | + | ||
| 12 | + | ||
| 13 | + | ||
| 14 | +<h2>{i18n}Edit RSS Feed{/i18n}</h2> | ||
| 15 | + | ||
| 16 | +<p class="descriptiveText">{i18n}Edit a RSS feed{/i18n}</p> | ||
| 17 | + | ||
| 18 | + <form action="{$smarty.server.PHP_SELF}" method="POST"> | ||
| 19 | + <input type="hidden" name="action" value="updateFeed" /> | ||
| 20 | + <input type="hidden" name="feed_id" value="{$feed_id}" /> | ||
| 21 | + <fieldset> | ||
| 22 | + <legend>{i18n}Edit RSS feed{/i18n}</legend> | ||
| 23 | + {foreach item=oWidget from=$add_fields} | ||
| 24 | + {$oWidget->render()} | ||
| 25 | + {/foreach} | ||
| 26 | + <div class="form_actions"> | ||
| 27 | + <input type="submit" value="{i18n}Save changes{/i18n}" /> | ||
| 28 | + <input type="submit" name="kt_cancel[]" value="{i18n}Cancel{/i18n}" /> | ||
| 29 | + </div> | ||
| 30 | + </fieldset> | ||
| 31 | + </form> | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + | ||
| 37 | + |
plugins/rssplugin/templates/RSSPlugin/managerssfeeds.smarty
0 โ 100644
| 1 | +<h2>{i18n}Manage RSS Feeds{/i18n}</h2> | ||
| 2 | +<fieldset> | ||
| 3 | +<legend>{i18n}Add RSS feeds{/i18n}</legend> | ||
| 4 | +<p class="descriptiveText">{i18n}These RSS feeds will be viewable on your dashboard.{/i18n}</p> | ||
| 5 | +<p><a class="ktAction ktInline ktAdd" href="{addQS}action=addFeed{/addQS}"> </a><a href="{addQS}action=addFeed{/addQS}">{i18n}Create a link to a new RSS feed{/i18n}</a></p> | ||
| 6 | +</fieldset> | ||
| 7 | + | ||
| 8 | +{if empty($feedlist)} | ||
| 9 | +<div class="ktInfo"><p>{i18n}Your RSS feed list is empty.{/i18n}</p></div> | ||
| 10 | +{else} | ||
| 11 | +<table class="listing"> | ||
| 12 | +<thead> | ||
| 13 | + <tr> | ||
| 14 | + <th>{i18n}Title{/i18n}</th> | ||
| 15 | + <th>{i18n}Edit{/i18n}</th> | ||
| 16 | + <th>{i18n}Delete{/i18n}</th> | ||
| 17 | + </tr> | ||
| 18 | +</thead> | ||
| 19 | + | ||
| 20 | + | ||
| 21 | +<tbody> | ||
| 22 | +{section name=feed loop=$feedlist} | ||
| 23 | + <tr> | ||
| 24 | + <td>{$feedlist[feed].title}</td> | ||
| 25 | + <td><a href="{addQS}action=editFeed&feed_id={$feedlist[feed].id}{/addQS}" class="ktAction ktEdit">{i18n}Edit{/i18n}</a></td> | ||
| 26 | + <td><a href="{addQS}action=deleteFeed&feed_id={$feedlist[feed].id}{/addQS}" class="ktAction ktDelete">{i18n}Delete{/i18n}</a></td> | ||
| 27 | + </tr> | ||
| 28 | +{/section} | ||
| 29 | +</tbody> | ||
| 30 | +</table> | ||
| 31 | +{/if} | ||
| 32 | + | ||
| 33 | + | ||
| 34 | + | ||
| 35 | + | ||
| 36 | + |
resources/graphics/ktlogo_rss.png
0 โ 100644
6.36 KB