Dotclear

Changeset 2492:8a25f7bf147d


Ignore:
Timestamp:
10/26/13 00:17:52 (10 years ago)
Author:
Denis Jean-Chirstian <contact@…>
Branch:
2.6
Message:

New class dcPlugins, fix backward compatibility with generic dcModules class and un-type modules

Location:
inc
Files:
1 added
4 edited

Legend:

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

    r2198 r2492  
    8787          $this->url = new dcUrlHandlers(); 
    8888           
    89           $this->plugins = new dcModules($this); 
     89          $this->plugins = new dcPlugins($this); 
    9090           
    9191          $this->rest = new dcRestServer($this); 
  • inc/core/class.dc.modules.php

    r2432 r2492  
    1616@brief Modules handler 
    1717 
    18 Provides an object to handle modules (themes or plugins). An instance of this 
    19 class is provided by dcCore $plugins property and used for plugins. 
     18Provides an object to handle modules (themes or plugins).  
    2019*/ 
    2120class dcModules 
     
    3635     protected static $_n; 
    3736 
    38      protected static $type = 'plugin'; 
     37     protected static $type = null; 
    3938      
    4039     public $core;  ///< <b>dcCore</b>  dcCore instance 
     
    161160     @param    author         <b>string</b>       Module author name 
    162161     @param    version        <b>string</b>       Module version 
    163      @param    properties     <b>array</b>        extra properties (currently available keys : permissions, priority) 
     162     @param    properties     <b>array</b>        extra properties  
     163     (currently available keys : permissions, priority, type) 
    164164     */ 
    165165     public function registerModule($name,$desc,$author,$version, $properties = array()) 
    166166     { 
     167          # Fallback to legacy registerModule parameters 
    167168          if (!is_array($properties)) { 
    168                //Fallback to legacy registerModule parameters 
    169169               $args = func_get_args(); 
    170170               $properties = array(); 
     
    176176               } 
    177177          } 
     178 
     179          # Default module properties 
    178180          $properties = array_merge( 
    179181               array( 
     
    185187          ); 
    186188 
    187           if ($properties['type'] !== null && $properties['type'] != self::$type) { 
     189          # Check module type 
     190          if (self::$type !== null && $properties['type'] !== null && $properties['type'] != self::$type) { 
    188191               $this->errors[] = sprintf( 
    189192                    __('Module "%s" has type "%s" that mismatch required module type "%s".'), 
     
    195198          } 
    196199 
     200          # Check module perms on admin side 
    197201          $permissions = $properties['permissions']; 
    198202          if ($this->ns == 'admin') { 
     
    204208          } 
    205209           
     210          # Check module install on multiple path 
    206211          if ($this->id) { 
    207212               $module_exists = array_key_exists($name,$this->modules_names); 
  • inc/core/class.dc.themes.php

    r2239 r2492  
    4141     @param    author         <b>string</b>       Module author name 
    4242     @param    version        <b>string</b>       Module version 
    43      @param    properties     <b>array</b>        extra properties (currently available keys : parent, priority, standalone_config) 
     43     @param    properties     <b>array</b>        extra properties  
     44     (currently available keys : parent, priority, standalone_config, type) 
    4445     */ 
    4546     public function registerModule($name,$desc,$author,$version,$properties = array()) 
    4647     { 
     48          # Fallback to legacy registerModule parameters 
    4749          if (!is_array($properties)) { 
    48                //Fallback to legacy registerModule parameters 
    4950               $args = func_get_args(); 
    5051               $properties = array(); 
     
    5657               } 
    5758          } 
     59          # Themes specifics properties 
    5860          $properties = array_merge( 
    59                array( 
    60                     'parent' => null, 
    61                     'priority' => 1000, 
    62                     'standalone_config' => false, 
    63                     'type' => null 
    64                ), $properties 
     61               array('parent' => null), 
     62               $properties, 
     63               array('permissions' => 'admin') // force themes perms 
    6564          ); 
    6665 
    67           if ($properties['type'] !== null && $properties['type'] != self::$type) { 
    68                $this->errors[] = sprintf( 
    69                     __('Module "%s" has type "%s" that mismatch required module type "%s".'), 
    70                     '<strong>'.html::escapeHTML($name).'</strong>', 
    71                     '<em>'.html::escapeHTML($properties['type']).'</em>', 
    72                     '<em>'.html::escapeHTML(self::$type).'</em>' 
    73                ); 
    74                return; 
    75           } 
    76  
    77           if ($this->id) { 
    78                $this->modules[$this->id] = array_merge( 
    79                     $properties, 
    80                     array( 
    81                          'root' => $this->mroot, 
    82                          'name' => $name, 
    83                          'desc' => $desc, 
    84                          'author' => $author, 
    85                          'version' => $version, 
    86                          'root_writable' => is_writable($this->mroot) 
    87                     ) 
    88                ); 
    89           } 
     66          parent::registerModule($name, $desc, $author, $version, $properties); 
    9067     }     
    9168      
     
    11491     } 
    11592} 
    116 ?> 
  • inc/prepend.php

    r2466 r2492  
    3535$__autoload['dcPostMedia']                   = dirname(__FILE__).'/core/class.dc.postmedia.php'; 
    3636$__autoload['dcModules']                = dirname(__FILE__).'/core/class.dc.modules.php'; 
     37$__autoload['dcPlugins']                = dirname(__FILE__).'/core/class.dc.plugins.php'; 
    3738$__autoload['dcThemes']                 = dirname(__FILE__).'/core/class.dc.themes.php'; 
    3839$__autoload['dcRestServer']             = dirname(__FILE__).'/core/class.dc.rest.php'; 
Note: See TracChangeset for help on using the changeset viewer.

Sites map