Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eznyheternoimporter.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: eznyheternoimporter.php 6423 2001-08-14 07:49:02Z br $
5 //
6 // Definition of eZNyhterNOImporter 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
44 class eZNyheterNOImporter
45 {
49 function __construct( $site, $login="", $password="" )
50 {
51 $this->Site = $site;
52 $this->Login = $login;
53 $this->Password = $password;
54 }
55
59 function &news( )
60 {
61 $db =& eZDB::globalDatabase();
62 print( $this->Login . "<br>" );
63 print( $this->Password . "<br>" );
64
65 $return_array = array();
66
67 $site = $this->Site;
68
69 $site = preg_replace( "#(ftp://)(.*)#", "\\1$this->Login:$this->Password@\\2", $site );
70
71 print( $site );
72
73 // $fp = eZPBFile::fopen( "$site", "r" );
74 // kracker: untested attempt at adding error protection to import process (original line above)
75
76 if (!($fp = @fopen($site, "r"))) {
77 // include_once( "classes/ezlog.php" );
78 eZPBLog::writeWarning( "RSS read failure: ".$this->Site."\n" );
79 return false;
80 }
81
82 $output = fread ( $fp, 100000000 );
83 fclose( $fp );
84
85 $doc = qdom_tree( $output );
86
87 $articleCount = 0;
88
89 foreach ( $doc->children as $child )
90 {
91 if ( $child->name == "NEWSFEED" )
92 {
93 foreach ( $child->children as $query )
94 {
95 if ( $query->name == "QUERYID" )
96 {
97 foreach ( $query->children as $article )
98 {
99
100 if ( $article->name == "ARTICLE" )
101 {
102 $name = "";
103 $description = "";
104 $urlSource = "";
105 $publishingDate = "";
106 $url = "";
107 $origin = "";
108
109 foreach ( $article->children as $articleElement )
110 {
111 $content = "";
112 foreach ( $articleElement->children as $value )
113 {
114 if ( $value->name == "#cdata-section" )
115 {
116 $content = $value->content;
117 }
118
119 if ( $value->name == "#text" )
120 {
121 $content = $value->content;
122 }
123 }
124
125 switch ( $articleElement->name )
126 {
127 case "URLSOURCE" :
128 {
129 $origin =& trim( $content );
130 }
131 break;
132
133 case "URL" :
134 {
135 $url =& trim( $content );
136 }
137 break;
138
139 case "URLTIME" :
140 {
141 $publishingDate =& trim( $content );
142 }
143 break;
144
145 case "LINKTEXT" :
146 {
147 $name =& trim( $content );
148 }
149 break;
150
151 case "CAPTION" :
152 {
153 $description =& trim( $content );
154 }
155 break;
156
157 }
158
159 }
160
161 $news = new eZNews( );
162
163 $news->setName( $name );
164 $news->setIntro( $description );
165 $news->setIsPublished( 1 );
166
167 $news->setOrigin( $origin );
168 $news->setURL( $url );
169
170 // print( "-$publishingDate-" );
171
172 if ( ereg( "([0-9]{4})([0-9]{2})([0-9]{2})-([0-9]{2})([0-9]{2})([0-9]{2})", $publishingDate, $valueArray ) )
173 {
174 $year = ( $valueArray[1] );
175 $month = ( $valueArray[2] );
176 $day = ( $valueArray[3] );
177 $hour = ( $valueArray[4] );
178 $minute = ( $valueArray[5] );
179 $second = ( $valueArray[6] );
180
181 $dateTime = new eZDateTime( $year, $month, $day, $hour, $minute, $second );
182 $news->setOriginalPublishingDate( $dateTime );
183
184 }
185 else
186 {
187 print( "<b>Error:</b> eZDateTime::setMySQLDate() received wrong MySQL date format." );
188 }
189
190
191 $return_array[] = $news;
192
193
194 $articleCount++;
195 }
196 }
197 }
198 }
199 }
200 }
201 return $return_array;
202 }
203
204 var $Site;
205 var $Login;
206 var $Password;
207 }
208
209 ?>
$articleCount
$articleCount
Definition: admin/articlelist.php:456
$day
else $day
Definition: appointmentedit.php:665
$year
else $year
Definition: appointmentedit.php:655
$month
else $month
Definition: appointmentedit.php:660
$article
$article
Definition: articlelog.php:45
$dateTime
$dateTime
Definition: authorview.php:77
eZDB\globalDatabase
static & globalDatabase()
Definition: ezdb.php:134
eZDateTime
Definition: ezdatetime.php:55
eZNews
Definition: eznews.php:63
eZNyheterNOImporter
Definition: eznyheternoimporter.php:45
eZNyheterNOImporter\$Site
$Site
Definition: eznyheternoimporter.php:204
eZNyheterNOImporter\news
& news()
Definition: eznyheternoimporter.php:59
eZNyheterNOImporter\__construct
__construct( $site, $login="", $password="")
Definition: eznyheternoimporter.php:49
eZNyheterNOImporter\$Password
$Password
Definition: eznyheternoimporter.php:206
eZNyheterNOImporter\$Login
$Login
Definition: eznyheternoimporter.php:205
eZPBLog\writeWarning
static writeWarning( $warning)
Definition: ezpblog.php:177
$name
$name
Definition: companytypelist.php:194
$query
if(isset( $Year) &&!is_numeric( $Year)||isset( $Month) &&!is_numeric( $Month)) $query
Definition: entryexitpages.php:65
$fp
$fp
Definition: export.php:97
$doc
$doc
Definition: export.php:93
$minute
$minute
Definition: export_froogle.php:311
$hour
$hour
Definition: export_froogle.php:310
$db
$db
Definition: ezarticle/user/authorlist.php:53
$content
$content
Definition: ezimagecatalogue/admin/filedownload.php:53
$news
if( $Action=="Insert") if( $Action=="Update") if( $Action=="Delete") $news
Definition: eznewsfeed/admin/categoryedit.php:69
$output
$output
Definition: formpreview.php:81
$url
$url
Definition: messagereviewlist.php:153
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+.