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

Classes

  • cGuiBackendHelpbox
  • cGuiFileOverview
  • cGuiFoldingRow
  • cGuiList
  • cGuiMenu
  • cGuiNavigation
  • cGuiNotification
  • cGuiObjectPager
  • cGuiPage
  • cGuiScrollList
  • cGuiSourceEditor
  • cGuiTableForm
  • cGuiTree
  • cPager
  • cTemplate
  • cTree
  • cTreeItem
  • NoteLink
  • NoteList
  • NoteListItem
  • NoteView
  • TODOLink
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * This file contains the tree GUI class.
  5:  *
  6:  * @package          Core
  7:  * @subpackage       GUI
  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:  * cGuiTree is a visual representation of a cTree. It supports folding,
 20:  * optional gridline marks and item icons.
 21:  *
 22:  * @package    Core
 23:  * @subpackage GUI
 24:  */
 25: class cGuiTree extends cTree {
 26: 
 27:     /**
 28:      *
 29:      * @var string
 30:      */
 31:     const TREEVIEW_GRIDLINE_SOLID = 'solid';
 32: 
 33:     /**
 34:      *
 35:      * @var string
 36:      */
 37:     const TREEVIEW_GRIDLINE_DASHED = 'dashed';
 38: 
 39:     /**
 40:      *
 41:      * @var string
 42:      */
 43:     const TREEVIEW_GRIDLINE_DOTTED = 'dotted';
 44: 
 45:     /**
 46:      *
 47:      * @var string
 48:      */
 49:     const TREEVIEW_GRIDLINE_NONE = 'none';
 50: 
 51:     /**
 52:      *
 53:      * @var string
 54:      * @deprecated [2015-05-21]
 55:      *    This constant is no longer supported (no replacement)
 56:      */
 57:     const TREEVIEW_BACKGROUND_NONE = 'none';
 58: 
 59:     /**
 60:      *
 61:      * @var string
 62:      * @deprecated [2015-05-21]
 63:      *         This constant is no longer supported (no replacement)
 64:      */
 65:     const TREEVIEW_BACKGROUND_SHADED = 'shaded';
 66: 
 67:     /**
 68:      *
 69:      * @var string
 70:      * @deprecated [2015-05-21]
 71:      *         This constant is no longer supported (no replacement)
 72:      */
 73:     const TREEVIEW_MOUSEOVER_NONE = 'none';
 74: 
 75:     /**
 76:      *
 77:      * @var string
 78:      * @deprecated [2015-05-21]
 79:      *         This constant is no longer supported (no replacement)
 80:      */
 81:     const TREEVIEW_MOUSEOVER_MARK = 'mark';
 82: 
 83:     /**
 84:      * @var cApiUser
 85:      */
 86:     protected $_user;
 87: 
 88:     /**
 89:      * @var string
 90:      */
 91:     protected $_uuid;
 92: 
 93:     /**
 94:      * @var string
 95:      */
 96:     protected $_gridlineMode;
 97: 
 98:     /**
 99:      * @var string
100:      */
101:     private $_baseLink;
102: 
103:     /**
104:      * Constructor to create an instance of this class.
105:      *
106:      * @param string $uuid
107:      * @param string $treename [optional]
108:      */
109:     public function __construct($uuid, $treename = false) {
110:         global $cfg, $auth;
111: 
112:         parent::__construct();
113: 
114:         $this->_uuid = $uuid;
115:         //$this->setGridlineMode(self::TREEVIEW_GRIDLINE_DOTTED);
116: 
117:         if ($treename != false) {
118:             $this->setTreeName($treename);
119:         }
120: 
121:         $this->_user = new cApiUser($auth->auth["uid"]);
122:     }
123: 
124:     /**
125:      *
126:      */
127:     public function processParameters() {
128:         if (($items = $this->_user->getUserProperty("expandstate", $this->_uuid)) !== false) {
129:             $list = unserialize($items);
130: 
131:             foreach ($list as $litem) {
132:                 $this->setCollapsed($litem);
133:             }
134:         }
135: 
136:         if (!empty($this->_name)) {
137:             $treename = $this->_name . "_";
138:         }
139: 
140:         if (array_key_exists($treename . "collapse", $_GET)) {
141:             $this->setCollapsed($_GET[$treename . "collapse"]);
142:         }
143: 
144:         if (array_key_exists($treename . "expand", $_GET)) {
145:             $this->setExpanded($_GET[$treename . "expand"]);
146:         }
147: 
148:         $xlist = array(); // Define variable before using it by reference...
149:         $this->getCollapsedList($xlist);
150:         $slist = serialize($xlist);
151: 
152:         $this->_user->setUserProperty("expandstate", $this->_uuid, $slist);
153:     }
154: 
155:     /**
156:      * @param int $mode
157:      *         Sets the gridline mode to one of the following values:
158:      *         - cGuiTree::TREEVIEW_GRIDLINE_SOLID
159:      *         - cGuiTree::TREEVIEW_GRIDLINE_DASHED
160:      *         - cGuiTree::TREEVIEW_GRIDLINE_DOTTED
161:      *         - cGuiTree::TREEVIEW_GRIDLINE_NONE
162:      */
163:     public function setGridlineMode($mode) {
164:         $this->_gridlineMode = $mode;
165:     }
166: 
167:     /**
168:      *
169:      * @param unknown_type $mode
170:      * @deprecated [2015-05-21]
171:      *         This method is no longer supported (no replacement)
172:      */
173:     public function setBackgroundMode($mode) {
174:         cDeprecated('This method is deprecated and is not needed any longer');
175:         $this->_backgroundMode = $mode;
176:     }
177: 
178:     /**
179:      *
180:      * @param unknown_type $mode
181:      * @deprecated [2015-05-21]
182:      *         This method is no longer supported (no replacement)
183:      */
184:     public function setMouseoverMode($mode) {
185:         cDeprecated('This method is deprecated and is not needed any longer');
186:         $this->_mouseoverMode = $mode;
187:     }
188: 
189:     /**
190:      *
191:      * @param unknown_type $colors
192:      * @deprecated [2015-05-21]
193:      *         This method is no longer supported (no replacement)
194:      */
195:     public function setBackgroundColors($colors) {
196:         cDeprecated('This method is deprecated and is not needed any longer');
197:         $this->_backgroundColors = $colors;
198:     }
199: 
200:     /**
201:      *
202:      * @param bool $with_root [optional]
203:      * @return string
204:      */
205:     public function render($with_root = true) {
206: 
207:         /* @var $objects cTreeItem[] */
208:         $objects = $this->flatTraverse(0);
209: 
210:         if ($with_root == false) {
211:             unset($objects[0]);
212:         }
213: 
214:         $img = new cHTMLImage;
215:         $r_table = new cHTMLTable;
216:         $r_row = new cHTMLTableRow;
217:         $r_leftcell = new cHTMLTableData;
218:         $r_rightcell = new cHTMLTableData;
219:         $r_actioncell = new cHTMLTableData;
220: 
221:         $img_spacer = new cHTMLImage;
222:         $img_spacer->updateAttributes(array('width' => '16', 'height' => '20'));
223:         $img_spacer->setAlt("");
224:         $img_spacer->setSrc("images/spacer.gif");
225:         $img_spacer->advanceID();
226: 
227:         $r_table->setCellPadding(0);
228:         $r_table->setCellSpacing(0);
229:         $r_table->setWidth("100%");
230:         $r_rightcell->appendStyleDefinition("padding-left", "3px");
231:         $r_rightcell->setVerticalAlignment("middle");
232:         $r_leftcell->setVerticalAlignment("middle");
233:         $r_leftcell->updateAttributes(array("nowrap" => "nowrap"));
234:         $r_rightcell->updateAttributes(array("nowrap" => "nowrap"));
235:         $r_actioncell->updateAttributes(array("nowrap" => "nowrap"));
236:         $r_leftcell->setWidth("1%");
237:         $r_rightcell->setWidth("100%");
238:         $r_actioncell->setAlignment("right");
239:         $r_actioncell->setWidth("1%");
240: 
241:         if (!is_object($this->_baseLink)) {
242:             $this->_baseLink = new cHTMLLink();
243:         }
244: 
245:         $out = $result = '';
246: 
247:         $lastitem = array();
248:         foreach ($objects as $key => $object) {
249:             $img->setAlt("");
250:             $r_table->advanceID();
251:             $r_rightcell->advanceID();
252:             $r_leftcell->advanceID();
253:             $r_row->advanceID();
254:             $r_actioncell->advanceID();
255: 
256:             for ($level = 1; $level < $object->_level + 1; $level++) {
257:                 if ($object->_level == $level) {
258:                     if ($object->_next === false) {
259:                         if (count($object->_subitems) > 0) {
260:                             $link = $this->_setExpandCollapseLink($this->_baseLink, $object);
261:                             $link->advanceID();
262:                             $img->setSrc($this->_getExpandCollapseIcon($object));
263:                             $img->advanceID();
264:                             $link->setContent($img);
265:                             $out .= $link->render();
266:                         } else {
267:                             if ($level == 1 && $with_root == false) {
268:                                 $out .= $img_spacer->render();
269:                             } else {
270:                                 $img->setSrc($this->_buildImagePath("grid_linedownrightend.gif"));
271:                                 $img->advanceID();
272:                                 $out .= $img->render();
273:                             }
274:                         }
275:                         $lastitem[$level] = true;
276:                     } else {
277:                         if (count($object->_subitems) > 0) {
278:                             $link = $this->_setExpandCollapseLink($this->_baseLink, $object);
279:                             $link->advanceID();
280:                             $img->setSrc($this->_getExpandCollapseIcon($object));
281:                             $img->advanceID();
282:                             $link->setContent($img);
283:                             $out .= $link->render();
284:                         } else {
285:                             if ($level == 1 && $with_root == false) {
286:                                 $out .= $img_spacer->render();
287:                             } else {
288:                                 $img->setSrc($this->_buildImagePath("grid_linedownright.gif"));
289:                                 $out .= $img->render();
290:                             }
291:                         }
292: 
293:                         $lastitem[$level] = false;
294:                     }
295:                 } else {
296:                     if ($lastitem[$level] == true) {
297:                         $out .= $img_spacer->render();
298:                     } else {
299:                         if ($level == 1 && $with_root == false) {
300:                             $out .= $img_spacer->render();
301:                         } else {
302:                             $img->setSrc($this->_buildImagePath("/grid_linedown.gif"));
303:                             $img->advanceID();
304:                             $out .= $img->render();
305:                         }
306:                     }
307:                 }
308:             }
309: 
310:             // Fetch Render icon from the meta object
311:             if (is_object($object->payload)) {
312:                 // Fetch payload object
313:                 $meta = $object->payload->getMetaObject();
314: 
315:                 if (is_object($meta)) {
316:                     $icon = $meta->getIcon();
317:                     $actions = $meta->getActions();
318: 
319:                     $r_actioncell->setContent($actions);
320: 
321:                     $img->setAlt($meta->getDescription());
322:                     $img->advanceID();
323: 
324:                     // Check if we've got an edit link
325:                     if (count($meta->_editAction) > 0) {
326:                         $meta->defineActions();
327: 
328:                         $edit = $meta->getAction($meta->_editAction);
329: 
330:                         $edit->setIcon($icon);
331: 
332:                         $renderedIcon = $edit->render();
333: 
334:                         $edit->_link->setContent($object->getName());
335:                         $edit->_link->advanceID();
336:                         $renderedName = $edit->_link->render();
337:                     } else {
338:                         $img->setSrc($icon);
339:                         $renderedIcon = $img->render();
340:                         $renderedName = $object->getName();
341:                     }
342:                 }
343:             } else {
344:                 if (isset($object->_attributes["icon"])) {
345:                     $img->setSrc($object->_attributes["icon"]);
346:                     $renderedIcon = $img->render();
347:                     $renderedName = $object->getName();
348:                 } else {
349:                     // Fetch tree icon
350:                     if ($object->getId() == 0) {
351:                         $icon = $object->getTreeIcon();
352:                         $img->setSrc($icon);
353:                         $renderedIcon = $img->render();
354:                         $renderedName = $object->getName();
355:                     } else {
356:                         $icon = $object->getTreeIcon();
357:                         $img->setSrc($icon);
358:                         $renderedIcon = $img->render();
359:                         $renderedName = $object->getName();
360:                     }
361:                 }
362:             }
363: 
364:             $img->setSrc($icon);
365:             $r_leftcell->setContent($out . $renderedIcon);
366:             $r_rightcell->setContent($renderedName);
367: 
368:             $r_row->setContent(array($r_leftcell, $r_rightcell, $r_actioncell));
369: 
370:             $r_table->setContent($r_row);
371: 
372:             $result .= $r_table->render();
373: 
374:             unset($out);
375:         }
376: 
377:         return '<table cellspacing="0" cellpadding="0" width="100%" border="0"><tr><td>' . $result . '</td></tr></table>';
378:     }
379: 
380:     /**
381:      *
382:      * @param cTreeItem $object
383:      * @return string
384:      */
385:     public function _getExpandCollapseIcon($object) {
386: 
387:         $img = $object->getCollapsed() ? "grid_expand.gif" : "grid_collapse.gif";
388: 
389:         return $this->_buildImagePath($img);
390:     }
391: 
392:     /**
393:      * Sets collapsed state.
394:      *
395:      * @param cHTMLLink  $link
396:      * @param cTreeItem  $object
397:      * @return cHTMLLink
398:      */
399:     public function _setExpandCollapseLink($link, $object) {
400:         if (!empty($this->_name)) {
401:             $treename = $this->_name . "_";
402:         }
403: 
404:         $link->unsetCustom($treename . "expand");
405:         $link->unsetCustom($treename . "collapse");
406: 
407:         if ($object->getCollapsed() == true) {
408:             $link->setCustom($treename . "expand", $object->getId());
409:         } else {
410:             $link->setCustom($treename . "collapse", $object->getId());
411:         }
412: 
413:         return $link;
414:     }
415: 
416:     /**
417:      *
418:      * @param string $image
419:      * @return string
420:      */
421:     public function _buildImagePath($image) {
422:         return "./images/" . $this->_gridlineMode . "/" . $image;
423:     }
424: 
425:     /**
426:      *
427:      * @param string $link
428:      */
429:     public function setBaseLink($link) {
430:         $this->_baseLink = $link;
431:     }
432: 
433: }
434: 
CMS CONTENIDO 4.9.11 API documentation generated by ApiGen 2.8.0