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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (show annotations)
Tue Oct 26 16:47:48 2004 UTC (19 years, 8 months ago) by jonen
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +2 -2 lines
 + bugfix: hardcoded language-key, replaced with var

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 2004/05/13 19:21:21 jonen 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
45 //we want a confirmation page for this form.
46 global $app;
47
48 $this->set_confirm();
49
50 // add hidden element for page control
51 $this->add_hidden_element( 't', 'News' );
52 $this->add_hidden_element( 'sub_lang', $_REQUEST['sub_lang'] );
53
54 $this->add_element( new FEText("Titel", true, 50, 255));
55 $this->add_element( new FETextArea("kurzer Text", true, 10, 50, 50));
56 $this->add_element( new FETextArea("langer Text", true, 10, 50, 50));
57 $this->add_element( new FEText("Quelle", true, 50, 255));
58
59 $handle=opendir ($app->getConfig("path.news.img.archive"));
60 $myFileList= array();
61 while ($myFile = readdir ($handle)) {
62 if (($myFile <> ".") && ($myFile<> "..") && (strstr($myFile, "."))){$myFileList[$myFile] = $myFile;}
63 }
64 closedir($handle);
65
66 $this->add_element( new FEListBox("Bilderarchiv", FALSE,"300px", "150px",$myFileList));
67
68 }
69 function form_init_data() {
70
71 foreach($this->_datasource->_result as $key => $value) {
72 if ($value['lcountrykey'] == $this->_language) {
73 if ($value['lkey'] == $this->_sql_key_long) {
74 $this->set_element_value("langer Text", $value['lvalue']);
75 }
76 if ($value['lkey'] == $this->_sql_key_short) {
77 $this->set_element_value("kurzer Text", $value['lvalue']);
78 }
79 if ($value['lkey'] == $this->_sql_key_title) {
80 $this->set_element_value("Titel", $value['lvalue']);
81 }
82 if ($value['lkey'] == $this->_sql_key_source) {
83 $this->set_element_value("Quelle", $value['lvalue']);
84 }
85 }
86 }
87
88 $this->set_element_value("Bilderarchiv", array());
89
90 }
91
92
93 function form_content() {
94 $this->add_form_block("Please enter new text below " . $this->_whichNews, $this->_upload() );
95 }
96
97 function &_upload() {
98
99 $table = &html_table($this->_width, 0, 2);
100
101 $table->add_row($this->element_label("Titel"), $this->element_form("Titel"));
102 $table->add_row($this->element_label("kurzer Text"), $this->element_form("kurzer Text") );
103 $table->add_row($this->element_label("langer Text"), $this->element_form("langer Text") );
104 $table->add_row($this->element_label("Quelle"), $this->element_form("Quelle"));
105 $table->add_row($this->element_label("Bilderarchiv"), $this->element_form("Bilderarchiv"));
106
107 return $table;
108 }
109
110
111 function form_action() {
112
113 $data = array();
114
115 foreach($this->_datasource->_result as $key => $value) {
116 if ($value['lcountrykey'] == $this->_language) {
117 if ($value['lkey'] == $this->_sql_key_long) {
118 $data[$key] = $value;
119 $data[$key]['lvalue'] = $this->get_element_value("langer Text");
120 }
121 if ($value['lkey'] == $this->_sql_key_short) {
122 $data[$key] = $value;
123 $data[$key]['lvalue'] = $this->get_element_value("kurzer Text");
124 }
125 if ($value['lkey'] == $this->_sql_key_title) {
126 $data[$key] = $value;
127 $data[$key]['lvalue'] = $this->get_element_value("Titel");
128 }
129 if ($value['lkey'] == $this->_sql_key_source) {
130 $data[$key] = $value;
131 $data[$key]['lvalue'] = $this->get_element_value("Quelle");
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
145 // This contains the image-file that has to be moved from the archive-dir to the online-dir.
146 // The name of the file has to be changed to the name which is hardcoded in the news-templates.
147 // The online-dir will already contain a file with this name but possibly with a different suffix.
148 // Make sure that this will be removed also, so that there is only one file matching in the online-dir.
149
150 // prepare to copy selected file from archive-dir to online-dir
151 global $app;
152
153 if ($this->get_element_value("Bilderarchiv")) {
154 $_dest_file_suffix = substr($this->get_element_value("Bilderarchiv"), count($this->get_element_value("Bilderarchiv")) - 4, 4);
155 $_dest_file_name = $app->getConfig("path.news.img.online"). $this->_language ."/img_news_" . $this->_whichNews . "." . $_dest_file_suffix;
156 $_source_file_name = $app->getConfig("path.news.img.archive") . $this->get_element_value("Bilderarchiv");
157
158 // delete all files in online-dir, which have the current news-number in the filename
159
160 $handle=opendir ($app->getConfig("path.news.img.online") . $this->_language. "/");
161
162 while ($myFile = readdir ($handle)) {
163 if (substr($myFile, 9, 1) == $this->_whichNews){unlink($app->getConfig("path.news.img.online") . $this->_language . "/" . $myFile);}
164 }
165 closedir($handle);
166
167 copy($_source_file_name, $_dest_file_name);
168 }
169
170 if(!$error) {
171 // fetch fresh data
172 $this->_options['data_locator_meta']['action'] = "read";
173 // unset previous initialed 'data' var
174 $this->_options['data_locator_meta']['data'] = NULL;
175 $this->data_prefetch();
176
177 $this->set_action_message($this->_confirm_msg);
178 return TRUE;
179 } else {
180 return FALSE;
181 }
182
183 }
184 function form_backend_validation() {
185
186 $this->set_action("Confirm");
187 return true;
188 }
189
190 /**
191 * This method is called ONLY after ALL validation has
192 * passed. This is the method that allows you to
193 * do something with the data, say insert/update records
194 * in the DB.
195 */
196 function confirm_action() {
197
198 //$this->set_action_message("WOO!");
199 //print "All fetched RPC items: " . Dumper($this->_datasource->_result) . "<br>";
200 /*
201 // all of the following is to be done later !!!!!
202
203 // get data
204 //print "All fetched RPC items: " . Dumper($this->_datasource->_result) . "<br>";
205
206 // write new data to datasource in $data as array (keep old indices, set new values)
207 $this->_options['data_locator_meta']['action'] = "write";
208 $this->_options['data_locator_meta']['data'] = $data;
209 // TODO: 'data_prefetch()' will never return ANYTHING!
210 // Implement some error-handling there or somewhere.
211 $error = $this->data_prefetch();
212
213 //$error = $this->_datasource->set($item);
214 if(!$error) {
215 // fetch fresh data
216 $this->_options['data_locator_meta']['action'] = "read";
217 // unset previous initialed 'data' var
218 $this->_options['data_locator_meta']['data'] = NULL;
219 $this->data_prefetch();
220
221 $this->set_action_message($this->_confirm_msg);
222 return TRUE;
223 } else {
224 return FALSE;
225 }*/
226 return FALSE;
227 }
228
229
230 }
231 ?>

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