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