[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Phpgroupware-cvs] CVS: headlines/inc class.rss.inc.php,NONE,1.1 class.h
From: |
Miles Lott <address@hidden> |
Subject: |
[Phpgroupware-cvs] CVS: headlines/inc class.rss.inc.php,NONE,1.1 class.headlines.inc.php,1.1,1.2 hook_website_right.inc.php,1.2,1.3 |
Date: |
Sun, 31 Mar 2002 07:20:57 -0500 |
Update of /cvsroot/phpgroupware/headlines/inc
In directory subversions:/tmp/cvs-serv22433/inc
Modified Files:
class.headlines.inc.php hook_website_right.inc.php
Added Files:
class.rss.inc.php
Log Message:
Convert to use of an rss class for parsing rdf/rss data; Read files into
a one line string using new network class function; New rss class parses
the whole line, which gets around sites that have questionable xml formatting
(Sophos);
added new site for antivirus alerts and moved headlines.rdf location to
phpgroupware.org
***** Error reading new file: [Errno 2] No such file or directory:
'class.rss.inc.php'
Index: class.headlines.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/headlines/inc/class.headlines.inc.php,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** class.headlines.inc.php 16 Feb 2002 20:25:51 -0000 1.1
--- class.headlines.inc.php 31 Mar 2002 12:20:55 -0000 1.2
***************
*** 41,50 ****
function getLinks($site)
{
! if (! $this->readtable($site))
{
return $links;
}
! if ($this->isCached())
{
$links = $this->getLinksDB();
--- 41,50 ----
function getLinks($site)
{
! if(!$this->readtable($site))
{
return $links;
}
! if($this->isCached())
{
$links = $this->getLinksDB();
***************
*** 54,58 ****
$links = $this->getLinksSite();
! if ($links)
{
$this->saveToDB($links);
--- 54,58 ----
$links = $this->getLinksSite();
! if($links)
{
$this->saveToDB($links);
***************
*** 72,76 ****
$GLOBALS['phpgw']->db->query("SELECT
con,display,base_url,newsfile,lastread,newstype,"
. "cachetime,listings FROM phpgw_headlines_sites WHERE
con = $site",__LINE__,__FILE__);
! if (! $GLOBALS['phpgw']->db->num_rows())
{
return False;
--- 72,76 ----
$GLOBALS['phpgw']->db->query("SELECT
con,display,base_url,newsfile,lastread,newstype,"
. "cachetime,listings FROM phpgw_headlines_sites WHERE
con = $site",__LINE__,__FILE__);
! if(!$GLOBALS['phpgw']->db->num_rows())
{
return False;
***************
*** 102,109 ****
$GLOBALS['phpgw']->db->query("SELECT title, link FROM
phpgw_headlines_cached WHERE site = ".$this->con);
! if (! $GLOBALS['phpgw']->db->num_rows())
{
$links = $this->getLinksSite(); // try from
site again
! if (!$links)
{
$display =
htmlspecialchars($this->display);
--- 102,109 ----
$GLOBALS['phpgw']->db->query("SELECT title, link FROM
phpgw_headlines_cached WHERE site = ".$this->con);
! if(!$GLOBALS['phpgw']->db->num_rows())
{
$links = $this->getLinksSite(); // try from
site again
! if(!$links)
{
$display =
htmlspecialchars($this->display);
***************
*** 114,118 ****
}
! while ($GLOBALS['phpgw']->db->next_record())
{
$links[$GLOBALS['phpgw']->db->f('title')] =
$GLOBALS['phpgw']->db->f('link');
--- 114,118 ----
}
! while($GLOBALS['phpgw']->db->next_record())
{
$links[$GLOBALS['phpgw']->db->f('title')] =
$GLOBALS['phpgw']->db->f('link');
***************
*** 124,183 ****
function getLinksSite()
{
- // determine the options to properly extract the links
- $startat = '</image>';
- $linkstr = 'link';
- $exclude = '';
-
- switch ($this->newstype)
- {
- case 'rdf-chan': $startat = '</channel>'; break;
- case 'lt': $linkstr = 'url'; break;
- case 'fm': $exclude = 'quick finder';
break;
- case 'sf': $startat = '</textinput>';
break;
- default: break;
- }
-
// get the file that contains the links
! $lines =
$GLOBALS['phpgw']->network->gethttpsocketfile($this->base_url.$this->newsfile);
! if (!$lines)
{
return False;
}
! $startnum = 0;
!
! // determine which line to begin grabbing the links
! for ($i=0;$i<count($lines);$i++)
{
! if (ereg($startat,$lines[$i],$regs))
! {
! $startnum = $i;
break;
! }
}
! // extract the links and assemble into array $links
$links = array();
! for ($i=$startnum;$i<count($lines);$i++)
{
! if (count($links)>=$this->listings)
{
break;
}
!
! if
(ereg("<title>(.*)</title>",$lines[$i],$regs))
! {
! if ($regs[1] == $exclude)
! {
! $i+=1;
! break;
! }
! $title = $regs[1];
! $title =
ereg_replace("&apos;","'",$title);
! }
! else if
(ereg("<$linkstr>(.*)</$linkstr>",$lines[$i],$regs))
! {
! $links[$title] = $regs[1];
! }
}
--- 124,164 ----
function getLinksSite()
{
// get the file that contains the links
! $data =
$GLOBALS['phpgw']->network->gethttpsocketfile($this->base_url.$this->newsfile,True);
! if(!$data)
{
return False;
}
! switch($this->newstype)
{
! case 'rdf':
! case 'fm':
! $simple = True;
break;
! case 'lt':
! $data =
@ereg_replace('<story>','<item>',$data);
! $data =
@ereg_replace('</story>','</item>',$data);
! $data =
@ereg_replace('<url>','<link>',$data);
! $data =
@ereg_replace('</url>','</link>',$data);
! $simple = True;
! break;
! default:
! $simple = False;
}
! $rss = CreateObject('headlines.rss',$data,$simple);
! $allItems = $rss->getAllItems();
!
! $i = 1;
$links = array();
! while(list($key,$val) = @each($allItems))
{
! if($i == $this->listings)
{
break;
}
! $i++;
! $links[$key] = $val;
}
***************
*** 196,202 ****
// get the file that contains the links
! // "http://www.phpgroupware.org/headlines.rdf";
! $lines =
$GLOBALS['phpgw']->network->gethttpsocketfile("http://blinkylight.com/headlines.rdf");
! if (!$lines)
{
return False;
--- 177,183 ----
// get the file that contains the links
! //$lines =
$GLOBALS['phpgw']->network->gethttpsocketfile("http://blinkylight.com/headlines.rdf");
! $lines =
$GLOBALS['phpgw']->network->gethttpsocketfile("http://www.phpgroupware.org/headlines.rdf");
! if(!$lines)
{
return False;
***************
*** 206,212 ****
// determine which line to begin grabbing the links
! for ($i=0;$i<count($lines);$i++)
{
! if (ereg($startat,$lines[$i],$regs))
{
$startnum = $i;
--- 187,193 ----
// determine which line to begin grabbing the links
! for($i=0;$i<count($lines);$i++)
{
! if(ereg($startat,$lines[$i],$regs))
{
$startnum = $i;
***************
*** 217,225 ****
// extract the links and assemble into array $links
$links = array();
! for ($i=$startnum,$j=0;$i<count($lines);$i++)
{
! if
(ereg("<title>(.*)</title>",$lines[$i],$regs))
{
! if ($regs[1] == $exclude)
{
$i+=1;
--- 198,206 ----
// extract the links and assemble into array $links
$links = array();
! for($i=$startnum,$j=0;$i<count($lines);$i++)
{
! if(ereg("<title>(.*)</title>",$lines[$i],$regs))
{
! if($regs[1] == $exclude)
{
$i+=1;
***************
*** 229,237 ****
$title[$j] =
ereg_replace("&apos;","'",$title[$j]);
}
! elseif
(ereg("<$linkstr>(.*)</$linkstr>",$lines[$i],$regs))
{
$links[$j] = $regs[1];
}
! elseif
(ereg("<description>(.*)</description>",$lines[$i],$regs))
{
$type[$j] = $regs[1];
--- 210,218 ----
$title[$j] =
ereg_replace("&apos;","'",$title[$j]);
}
!
elseif(ereg("<$linkstr>(.*)</$linkstr>",$lines[$i],$regs))
{
$links[$j] = $regs[1];
}
!
elseif(ereg("<description>(.*)</description>",$lines[$i],$regs))
{
$type[$j] = $regs[1];
***************
*** 241,245 ****
$GLOBALS['phpgw']->db->transaction_begin();
! for ($i=0;$i<count($title);$i++)
{
$server = str_replace('http://','',$links[$i]);
--- 222,226 ----
$GLOBALS['phpgw']->db->transaction_begin();
! for($i=0;$i<count($title);$i++)
{
$server = str_replace('http://','',$links[$i]);
***************
*** 250,254 ****
. "FROM phpgw_headlines_sites WHERE
display='".$title[$i]."' AND "
. "base_url='$server' AND
newsfile='$file'",__LINE__,__FILE__);
! if ($GLOBALS['phpgw']->db->num_rows() == 0)
{
$GLOBALS['phpgw']->db->query("INSERT
INTO phpgw_headlines_sites (display,base_url,newsfile,"
--- 231,235 ----
. "FROM phpgw_headlines_sites WHERE
display='".$title[$i]."' AND "
. "base_url='$server' AND
newsfile='$file'",__LINE__,__FILE__);
! if($GLOBALS['phpgw']->db->num_rows() == 0)
{
$GLOBALS['phpgw']->db->query("INSERT
INTO phpgw_headlines_sites (display,base_url,newsfile,"
***************
*** 259,263 ****
$GLOBALS['phpgw']->db->next_record();
! if ($GLOBALS['phpgw']->db->f('newstype') <>
$type[$i])
{
$GLOBALS['phpgw']->db->query("UPDATE
phpgw_headlines_sites SET newstype='".$type[$i]."' WHERE
con=".$this->db->f('con'),__LINE__,__FILE__);
--- 240,244 ----
$GLOBALS['phpgw']->db->next_record();
! if($GLOBALS['phpgw']->db->f('newstype') <>
$type[$i])
{
$GLOBALS['phpgw']->db->query("UPDATE
phpgw_headlines_sites SET newstype='".$type[$i]."' WHERE
con=".$this->db->f('con'),__LINE__,__FILE__);
***************
*** 273,277 ****
// save links
! while (list($title,$link) = each($links))
{
$link = addslashes($link);
--- 254,258 ----
// save links
! while(list($title,$link) = @each($links))
{
$link = addslashes($link);
Index: hook_website_right.inc.php
===================================================================
RCS file: /cvsroot/phpgroupware/headlines/inc/hook_website_right.inc.php,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -r1.2 -r1.3
*** hook_website_right.inc.php 20 Feb 2002 13:44:30 -0000 1.2
--- hook_website_right.inc.php 31 Mar 2002 12:20:55 -0000 1.3
***************
*** 26,38 ****
$tpl->set_block('form','row');
! $sites = array(
! 0 => 35,
! 1 => 13
! );
$j = 0;
$i = count($sites);
! while (list(,$site) = @each($sites))
{
$j++;
--- 26,41 ----
$tpl->set_block('form','row');
! while ($preference =
each($GLOBALS['phpgw_info']['user']['preferences']['headlines']))
! {
! if ($preference[0] != 'headlines_layout')
! {
! $sites[] = $preference[0];
! }
! }
$j = 0;
$i = count($sites);
! while(list(,$site) = @each($sites))
{
$j++;
***************
*** 43,46 ****
--- 46,50 ----
$links = $headlines->getLinks($site);
+ @reset($links);
if($links == False)
{
***************
*** 55,66 ****
else
{
! while (list($title,$link) = each($links))
{
! $var = Array(
! 'item_link' => stripslashes($link),
! 'item_label' => stripslashes($title)
! );
! $tpl->set_var($var);
! $s .= $tpl->parse('o_','row');
}
}
--- 59,73 ----
else
{
! while(list($title,$link) = each($links))
{
! if($link && $title)
! {
! $var = Array(
! 'item_link' =>
stripslashes($link),
! 'item_label' =>
stripslashes($title)
! );
! $tpl->set_var($var);
! $s .= $tpl->parse('o_','row');
! }
}
}
***************
*** 70,74 ****
$tpl->set_var('section_' . $j,$tpl->parse('o','channel'));
! if ($j == 3 || $i == 1)
{
$GLOBALS['phpgw_info']['wcm']['right'] .=
$tpl->fp('out','layout_row');
--- 77,81 ----
$tpl->set_var('section_' . $j,$tpl->parse('o','channel'));
! if ($j == 1 || $i == 1)
{
$GLOBALS['phpgw_info']['wcm']['right'] .=
$tpl->fp('out','layout_row');
***************
*** 80,82 ****
--- 87,90 ----
$i--;
}
+ echo $GLOBALS['phpgw_info']['wcm']['right'];
?>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Phpgroupware-cvs] CVS: headlines/inc class.rss.inc.php,NONE,1.1 class.headlines.inc.php,1.1,1.2 hook_website_right.inc.php,1.2,1.3,
Miles Lott <address@hidden> <=
- Prev by Date:
[Phpgroupware-cvs] CVS: headlines admin.php,1.13,1.14 index.php,1.25,1.26
- Next by Date:
[Phpgroupware-cvs] CVS: headlines/setup setup.inc.php,1.8,1.9
- Previous by thread:
[Phpgroupware-cvs] CVS: headlines admin.php,1.13,1.14 index.php,1.25,1.26
- Next by thread:
[Phpgroupware-cvs] CVS: headlines/setup setup.inc.php,1.8,1.9
- Index(es):