[0] | 1 | <?php |
---|
[3731] | 2 | /** |
---|
| 3 | * @brief Themes specific handler |
---|
| 4 | * |
---|
| 5 | * Provides an specialized object to handle themes. An instance of this |
---|
| 6 | * class should be created when needed. |
---|
| 7 | * |
---|
| 8 | * @package Dotclear |
---|
| 9 | * @subpackage Core |
---|
| 10 | * |
---|
| 11 | * @copyright Olivier Meunier & Association Dotclear |
---|
| 12 | * @copyright GPL-2.0-only |
---|
| 13 | */ |
---|
| 14 | |
---|
[3730] | 15 | if (!defined('DC_RC_PATH')) {return;} |
---|
[0] | 16 | |
---|
| 17 | class dcThemes extends dcModules |
---|
[2566] | 18 | { |
---|
[3730] | 19 | protected static $type = 'theme'; |
---|
[2239] | 20 | |
---|
[3730] | 21 | /** |
---|
| 22 | This method registers a theme in modules list. You should use this to |
---|
| 23 | register a new theme. |
---|
[2566] | 24 | |
---|
[3730] | 25 | <var>$parent</var> is a optional value to indicate them inheritance. |
---|
| 26 | If <var>$parent</var> is null / not set, we simply fall back to |
---|
| 27 | the standard behavior, by using 'default'. |
---|
[2566] | 28 | |
---|
[3730] | 29 | <var>$priority</var> is an integer. Modules are sorted by priority and name. |
---|
| 30 | Lowest priority comes first. This property is currently ignored when dealing |
---|
| 31 | with themes. |
---|
[2566] | 32 | |
---|
[3730] | 33 | @param name <b>string</b> Module name |
---|
| 34 | @param desc <b>string</b> Module description |
---|
| 35 | @param author <b>string</b> Module author name |
---|
| 36 | @param version <b>string</b> Module version |
---|
| 37 | @param properties <b>array</b> extra properties |
---|
| 38 | (currently available keys : parent, priority, standalone_config, type, tplset) |
---|
| 39 | */ |
---|
[3874] | 40 | public function registerModule($name, $desc, $author, $version, $properties = []) |
---|
[3730] | 41 | { |
---|
| 42 | # Fallback to legacy registerModule parameters |
---|
| 43 | if (!is_array($properties)) { |
---|
| 44 | $args = func_get_args(); |
---|
[3874] | 45 | $properties = []; |
---|
[3730] | 46 | if (isset($args[4])) { |
---|
| 47 | $properties['parent'] = $args[4]; |
---|
| 48 | } |
---|
| 49 | if (isset($args[5])) { |
---|
| 50 | $properties['priority'] = (integer) $args[5]; |
---|
| 51 | } |
---|
| 52 | } |
---|
| 53 | # Themes specifics properties |
---|
| 54 | $properties = array_merge( |
---|
[3874] | 55 | ['parent' => null, 'tplset' => DC_DEFAULT_TPLSET], |
---|
[3730] | 56 | $properties, |
---|
[3874] | 57 | ['permissions' => 'admin'] // force themes perms |
---|
[3730] | 58 | ); |
---|
[2239] | 59 | |
---|
[3730] | 60 | parent::registerModule($name, $desc, $author, $version, $properties); |
---|
| 61 | } |
---|
[2566] | 62 | |
---|
[3730] | 63 | /** |
---|
| 64 | Loads namespace <var>$ns</var> specific file for module with ID |
---|
| 65 | <var>$id</var> |
---|
| 66 | Note : actually, only 'public' namespace is supported with themes. |
---|
[2566] | 67 | |
---|
[3730] | 68 | @param id <b>string</b> Module ID |
---|
| 69 | @param ns <b>string</b> Namespace name |
---|
| 70 | */ |
---|
| 71 | public function loadNsFile($id, $ns = null) |
---|
| 72 | { |
---|
| 73 | switch ($ns) { |
---|
| 74 | case 'public': |
---|
| 75 | $parent = $this->modules[$id]['parent']; |
---|
| 76 | if ($parent) { |
---|
| 77 | // This is not a real cascade - since we don't call loadNsFile -, |
---|
| 78 | // thus limiting inclusion process. |
---|
| 79 | // TODO : See if we have to change this. |
---|
| 80 | $this->loadModuleFile($this->modules[$parent]['root'] . '/_public.php'); |
---|
| 81 | } |
---|
| 82 | $this->loadModuleFile($this->modules[$id]['root'] . '/_public.php'); |
---|
| 83 | break; |
---|
| 84 | } |
---|
| 85 | } |
---|
[0] | 86 | } |
---|