| 1 | <?php |
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
|---|
| 3 | # |
|---|
| 4 | # This file is part of Dotclear 2. |
|---|
| 5 | # |
|---|
| 6 | # Copyright (c) 2003-2013 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 | protected static $type = 'theme'; |
|---|
| 26 | |
|---|
| 27 | /** |
|---|
| 28 | This method registers a theme in modules list. You should use this to |
|---|
| 29 | register a new theme. |
|---|
| 30 | |
|---|
| 31 | <var>$parent</var> is a optional value to indicate them inheritance. |
|---|
| 32 | If <var>$parent</var> is null / not set, we simply fall back to |
|---|
| 33 | the standard behavior, by using 'default'. |
|---|
| 34 | |
|---|
| 35 | <var>$priority</var> is an integer. Modules are sorted by priority and name. |
|---|
| 36 | Lowest priority comes first. This property is currently ignored when dealing |
|---|
| 37 | with themes. |
|---|
| 38 | |
|---|
| 39 | @param name <b>string</b> Module name |
|---|
| 40 | @param desc <b>string</b> Module description |
|---|
| 41 | @param author <b>string</b> Module author name |
|---|
| 42 | @param version <b>string</b> Module version |
|---|
| 43 | @param properties <b>array</b> extra properties |
|---|
| 44 | (currently available keys : parent, priority, standalone_config, type, tplset) |
|---|
| 45 | */ |
|---|
| 46 | public function registerModule($name,$desc,$author,$version,$properties = array()) |
|---|
| 47 | { |
|---|
| 48 | # Fallback to legacy registerModule parameters |
|---|
| 49 | if (!is_array($properties)) { |
|---|
| 50 | $args = func_get_args(); |
|---|
| 51 | $properties = array(); |
|---|
| 52 | if (isset($args[4])) { |
|---|
| 53 | $properties['parent']=$args[4]; |
|---|
| 54 | } |
|---|
| 55 | if (isset($args[5])) { |
|---|
| 56 | $properties['priority']= (integer)$args[5]; |
|---|
| 57 | } |
|---|
| 58 | } |
|---|
| 59 | # Themes specifics properties |
|---|
| 60 | $properties = array_merge( |
|---|
| 61 | array('parent' => null, 'tplset' => DC_DEFAULT_TPLSET), |
|---|
| 62 | $properties, |
|---|
| 63 | array('permissions' => 'admin') // force themes perms |
|---|
| 64 | ); |
|---|
| 65 | |
|---|
| 66 | parent::registerModule($name, $desc, $author, $version, $properties); |
|---|
| 67 | } |
|---|
| 68 | |
|---|
| 69 | /** |
|---|
| 70 | Loads namespace <var>$ns</var> specific file for module with ID |
|---|
| 71 | <var>$id</var> |
|---|
| 72 | Note : actually, only 'public' namespace is supported with themes. |
|---|
| 73 | |
|---|
| 74 | @param id <b>string</b> Module ID |
|---|
| 75 | @param ns <b>string</b> Namespace name |
|---|
| 76 | */ |
|---|
| 77 | public function loadNsFile($id,$ns=null) |
|---|
| 78 | { |
|---|
| 79 | switch ($ns) { |
|---|
| 80 | case 'public': |
|---|
| 81 | $parent = $this->modules[$id]['parent']; |
|---|
| 82 | if ($parent) { |
|---|
| 83 | // This is not a real cascade - since we don't call loadNsFile -, |
|---|
| 84 | // thus limiting inclusion process. |
|---|
| 85 | // TODO : See if we have to change this. |
|---|
| 86 | $this->loadModuleFile($this->modules[$parent]['root'].'/_public.php'); |
|---|
| 87 | } |
|---|
| 88 | $this->loadModuleFile($this->modules[$id]['root'].'/_public.php'); |
|---|
| 89 | break; |
|---|
| 90 | } |
|---|
| 91 | } |
|---|
| 92 | } |
|---|