Dotclear


Ignore:
Timestamp:
07/01/11 09:20:53 (14 years ago)
Author:
Dsls <dsls@…>
Branch:
default
Message:
  • New way of registering modules/themes, more extensible (backward compatible with previous method)
  • small fix on attachments plugin template tags

Closes #1223.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.modules.php

    r270 r464  
    159159     @param    author         <b>string</b>       Module author name 
    160160     @param    version        <b>string</b>       Module version 
    161      @param    permissions    <b>string</b>       Module permissions 
    162      @param    priority       <b>integer</b>      Module priority 
    163      */ 
    164      public function registerModule($name,$desc,$author,$version,$permissions=null,$priority=1000) 
    165      { 
     161     @param    properties     <b>array</b>        extra properties (currently available keys : permissions, priority) 
     162     */ 
     163     public function registerModule($name,$desc,$author,$version, $properties = array()) 
     164     { 
     165          if (!is_array($properties)) { 
     166               //Fallback to legacy registerModule parameters 
     167               $args = func_get_args(); 
     168               $properties = array(); 
     169               if (isset($args[4])) { 
     170                    $properties['permissions']=$args[4]; 
     171               } 
     172               if (isset($args[5])) { 
     173                    $properties['priority']= (integer)$args[5]; 
     174               } 
     175          } 
     176          $properties = array_merge( 
     177               array( 
     178                    'permissions' => null, 
     179                    'priority' => 1000 
     180               ), $properties 
     181          ); 
     182          $permissions = $properties['permissions']; 
    166183          if ($this->ns == 'admin') { 
    167184               if ($permissions == '' && !$this->core->auth->isSuperAdmin()) { 
     
    177194               if (!$module_exists || ($module_exists && $module_overwrite)) { 
    178195                    $this->modules_names[$name] = $version; 
    179                     $this->modules[$this->id] = array( 
    180                          'root' => $this->mroot, 
    181                          'name' => $name, 
    182                          'desc' => $desc, 
    183                          'author' => $author, 
    184                          'version' => $version, 
    185                          'permissions' => $permissions, 
    186                          'priority' => $priority === null ? 1000 : (integer) $priority, 
    187                          'root_writable' => is_writable($this->mroot) 
     196                    $this->modules[$this->id] = array_merge( 
     197                         $properties, 
     198                         array( 
     199                              'root' => $this->mroot, 
     200                              'name' => $name, 
     201                              'desc' => $desc, 
     202                              'author' => $author, 
     203                              'version' => $version, 
     204                              'root_writable' => is_writable($this->mroot) 
     205                         ) 
    188206                    ); 
    189207               } 
Note: See TracChangeset for help on using the changeset viewer.

Sites map