[Svn] r2305 - branches/devel-api/program/include

trac at roundcube.net trac at roundcube.net
Sat Feb 21 19:09:38 CET 2009


Author: thomasb
Date: 2009-02-21 12:09:38 -0600 (Sat, 21 Feb 2009)
New Revision: 2305

Modified:
   branches/devel-api/program/include/rcube_plugin.php
   branches/devel-api/program/include/rcube_plugin_api.php
Log:
New methods for plugins to add buttons to template containers

Modified: branches/devel-api/program/include/rcube_plugin.php
===================================================================
--- branches/devel-api/program/include/rcube_plugin.php	2009-02-21 17:46:42 UTC (rev 2304)
+++ branches/devel-api/program/include/rcube_plugin.php	2009-02-21 18:09:38 UTC (rev 2305)
@@ -151,6 +151,25 @@
   {
     $this->api->include_stylesheet($this->ressource_url($fn));
   }
+  
+  /**
+   * Append a button to a certain container
+   *
+   * @param array Hash array with named parameters (as used in skin templates)
+   * @param string Container name where the buttons should be added to
+   * @see rcube_remplate::button()
+   */
+  public function add_button($p, $container)
+  {
+    if ($this->api->output->type == 'html') {
+      // fix relative paths
+      foreach (array('imagepas', 'imageact', 'imagesel') as $key)
+        if ($p[$key])
+          $p[$key] = $this->api->url . $this->ressource_url($p[$key]);
+      
+      $this->api->add_content($this->api->output->button($p), $container);
+    }
+  }
 
   /**
    * Make the given file name link into the plugin directory

Modified: branches/devel-api/program/include/rcube_plugin_api.php
===================================================================
--- branches/devel-api/program/include/rcube_plugin_api.php	2009-02-21 17:46:42 UTC (rev 2304)
+++ branches/devel-api/program/include/rcube_plugin_api.php	2009-02-21 18:09:38 UTC (rev 2305)
@@ -30,13 +30,14 @@
   
   public $dir;
   public $url = 'plugins/';
+  public $output;
   
   private $handlers = array();
   private $plugins = array();
   private $actions = array();
   private $actionmap = array();
   private $objectsmap = array();
-  private $output;
+  private $template_contents = array();
   
 
   /**
@@ -102,6 +103,9 @@
       }
     }
     
+    // register an internal hook
+    $this->register_hook('template_container', array($this, 'template_container_hook'));
+    
     // maybe also register a shudown function which triggers shutdown functions of all plugin objects
   }
   
@@ -222,7 +226,7 @@
   }
 
   /**
-    * Include a plugin stylesheet in the current HTML page
+   * Include a plugin stylesheet in the current HTML page
    */
   public function include_stylesheet($fn)
   {
@@ -232,8 +236,25 @@
     }
   }
   
+  /**
+   * Save the given HTML content to be added to a template container
+   */
+  public function add_content($html, $container)
+  {
+    console($html, $container);
+    $this->template_contents[$container] .= $html . "\n";
+  }
   
   /**
+   * Callback for template_container hooks
+   */
+  private function template_container_hook($attrib)
+  {
+    $container = $attrib['name'];
+    return array('content' => $this->template_contents[$container]);
+  }
+  
+  /**
    * Make the given file name link into the plugins directory
    */
   private function ressource_url($fn)

_______________________________________________
http://lists.roundcube.net/mailman/listinfo/svn



More information about the Svn mailing list