Changeset 2305 in subversion


Ignore:
Timestamp:
Feb 21, 2009 1:09:38 PM (4 years ago)
Author:
thomasb
Message:

New methods for plugins to add buttons to template containers

Location:
branches/devel-api/program/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/devel-api/program/include/rcube_plugin.php

    r2289 r2305  
    152152    $this->api->include_stylesheet($this->ressource_url($fn)); 
    153153  } 
     154   
     155  /** 
     156   * Append a button to a certain container 
     157   * 
     158   * @param array Hash array with named parameters (as used in skin templates) 
     159   * @param string Container name where the buttons should be added to 
     160   * @see rcube_remplate::button() 
     161   */ 
     162  public function add_button($p, $container) 
     163  { 
     164    if ($this->api->output->type == 'html') { 
     165      // fix relative paths 
     166      foreach (array('imagepas', 'imageact', 'imagesel') as $key) 
     167        if ($p[$key]) 
     168          $p[$key] = $this->api->url . $this->ressource_url($p[$key]); 
     169       
     170      $this->api->add_content($this->api->output->button($p), $container); 
     171    } 
     172  } 
    154173 
    155174  /** 
  • branches/devel-api/program/include/rcube_plugin_api.php

    r2289 r2305  
    3131  public $dir; 
    3232  public $url = 'plugins/'; 
     33  public $output; 
    3334   
    3435  private $handlers = array(); 
     
    3738  private $actionmap = array(); 
    3839  private $objectsmap = array(); 
    39   private $output; 
     40  private $template_contents = array(); 
    4041   
    4142 
     
    103104    } 
    104105     
     106    // register an internal hook 
     107    $this->register_hook('template_container', array($this, 'template_container_hook')); 
     108     
    105109    // maybe also register a shudown function which triggers shutdown functions of all plugin objects 
    106110  } 
     
    223227 
    224228  /** 
    225     * Include a plugin stylesheet in the current HTML page 
     229   * Include a plugin stylesheet in the current HTML page 
    226230   */ 
    227231  public function include_stylesheet($fn) 
     
    233237  } 
    234238   
     239  /** 
     240   * Save the given HTML content to be added to a template container 
     241   */ 
     242  public function add_content($html, $container) 
     243  { 
     244    console($html, $container); 
     245    $this->template_contents[$container] .= $html . "\n"; 
     246  } 
     247   
     248  /** 
     249   * Callback for template_container hooks 
     250   */ 
     251  private function template_container_hook($attrib) 
     252  { 
     253    $container = $attrib['name']; 
     254    return array('content' => $this->template_contents[$container]); 
     255  } 
    235256   
    236257  /** 
Note: See TracChangeset for help on using the changeset viewer.