| [ Index ] |
|
Code source de vtiger CRM 5.0.2 |
1 <?php 2 /********************************************************************************* 3 ** The contents of this file are subject to the vtiger CRM Public License Version 1.0 4 * ("License"); You may not use this file except in compliance with the License 5 * The Original Code is: vtiger CRM Open Source 6 * The Initial Developer of the Original Code is vtiger. 7 * Portions created by vtiger are Copyright (C) vtiger. 8 * All Rights Reserved. 9 * 10 ********************************************************************************/ 11 global $calpath; 12 global $app_strings,$mod_strings; 13 global $theme; 14 $theme_path="themes/".$theme."/"; 15 $image_path=$theme_path."images/"; 16 17 require_once ('data/CRMEntity.php'); 18 require_once ('include/database/PearDatabase.php'); 19 //require_once($theme_path."layout_utils.php"); 20 // Require the xmlParser class 21 //require_once('include/feedParser/xmlParser.php'); 22 23 // Require the feedParser class 24 //require_once('include/feedParser/feedParser.php'); 25 26 require_once ('include/magpierss/rss_fetch.inc'); 27 28 class vtigerRSS extends CRMEntity 29 { 30 var $rsscache_time = 1200; 31 32 /** Function to get the Rss Feeds from the Given URL 33 * This Function accepts the url string as the argument 34 * and assign the value for the class variables correspondingly 35 */ 36 function setRSSUrl($url) 37 { 38 global $cache_dir; 39 $this->rss = fetch_rss($url); 40 // Read in our sample feed file 41 //$data = @implode("",@file($url)); 42 // Tell feedParser to parse the data 43 $info = $this->rss->items; 44 45 if(isset($info)) 46 { 47 $this->rss_object = $info; 48 }else 49 { 50 return false; 51 } 52 if(isset($this->rss)) 53 { 54 $this->rss_title = $this->rss->channel["title"]; 55 $this->rss_link = $this->rss->channel["link"]; 56 $this->rss_object = $info; 57 return true; 58 }else 59 { 60 return false; 61 } 62 63 } 64 65 /** Function to get the List of Rss feeds 66 * This Function accepts no arguments and returns the listview contents on Sucess 67 * returns "Sorry: It's not possible to reach RSS URL" if fails 68 */ 69 70 function getListViewRSSHtml() 71 { 72 if(isset($this->rss_object)) 73 { 74 $i = 0; 75 foreach($this->rss_object as $key=>$item) 76 { 77 $i = $i + 1; 78 $shtml .= "<tr class='prvPrfHoverOff' onmouseover=\"this.className='prvPrfHoverOn'\" onmouseout=\"this.className='prvPrfHoverOff'\"><td><a href=\"javascript:display('".$item[link]."','feedlist_".$i."')\"; id='feedlist_".$i."' class=\"rssNews\">".$item[title]."</a></td><td>".$this->rss_title."</td></tr>"; 79 if($i == 10) 80 { 81 return $shtml; 82 } 83 } 84 85 return $shtml; 86 87 }else 88 { 89 $shtml = "<strong>".$mod_strings['LBL_REGRET_MSG']."</strong>"; 90 } 91 } 92 93 /** Function to save the Rss Feeds 94 * This Function accepts the RssURl,Starred Status as arguments and 95 * returns true on sucess 96 * returns false if fails 97 */ 98 function saveRSSUrl($url,$makestarred=0) 99 { 100 global $adb; 101 102 if ($url != "") 103 { 104 $rsstitle = $this->rss_title; 105 if($rsstitle == "") 106 { 107 $rsstitle = $url; 108 } 109 $genRssId = $adb->getUniqueID("vtiger_rss"); 110 $sSQL = "insert into vtiger_rss (RSSID,RSSURL,RSSTITLE,RSSTYPE,STARRED) values (".$genRssId.",'".addslashes($url); 111 $sSQL .= "','".addslashes($rsstitle)."',0,".$makestarred.")"; 112 $result = $adb->query($sSQL); 113 if($result) 114 { 115 return $genRssId; 116 }else 117 { 118 return false; 119 } 120 } 121 } 122 function getCRMRssFeeds() 123 { 124 global $adb; 125 global $image_path; 126 127 $sSQL = "select * from vtiger_rss where rsstype=1"; 128 $result = $adb->query($sSQL); 129 while($allrssrow = $adb->fetch_array($result)) 130 { 131 $shtml .= "<tr>"; 132 if($allrssrow["starred"] == 1) 133 { 134 $shtml .= "<td width=\"15\"> 135 <img src=\"".$image_path."onstar.gif\" align=\"absmiddle\" onMouseOver=\"this.style.cursor='pointer'\" id=\"star-$allrssrow[rssid]\"></td>"; 136 }else 137 { 138 $shtml .= "<td width=\"15\"> 139 <img src=\"".$image_path."offstar.gif\" align=\"absmiddle\" onMouseOver=\"this.style.cursor='pointer'\" id=\"star-$allrssrow[rssid]\" onClick=\"makedefaultRss($allrssrow[rssid])\"></td>"; 140 } 141 $shtml .= "<td class=\"rssTitle\"><a href=\"index.php?module=Rss&action=ListView&record=$allrssrow[rssid] 142 \" class=\"rssTitle\">".$allrssrow[rsstitle]."</a></td>"; 143 $shtml .= "<td> </td></tr>"; 144 145 } 146 return $shtml; 147 148 } 149 150 function getAllRssFeeds() 151 { 152 global $adb; 153 global $image_path; 154 155 $sSQL = "select * from vtiger_rss where rsstype <> 1"; 156 $result = $adb->query($sSQL); 157 while($allrssrow = $adb->fetch_array($result)) 158 { 159 $shtml .= "<tr>"; 160 if($allrssrow["starred"] == 1) 161 { 162 $shtml .= "<td width=\"15\"> 163 <img src=\"".$image_path."onstar.gif\" align=\"absmiddle\" onMouseOver=\"this.style.cursor='pointer'\" id=\"star-$allrssrow[rssid]\"></td>"; 164 }else 165 { 166 $shtml .= "<td width=\"15\"> 167 <img src=\"".$image_path."offstar.gif\" align=\"absmiddle\" onMouseOver=\"this.style.cursor='pointer'\" id=\"star-$allrssrow[rssid]\" onClick=\"makedefaultRss($allrssrow[rssid])\"></td>"; 168 } 169 $shtml .= "<td class=\"rssTitle\"><a href=\"index.php?module=Rss&action=ListView&record=$allrssrow[rssid]\" class=\"rssTitle\">".$allrssrow[rsstitle]."</a></td><td> </td>"; 170 $shtml .= "</tr>"; 171 172 } 173 174 return $shtml; 175 } 176 177 /** Function to get the rssurl for the given id 178 * This Function accepts the rssid as argument and returns the rssurl for that id 179 */ 180 function getRssUrlfromId($rssid) 181 { 182 global $adb; 183 184 if($rssid != "") 185 { 186 $sSQL = "select * from vtiger_rss where rssid=".$rssid; 187 $result = $adb->query($sSQL); 188 $rssrow = $adb->fetch_array($result); 189 190 if(count($rssrow) > 0) 191 { 192 $rssurl = $rssrow[rssurl]; 193 } 194 } 195 return $rssurl; 196 } 197 198 function getRSSHeadings($rssid) 199 { 200 global $image_path; 201 global $adb; 202 203 if($rssid != "") 204 { 205 $sSQL = "select * from vtiger_rss where rssid=".$rssid; 206 $result = $adb->query($sSQL); 207 $rssrow = $adb->fetch_array($result); 208 209 if(count($rssrow) > 0) 210 { 211 $shtml = "<table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"4\"> 212 <tr> 213 <td class=\"rssPgTitle\">"; 214 if($rssrow[starred] == 1) 215 { 216 $shtml .= "<img src=\"".$image_path."starred.gif\" align=\"absmiddle\">"; 217 }else 218 { 219 $shtml .= "<img src=\"".$image_path."unstarred.gif\" align=\"absmiddle\">"; 220 } 221 $shtml .= "<a href=\"".$this->rss_object[link]."\"> ".$rssrow[rsstitle]."</a> 222 </td> 223 </tr> 224 </table>"; 225 226 } 227 } 228 return $shtml; 229 } 230 231 /** Function to get the StarredRSSFeeds lists 232 * This Function accepts no argument and returns the rss feeds of 233 * the starred Feeds as HTML strings 234 */ 235 function getTopStarredRSSFeeds() 236 { 237 global $adb; 238 global $image_path; 239 240 $sSQL = "select * from vtiger_rss where starred=1"; 241 $result = $adb->query($sSQL); 242 $shtml .= "<img src=\"".$image_path."rss.gif\" border=\"0\" align=\"absmiddle\" hspace=\"2\"><a href=\"#\" onclick='window.open(\"index.php?module=Rss&action=Popup\",\"new\",\"width=500,height=300,resizable=1,scrollbars=1\");'>Add New Rss</a>"; 243 244 while($allrssrow = $adb->fetch_array($result)) 245 { 246 $shtml .= "<img src=\"".$image_path."rss.gif\" border=\"0\" align=\"absmiddle\" hspace=\"2\">"; 247 $shtml .= "<a href=\"index.php?module=Rss&action=ListView&record=$allrssrow[rssid]\" class=\"rssFavLink\"> ".substr($allrssrow['rsstitle'],0,10)."...</a></img>"; 248 } 249 return $shtml; 250 } 251 252 /** Function to get the rssfeed lists for the starred Rss feeds 253 * This Function accepts no argument and returns the rss feeds of 254 * the starred Feeds as HTML strings 255 */ 256 function getStarredRssHTML() 257 { 258 global $adb; 259 global $image_path,$mod_strings; 260 261 $sSQL = "select * from vtiger_rss where starred=1"; 262 $result = $adb->query($sSQL); 263 while($allrssrow = $adb->fetch_array($result)) 264 { 265 if($this->setRSSUrl($allrssrow["rssurl"])) 266 { 267 $rss_html = $this->getListViewRSSHtml(); 268 } 269 $shtml .= $rss_html; 270 if(isset($this->rss_object)) 271 { 272 if(count($this->rss_object) > 10) 273 { 274 $shtml .= "<tr><td colspan='3' align=\"right\"> 275 <a target=\"_BLANK\" href=\"$this->rss_link\">".$mod_strings['LBL_MORE']."</a> 276 </td></tr>"; 277 } 278 } 279 $sreturnhtml[] = $shtml; 280 $shtml = ""; 281 } 282 283 $recordcount = round((count($sreturnhtml))/2); 284 $j = $recordcount; 285 for($i=0;$i<$recordcount;$i++) 286 { 287 $starredhtml .= $sreturnhtml[$i].$sreturnhtml[$j]; 288 $j = $j + 1; 289 } 290 $starredhtml = "<table class='rssTable' cellspacing='0' cellpadding='0'> 291 <tr> 292 <th width='75%'>".$mod_strings['LBL_SUBJECT']."</th> 293 <th width='25%'>".$mod_strings['LBL_SENDER']."</th> 294 </tr>".$starredhtml."</table>"; 295 296 return $starredhtml; 297 298 } 299 300 /** Function to get the rssfeed lists for the given rssid 301 * This Function accepts the rssid as argument and returns the rss feeds as HTML strings 302 */ 303 function getSelectedRssHTML($rssid) 304 { 305 global $adb; 306 global $image_path, $mod_strings; 307 308 $sSQL = "select * from vtiger_rss where rssid=".$rssid; 309 $result = $adb->query($sSQL); 310 while($allrssrow = $adb->fetch_array($result)) 311 { 312 if($this->setRSSUrl($allrssrow["rssurl"])) 313 { 314 $rss_html = $this->getListViewRSSHtml(); 315 } 316 $shtml .= $rss_html; 317 if(isset($this->rss_object)) 318 { 319 if(count($this->rss_object) > 10) 320 { 321 $shtml .= "<tr><td colspan='3' align=\"right\"> 322 <a target=\"_BLANK\" href=\"$this->rss_link\">".$mod_strings['LBL_MORE']."</a> 323 </td></tr>"; 324 } 325 } 326 $sreturnhtml[] = $shtml; 327 $shtml = ""; 328 } 329 330 $recordcount = round((count($sreturnhtml))/2); 331 $j = $recordcount; 332 for($i=0;$i<$recordcount;$i++) 333 { 334 $starredhtml .= $sreturnhtml[$i].$sreturnhtml[$j]; 335 $j = $j + 1; 336 } 337 $starredhtml = "<table class='rssTable' cellspacing='0' cellpadding='0'> 338 <tr> 339 <th width='75%'>".$mod_strings['LBL_SUBJECT']."</th> 340 <th width='25%'>".$mod_strings['LBL_SENDER']."</th> 341 </tr>".$starredhtml."</table>"; 342 343 return $starredhtml; 344 345 } 346 347 /** Function to get the Rss Feeds by Category 348 * This Function accepts the RssCategory as argument 349 * and returns the html string for the Rss feeds lists 350 */ 351 function getRSSCategoryHTML() 352 { 353 global $adb; 354 global $image_path; 355 $shtml .= "<tr> 356 <td colspan=\"3\"> 357 <table width=\"100%\" border=\"0\" cellspacing=\"2\" cellpadding=\"2\" style=\"margin:5 0 0 35\">".$this->getRssFeedsbyCategory()."</table> 358 </td> 359 </tr>"; 360 361 return $shtml; 362 } 363 364 /** Function to get the Rss Feeds for the Given Category 365 * This Function accepts the RssCategory as argument 366 * and returns the html string for the Rss feeds lists 367 */ 368 function getRssFeedsbyCategory() 369 { 370 371 global $adb; 372 global $image_path; 373 374 $sSQL = "select * from vtiger_rss"; 375 $result = $adb->query($sSQL); 376 while($allrssrow = $adb->fetch_array($result)) 377 { 378 $shtml .= "<tr id='feed_".$allrssrow[rssid]."'>"; 379 $shtml .= "<td align='left' width=\"15\">"; 380 if($allrssrow["starred"] == 1) 381 { 382 $shtml .= "<img src=\"".$image_path."onstar.gif\" align=\"absmiddle\" onMouseOver=\"this.style.cursor='pointer'\" id=\"star-$allrssrow[rssid]\">"; 383 }else 384 { 385 $shtml .= "<img src=\"".$image_path."offstar.gif\" align=\"absmiddle\" onMouseOver=\"this.style.cursor='pointer'\" id=\"star-$allrssrow[rssid]\" onClick=\"makedefaultRss($allrssrow[rssid])\">"; 386 } 387 $shtml .= "</td>"; 388 $shtml .= "<td class=\"rssTitle\" width=\"10%\" nowrap><a href=\"javascript:GetRssFeedList('$allrssrow[rssid]')\" class=\"rssTitle\">".$allrssrow[rsstitle]."</a></td><td> </td>"; 389 $shtml .= "</tr>"; 390 } 391 return $shtml; 392 393 } 394 395 } 396 397 /** Function to get the rsstitle for the given rssid 398 * This Function accepts the rssid as an optional argument and returns the title 399 * if no id is passed it will return the tittle of the starred rss 400 */ 401 function gerRssTitle($id='') 402 { 403 global $adb; 404 if($id == '') 405 $query = 'select * from vtiger_rss where starred=1'; 406 else 407 $query = 'select * from vtiger_rss where rssid ='.$id; 408 $result = $adb->query($query); 409 $title = $adb->query_result($result,0,'rsstitle'); 410 return $title; 411 412 } 413 414 415 416 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sun Feb 25 10:22:19 2007 | par Balluche grâce à PHPXref 0.7 |