Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezrssimporter.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezrssimporter.php 9277 2002-02-26 17:27:44Z br $
5 //
6 // Definition of ezrdfimporter class
7 //
8 // Created on: <13-Nov-2000 17:07:56 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
40 // include_once( "classes/ezdb.php" );
41 // include_once( "classes/ezdatetime.php" );
42 // include_once( "eznewsfeed/classes/eznews.php" );
43 // include_once( "ezxml/classes/ezxml.php" );
44
45 class eZRSSImporter
46 {
50 function __construct( $site, $login="", $password="" )
51 {
52 $this->Site = $site;
53 $this->Login = $login;
54 $this->Password = $password;
55 }
56
60 function &news( )
61 {
62 $source ="";
63 $db =& eZDB::globalDatabase();
64 $return_array = array();
65
66 if (!($fp = @fopen($this->Site, "r"))) {
67 // include_once( "classes/ezlog.php" );
68 eZPBLog::writeWarning( "RSS read failure: ".$this->Site."\n" );
69 return false;
70 }
71
72 $output = "";
73 while ( !feof ( $fp ) )
74 {
75 $output .= fgets( $fp, 4096 );
76 }
77
78 fclose( $fp );
79
80 $params["TrimWhiteSpace"] = true;
81 $doc = eZXML::domTree( $output, $params );
82
83 if ( count( $doc->children ) > 0 )
84 {
85 foreach ( $doc->children as $child )
86 {
87 if ( $child->name == "rss" )
88 {
89 foreach ( $child->children as $rss )
90 {
91 if ( $rss->name == "channel" )
92 {
93 foreach ( $rss->children as $channel )
94 {
95 if ( $channel->name == "title" )
96 {
97 // get the source title
98 if ( count( $channel->children ) > 0 )
99 {
100 foreach ( $channel->children as $value )
101 {
102 if ( $value->name = "text" )
103 {
104 $source = $value->content;
105 }
106 }
107 }
108 }
109
110 if ( $channel->name == "item" )
111 {
112 $title = "";
113 $link = "";
114 $description = "";
115 foreach ( $channel->children as $value )
116 {
117 $contentValue = "";
118 if ( isset( $value->children ) && count( $value->children ) > 0 )
119 {
120 foreach ( $value->children as $content )
121 {
122 if ( $content->name = "text" )
123 {
124 $contentValue = $content->content;
125 }
126 }
127 }
128
129 switch ( $value->name )
130 {
131 case "title" :
132 {
133 $title = $contentValue;
134 }
135 break;
136
137 case "link" :
138 {
139 $link = $contentValue;
140 }
141 break;
142
143 case "description" :
144 {
145 $description = $contentValue;
146 }
147 break;
148 }
149 }
150 $news = new eZNews();
151 $news->setName( $title );
152 $news->setIntro( $description );
153 $news->setURL( $link );
154
155 $dateTime = new eZDateTime();
156 $news->setOriginalPublishingDate( $dateTime );
157 $news->setOrigin( $source );
158 $return_array[] = $news;
159
160 }
161 }
162 }
163 }
164 }
165 }
166 }
167 return $return_array;
168 }
169
170 var $Site;
171 var $Login;
172 var $Password;
173 }
174
175 ?>
$dateTime
$dateTime
Definition: authorview.php:77
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZNews
Definition: eznews.php:63
eZPBLog\writeWarning
static writeWarning( $warning)
Definition: ezpblog.php:177
eZRSSImporter
Definition: ezrssimporter.php:46
eZRSSImporter\$Password
$Password
Definition: ezrssimporter.php:172
eZRSSImporter\$Site
$Site
Definition: ezrssimporter.php:170
eZRSSImporter\news
& news()
Definition: ezrssimporter.php:60
eZRSSImporter\__construct
__construct( $site, $login="", $password="")
Definition: ezrssimporter.php:50
eZRSSImporter\$Login
$Login
Definition: ezrssimporter.php:171
eZXML\domTree
static domTree( $xmlDoc, $params=array())
Definition: ezxml.php:60
$fp
$fp
Definition: export.php:97
$doc
$doc
Definition: export.php:93
$db
$db
Definition: ezarticle/user/authorlist.php:53
$content
$content
Definition: ezimagecatalogue/admin/filedownload.php:53
$link
$link
Definition: ezlink/admin/attributeedit.php:49
$news
if( $Action=="Insert") if( $Action=="Update") if( $Action=="Delete") $news
Definition: eznewsfeed/admin/categoryedit.php:69
$output
$output
Definition: formpreview.php:81
Password
</td ></tr >< tr >< td style="color:<?= isset( $error['password1'] ) ?> Password
Definition: step1.php:146
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.