From 798764c2bbe0834e9d73031095efe520a84fc701 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Fri, 18 Feb 2011 04:54:19 -0500
Subject: [PATCH] Add plugin hook before the final HTML content of a page is sent

---
 program/include/rcube_html_page.php |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/program/include/rcube_html_page.php b/program/include/rcube_html_page.php
index ab226bc..5b56ccc 100644
--- a/program/include/rcube_html_page.php
+++ b/program/include/rcube_html_page.php
@@ -266,19 +266,23 @@
             $output = substr($output, 0, $pos) . $css . substr($output, $pos);
         }
 
-	    $this->base_path = $base_path;
+        $this->base_path = $base_path;
 
         // correct absolute paths in images and other tags
-	    // add timestamp to .js and .css filename
+        // add timestamp to .js and .css filename
         $output = preg_replace_callback(
             '!(src|href|background)=(["\']?)([a-z0-9/_.-]+)(["\'\s>])!i',
-	        array($this, 'file_callback'), $output);
+            array($this, 'file_callback'), $output);
         $output = str_replace('$__skin_path', $base_path, $output);
 
-        if ($this->charset != RCMAIL_CHARSET)
-	        echo rcube_charset_convert($output, RCMAIL_CHARSET, $this->charset);
-	    else
-	        echo $output;
+        // trigger hook with final HTML content to be sent
+        $hook = rcmail::get_instance()->plugins->exec_hook("send_page", array('content' => $output));
+        if (!$hook['abort']) {
+            if ($this->charset != RCMAIL_CHARSET)
+                echo rcube_charset_convert($hook['content'], RCMAIL_CHARSET, $this->charset);
+            else
+                echo $hook['content'];
+        }
     }
     
     /**

--
Gitblit v1.9.1