/[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.2 - (hide annotations)
Mon Dec 15 21:04:17 2003 UTC (21 years ago) by udo
Branch: MAIN
Changes since 1.1: +5 -30 lines
finished

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 udo 1.2 * $Id: EditTextForm.php,v 1.1 2003/11/22 18:37:39 udo Exp $
15 udo 1.1 */
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 udo 1.2
45 udo 1.1 //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 udo 1.2 $this->add_hidden_element( 'sub_lang', $_REQUEST['sub_lang'] );
53 udo 1.1
54     $this->add_element( new FEText("Titel", true, 10, 20));
55     $this->add_element( new FETextArea("kurzer Text", true, 10, 20));
56     $this->add_element( new FETextArea("langer Text", true, 10, 20));
57     $this->add_element( new FEText("Quelle", true, 10, 20));
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,"200px", "80px",$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 udo 1.2 $this->set_element_value("langer Text", $value['lvalue']);
75 udo 1.1 }
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 udo 1.2
144 udo 1.1 //$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_backend_validation() {
186    
187     $this->set_action("Confirm");
188     return true;
189     }
190    
191     /**
192     * This method is called ONLY after ALL validation has
193     * passed. This is the method that allows you to
194     * do something with the data, say insert/update records
195     * in the DB.
196     */
197     function confirm_action() {
198    
199     //$this->set_action_message("WOO!");
200     //print "All fetched RPC items: " . Dumper($this->_datasource->_result) . "<br>";
201     /*
202     // all of the following is to be done later !!!!!
203    
204     // get data
205     //print "All fetched RPC items: " . Dumper($this->_datasource->_result) . "<br>";
206    
207     // write new data to datasource in $data as array (keep old indices, set new values)
208     $this->_options['data_locator_meta']['action'] = "write";
209     $this->_options['data_locator_meta']['data'] = $data;
210     // TODO: 'data_prefetch()' will never return ANYTHING!
211     // Implement some error-handling there or somewhere.
212     $error = $this->data_prefetch();
213    
214     //$error = $this->_datasource->set($item);
215     if(!$error) {
216     // fetch fresh data
217     $this->_options['data_locator_meta']['action'] = "read";
218     // unset previous initialed 'data' var
219     $this->_options['data_locator_meta']['data'] = NULL;
220     $this->data_prefetch();
221    
222     $this->set_action_message($this->_confirm_msg);
223     return TRUE;
224     } else {
225     return FALSE;
226     }*/
227     return FALSE;
228     }
229    
230    
231     }
232     ?>

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