Overview

Packages

  • CONTENIDO
  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentRssCreator
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
    • ScriptCookieDirective
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob
  • Smarty
    • Cacher
    • Compiler
    • Config
    • Debug
    • PluginsBlock
    • PluginsFilter
    • PluginsFunction
    • PluginsInternal
    • PluginsModifier
    • PluginsModifierCompiler
    • PluginsShared
    • Security
    • Template
    • TemplateResources
  • Swift
    • ByteStream
    • CharacterStream
    • Encoder
    • Events
    • KeyCache
    • Mailer
    • Mime
    • Plugins
    • Transport

Classes

  • Swift_FailoverTransport
  • Swift_LoadBalancedTransport
  • Swift_MailTransport
  • Swift_Plugins_Loggers_ArrayLogger
  • Swift_Plugins_Loggers_EchoLogger
  • Swift_SendmailTransport
  • Swift_SmtpTransport
  • Swift_Transport_AbstractSmtpTransport
  • Swift_Transport_Esmtp_Auth_CramMd5Authenticator
  • Swift_Transport_Esmtp_Auth_LoginAuthenticator
  • Swift_Transport_Esmtp_Auth_PlainAuthenticator
  • Swift_Transport_Esmtp_AuthHandler
  • Swift_Transport_EsmtpTransport
  • Swift_Transport_FailoverTransport
  • Swift_Transport_LoadBalancedTransport
  • Swift_Transport_MailTransport
  • Swift_Transport_SendmailTransport
  • Swift_Transport_SimpleMailInvoker
  • Swift_Transport_StreamBuffer

Interfaces

  • Swift_Plugins_Logger
  • Swift_Plugins_Pop_Pop3Exception
  • Swift_Transport
  • Swift_Transport_Esmtp_Authenticator
  • Swift_Transport_EsmtpHandler
  • Swift_Transport_IoBuffer
  • Swift_Transport_MailInvoker
  • Swift_Transport_SmtpAgent
  • Swift_TransportException
  • Overview
  • Package
  • Function
  • Todo
  • Download
  1: <?php
  2: /**
  3:  * This file contains the table form GUI class.
  4:  *
  5:  * @package Core
  6:  * @subpackage GUI
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Mischa Holz
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Table form GUI class.
 20:  *
 21:  * @package Core
 22:  * @subpackage GUI
 23:  */
 24: class cGuiTableForm {
 25: 
 26:     /**
 27:      * accept charset of form tag
 28:      * @var string
 29:      */
 30:     private $_acceptCharset = '';
 31: 
 32:     /**
 33:      *
 34:      * @var array
 35:      */
 36:     public $items = array();
 37: 
 38:     /**
 39:      *
 40:      * @var array
 41:      */
 42:     public $captions = array();
 43: 
 44:     /**
 45:      *
 46:      * @var int
 47:      */
 48:     public $id = 0;
 49: 
 50:     /**
 51:      *
 52:      * @var array
 53:      */
 54:     public $rownames = array();
 55: 
 56:     /**
 57:      *
 58:      * @var  array
 59:      */
 60:     public $itemType = array();
 61: 
 62:     /**
 63:      *
 64:      * @var string
 65:      */
 66:     public $formname;
 67: 
 68:     /**
 69:      *
 70:      * @var string
 71:      */
 72:     public $formmethod;
 73: 
 74:     /**
 75:      *
 76:      * @var string
 77:      */
 78:     public $formaction;
 79: 
 80:     /**
 81:      *
 82:      * @var array
 83:      */
 84:     public $formvars = array();
 85: 
 86:     /**
 87:      *
 88:      * @var string
 89:      */
 90:     public $tableid = "";
 91: 
 92:     /**
 93:      *
 94:      * @var string
 95:      */
 96:     public $header;
 97: 
 98:     /**
 99:      *
100:      * @var string
101:      */
102:     public $cancelLink;
103: 
104:     /**
105:      *
106:      * @var string
107:      */
108:     public $submitjs;
109: 
110:     /**
111:      *
112:      * @var array
113:      */
114:     public $custom = array();
115: 
116:     /**
117:      * Creates a new cGuiTableForm with given name, action & method of form.
118:      *
119:      * @param string $name of form
120:      * @param string $action of form defaults to 'main.php'
121:      * @param string $method of form defaults to 'post'
122:      */
123:     public function __construct($name, $action = 'main.php', $method = 'post') {
124: 
125:         // action defaults to 'main.php'
126:         if ($action == '') {
127:             $action = 'main.php';
128:         }
129: 
130:         // set name, action & method
131:         $this->formname = $name;
132:         $this->formaction = $action;
133:         $this->formmethod = $method;
134: 
135:         $this->setActionButton('submit', cRegistry::getBackendUrl() . 'images/but_ok.gif', i18n('Save changes'), 's');
136:     }
137: 
138:     /**
139:      *
140:      * @param string $name
141:      * @param mixed $value
142:      */
143:     public function setVar($name, $value) {
144:         $this->formvars[$name] = $value;
145:     }
146: 
147:     /**
148:      * Adds a new caption, item and row name.
149:      *
150:      * @param string $caption
151:      * @param array|object|string $item
152:      * @param string $rowname
153:      */
154:     public function add($caption, $item, $rowname = "") {
155: 
156:         // handle item as array of items
157:         if (is_array($item)) {
158:             $temp = "";
159:             foreach ($item as $value) {
160:                 if (is_object($value) && method_exists($value, "render")) {
161:                     $temp .= $value->render();
162:                 } else {
163:                     $temp .= $value;
164:                 }
165:             }
166:             $item = $temp;
167:         }
168: 
169:         // handle item as object
170:         if (is_object($item) && method_exists($item, "render")) {
171:             $item = $item->render();
172:         }
173: 
174:         // increase ID
175:         $this->id++;
176: 
177:         // set defaults
178:         if ($caption == "") {
179:             $caption = "&nbsp;";
180:         }
181:         if ($item == "") {
182:             $item = "&nbsp;";
183:         }
184:         if ($rowname == "") {
185:             $rowname = $this->id;
186:         }
187: 
188:         $this->captions[$this->id] = $caption;
189:         $this->items[$this->id] = $item;
190:         $this->rownames[$this->id] = $rowname;
191:     }
192: 
193:     /**
194:      * Sets an URL as HREF of a cancel icon.
195:      *
196:      * @param string $link
197:      */
198:     public function addCancel($link) {
199:         $this->cancelLink = $link;
200:     }
201: 
202:     /**
203:      * Sets the header. The header is *set* not *added*!
204:      *
205:      * @param string $header
206:      * @todo rename addHeader() to setHeader()
207:      */
208:     public function addHeader($header) {
209:         $this->header = $header;
210:     }
211: 
212:     /**
213:      *
214:      * @param string $header
215:      */
216:     public function addSubHeader($header) {
217:         $this->id++;
218:         $this->items[$this->id] = '';
219:         $this->captions[$this->id] = $header;
220:         $this->itemType[$this->id] = 'subheader';
221:     }
222: 
223:     /**
224:      *
225:      * @param string $js
226:      */
227:     public function setSubmitJS($js) {
228:         $this->submitjs = $js;
229:     }
230: 
231:     /**
232:      * Sets the accept-charset attribute of form tag
233:      * @param string $charset
234:      */
235:     public function setAcceptCharset($charset) {
236:         $this->_acceptCharset = $charset;
237:     }
238: 
239:     /**
240:      *
241:      * @param unknown_type $id
242:      * @param unknown_type $event
243:      */
244:     public function setActionEvent($id, $event) {
245:         $this->custom[$id]["event"] = $event;
246:     }
247: 
248:     /**
249:      *
250:      * @param unknown_type $id
251:      * @param unknown_type $image
252:      * @param unknown_type $description
253:      * @param unknown_type $accesskey
254:      * @param unknown_type $action
255:      */
256:     public function setActionButton($id, $image, $description = "", $accesskey = false, $action = false) {
257:         $this->custom[$id]["image"] = $image;
258:         $this->custom[$id]["type"] = "actionsetter";
259:         $this->custom[$id]["action"] = $action;
260:         $this->custom[$id]["description"] = $description;
261:         $this->custom[$id]["accesskey"] = $accesskey;
262:         $this->custom[$id]["event"] = "";
263:     }
264: 
265:     /**
266:      *
267:      * @param unknown_type $id
268:      * @param unknown_type $title
269:      * @param unknown_type $description
270:      */
271:     public function setConfirm($id, $title, $description) {
272:         $this->custom[$id]["confirmtitle"] = $title;
273:         $this->custom[$id]["confirmdescription"] = $description;
274:     }
275: 
276:     /**
277:      *
278:      * @param string $tableid
279:      */
280:     public function setTableID($tableid) {
281:         $this->tableid = $tableid;
282:     }
283: 
284:     /**
285:      *
286:      * @param unknown_type $id
287:      */
288:     public function unsetActionButton($id) {
289:         unset($this->custom[$id]);
290:     }
291: 
292:     /**
293:      * Renders this cGuiTableForm and either returs ist markup or echoes it
294:      * immediately.
295:      *
296:      * @param bool $return if true then return markup, else echo immediately
297:      * @return Ambigous <string, mixed>
298:      */
299:     public function render($return = true) {
300:         global $sess, $cfg;
301: 
302:         $tpl = new cTemplate();
303: 
304:         if ($this->submitjs != "") {
305:             if (strlen($this->_acceptCharset) > 0) {
306:                 $tpl->set("s", "JSEXTRA", 'onsubmit="' . $this->submitjs
307:                         . '" accept-charset="' . $this->_acceptCharset . '"');
308:             } else {
309:                 $tpl->set("s", "JSEXTRA", 'onsubmit="' . $this->submitjs . '"');
310:             }
311:         } else {
312:             if (strlen($this->_acceptCharset) > 0) {
313:                 $tpl->set("s", "JSEXTRA", 'accept-charset="' . $this->_acceptCharset . '"');
314:             } else {
315:                 $tpl->set("s", "JSEXTRA", '');
316:             }
317:         }
318: 
319:         $tpl->set("s", "FORMNAME", $this->formname);
320:         $tpl->set("s", "METHOD", $this->formmethod);
321:         $tpl->set("s", "ACTION", $this->formaction);
322: 
323:         $this->formvars[$sess->name] = $sess->id;
324: 
325:         $hidden = "";
326:         if (is_array($this->formvars)) {
327:             foreach ($this->formvars as $key => $value) {
328:                 $val = new cHTMLHiddenField($key, $value);
329:                 $hidden .= $val->render() . "\n";
330:             }
331:         }
332: 
333:         if (!array_key_exists("action", $this->formvars)) {
334:             $val = new cHTMLHiddenField("", "");
335:             $hidden .= $val->render() . "\n";
336:         }
337: 
338:         $tpl->set("s", "HIDDEN_VALUES", $hidden);
339: 
340:         $tpl->set('s', 'ID', $this->tableid);
341: 
342:         $header = "";
343:         if ($this->header != "") {
344:             $tablerow = new cHTMLTableRow();
345:             $tablehead = new cHTMLTableHead();
346:             $tablehead->setAttribute("colspan", "2");
347:             $tablehead->setAttribute("valign", "top");
348:             $tablehead->setContent($this->header);
349:             $tablerow->setContent($tablehead);
350:             $header = $tablerow->render();
351:         }
352: 
353:         $tpl->set('s', 'HEADER', $header);
354: 
355:         if (is_array($this->items)) {
356:             foreach ($this->items as $key => $value) {
357:                 if ($this->itemType[$key] == 'subheader') {
358:                     $tablerow = new cHTMLTableRow();
359:                     $tabledata = new cHTMLTableData();
360:                     $tabledata->setAttribute("colspan", "2");
361:                     $tabledata->setAttribute("valign", "top");
362:                     $tabledata->setContent($this->captions[$key]);
363:                     $tablerow->setContent($tablehead);
364: 
365:                     $tpl->set('d', 'SUBHEADER', $tablerow->render());
366:                 } else {
367:                     $tpl->set('d', 'SUBHEADER', '');
368:                     $tpl->set('d', 'CATNAME', $this->captions[$key]);
369:                     $tpl->set('d', 'CATFIELD', $value);
370:                     $tpl->set('d', 'ROWNAME', $this->rownames[$key]);
371: 
372:                     $tpl->next();
373:                 }
374:             }
375:         }
376: 
377:         if ($this->cancelLink != "") {
378:             $image = new cHTMLImage(cRegistry::getBackendUrl() . 'images/but_cancel.gif');
379:             $link = new cHTMLLink($this->cancelLink);
380:             $link->setContent($image);
381: 
382:             $tpl->set('s', 'CANCELLINK', $link->render());
383:         } else {
384:             $tpl->set('s', 'CANCELLINK', '');
385:         }
386: 
387:         $custombuttons = "";
388: 
389:         foreach ($this->custom as $key => $value) {
390:             if ($value["accesskey"] != "") {
391:                 $accesskey = $value["accesskey"];
392:             } else {
393:                 $accesskey = "";
394:             }
395: 
396:             $onclick = "";
397:             if ($value["action"] !== false) {
398: 
399:                 if ($value["confirmtitle"] != "") {
400:                     $action = 'document.forms["' . $this->formname . '"].elements["action"].value = "' . $value['action'] . '";';
401:                     $action .= 'document.forms["' . $this->formname . '"].submit()';
402: 
403:                     $onclick = 'Con.showConfirmation("' . $value['confirmdescription'] . '", function() { ' . $action . ' });return false;';
404:                 } else {
405:                     $onclick = 'document.forms["' . $this->formname . '"].elements["action"].value = "' . $value['action'] . '";';
406:                 }
407:             }
408: 
409:             if ($value["event"] != "") {
410:                 $onclick .= $value["event"];
411:             }
412: 
413:             $button = new cHTMLFormElement("submit", "", "", "", "", "image_button");
414:             $button->setAttribute("type", "image");
415:             $button->setAttribute("src", $value["image"]);
416:             $button->setAlt($value['description']);
417:             $button->setAttribute("accesskey", $accesskey);
418:             $button->setEvent("onclick", $onclick);
419:             $custombuttons .= $button->render();
420:         }
421: 
422:         $tpl->set('s', 'EXTRABUTTONS', $custombuttons);
423: 
424:         $tpl->set('s', 'ROWNAME', $this->id);
425: 
426:         $rendered = $tpl->generate(cRegistry::getBackendPath() . $cfg['path']['templates'] . $cfg['templates']['generic_table_form'], true);
427: 
428:         if ($return == true) {
429:             return $rendered;
430:         } else {
431:             echo $rendered;
432:         }
433:     }
434: }
435: 
CMS CONTENIDO 4.9.7 API documentation generated by ApiGen