Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationMain
    • NavigationTop
  • 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

Classes

  • ArticleForumRightBottom
  • cApiClickableAction
  • cApiClickableQuestionAction
  • cGuiFoldingRow
  • cGuiList
  • cGuiMenu
  • cGuiNavigation
  • cGuiNotification
  • cGuiObjectPager
  • cGuiPage
  • cGuiScrollList
  • cGuiTableForm
  • cGuiTree
  • cPager
  • cTemplate
  • cTree
  • cTreeItem
  • NoteLink
  • NoteList
  • NoteListItem
  • NoteView
  • TODOBackendList
  • TODOLink
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  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:     public $items;
 27:     public $captions;
 28:     public $id;
 29:     public $rownames;
 30:     public $itemType;
 31:     public $formname;
 32:     public $formmethod;
 33:     public $formaction;
 34:     public $formvars;
 35:     public $tableid;
 36:     public $header;
 37:     public $cancelLink;
 38:     public $submitjs;
 39: 
 40:     public function __construct($name, $action = "", $method = "post") {
 41:         global $sess;
 42:         $this->formname = $name;
 43: 
 44:         if ($action == "") {
 45:             $this->formaction = "main.php";
 46:         } else {
 47:             $this->formaction = $action;
 48:         }
 49: 
 50:         $this->formmethod = $method;
 51: 
 52:         $this->tableid = "";
 53:         $this->custom = array();
 54: 
 55:         $this->setActionButton("submit", cRegistry::getBackendUrl() . "images/but_ok.gif", i18n("Save changes"), "s");
 56:     }
 57: 
 58:     public function setVar($name, $value) {
 59:         $this->formvars[$name] = $value;
 60:     }
 61: 
 62:     public function add($caption, $field, $rowname = "") {
 63:         $n = "";
 64: 
 65:         if (is_array($field)) {
 66:             foreach ($field as $value) {
 67:                 if (is_object($value) && method_exists($value, "render")) {
 68:                     $n .= $value->render();
 69:                 } else {
 70:                     $n .= $value;
 71:                 }
 72:             }
 73: 
 74:             $field = $n;
 75:         }
 76:         if (is_object($field) && method_exists($field, "render")) {
 77:             $n = $field->render();
 78:             $field = $n;
 79:         }
 80:         if ($field == "") {
 81:             $field = "&nbsp;";
 82:         }
 83: 
 84:         if ($caption == "") {
 85:             $caption = "&nbsp;";
 86:         }
 87: 
 88:         $this->id++;
 89:         $this->items[$this->id] = $field;
 90:         $this->captions[$this->id] = $caption;
 91: 
 92:         if ($rowname == "") {
 93:             $rowname = $this->id;
 94:         }
 95: 
 96:         $this->rownames[$this->id] = $rowname;
 97:     }
 98: 
 99:     public function addCancel($link) {
100:         $this->cancelLink = $link;
101:     }
102: 
103:     public function addHeader($header) {
104:         $this->header = $header;
105:     }
106: 
107:     public function addSubHeader($header) {
108:         $this->id++;
109:         $this->items[$this->id] = '';
110:         $this->captions[$this->id] = $header;
111:         $this->itemType[$this->id] = 'subheader';
112:     }
113: 
114:     public function setSubmitJS($js) {
115:         $this->submitjs = $js;
116:     }
117: 
118:     public function setActionEvent($id, $event) {
119:         $this->custom[$id]["event"] = $event;
120:     }
121: 
122:     public function setActionButton($id, $image, $description = "", $accesskey = false, $action = false) {
123:         $this->custom[$id]["image"] = $image;
124:         $this->custom[$id]["type"] = "actionsetter";
125:         $this->custom[$id]["action"] = $action;
126:         $this->custom[$id]["description"] = $description;
127:         $this->custom[$id]["accesskey"] = $accesskey;
128:         $this->custom[$id]["event"] = "";
129:     }
130: 
131:     public function setConfirm($id, $title, $description) {
132:         $this->custom[$id]["confirmtitle"] = $title;
133:         $this->custom[$id]["confirmdescription"] = $description;
134:     }
135: 
136:     public function setTableID($tableid) {
137:         $this->tableid = $tableid;
138:     }
139: 
140:     public function unsetActionButton($id) {
141:         unset($this->custom[$id]);
142:     }
143: 
144:     public function render($return = true) {
145:         global $sess, $cfg;
146: 
147:         $tpl = new cTemplate();
148: 
149:         if ($this->submitjs != "") {
150:             $tpl->set("s", "JSEXTRA", 'onsubmit="' . $this->submitjs . '"');
151:         } else {
152:             $tpl->set("s", "JSEXTRA", '');
153:         }
154: 
155:         $tpl->set("s", "FORMNAME", $this->formname);
156:         $tpl->set("s", "METHOD", $this->formmethod);
157:         $tpl->set("s", "ACTION", $this->formaction);
158: 
159:         $this->formvars[$sess->name] = $sess->id;
160: 
161:         $hidden = "";
162:         if (is_array($this->formvars)) {
163:             foreach ($this->formvars as $key => $value) {
164:                 $val = new cHTMLHiddenField($key, $value);
165:                 $hidden .= $val->render() . "\n";
166:             }
167:         }
168: 
169:         if (!array_key_exists("action", $this->formvars)) {
170:             $val = new cHTMLHiddenField("", "");
171:             $hidden .= $val->render() . "\n";
172:         }
173: 
174:         $tpl->set("s", "HIDDEN_VALUES", $hidden);
175: 
176:         $tpl->set('s', 'ID', $this->tableid);
177: 
178:         $header = "";
179:         if ($this->header != "") {
180:             $tablerow = new cHTMLTableRow();
181:             $tablehead = new cHTMLTableHead();
182:             $tablehead->setAttribute("colspan", "2");
183:             $tablehead->setAttribute("valign", "top");
184:             $tablehead->setContent($this->header);
185:             $tablerow->setContent($tablehead);
186:             $header = $tablerow->render();
187:         }
188: 
189:         $tpl->set('s', 'HEADER', $header);
190: 
191:         if (is_array($this->items)) {
192:             foreach ($this->items as $key => $value) {
193:                 if ($this->itemType[$key] == 'subheader') {
194:                     $tablerow = new cHTMLTableRow();
195:                     $tabledata = new cHTMLTableData();
196:                     $tabledata->setAttribute("colspan", "2");
197:                     $tabledata->setAttribute("valign", "top");
198:                     $tabledata->setContent($this->captions[$key]);
199:                     $tablerow->setContent($tablehead);
200: 
201:                     $tpl->set('d', 'SUBHEADER', $tablerow->render());
202:                 } else {
203:                     $tpl->set('d', 'SUBHEADER', '');
204:                     $tpl->set('d', 'CATNAME', $this->captions[$key]);
205:                     $tpl->set('d', 'CATFIELD', $value);
206:                     $tpl->set('d', 'ROWNAME', $this->rownames[$key]);
207: 
208:                     $tpl->next();
209:                 }
210:             }
211:         }
212: 
213:         if ($this->cancelLink != "") {
214:             $image = new cHTMLImage(cRegistry::getBackendUrl() . 'images/but_cancel.gif');
215:             $link = new cHTMLLink($this->cancelLink);
216:             $link->setContent($image);
217: 
218:             $tpl->set('s', 'CANCELLINK', $link->render());
219:         } else {
220:             $tpl->set('s', 'CANCELLINK', '');
221:         }
222: 
223:         $custombuttons = "";
224: 
225:         foreach ($this->custom as $key => $value) {
226:             if ($value["accesskey"] != "") {
227:                 $accesskey = $value["accesskey"];
228:             } else {
229:                 $accesskey = "";
230:             }
231: 
232:             $onclick = "";
233:             if ($value["action"] !== false) {
234: 
235:                 if ($value["confirmtitle"] != "") {
236:                     $action = 'document.forms["' . $this->formname . '"].elements["action"].value = "' . $value['action'] . '";';
237:                     $action .= 'document.forms["' . $this->formname . '"].submit()';
238: 
239:                     $onclick = 'showConfirmation("' . $value['confirmdescription'] . '", function() { ' . $action . ' });return false;';
240:                 } else {
241:                     $onclick = 'document.forms["' . $this->formname . '"].elements["action"].value = "' . $value['action'] . '";';
242:                 }
243:             }
244: 
245:             if ($value["event"] != "") {
246:                 $onclick .= $value["event"];
247:             }
248: 
249:             $button = new cHTMLFormElement("submit", "", "", "", "", "image_button");
250:             $button->setAttribute("type", "image");
251:             $button->setAttribute("src", $value["image"]);
252:             $button->setAlt($value['description']);
253:             $button->setAttribute("accesskey", $accesskey);
254:             $button->setEvent("onclick", $onclick);
255:             $custombuttons .= $button->render();
256:         }
257: 
258:         $tpl->set('s', 'EXTRABUTTONS', $custombuttons);
259: 
260:         $tpl->set('s', 'ROWNAME', $this->id);
261: 
262:         $rendered = $tpl->generate(cRegistry::getBackendPath() . $cfg['path']['templates'] . $cfg['templates']['generic_table_form'], true);
263: 
264:         if ($return == true) {
265:             return ($rendered);
266:         } else {
267:             echo $rendered;
268:         }
269:     }
270: 
271: }
272: 
CMS CONTENIDO 4.9.0 API documentation generated by ApiGen 2.8.0