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
    • 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
  • cGuiBackendHelpbox
  • 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 generic page 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: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 16: 
 17: /**
 18:  * Generic page GUI class.
 19:  * Manages HTML pages and provides functions for rendering them.
 20:  *
 21:  * @package Core
 22:  * @subpackage GUI
 23:  */
 24: class cGuiPage {
 25: 
 26:     /**
 27:      * The name of the page.
 28:      * This will be used to load the template, stylesheets and scripts.
 29:      *
 30:      * @var string
 31:      */
 32:     protected $_pageName;
 33: 
 34:     /**
 35:      * The name of the plugin of the current webpage.
 36:      *
 37:      * @var string
 38:      */
 39:     protected $_pluginName;
 40: 
 41:     /**
 42:      * The general page template.
 43:      *
 44:      * @var cTemplate
 45:      */
 46:     protected $_pageTemplate;
 47: 
 48:     /**
 49:      * The template for everything that is inside the body.
 50:      * (Usually template.PAGENAME.html)
 51:      *
 52:      * @var cTemplate
 53:      */
 54:     protected $_contentTemplate;
 55: 
 56:     /**
 57:      * An array of script names (inside /scripts/) which will be included in the
 58:      * final page.
 59:      *
 60:      * @var array
 61:      */
 62:     protected $_scripts;
 63: 
 64:     /**
 65:      * An array of stylesheets (inside /styles/) which will be included in the
 66:      * final page.
 67:      *
 68:      * @var array
 69:      */
 70:     protected $_styles;
 71: 
 72:     /**
 73:      * The script to set the subnavigation.
 74:      * This will be included in the final page.
 75:      *
 76:      * @var string
 77:      */
 78:     protected $_subnav;
 79: 
 80:     /**
 81:      * The script to markup the current submenu item.
 82:      * This will be included in the final page.
 83:      *
 84:      * @var string
 85:      */
 86:     protected $_markScript;
 87: 
 88:     /**
 89:      * An error message which will be used to display an error with the help of
 90:      * cGuiNotification
 91:      *
 92:      * @var string
 93:      */
 94:     protected $_error;
 95: 
 96:     /**
 97:      * A warning which will be used to display an error with the help of
 98:      * cGuiNotification
 99:      *
100:      * @var string
101:      */
102:     protected $_warning;
103: 
104:     /**
105:      * An info which will be used to display an error with the help of
106:      * cGuiNotification
107:      *
108:      * @var string
109:      */
110:     protected $_info;
111: 
112:     /**
113:      * If true, just display the message and don't render the template
114:      *
115:      * @var bool
116:      */
117:     protected $_abort;
118: 
119:     /**
120:      * An array of cHTML objects which will be rendered instead of filling a
121:      * template.
122:      *
123:      * @var array
124:      */
125:     protected $_objects;
126: 
127:     /**
128:      * Array of arrays where each array contains information about a meta tag.
129:      *
130:      * @var array
131:      */
132:     protected $_metaTags;
133: 
134:     /**
135:      * Array of class attribute values for body tag.
136:      *
137:      * @var array
138:      */
139:     protected $_bodyClassNames;
140: 
141:     /**
142:      * The constructor initializes the class and tries to get the encoding from
143:      * the currently selected language.
144:      * It will also add every script in the form of /scripts/*.PAGENAME.js and
145:      * every stylesheet in the form
146:      * of/styles/*.PAGENAME.css to the page as well as /scripts/PAGENAME.js and
147:      * /styles/PAGENAME.css.
148:      *
149:      * @param string $pageName The name of the page which will be used to load
150:      *        corresponding stylehseets, templates and scripts.
151:      * @param string $pluginName The name of the plugin in which the site is run
152:      * @param string $subMenu The number of the submenu which should be
153:      *        highlighted when this page is shown.
154:      */
155:     /**
156:      * Scripts and styles subfolder for cGuiPage objects
157:      *
158:      * @var string
159:      */
160:     const filesDirectory = 'includes/';
161: 
162:     public function __construct($pageName, $pluginName = '', $subMenu = '') {
163:         global $lang, $cfg, $sess;
164: 
165:         $this->_pageName = $pageName;
166:         $this->_pluginName = $pluginName;
167:         $this->_pageTemplate = new cTemplate();
168:         $this->_contentTemplate = new cTemplate();
169:         $this->_scripts = array();
170:         $this->_styles = array();
171:         $this->_subnav = '';
172:         $this->_markScript = '';
173:         $this->_error = '';
174:         $this->_warning = '';
175:         $this->_info = '';
176:         $this->_abort = false;
177:         $this->_objects = array();
178:         $this->_metaTags = array();
179:         $this->_bodyClassNames = array();
180: 
181:         // Try to extract the current CONTENIDO language
182:         $clang = new cApiLanguage($lang);
183: 
184:         if ($clang->isLoaded()) {
185:             $this->setEncoding($clang->get('encoding'));
186:         }
187: 
188:         $this->_pageTemplate->set('s', 'SUBMENU', $subMenu);
189:         $this->_pageTemplate->set('s', 'PAGENAME', $pageName);
190:         $pageid = str_replace('.', '_', $pageName);
191:         $this->_pageTemplate->set('s', 'PAGENAME', $pageName);
192:         $this->_pageTemplate->set('s', 'PAGEID', $pageid);
193: 
194:         $this->addBodyClassName('page_generic');
195:         $this->addBodyClassName('page_' . $pageid);
196: 
197:         if (cFileHandler::exists($cfg['path']['styles_includes'] . $pageName . '.css')) {
198:             $this->addStyle(cGuiPage::filesDirectory . $pageName . '.css');
199:         }
200: 
201:         /**
202:          *
203:          * @var $stylefile SplFileInfo
204:          */
205:         foreach (new DirectoryIterator($cfg['path']['styles_includes']) as $stylefile) {
206:             if (cString::endsWith($stylefile->getFilename(), '.' . $pageName . '.css')) {
207:                 $this->addStyle(cGuiPage::filesDirectory . $stylefile->getFilename());
208:             }
209:         }
210: 
211:         if (cFileHandler::exists($cfg['path']['scripts_includes'] . $pageName . '.js')) {
212:             $this->addScript(cGuiPage::filesDirectory . $pageName . '.js');
213:         }
214: 
215:         /**
216:          *
217:          * @var $scriptfile SplFileInfo
218:          */
219:         foreach (new DirectoryIterator($cfg['path']['scripts_includes']) as $scriptfile) {
220:             if (cString::endsWith($scriptfile->getFilename(), '.' . $pageName . '.js')) {
221:                 $this->addScript(cGuiPage::filesDirectory . $scriptfile->getFilename());
222:             }
223:         }
224:     }
225: 
226:     /**
227:      * Adds a script to the website - path can be absolute, relative to the
228:      * plugin scripts folder and relative to the CONTENIDO scripts folder.
229:      * NOTE: This function will also add inline JavaScript in the form of
230:      * "<script...". However this shouldn't be used.
231:      *
232:      * If the page was constructed in a plugin and the plugin name was given
233:      * in the constructor it will find the JS script in
234:      * plugins/PLUGINNAME/scripts/
235:      * too.
236:      *
237:      * @param string $script The filename of the script. It has to reside in
238:      *        /scripts/ in order to be found.
239:      */
240:     public function addScript($script) {
241:         $script = trim($script);
242:         if (empty($script)) {
243:             return;
244:         }
245: 
246:         $cfg = cRegistry::getConfig();
247:         $backendUrl = cRegistry::getBackendUrl();
248:         $backendPath = cRegistry::getBackendPath();
249:         $filePathName = $this->_getRealFilePathName($script);
250: 
251:         if (strpos(trim($script), 'http') === 0 || strpos(trim($script), '<script') === 0 || strpos(trim($script), '//') === 0) {
252:             if (strpos(trim($script), '<script') === 0) {
253:                 cDeprecated("You shouldn't use inline JS for backend pages");
254:             }
255:             // the given script path is absolute
256:             $this->_scripts[] = $script;
257:         } else if (!empty($this->_pluginName) && cFileHandler::exists($backendPath . $cfg['path']['plugins'] . $this->_pluginName . '/' . $cfg['path']['scripts'] . $filePathName)) {
258:             // the given script path is relative to the plugin scripts folder
259:             $fullpath = $backendUrl . $cfg['path']['plugins'] . $this->_pluginName . '/' . $cfg['path']['scripts'] . $script;
260:             $this->_scripts[] = $fullpath;
261:         } else if (cFileHandler::exists($backendPath . $cfg['path']['scripts'] . $filePathName)) {
262:             // the given script path is relative to the CONTENIDO scripts folder
263:             $fullpath = $backendUrl . $cfg['path']['scripts'] . $script;
264: 
265:             $this->_scripts[] = $fullpath;
266:         }
267:     }
268: 
269:     /**
270:      * Adds a stylesheet to the website - path can be absolute, relative to the
271:      * plugin stylesheets folder and relative to the CONTENIDO stylesheets
272:      * folder.
273:      *
274:      * @param string $stylesheet The filename of the stylesheet. It has to
275:      *        reside in /styles/ in order to be found.
276:      */
277:     public function addStyle($stylesheet) {
278:         $stylesheet = trim($stylesheet);
279:         if (empty($stylesheet)) {
280:             return;
281:         }
282: 
283:         $cfg = cRegistry::getConfig();
284:         $backendUrl = cRegistry::getBackendUrl();
285:         $backendPath = cRegistry::getBackendPath();
286:         $filePathName = $this->_getRealFilePathName($stylesheet);
287: 
288:         if (strpos($stylesheet, 'http') === 0 || strpos($stylesheet, '//') === 0) {
289:             // the given stylesheet path is absolute
290:             $this->_styles[] = $stylesheet;
291:         } else if (!empty($this->_pluginName) && cFileHandler::exists($backendPath . $cfg['path']['plugins'] . $this->_pluginName . '/' . $cfg['path']['styles'] . $filePathName)) {
292:             // the given stylesheet path is relative to the plugin stylesheets
293:             // folder
294:             $fullpath = $backendUrl . $cfg['path']['plugins'] . $this->_pluginName . '/' . $cfg['path']['styles'] . $stylesheet;
295:             $this->_styles[] = $fullpath;
296:         } else if (cFileHandler::exists($backendPath . $cfg['path']['styles'] . $filePathName)) {
297:             // the given stylesheet path is relative to the CONTENIDO
298:             // stylesheets folder
299:             $fullpath = $backendUrl . $cfg['path']['styles'] . $stylesheet;
300:             $this->_styles[] = $fullpath;
301:         }
302:     }
303: 
304:     /**
305:      * Adds a meta tag to the website.
306:      *
307:      * @param array $meta Associative array with the meta tag attributes
308:      * @throws cInvalidArgumentException if an invalid attribute for the meta
309:      *         tag has been given
310:      */
311:     public function addMeta(array $meta) {
312:         $allowedAttributes = array(
313:             'charset',
314:             'content',
315:             'http-equiv',
316:             'name',
317:             'itemprop'
318:         );
319:         foreach ($meta as $key => $value) {
320:             if (!in_array($key, $allowedAttributes)) {
321:                 throw new cInvalidArgumentException('Unallowed attribute for meta tag given - meta tag will be ignored!');
322:             }
323:         }
324:         $this->_metaTags[] = $meta;
325:     }
326: 
327:     /**
328:      * Adds class attribute value to the body tag.
329:      *
330:      * @param string $className
331:      */
332:     public function addBodyClassName($className) {
333:         if (!in_array($className, $this->_bodyClassNames)) {
334:             $this->_bodyClassNames[] = $className;
335:         }
336:     }
337: 
338:     /**
339:      * Loads the subnavigation of the current area upon rendering.
340:      *
341:      * @param string $additional Additional parameters the subnavigation might
342:      *        need. These have to look like "key=value&key2=value2..."
343:      * @param string $aarea The area of the subnavigation. If none is given the
344:      *        current area will be loaded
345:      */
346:     public function setSubnav($additional = '', $aarea = '') {
347:         global $area, $sess;
348: 
349:         if ($aarea == '') {
350:             $aarea = $area;
351:         }
352: 
353:         $this->_subnav = '
354:         <script type="text/javascript">
355:         Con.getFrame("right_top").location.href = "' . $sess->url("main.php?area={$aarea}&frame=3&{$additional}") . '";
356:         </script>
357:         ';
358:     }
359: 
360:     /**
361:      * Adds the reload script for the left_bottom frame to the website
362:      */
363:     public function setReload() {
364:         $this->_scripts[] = 'reload.js';
365:     }
366: 
367:     /**
368:      * Sets the markscript
369:      *
370:      * @param string $item The number of the submenu which should be marked.
371:      */
372:     public function setMarkScript($item) {
373:         $this->_markScript = markSubMenuItem($item, true);
374:     }
375: 
376:     /**
377:      * Sets the encoding of the website
378:      *
379:      * @param string $encoding An encoding which should be valid to use in the
380:      *        meta tag
381:      */
382:     public function setEncoding($encoding) {
383:         if (empty($encoding)) {
384:             return;
385:         }
386:         $this->_metaTags[] = array(
387:             'http-equiv' => 'Content-type',
388:             'content' => 'text/html;charset=' . $encoding
389:         );
390:     }
391: 
392:     /**
393:      * Applies a value to a key in the content template.
394:      *
395:      * @param string $type Either "s" or "d" for "static" or "dynamic" values
396:      * @param string $key The key which should be replaced
397:      * @param string $value The value which should replace the key
398:      * @see cTemplate::set()
399:      */
400:     public function set($type, $key, $value) {
401:         $this->_contentTemplate->set($type, $key, $value);
402:     }
403: 
404:     /**
405:      * Calls the next() method on the content template.
406:      *
407:      * @see cTemplate::next()
408:      */
409:     public function next() {
410:         $this->_contentTemplate->next();
411:     }
412: 
413:     /**
414:      * After calling this the page will only display messages and not render the
415:      * content template.
416:      * NOTE: You still have to call render() to actually show any messages
417:      */
418:     public function abortRendering() {
419:         $this->_abort = true;
420:     }
421: 
422:     /**
423:      * Displays an error message and aborts rendering after that
424:      * NOTE: You still have to call render() to actually show any messages
425:      *
426:      * @param string $msg A message
427:      */
428:     public function displayCriticalError($msg) {
429:         $this->_error = $msg;
430:         $this->_abort = true;
431:     }
432: 
433:     /**
434:      * Displays an error but the rendering of the content template will
435:      * continue.
436:      *
437:      * @param string $msg A message
438:      */
439:     public function displayError($msg) {
440:         $this->_error .= $msg . '<br>';
441:     }
442: 
443:     /**
444:      * Displays a warning
445:      *
446:      * @param string $msg The warning
447:      */
448:     public function displayWarning($msg) {
449:         $this->_warning .= $msg . '<br>';
450:     }
451: 
452:     /**
453:      * Displays an info
454:      *
455:      * @param string $msg The info message
456:      */
457:     public function displayInfo($msg) {
458:         $this->_info .= $msg . '<br>';
459:     }
460: 
461:     /**
462:      * Sets an array (or a single object) of cHTML objects which build up the
463:      * site instead of a content template.
464:      * NOTE: All these objects must have a render() method or else they won't be
465:      * shown
466:      *
467:      * @param array|object $objects An array of objects
468:      */
469:     public function setContent($objects) {
470:         if (!is_array($objects)) {
471:             $objects = array(
472:                 $objects
473:             );
474:         }
475:         $this->_objects = $objects;
476:     }
477: 
478:     /**
479:      * Appends all cHTML objects in an array (or a single object) which build up
480:      * the
481:      * site instead of a content template.
482:      * NOTE: All these objects must have a render() method or else they won't be
483:      * shown
484:      *
485:      * @param array|object $objects An array of objects or a single object
486:      */
487:     public function appendContent($objects) {
488:         if (!is_array($objects)) {
489:             $this->_objects[] = $objects;
490:         } else {
491:             $this->_objects = array_merge($this->_objects, $objects);
492:         }
493:     }
494: 
495:     /**
496:      * Example:
497:      * setPluginScript('content_allocation', 'complexlist.js');
498:      * $this->_scripts[] =
499:      * 'http://contenido.local/contenido/plugins/content_allocation/scripts/complexlist.js';
500:      *
501:      * @param unknown_type $plugin
502:      * @param unknown_type $filename
503:      * @return Ambigous <string, mixed>
504:      */
505:     public function setPluginScript($plugin, $filename) {
506:         global $cfg;
507:         $path = $cfg['pica']['script_complexlist'];
508:     }
509: 
510:     public function setStyleDirect($filepath) {
511:         global $cfg;
512:         $path = $cfg['pica']['style_complexlist'];
513:         $this->_pageTemplate->set('s', 'SCRIPTS', $path);
514: 
515:         $strstyle = '';
516: 
517:         $strstyle .= "<link href='styles/" . $path . "' type='text/css' rel='stylesheet'>\n";
518: 
519:         $this->_pageTemplate->set('s', 'STYLES', $strstyle);
520:         return $this->_pageTemplate->generate($cfg['path']['templates'] . $cfg['templates']['generic_page'], false);
521:     }
522: 
523:     /**
524:      * Renders the page and either prints it or returns it
525:      *
526:      * @param cTemplate|NULL $template If set, use this content template instead
527:      *        of the default one
528:      * @param bool $return If true, the page will be returned instead of echoed
529:      * @return string void either the webpage or nothing
530:      */
531:     public function render($template = NULL, $return = false) {
532:         global $cfg;
533: 
534:         if ($template == NULL) {
535:             $template = $this->_contentTemplate;
536:         }
537: 
538:         // Render some parts like meta tags, scripts, styles, etc...
539:         $this->_renderMetaTags();
540:         $this->_renderScripts();
541:         $this->_renderStyles();
542: 
543:         // Set body class attribute values
544:         $this->_pageTemplate->set('s', 'PAGECLASS', implode(' ', $this->_bodyClassNames));
545: 
546:         // Get all messages for the content
547:         $text = $this->_renderContentMessages();
548: 
549:         if (!$this->_abort) {
550:             if (count($this->_objects) == 0) {
551:                 $output = $this->_renderTemplate($template);
552:             } else {
553:                 $output = $this->_renderObjects();
554:             }
555:             $this->_pageTemplate->set('s', 'CONTENT', $text . $output);
556:         } else {
557:             $this->_pageTemplate->set('s', 'CONTENT', $text);
558:         }
559: 
560:         return $this->_pageTemplate->generate($cfg['path']['templates'] . $cfg['templates']['generic_page'], $return);
561:     }
562: 
563:     /**
564:      * Renders set meta tags and adds them to _pageTemplate property.
565:      */
566:     protected function _renderMetaTags() {
567:         // render the meta tags
568:         // NB! We don't produce xhtml in the backend
569:         // $produceXhtml = getEffectiveSetting('generator', 'xhtml', 'false');
570:         $produceXhtml = false;
571:         $meta = '';
572:         foreach ($this->_metaTags as $metaTag) {
573:             $tag = '<meta';
574:             foreach ($metaTag as $key => $value) {
575:                 $tag .= ' ' . $key . '="' . $value . '"';
576:             }
577:             if ($produceXhtml) {
578:                 $tag .= ' /';
579:             }
580:             $tag .= ">\n";
581:             $meta .= $tag;
582:         }
583:         if (!empty($meta)) {
584:             $this->_pageTemplate->set('s', 'META', $meta);
585:         } else {
586:             $this->_pageTemplate->set('s', 'META', '');
587:         }
588:     }
589: 
590:     /**
591:      * Renders set scripts and adds them to _pageTemplate property.
592:      */
593:     protected function _renderScripts() {
594:         $strscript = $this->_subnav . "\n" . $this->_markScript . "\n";
595:         foreach ($this->_scripts as $script) {
596:             if (strpos($script, 'http') === 0 || strpos($script, '//') === 0) {
597:                 $strscript .= '<script type="text/javascript" src="' . $script . '"></script>' . "\n";
598:             } else if (strpos($script, '<script') === false) {
599:                 $strscript .= '<script type="text/javascript" src="scripts/' . $script . '"></script>' . "\n";
600:             } else {
601:                 $strscript .= $script;
602:             }
603:         }
604:         $this->_pageTemplate->set('s', 'SCRIPTS', $strscript);
605:     }
606: 
607:     /**
608:      * Renders set styles and adds them to _pageTemplate property.
609:      */
610:     protected function _renderStyles() {
611:         $strstyle = '';
612:         foreach ($this->_styles as $style) {
613:             if (strpos($style, 'http') === 0 || strpos($style, '//') === 0) {
614:                 $strstyle .= '<link href="' . $style . '" type="text/css" rel="stylesheet">' . "\n";
615:             } else {
616:                 $strstyle .= '<link href="styles/' . $style . '" type="text/css" rel="stylesheet">' . "\n";
617:             }
618:         }
619:         $this->_pageTemplate->set('s', 'STYLES', $strstyle);
620:     }
621: 
622:     /**
623:      * Renders text for all available content messages and returns the assembled
624:      * message
625:      * string.
626:      *
627:      * @return string
628:      */
629:     protected function _renderContentMessages() {
630:         global $notification;
631: 
632:         // Get messages from cRegistry
633:         $infoMessages = cRegistry::getInfoMessages();
634:         foreach ($infoMessages as $message) {
635:             $this->displayInfo($message);
636:         }
637: 
638:         $errorMessages = cRegistry::getErrorMessages();
639:         foreach ($errorMessages as $message) {
640:             $this->displayError($message);
641:         }
642: 
643:         $warningMessages = cRegistry::getWarningMessages();
644:         foreach ($warningMessages as $message) {
645:             $this->displayWarning($message);
646:         }
647: 
648:         $text = '';
649:         if ($this->_info != '') {
650:             $text .= $notification->returnNotification('info', $this->_info) . '<br>';
651:         }
652:         if ($this->_warning != '') {
653:             $text .= $notification->returnNotification('warning', $this->_warning) . '<br>';
654:         }
655:         if ($this->_error != '') {
656:             $text .= $notification->returnNotification('error', $this->_error) . '<br>';
657:         }
658: 
659:         return $text;
660:     }
661: 
662:     /**
663:      * Loops through all defined objects, calls their render function,
664:      * collects the output of the objects and returns it back.
665:      *
666:      * @return string
667:      */
668:     protected function _renderObjects() {
669:         $output = '';
670: 
671:         foreach ($this->_objects as $obj) {
672:             if (!method_exists($obj, 'render')) {
673:                 continue;
674:             }
675: 
676:             // Ridiculous workaround because some objects return
677:             // code if the parameter is true and some return the
678:             // code if the parameter is false.
679:             $oldOutput = $output;
680:             ob_start(); // We don't want any code outside the body
681:                         // (in case the object outputs directly we
682:                         // will catch this output)
683:             $output .= $obj->render(false);
684:             // We get the code either directly or via the output
685:             $output .= ob_get_contents();
686:             if ($oldOutput == $output) {
687:                 cWarning(__FILE__, __LINE__, "Rendering this object (" . print_r($obj, true) . ") doesn't seem to have any effect.");
688:             }
689:             ob_end_clean();
690:         }
691: 
692:         return $output;
693:     }
694: 
695:     /**
696:      * Renders template of a page or of a plugin and returns the output back
697:      *
698:      * @param cTemplate $template
699:      * @return string
700:      */
701:     protected function _renderTemplate($template) {
702:         $cfg = cRegistry::getConfig();
703: 
704:         $file = '';
705:         if ($this->_pluginName == '') {
706:             $file = $cfg['path']['templates'] . 'template.' . $this->_pageName . '.html';
707:         } else {
708:             $file = $cfg['path']['plugins'] . $this->_pluginName . '/templates/template.' . $this->_pageName . '.html';
709:         }
710: 
711:         if (cFileHandler::exists($file)) {
712:             $output = $template->generate($file, true);
713:         } else {
714:             $output = '';
715:         }
716: 
717:         return $output;
718:     }
719: 
720:     /**
721:      * Returns only the path and name of the given file.
722:      * Some JS or CSS file URLs may contain a query part, like
723:      * "/path/to/file.js.php?contenido=12234"
724:      * and this function returns only the path part "/path/to/file.js.php" of
725:      * it.
726:      *
727:      * @param string $file
728:      * @return string
729:      */
730:     protected function _getRealFilePathName($file) {
731:         $tmp = explode('?', $file);
732:         return $tmp[0];
733:     }
734: 
735: }
CMS CONTENIDO 4.9.3 API documentation generated by ApiGen 2.8.0