Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

newsedit.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: newsedit.php 9168 2002-02-07 08:39:56Z jhe $
5 //
6 // Created on: <16-Nov-2000 13:02:32 bf>
7 //
8 // This source file is part of Exponential Basic, publishing software.
9 //
10 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
11 //
12 // This program is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU General Public License
14 // as published by the Free Software Foundation; either version 2
15 // of the License, or (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
25 //
26
27 // include_once( "classes/INIFile.php" );
28 // include_once( "classes/eztemplate.php" );
29 // include_once( "classes/ezlocale.php" );
30 // include_once( "classes/ezdatetime.php" );
31
32 // include_once( "eznewsfeed/classes/eznews.php" );
33
34 // include_once( "classes/ezdatetime.php" );
35
36 // include_once( "eznewsfeed/classes/eznews.php" );
37 // include_once( "eznewsfeed/classes/eznewscategory.php" );
38 // include_once( "classes/ezhttptool.php" );
39
40
41 if ( isset( $Cancel ) )
42 {
43 eZHTTPTool::header( "Location: /newsfeed/archive/" );
44 exit();
45 }
46
47 if ( isset( $Action ) && $Action == "Insert" )
48 {
49 $category = new eZNewsCategory( $CategoryID );
50
51 $news = new eZNews( );
52
53 $news->setName( $NewsTitle );
54 $news->setIntro( $NewsIntro );
55
56 if ( $IsPublished == "on" )
57 {
58 $news->setIsPublished( 1 );
59 }
60 else
61 {
62 $news->setIsPublished( 0 );
63 }
64
65 $news->setKeywords( $NewsKeywords );
66 $news->setOrigin( $NewsSource );
67 $news->setURL( $NewsURL );
68
69 $dateTime = new eZDateTime( $Year, $Month, $Day, $Hour, $Second, $Minute );
70 $news->setOriginalPublishingDate( $dateTime );
71
72 $news->store();
73
74 $category->addNews( $news );
75
76 // delete the cache
77 $dir = eZPBFile::dir( "eznewsfeed/cache/" );
78 $files = array();
79 while ( $entry = $dir->read() )
80 {
81 if ( $entry != "." && $entry != ".." )
82 {
83 if ( ereg( "latestnews,([^,]+)\..*", $entry, $regArray ) )
84 {
85 if ( $regArray[1] == $CategoryID )
86 {
87 eZPBFile::unlink( "eznewsfeed/cache/" . $entry );
88 }
89 }
90
91 if ( ereg( "headlines,([^,]+)\..*", $entry, $regArray ) )
92 {
93 if ( $regArray[1] == $CategoryID )
94 {
95 eZPBFile::unlink( "eznewsfeed/cache/" . $entry );
96 }
97 }
98 }
99 }
100 $dir->close();
101 if ( $news->isPublished() == 1 )
102 {
103 eZHTTPTool::header( "Location: /newsfeed/archive/$CategoryID/" );
104 }
105 else
106 {
107 eZHTTPTool::header( "Location: /newsfeed/unpublished/$CategoryID/" );
108 }
109
110 exit();
111 }
112
113 if ( isset( $Action ) && $Action == "Update" )
114 {
115 $category = new eZNewsCategory( $CategoryID );
116
117 $news = new eZNews( $NewsID );
118
119 $news->setName( $NewsTitle );
120 $news->setIntro( $NewsIntro );
121
122 if ( $IsPublished == "on" )
123 {
124 $news->setIsPublished( 1 );
125 }
126 else
127 {
128 $news->setIsPublished( 0 );
129 }
130
131
132 $news->setKeywords( $NewsKeywords );
133 $news->setOrigin( $NewsSource );
134 $news->setURL( $NewsURL );
135
136 $dateTime = new eZDateTime( $Year, $Month, $Day, $Hour, $Second, $Minute );
137 $news->setOriginalPublishingDate( $dateTime );
138
139 $news->store();
140
141 $news->removeFromCategories();
142 $category->addNews( $news );
143
144 // delete the cache
145 $dir = eZPBFile::dir( "eznewsfeed/cache/" );
146 $files = array();
147 while ( $entry = $dir->read() )
148 {
149 if ( $entry != "." && $entry != ".." )
150 {
151 if ( ereg( "latestnews,([^,]+)\..*", $entry, $regArray ) )
152 {
153 if ( ( $regArray[1] == $CategoryID ) ||
154 ( $regArray[1] == $OldCategoryID ) )
155 {
156 eZPBFile::unlink( "eznewsfeed/cache/" . $entry );
157 }
158 }
159
160 if ( ereg( "headlines,([^,]+)\..*", $entry, $regArray ) )
161 {
162 if ( ( $regArray[1] == $CategoryID ) ||
163 ( $regArray[1] == $OldCategoryID ) )
164 {
165 eZPBFile::unlink( "eznewsfeed/cache/" . $entry );
166 }
167 }
168 }
169 }
170 $dir->close();
171
172 if ( $news->isPublished() == 1 )
173 {
174 eZHTTPTool::header( "Location: /newsfeed/archive/$CategoryID/" );
175 }
176 else
177 {
178 eZHTTPTool::header( "Location: /newsfeed/unpublished/$CategoryID/" );
179 }
180 exit();
181 }
182
183
184 if ( isset( $Action ) && $Action == "Delete" )
185 {
186 $news = new eZNews( $NewsID );
187
188 $cats = $news->categories();
189 $defCat = $cats[0];
190
191 $CategoryID = $defCat->id();
192
193 // delete the cache
194 $dir = eZPBFile::dir( "eznewsfeed/cache/" );
195 $files = array();
196 while ( $entry = $dir->read() )
197 {
198 if ( $entry != "." && $entry != ".." )
199 {
200 if ( ereg( "latestnews,([^,]+)\..*", $entry, $regArray ) )
201 {
202 if ( $regArray[1] == $CategoryID )
203 {
204 eZPBFile::unlink( "eznewsfeed/cache/" . $entry );
205 }
206 }
207
208 if ( ereg( "headlines,([^,]+)\..*", $entry, $regArray ) )
209 {
210 if ( $regArray[1] == $CategoryID )
211 {
212 eZPBFile::unlink( "eznewsfeed/cache/" . $entry );
213 }
214 }
215 }
216 }
217 $dir->close();
218
219 $news->delete();
220
221 eZHTTPTool::header( "Location: /newsfeed/archive/$CategoryID/" );
222 exit();
223 }
224
225
226 $ini = eZINI::instance( 'site.ini' );
227
228 $Language = $ini->variable( "eZNewsFeedMain", "Language" );
229 $ImageDir = $ini->variable( "eZNewsFeedMain", "ImageDir" );
230
231 $t = new eZTemplate( "kernel/eznewsfeed/admin/" . $ini->variable( "eZNewsFeedMain", "AdminTemplateDir" ),
232 "kernel/eznewsfeed/admin/intl/", $Language, "newsedit.php" );
233
234 $t->setAllStrings();
235
236 $t->set_file( array(
237 "news_edit_page_tpl" => "newsedit.tpl"
238 ) );
239
240 $t->set_block( "news_edit_page_tpl", "value_tpl", "value" );
241
242 $t->set_var( "action_value", "Insert" );
243
244 $t->set_var( "news_title_value", "" );
245 $t->set_var( "news_source_value", "" );
246
247 $today = new eZDateTime();
248
249 $t->set_var( "news_year_value", $today->year() );
250 $t->set_var( "news_month_value", $today->month() );
251 $t->set_var( "news_day_value", $today->day() );
252 $t->set_var( "news_hour_value", $today->hour() );
253 $t->set_var( "news_minute_value", $today->minute() );
254 $t->set_var( "news_second_value", $today->second() );
255 $t->set_var( "news_intro_value", "" );
256 $t->set_var( "news_url_value", "" );
257 $t->set_var( "news_keywords_value", "" );
258 $t->set_var( "news_id", "" );
259
260 if ( isset( $Action ) && $Action == "Edit" )
261 {
262 $news = new eZNews( $NewsID );
263
264 $published = $news->originalPublishingDate();
265
266 $t->set_var( "news_year_value", $published->year() );
267 $t->set_var( "news_month_value", $published->month() );
268 $t->set_var( "news_day_value", $published->day() );
269 $t->set_var( "news_hour_value", $published->hour() );
270 $t->set_var( "news_minute_value", $published->minute() );
271 $t->set_var( "news_second_value", $published->second() );
272
273 $t->set_var( "news_title_value", $news->name() );
274 $t->set_var( "news_source_value", $news->origin() );
275 $t->set_var( "news_intro_value", $news->intro() );
276 $t->set_var( "news_url_value", $news->url() );
277 $t->set_var( "news_keywords_value", $news->keywords() );
278 $t->set_var( "news_id", $news->id() );
279 $t->set_var( "action_value", "Update" );
280
281
282 if ( $news->isPublished() == 1 )
283 {
284 $t->set_var( "news_is_published", "checked" );
285 }
286 else
287 {
288 $t->set_var( "news_is_published", "" );
289 }
290
291 $cats = $news->categories();
292 $defCat = $cats[0];
293 $t->set_var( "old_category_id", $defCat->id() );
294 }
295
296 // category select
297 $category = new eZNewsCategory();
298 $categoryArray = $category->getAll( );
299
300 foreach ( $categoryArray as $catItem )
301 {
302 if ( isset( $Action ) && $Action == "Edit" )
303 {
304 if ( $defCat->id() == $catItem->id() )
305 {
306 $t->set_var( "selected", "selected" );
307 }
308 else
309 {
310 $t->set_var( "selected", "" );
311 }
312 }
313 else
314 {
315 $t->set_var( "selected", "" );
316 }
317
318 $t->set_var( "option_value", $catItem->id() );
319 $t->set_var( "option_name", $catItem->name() );
320
321 $t->parse( "value", "value_tpl", true );
322 }
323
324 $t->pparse( "output", "news_edit_page_tpl" );
325
326 ?>
$CategoryID
$CategoryID
Definition: admin/articleedit.php:53
$files
$files
Definition: articlepreview.php:91
$dateTime
$dateTime
Definition: authorview.php:77
eZDateTime
Definition: ezdatetime.php:55
eZHTTPTool\header
static header( $string)
Definition: ezhttptool.php:96
eZNewsCategory
Definition: eznewscategory.php:42
eZNews
Definition: eznews.php:63
eZPBFile\dir
static dir( $dir, $add_sitedir=true)
Definition: ezpbfile.php:384
eZPBFile\unlink
static unlink( $filename)
Definition: ezpbfile.php:352
eZTemplate
Definition: eztemplate.php:107
$Action
$Action
Definition: companysearch.php:80
$Month
$Month
Definition: ezcalendar/user/dayview.php:78
$Day
$Day
Definition: ezcalendar/user/dayview.php:79
$news
if( $Action=="Insert") if( $Action=="Update") if( $Action=="Delete") $news
Definition: eznewsfeed/admin/categoryedit.php:69
$dir
$dir
Definition: ezsitemanager/admin/filelist.php:87
exit
exit
Definition: folder.php:81
$ini
if(isset( $Cancel)) if(isset( $Action) && $Action=="Insert") if(isset( $Action) && $Action=="Update") if(isset( $Action) && $Action=="Delete") $ini
Definition: newsedit.php:226
$ImageDir
$ImageDir
Definition: newsedit.php:229
$t
$t
Definition: newsedit.php:231
$Language
$Language
Definition: newsedit.php:228
$categoryArray
$categoryArray
Definition: newsedit.php:298
$category
if(isset( $Action) && $Action=="Edit") $category
Definition: newsedit.php:297
$today
$today
Definition: newsedit.php:247
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.