/[cvs]/nfo/php/libs/org.netfrag.patches/phphtmllib/forms/EditTextForm.php
ViewVC logotype

Annotation of /nfo/php/libs/org.netfrag.patches/phphtmllib/forms/EditTextForm.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sat Nov 22 18:37:39 2003 UTC (20 years, 10 months ago) by udo
Branch: MAIN
initial commit

1 udo 1.1 <?
2     /**
3     * This file contains the EditTextForm child class.
4     *
5     *
6     * @package org.netfrag.patches
7     * @name EditTextFrom
8     *
9     */
10    
11     /**
12     * Cvs-Log
13     *
14     * $Id: EditTextForm.php,v 1.3 2003/11/14 18:04:13 udo Exp $
15     */
16    
17    
18    
19     //class EditTextForm extends StandardFormContent {
20     class EditTextForm extends EditDataItem {
21    
22     var $_whichNews;
23     var $_sql_key_long;
24     var $_sql_key_short;
25     var $_sql_key_title;
26     var $_sql_key_source;
27     var $_language;
28    
29     function EditTextForm($title, $width, $whichNews, $whichLanguage, $options=array()) {
30     // something that has to be executed BEFORE parent constructor
31     //
32    
33     $parent = get_parent_class($this);
34     $this->$parent($title,$options);
35     $this->_whichNews = $whichNews;
36     $this->_sql_key_long = "page/news/feed/" . $whichNews . "/long";
37     $this->_sql_key_short = "page/news/feed/" . $whichNews . "/short";
38     $this->_sql_key_title = "page/news/feed/" . $whichNews . "/title";
39     $this->_sql_key_source = "page/news/feed/" . $whichNews . "/source";
40     $this->_language = $whichLanguage;
41     }
42    
43     function form_init_elements() {
44     //we want a confirmation page for this form.
45     global $app;
46    
47     $this->set_confirm();
48    
49     // add hidden element for page control
50     $this->add_hidden_element( 't', 'News' );
51     $this->add_hidden_element( 'subtopic', $_REQUEST['subtopic'] );
52    
53     $this->add_element( new FEText("Titel", true, 10, 20));
54     $this->add_element( new FETextArea("kurzer Text", true, 10, 20));
55     $this->add_element( new FETextArea("langer Text", true, 10, 20));
56     $this->add_element( new FEText("Quelle", true, 10, 20));
57    
58     $handle=opendir ($app->getConfig("path.news.img.archive"));
59     $myFileList= array();
60     while ($myFile = readdir ($handle)) {
61     if (($myFile <> ".") && ($myFile<> "..") && (strstr($myFile, "."))){$myFileList[$myFile] = $myFile;}
62     }
63     closedir($handle);
64    
65     $this->add_element( new FEListBox("Bilderarchiv", FALSE,"200px", "80px",$myFileList));
66    
67     }
68     function form_init_data() {
69    
70     foreach($this->_datasource->_result as $key => $value) {
71     if ($value['lcountrykey'] == $this->_language) {
72     if ($value['lkey'] == $this->_sql_key_long) {
73     $this->set_element_value("langer Text", $value['lvalue']);
74     }
75     if ($value['lkey'] == $this->_sql_key_short) {
76     $this->set_element_value("kurzer Text", $value['lvalue']);
77     }
78     if ($value['lkey'] == $this->_sql_key_title) {
79     $this->set_element_value("Titel", $value['lvalue']);
80     }
81     if ($value['lkey'] == $this->_sql_key_source) {
82     $this->set_element_value("Quelle", $value['lvalue']);
83     }
84     }
85     }
86    
87     $this->set_element_value("Bilderarchiv", array());
88    
89     }
90    
91    
92     function form_content() {
93     $this->add_form_block("Please enter new text below " . $this->_whichNews, $this->_upload() );
94     }
95    
96     function &_upload() {
97    
98     $table = &html_table($this->_width, 0, 2);
99    
100     $table->add_row($this->element_label("Titel"), $this->element_form("Titel"));
101     $table->add_row($this->element_label("kurzer Text"), $this->element_form("kurzer Text") );
102     $table->add_row($this->element_label("langer Text"), $this->element_form("langer Text") );
103     $table->add_row($this->element_label("Quelle"), $this->element_form("Quelle"));
104     $table->add_row($this->element_label("Bilderarchiv"), $this->element_form("Bilderarchiv"));
105    
106     return $table;
107     }
108    
109    
110     function form_action() {
111    
112     $data = array();
113    
114     foreach($this->_datasource->_result as $key => $value) {
115     if ($value['lcountrykey'] == $this->_language) {
116     if ($value['lkey'] == $this->_sql_key_long) {
117     $data[$key] = $value;
118     $data[$key]['lvalue'] = $this->get_element_value("langer Text");
119     }
120     if ($value['lkey'] == $this->_sql_key_short) {
121     $data[$key] = $value;
122     $data[$key]['lvalue'] = $this->get_element_value("kurzer Text");
123     }
124     if ($value['lkey'] == $this->_sql_key_title) {
125     $data[$key] = $value;
126     $data[$key]['lvalue'] = $this->get_element_value("Titel");
127     }
128     if ($value['lkey'] == $this->_sql_key_source) {
129     $data[$key] = $value;
130     $data[$key]['lvalue'] = $this->get_element_value("Quelle");
131     }
132     }
133     }
134    
135    
136    
137     // write new data to datasource in $data as array (keep old indices, set new values)
138     $this->_options['data_locator_meta']['action'] = "write";
139     $this->_options['data_locator_meta']['data'] = $data;
140     // TODO: 'data_prefetch()' will never return ANYTHING!
141     // Implement some error-handling there or somewhere.
142     $error = $this->data_prefetch();
143    
144     //$error = $this->_datasource->set($item);
145     /* if(!$error) {
146     // fetch fresh data
147     $this->_options['data_locator_meta']['action'] = "read";
148     // unset previous initialed 'data' var
149     $this->_options['data_locator_meta']['data'] = NULL;
150     $this->data_prefetch();
151    
152     $this->set_action_message($this->_confirm_msg);
153     return TRUE;
154     } else {
155     return FALSE;
156     }*/
157     global $app;
158    
159     // This contains the image-file that has to be moved from the archive-dir to the online-dir.
160     // The name of the file has to be changed to the name which is hardcoded in the news-templates.
161     // The online-dir will already contain a file with this name but possibly with a different suffix.
162     // Make sure that this will be removed also, so that there is only one file matching in the online-dir.
163    
164     // prepare to copy selected file from archive-dir to online-dir
165    
166    
167     if ($this->get_element_value("Bilderarchiv")) {
168     $_dest_file_suffix = substr($this->get_element_value("Bilderarchiv"), count($this->get_element_value("Bilderarchiv")) - 4, 4);
169     $_dest_file_name = $app->getConfig("path.news.img.online"). $this->_language ."/img_news_" . $this->_whichNews . "." . $_dest_file_suffix;
170     $_source_file_name = $app->getConfig("path.news.img.archive") . $this->get_element_value("Bilderarchiv");
171    
172     // delete all files in online-dir, which have the current news-number in the filename
173    
174     $handle=opendir ($app->getConfig("path.news.img.online") . $this->_language. "/");
175    
176     while ($myFile = readdir ($handle)) {
177     if (substr($myFile, 9, 1) == $this->_whichNews){unlink($app->getConfig("path.news.img.online") . "de/" . $myFile);}
178     }
179     closedir($handle);
180    
181     copy($_source_file_name, $_dest_file_name);
182     }
183    
184     }
185     function form_confirm( ) {
186     $title = "Form Confirmation / " . $this->_options['caption'];
187     $title .="( ".$this->_required_field_marker." ".$this->_required_field_text." )";
188     $table = new InfoTable($title, $this->_width);
189    
190     $this->build_confirm_table( $table );
191    
192     //now add the confirmation button
193     $td = new TDtag(array("colspan" => 2,
194     "class" => "contentnovertical",
195     "align" => "center"),
196     form_submit('ecdfe', "Confirm"),
197     _HTML_SPACE,
198     $this->add_action("Edit"));
199    
200     if ($this->_cancel_action) {
201     $td->add(_HTML_SPACE, $this->add_cancel());
202     }
203    
204     $table->add_row( $td );
205    
206     return $table;
207     }
208     function form_backend_validation() {
209    
210     $this->set_action("Confirm");
211    
212     $this->add_error("Titel", "Duplicate!! You suck!");
213     return true;
214     }
215    
216     /**
217     * This method is called ONLY after ALL validation has
218     * passed. This is the method that allows you to
219     * do something with the data, say insert/update records
220     * in the DB.
221     */
222     function confirm_action() {
223    
224     //$this->set_action_message("WOO!");
225     //print "All fetched RPC items: " . Dumper($this->_datasource->_result) . "<br>";
226     /*
227     // all of the following is to be done later !!!!!
228    
229     // get data
230     //print "All fetched RPC items: " . Dumper($this->_datasource->_result) . "<br>";
231    
232     // write new data to datasource in $data as array (keep old indices, set new values)
233     $this->_options['data_locator_meta']['action'] = "write";
234     $this->_options['data_locator_meta']['data'] = $data;
235     // TODO: 'data_prefetch()' will never return ANYTHING!
236     // Implement some error-handling there or somewhere.
237     $error = $this->data_prefetch();
238    
239     //$error = $this->_datasource->set($item);
240     if(!$error) {
241     // fetch fresh data
242     $this->_options['data_locator_meta']['action'] = "read";
243     // unset previous initialed 'data' var
244     $this->_options['data_locator_meta']['data'] = NULL;
245     $this->data_prefetch();
246    
247     $this->set_action_message($this->_confirm_msg);
248     return TRUE;
249     } else {
250     return FALSE;
251     }*/
252     return FALSE;
253     }
254    
255    
256     }
257     ?>

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed