| 1 | <?php |
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
|---|
| 3 | # |
|---|
| 4 | # This file is part of Dotclear 2. |
|---|
| 5 | # |
|---|
| 6 | # Copyright (c) 2003-2011 Olivier Meunier & Association Dotclear |
|---|
| 7 | # Licensed under the GPL version 2.0 license. |
|---|
| 8 | # See LICENSE file or |
|---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|---|
| 10 | # |
|---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
|---|
| 12 | if (!defined('DC_RC_PATH')) { return; } |
|---|
| 13 | |
|---|
| 14 | /** |
|---|
| 15 | @ingroup DC_CORE |
|---|
| 16 | @brief Themes specific handler |
|---|
| 17 | |
|---|
| 18 | Provides an specialized object to handle themes. An instance of this |
|---|
| 19 | class should be created when needed. |
|---|
| 20 | |
|---|
| 21 | This class extends dcModules. |
|---|
| 22 | */ |
|---|
| 23 | class dcThemes extends dcModules |
|---|
| 24 | { |
|---|
| 25 | /** |
|---|
| 26 | This method registers a theme in modules list. You should use this to |
|---|
| 27 | register a new theme. |
|---|
| 28 | |
|---|
| 29 | <var>$parent</var> is a optional value to indicate them inheritance. |
|---|
| 30 | If <var>$parent</var> is null / not set, we simply fall back to |
|---|
| 31 | the standard behavior, by using 'default'. |
|---|
| 32 | |
|---|
| 33 | <var>$priority</var> is an integer. Modules are sorted by priority and name. |
|---|
| 34 | Lowest priority comes first. This property is currently ignored when dealing |
|---|
| 35 | with themes. |
|---|
| 36 | |
|---|
| 37 | @param name <b>string</b> Module name |
|---|
| 38 | @param desc <b>string</b> Module description |
|---|
| 39 | @param author <b>string</b> Module author name |
|---|
| 40 | @param version <b>string</b> Module version |
|---|
| 41 | @param properties <b>array</b> extra properties (currently available keys : parent, priority, standalone_config) |
|---|
| 42 | */ |
|---|
| 43 | public function registerModule($name,$desc,$author,$version,$properties = array()) |
|---|
| 44 | { |
|---|
| 45 | if (!is_array($properties)) { |
|---|
| 46 | //Fallback to legacy registerModule parameters |
|---|
| 47 | $args = func_get_args(); |
|---|
| 48 | $properties = array(); |
|---|
| 49 | if (isset($args[4])) { |
|---|
| 50 | $properties['parent']=$args[4]; |
|---|
| 51 | } |
|---|
| 52 | if (isset($args[5])) { |
|---|
| 53 | $properties['priority']= (integer)$args[5]; |
|---|
| 54 | } |
|---|
| 55 | } |
|---|
| 56 | $properties = array_merge( |
|---|
| 57 | array( |
|---|
| 58 | 'parent' => null, |
|---|
| 59 | 'priority' => 1000, |
|---|
| 60 | 'standalone_config' => false |
|---|
| 61 | ), $properties |
|---|
| 62 | ); |
|---|
| 63 | if ($this->id) { |
|---|
| 64 | $this->modules[$this->id] = array_merge( |
|---|
| 65 | $properties, |
|---|
| 66 | array( |
|---|
| 67 | 'root' => $this->mroot, |
|---|
| 68 | 'name' => $name, |
|---|
| 69 | 'desc' => $desc, |
|---|
| 70 | 'author' => $author, |
|---|
| 71 | 'version' => $version, |
|---|
| 72 | 'root_writable' => is_writable($this->mroot) |
|---|
| 73 | ) |
|---|
| 74 | ); |
|---|
| 75 | } |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | /** |
|---|
| 79 | Loads namespace <var>$ns</var> specific file for module with ID |
|---|
| 80 | <var>$id</var> |
|---|
| 81 | Note : actually, only 'public' namespace is supported with themes. |
|---|
| 82 | |
|---|
| 83 | @param id <b>string</b> Module ID |
|---|
| 84 | @param ns <b>string</b> Namespace name |
|---|
| 85 | */ |
|---|
| 86 | public function loadNsFile($id,$ns=null) |
|---|
| 87 | { |
|---|
| 88 | switch ($ns) { |
|---|
| 89 | case 'public': |
|---|
| 90 | $parent = $this->modules[$id]['parent']; |
|---|
| 91 | if ($parent) { |
|---|
| 92 | // This is not a real cascade - since we don't call loadNsFile -, |
|---|
| 93 | // thus limiting inclusion process. |
|---|
| 94 | // TODO : See if we have to change this. |
|---|
| 95 | $this->loadModuleFile($this->modules[$parent]['root'].'/_public.php'); |
|---|
| 96 | } |
|---|
| 97 | $this->loadModuleFile($this->modules[$id]['root'].'/_public.php'); |
|---|
| 98 | break; |
|---|
| 99 | } |
|---|
| 100 | } |
|---|
| 101 | } |
|---|
| 102 | ?> |
|---|