logo       

CVS: squirrelmail/class/template template.class.php, 1.19, 1.20: msg#00075

Subject: CVS: squirrelmail/class/template template.class.php, 1.19, 1.20
Update of /cvsroot/squirrelmail/squirrelmail/class/template
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv20620/class/template

Modified Files:
        template.class.php 
Log Message:
Adding template_construct and template_output hooks.  Yikes.

Index: template.class.php
===================================================================
RCS file: /cvsroot/squirrelmail/squirrelmail/class/template/template.class.php,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -w -r1.19 -r1.20
--- template.class.php  21 Sep 2006 13:29:22 -0000      1.19
+++ template.class.php  21 Sep 2006 15:24:41 -0000      1.20
@@ -378,17 +378,46 @@
      */
     function display($file)
     {
-        // Pull in our config file
-        $t = &$this->values; // place values array directly in scope
 
-        // Get right template file
+        // get right template file
+        //
         $template = $this->get_template_file_path($file);
         if (empty($template)) {
-            trigger_error('The template "'.htmlspecialchars($file).'" could 
not be displayed!', E_USER_ERROR);
+
+            trigger_error('The template "' . htmlspecialchars($file) 
+                          . '" could not be displayed!', E_USER_ERROR);
+
         } else {
+
+            $aPluginOutput = array();
+            $aPluginOutput = do_hook_function('template_construct', 
+                                              array($aPluginOutput, $file, 
$this));
+            $this->assign('plugin_output', $aPluginOutput);
+
+            // pull in our config file ($t?  let's try to be more verbose 
please :-) )
+            //
+            $t = &$this->values; // place values array directly in scope
+
             ob_start();
             include($template);
+
+            // CAUTION: USE OF THIS HOOK IS HIGHLY DISCOURAGED AND CAN
+            // RESULT IN NOTICABLE PERFORMANCE DEGREDATION.  Plugins
+            // using this hook will probably be rejected by the 
+            // SquirrelMail team.
+            //
+            // Anyone hooking in here that wants to manipulate the output
+            // buffer has to get the buffer, clean it and then echo the 
+            // new buffer like this:
+            // $buffer = ob_get_contents(); ob_clean(); .... echo $new_buffer;
+            //
+            // Don't need to pass buffer contents ourselves
+            // do_hook_function('template_output', array(ob_get_contents()));
+            //
+            do_hook('template_output');
+
             ob_end_flush();
+
         }
     }
 
@@ -399,18 +428,48 @@
      * @return string A string of the results
      */
     function fetch($file) {
-        $t = &$this->values; // place values array directly in scope
 
-        // Get right template file
+        // get right template file
+        //
         $template = $this->get_template_file_path($file);
         if (empty($template)) {
-            trigger_error('The template "'.htmlspecialchars($file).'" could 
not be fetched!', E_USER_ERROR);
+
+            trigger_error('The template "' . htmlspecialchars($file) 
+                          . '" could not be fetched!', E_USER_ERROR);
+
         } else {
+
+            $aPluginOutput = array();
+            $aPluginOutput = do_hook_function('template_construct', 
+                                              array($aPluginOutput, $file, 
$this));
+            $this->assign('plugin_output', $aPluginOutput);
+
+            // pull in our config file ($t?  let's try to be more verbose 
please :-) )
+            //
+            $t = &$this->values; // place values array directly in scope
+
             ob_start();
             include($template);
+
+            // CAUTION: USE OF THIS HOOK IS HIGHLY DISCOURAGED AND CAN
+            // RESULT IN NOTICABLE PERFORMANCE DEGREDATION.  Plugins
+            // using this hook will probably be rejected by the 
+            // SquirrelMail team.
+            //
+            // Anyone hooking in here that wants to manipulate the output
+            // buffer has to get the buffer, clean it and then echo the 
+            // new buffer like this:
+            // $buffer = ob_get_contents(); ob_clean(); .... echo $new_buffer;
+            //
+            // Don't need to pass buffer contents ourselves
+            // do_hook_function('template_output', array(ob_get_contents()));
+            //
+            do_hook('template_output');
+
             $contents = ob_get_contents();
             ob_end_clean();
             return $contents;
+
         }
     }
 


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
boot-loaders.gr...    php.pear.genera...    debugging.valgr...    kde.redhat.user...    text.xml.xsl.ge...    culture.languag...    hardware.microc...    java.servicemix...    redhat.release....    web.zope.plone....    user-groups.lin...    opendarwin.webk...    video.mjpeg.use...    sysutils.bcfg2....    encryption.gpg....    lx-office.devel...    xfree86.forum/2...    mail.mutt.devel...    acpi.devel/2003...    qnx.openqnx.dev...    network.irc.irs...    freebsd.devel.m...   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe