Source for file basic_view_edit.php

Documentation is available at basic_view_edit.php


1 <?php
2 /**
3 * @author Jan H. Andersen <jha@ipwsystems.dk>
4 * @author Martin R. Larsen <mrl@ipwsystems.dk>
5 * @copyright {@link http://www.ipwsystems.dk/ IPW Systems a.s}
6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
7 * @package METAjour
8 * @subpackage view
9 * $Id: basic_view_edit.php,v 1.18 2005/02/15 12:18:10 jan Exp $
10 */
11
12 require_once('basic_view.php');
13 require_once('basic_field.php');
14
15 class basic_view_edit extends basic_view {
16
17 var $_obj;
18 var $_objcols;
19 var $submittop;
20 var $_editable = true;
21
22 function basic_view_edit() {
23 $this->basic_view();
24 $this->submittop = 13;
25 }
26
27 function loadLanguage() {
28 basic_view::loadLanguage();
29 $this->loadLangFile('basic_view_edit');
30 }
31
32 function edit_create($objectid) {
33 if ($this->canView('create')) return $this->button('create.png',$this->gl('img_create'),$this->callgui($this->otype,'','','create','','combi',$this->parentid)); else return '';
34 }
35
36 function edit_tree($objectid) {
37 if ($this->CanView('list') && empty($this->parentid) && empty($this->relcol))
38 return $this->button('tree.png',$this->gl('img_hierarchy'),$this->callgui($this->otype,'','','split')); else return '';
39 }
40
41 function edit_createvariant($objectid) {
42 $_obj = owRead($objectid);
43 if ($this->CanView('createvariant') && !$_obj->isVariant()) return $this->buttononclick('createvariant.png',$this->gl('img_createvariant'),$this->ModelessDialog('',$objectid,'','createvariant','jscallerreload,jswindowclose'));
44 }
45
46 function edit_delete($objectid) {
47 if ($this->CanView('delete')) return $this->buttononclick('delete.png',$this->gl('img_delete'),$this->ModelessDialog('',$objectid,'','delete','jswindowclose'));
48 #if ($this->CanView('delete')) return $this->buttononclick('delete.png','Slet',$this->WizardDialog($this->otype,'','','wizard','jsopenerreload,jswindowclose'));
49 }
50
51 function edit_list($objectid) {
52 $_obj = owRead($objectid);
53 if ($this->CanView('list')) return $this->button('list.png',$this->gl('img_list'),$this->callgui($this->otype,'','','list','','',$_obj->getParentId()));
54 }
55
56 function edit_start($objectid) {
57 /* $nextid = $_SESSION['guitemp'][$this->otype]['list'][0];
58 if ($this->CanView('list') && empty($this->parentid) && empty($this->relcol)) {
59 if (isset($_SESSION['guitemp'][$this->otype]['list'])) {
60 return $this->button('start.png',$this->gl('img_start'),$this->callgui('',$nextid,'',$this->view));
61 }
62 }*/
63 }
64
65 function edit_previous($objectid) {
66 if ($this->CanView('list') && empty($this->parentid) && empty($this->relcol)) {
67 if (isset($_SESSION['guitemp'][$this->otype]['list'])) {
68 $index = array_search($objectid,$_SESSION['guitemp'][$this->otype]['list']);
69 if ($index !== false && $index > 0) {
70 $nextid = $_SESSION['guitemp'][$this->otype]['list'][$index-1];
71 return $this->button('prev.png',$this->gl('img_previous'),$this->callgui('',$nextid,'',$this->view,'','',$this->parentid));
72 }
73 }
74 }
75 }
76
77 function edit_next($objectid) {
78 if ($this->CanView('list') && empty($this->parentid) && empty($this->relcol)) {
79 if (isset($_SESSION['guitemp'][$this->otype]['list'])) {
80 $index = array_search($objectid,$_SESSION['guitemp'][$this->otype]['list']);
81 if ($index !== false && $index < sizeof($_SESSION['guitemp'][$this->otype]['list'])-1) {
82 $nextid = $_SESSION['guitemp'][$this->otype]['list'][$index+1];
83 return $this->button('next.png',$this->gl('img_next'),$this->callgui('',$nextid,'',$this->view,'','',$this->parentid));
84 }
85 }
86 }
87 }
88
89 function edit_end($objectid) {
90 /* $index = count($_SESSION['guitemp'][$this->otype]['list']);
91 $nextid = $_SESSION['guitemp'][$this->otype]['list'][$index-1];
92 if ($this->CanView('list') && empty($this->parentid) && empty($this->relcol)) {
93 if (isset($_SESSION['guitemp'][$this->otype]['list'])) {
94 return $this->button('end.png',$this->gl('img_end'),$this->callgui('',$nextid,'',$this->view));
95 }
96 }*/
97 }
98
99 function edit_variants($objectid) {
100 $_obj = owRead($objectid);
101 $str = '';
102 if ($_obj->hasVariant() || $_obj->getVariantOf() != 0) {
103 $str = '<select style="position: relative; top: -15px; margin-left: 10px; width: 150px;" onChange="location.href = \''.$this->ReturnMeUrl().'objectid=\' + this.options[this.selectedIndex].value;">';
104 if ($_obj->getVariantOf() != 0) {
105 $origobj = owRead($_obj->getVariantOf());
106 $str .= '<option value="'.$origobj->getObjectId().'">'.languageName($origobj->getLanguage()).' ('.$origobj->getLanguage().')</option>';
107 $arr = $origobj->getVariantsLang();
108 foreach ($arr as $cur) {
109 $s = '';
110 if ($objectid == $cur['objectid']) $s = ' SELECTED';
111 $str .= '<option value="'.$cur['objectid'].'"'.$s.'>'.languageName($cur['language']).' ('.$cur['language'].')</option>';
112 }
113 }
114 if ($_obj->hasVariant()) {
115 $str .= '<option value="'.$_obj->getObjectId().'">'.languageName($_obj->getLanguage()).' ('.$_obj->getLanguage().')</option>';
116 $arr = $_obj->getVariantsLang();
117 foreach ($arr as $cur) {
118 $s = '';
119 if ($objectid == $cur['objectid']) $s = ' SELECTED';
120 $str .= '<option value="'.$cur['objectid'].'"'.$s.'>'.languageName($cur['language']).' ('.$cur['language'].')</option>';
121 }
122 }
123 $str .= '</select>';
124 }
125 if ($this->CanView('list')) return $str;
126 }
127
128 function titleBar() {
129 return '<div class="metatitle">'.$this->shadowtext($this->gl('title').' :: '.$this->gl('name').' :: '.$this->_obj->getName()).'</div>';
130 }
131
132 function buttonBar() {
133 $result .= '<div id="buttonbar" style="margin-bottom: 5px;">';
134 $result .= $this->edit_list($this->objectid[0]);
135 $result .= $this->edit_tree($this->objectid[0]);
136 $result .= $this->edit_create($this->objectid[0]);
137 $result .= $this->edit_createvariant($this->objectid[0]);
138 $result .= $this->edit_delete($this->objectid[0]);
139 $result .= $this->edit_start($this->objectid[0]);
140 $result .= $this->edit_previous($this->objectid[0]);
141 $result .= $this->edit_next($this->objectid[0]);
142 $result .= $this->edit_end($this->objectid[0]);
143 if ($this->canView('createvariant')) $result .= $this->edit_variants($this->objectid[0]);
144 $result .= '</div>';
145 return $result;
146 }
147
148 function customFields() {
149 }
150
151 function beforeForm() {
152 return '<div class="metabox">';
153 }
154
155 function startForm() {
156 }
157
158 function endForm() {
159 }
160
161 function afterForm() {
162 return '</div>';
163 }
164
165 function viewStart() {
166 return '<div class="metawindow">';
167 }
168
169 function viewEnd() {
170 return '</div>';
171 }
172
173
174 function submitButtons() {
175 $result .= '<div style="padding-bottom: 14px;">';
176 $result .= '<input id="submit1" name="submit1" type="submit" class="mformsubmit" value="'.$this->gl('button_save').'">';
177 $result .= '<input id="submit2" name="submit2" type="button" onclick="this.form._ret.value = this.form.view.value; this.form.view.value=\'combi\'; this.form.submit();" class="mformsubmit" value="'.$this->gl('button_apply').'">';
178 $result .= '</div>';
179 return $result;
180 }
181
182 function categorySelection() {
183 $field = new basic_field($this);
184 $result .= '<div class="mformfieldset" style=""><div class="mformlabel" style="">'.$this->gl('_label_category').'</div><div class="mformfield" style="">';
185 $result .= $field->categorySelection($this->objectid[0],'__categories__');
186 $result .= '</div></div>';
187 return $result;
188 }
189
190 function webAccessSelection() {
191 $field = new basic_field($this);
192 $result .= '<div class="mformfieldset" style=""><div class="mformlabel" style="">'.$this->gl('_label_webaccess').'</div><div class="mformfield" style="">';
193 $result .= $field->webAccessSelection($this->objectid[0],'__webaccess__');
194 $result .= '</div></div>';
195 return $result;
196 }
197
198 function sysAccessSelection() {
199 $field = new basic_field($this);
200 $result .= '<div class="mformfieldset" style=""><div class="mformlabel" style="">'.$this->gl('_label_sysaccess').'</div><div class="mformfield" style="">';
201 $result .= $field->sysAccessSelection($this->objectid[0],'__sysaccess__');
202 $result .= '</div></div>';
203 return $result;
204 }
205
206 function parseFields() {
207 $fieldobj = new basic_field($this);
208 if ($this->_editable) {
209 $result .= $fieldobj->parseFieldsForm($this->_objcols,$this->_obj->elements[0],$this->_obj->isVariant(),$this->_obj->getVariantFields());
210 } else {
211 $result .= $fieldobj->parseFieldsView($this->_objcols,$this->_obj->elements[0]);
212 }
213 return $result;
214 }
215
216 function numNoneHiddenCols() {
217 $res = 0;
218 foreach ($this->_objcols as $cur) {
219 if ($cur['inputtype'] != UI_HIDDEN) $res++;
220 }
221 return $res;
222 }
223
224 function view() {
225 $stack = $this->userhandler->getObjectIdStack();
226 if (!empty($stack) && empty($this->objectid)) $this->objectid = $stack;
227 $this->context->addheader('
228 <script type="text/javascript" src="js/fValidate.config.js"></script>
229 <script type="text/javascript" src="js/fValidate.core.js"></script>
230 <script type="text/javascript" src="js/fValidate.lang-enUS.js"></script>
231 <script type="text/javascript" src="js/fValidate.validators.js"></script>
232 ');
233 $this->_obj = owRead($this->objectid[0]);
234 $this->context->addHeader('<script type="text/javascript">'.$this->relatedFieldsHeader().'</script>');
235 $this->_obj->initLayout();
236 $result .= $this->viewStart();
237 $result .= $this->titleBar();
238 $result .= $this->buttonBar();
239 $result .= $this->beforeForm();
240 $result .= '<form name="metaform" method="post" action="'.$_SERVER['PHP_SELF'].'" enctype="multipart/form-data" onsubmit="return validateForm(this);" style="spacing: 0px; margin: 0px; padding: 0px;">';
241 $result .= '<input type="hidden" name="objectid" value="'.$this->objectid[0].'">';
242 $result .= '<input type="hidden" name="cmd" value="update">';
243 $result .= '<input type="hidden" name="_ret" value="">';
244 if ($this->parentid) $result .= '<input type="hidden" name="_parentid" value="'.$this->parentid.'">';
245 if ($this->relcol) $result .= '<input type="hidden" name="_relcol" value="'.$this->relcol.'">';
246 if ($this->relval) $result .= '<input type="hidden" name="_relval" value="'.$this->relval.'">';
247 $result .= $this->returnviewpost($this->view);
248 $this->_objcols = owDatatypeColsDesc($this->otype);
249 if ($this->numNoneHiddenCols() > $this->submittop)
250 if ($this->_editable) $result .= $this->submitButtons();
251 $result .= $this->startForm();
252 $result .= $this->parseFields();
253 $result .= $this->customFields();
254 #$result .= $this->extraFields();
255 $result .= '<br>';
256 $result .= $this->endForm();
257 if ($this->_editable) $result .= $this->submitButtons();
258 if ($this->CanView('category') && $this->_editable && !$this->_obj->isVariant()) $result .= $this->categorySelection();
259 if ($this->CanView('access') && $this->_editable && !$this->_obj->isVariant()) $result .= $this->webAccessSelection();
260 if ($this->CanView('access') && $this->_editable && !$this->_obj->isVariant()) $result .= $this->sysAccessSelection();
261 $result .= '</form>';
262 $result .= $this->afterForm();
263 $result .= '<br><br><br>';
264 $result .= $this->viewEnd();;
265
266 $result .= '<script type="text/javascript">';
267 $fieldobj = new basic_field($this);
268 if ($this->_obj->isVariant()) $result .= $fieldobj->GetStatusJs($this->_obj->prv_column);
269 $result .= '</script>';
270
271 return $result;
272 }
273 }
274
275 ?>

Documentation generated on Thu, 9 Jun 2005 06:51:21 +0200 by phpDocumentor 1.2.3