* Added hook #7657: New hook "tslib_fe-contentStrReplace" allows to overwrite content...
authorMichael Stucki <michael.stucki@typo3.org>
Sun, 2 Mar 2008 01:23:29 +0000 (01:23 +0000)
committerMichael Stucki <michael.stucki@typo3.org>
Sun, 2 Mar 2008 01:23:29 +0000 (01:23 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Core/trunk@3338 709f56b5-9817-0410-a4d7-c38de5d9e867

ChangeLog
typo3/sysext/cms/tslib/class.tslib_fe.php

index f0f0e35..8c149e8 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,7 @@
 
        * Fixed bug #7291: Taskcenter -> sys_action - viewport is too small when creating records (patch by Steffen Kamper)
        * Fixed bug #5788: Add a delete button to the yellow warning box for removing the ENABLE_INSTALL_TOOL_FILE
+       * Added hook #7657: New hook "tslib_fe-contentStrReplace" allows to overwrite content on a website after all the caching was already done. Only applies if "config.sendCacheHeaders" is disabled! This hook is very useful for small on-the-fly replacements, for example display the fe_user name, or the time used for page generation.
 
 2008-03-01  Dmitry Dulepov  <dmitry@typo3.org>
 
index f94d6ac..490b1dd 100755 (executable)
@@ -3404,22 +3404,47 @@ if (version == "n3") {
         * @return      void
         */
        function contentStrReplace()    {
+               $search = array();
+               $replace = array();
+
                        // Substitutes username mark with the username
                if ($this->fe_user->user['uid'])        {
 
                                // User name:
                        $token = trim($this->config['config']['USERNAME_substToken']);
-                       $this->content = str_replace($token ? $token : '<!--###USERNAME###-->',$this->fe_user->user['username'],$this->content);
+                       $search[] = ($token ? $token : '<!--###USERNAME###-->');
+                       $replace[] = $this->fe_user->user['username'];
 
                                // User uid (if configured):
                        $token = trim($this->config['config']['USERUID_substToken']);
-                       if ($token)     {
-                               $this->content = str_replace($token, $this->fe_user->user['uid'], $this->content);
+                       if ($token) {
+                               $search[] = $token;
+                               $replace[] = $this->fe_user->user['uid'];
                        }
                }
+
                        // Substitutes get_URL_ID in case of GET-fallback
                if ($this->getMethodUrlIdToken) {
-                       $this->content = str_replace($this->getMethodUrlIdToken, $this->fe_user->get_URL_ID, $this->content);
+                       $search[] = $this->getMethodUrlIdToken;
+                       $replace[] = $this->fe_user->get_URL_ID;
+               }
+
+                       // Hook for supplying custom search/replace data
+               if (isset($this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-contentStrReplace'])) {
+                       $contentStrReplaceHooks = &$this->TYPO3_CONF_VARS['SC_OPTIONS']['tslib/class.tslib_fe.php']['tslib_fe-contentStrReplace'];
+                       if (is_array($contentStrReplaceHooks)) {
+                               $_params = array(
+                                       'search' => &$search,
+                                       'replace' => &$replace,
+                               );
+                               foreach ($contentStrReplaceHooks as $_funcRef) {
+                                       t3lib_div::callUserFunction($_funcRef, $_params, $this);
+                               }
+                       }
+               }
+
+               if (count($search)) {
+                       $this->content = str_replace($search, $replace, $this->content);
                }
        }