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

Functions

  • cecCreateBaseHref
  • cecCreateMetatags
  • cecFrontendCategoryAccess
  • cecFrontendCategoryAccess_Backend
  • cecIndexArticle
  • cecParseTemplate
  • CheckIfMetaTagExists
  • Overview
  • Package
  • Function
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * CONTENIDO Chain.
  5:  * Parse template to do some CONTENIDO specific replacements.
  6:  *
  7:  * Replaces following placeholders in templates:
  8:  * - {_SID_}:  CONTENIDO session id
  9:  * - {_PATH_CONTENIDO_FULLHTML_}:  Full URL to contenido backend (protocol + host + path)
 10:  * - {_META_HEAD_CONTENIDO_}:  Default meta tags
 11:  * - {_CSS_HEAD_CONTENIDO_}:  Default links tags to load core CSS files
 12:  * - {_CSS_HEAD_CONTENIDO_FULLHTML_}:  Default links tags with full URL to contenido backend
 13:  * - {_JS_HEAD_CONTENIDO_}:  Default script tags to load core JS files
 14:  * - {_JS_HEAD_CONTENIDO_FULLHTML_}:  Default script tags with full URL to contenido backend
 15:  *
 16:  * @package          Core
 17:  * @subpackage       Chain
 18:  * @version          SVN Revision $Rev$
 19:  *
 20:  * @author           Murat Purc <murat@purc.de>
 21:  * @copyright        four for business AG <www.4fb.de>
 22:  * @license          http://www.contenido.org/license/LIZENZ.txt
 23:  * @link             http://www.4fb.de
 24:  * @link             http://www.contenido.org
 25:  */
 26: 
 27: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 28: 
 29: /**
 30:  * Does some replacements in the given template.
 31:  * Replaces some CONTENIDO specific placeholders against their values.
 32:  *
 33:  * @param string $template
 34:  *         Template string to preprocess
 35:  * @param cTemplate $templateObj
 36:  *         The current template instance
 37:  * @return string
 38:  */
 39: function cecParseTemplate($template, cTemplate $templateObj) {
 40: 
 41:     global $frame;
 42: 
 43:     // Autofill special placeholders like
 44:     // - Session id
 45:     // - Initial CONTENIDO scripts
 46: 
 47:     $prefix = "\n    ";
 48: 
 49:     $cfg = cRegistry::getConfig();
 50:     $sessid = (string) cRegistry::getBackendSessionId();
 51:     $backendPath = cRegistry::getBackendUrl();
 52:     $backendLang = cRegistry::getBackendLanguage();
 53:     // Fixme: Creates an error on backend login form, since we have no language there, see main.loginform.php
 54:     // $oLanguage = cRegistry::getLanguage();
 55:     // $encoding = $oLanguage->get("encoding");
 56:     $languageid = cRegistry::getLanguageId();
 57:     if ($languageid) {
 58:         $oLanguage = cRegistry::getLanguage();
 59:         $encoding = $oLanguage->get('encoding');
 60:     } else {
 61:         $encoding = 'utf-8';
 62:     }
 63:     $frameNr = (!empty($frame) && is_numeric($frame)) ? $frame : 0;
 64: 
 65:     // Default meta tags
 66:     // @TODO  Make this also configurable
 67:     $metaCon = '
 68:     <meta http-equiv="Content-type" content="text/html;charset=' . $encoding . '">
 69:     <meta http-equiv="expires" content="0">
 70:     <meta http-equiv="cache-control" content="no-cache">
 71:     <meta http-equiv="pragma" content="no-cache">';
 72: 
 73:     // JavaScript configuration
 74:     $jsConfigurationAdded = false;
 75:     $jsConfiguration = '
 76:     <script type="text/javascript">
 77:     (function(Con, $) {
 78:         Con.sid = "' . $sessid . '";
 79:         $.extend(Con.cfg, {
 80:             urlBackend: "' .  $backendPath . '",
 81:             urlHelp: "' . $cfg['help_url'] . '",
 82:             belang: "' . $backendLang . '",
 83:             frame: ' . $frameNr . '
 84:         });
 85:     })(Con, Con.$);
 86:     </script>';
 87: 
 88:     // Default CSS styles
 89:     $cssHeadCon = '';
 90:     $files = $cfg['backend_template']['css_files'];
 91:     foreach ($files as $file) {
 92:         $cssHeadCon .= $prefix . '<link rel="stylesheet" type="text/css" href="' . $file . '">';
 93:     }
 94:     $cssHeadCon = $prefix . "<!-- CSS -->" . $cssHeadCon . $prefix . "<!-- /CSS -->";
 95: 
 96:     // Default JavaScript files & JS code
 97:     $jsHeadCon = '';
 98:     $files = $cfg['backend_template']['js_files'];
 99:     foreach ($files as $file) {
100:         if ('_CONFIG_' === $file) {
101:             $jsHeadCon .= $jsConfiguration;
102:             $jsConfigurationAdded = true;
103:         } else {
104:             $jsHeadCon .= $prefix . '<script type="text/javascript" src="' . $file . '"></script>';
105:         }
106:     }
107: 
108:     if (false === $jsConfigurationAdded) {
109:         $jsHeadCon .= $jsConfiguration;
110:     }
111: 
112:     $jsHeadCon = $prefix . "<!-- JS -->" . $jsHeadCon . $prefix . "<!-- /JS -->";
113: 
114:     // Placeholders to replace
115:     $replacements = array(
116:         '_SID_' => $sessid,
117:         '_PATH_CONTENIDO_FULLHTML_' => $backendPath,
118:         '_META_HEAD_CONTENIDO_' => $metaCon,
119:         '_CSS_HEAD_CONTENIDO_' => str_replace('{basePath}', '', $cssHeadCon),
120:         '_CSS_HEAD_CONTENIDO_FULLHTML_' => str_replace('{basePath}', $backendPath, $cssHeadCon),
121:         '_JS_HEAD_CONTENIDO_' => str_replace('{basePath}', '', $jsHeadCon),
122:         '_JS_HEAD_CONTENIDO_FULLHTML_' => str_replace('{basePath}', $backendPath, $jsHeadCon),
123:     );
124: 
125:     // Loop through all replacements and replace keys which are not in needles but found
126:     // in the template
127:     foreach ($replacements as $key => $value) {
128:         $placeholder = '{' . $key . '}';
129:         if (!in_array($key, $templateObj->needles) && false !== strpos($template, $placeholder)) {
130:             $template = str_replace($placeholder, $value, $template);
131:         }
132:     }
133: 
134:     return $template;
135: 
136: }
137: 
CMS CONTENIDO 4.9.8 API documentation generated by ApiGen 2.8.0