[0] | 1 | <?php |
---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
| 3 | # |
---|
| 4 | # This file is part of Dotclear 2. |
---|
| 5 | # |
---|
[1179] | 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
---|
[0] | 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 |
---|
[2566] | 24 | { |
---|
[2239] | 25 | protected static $type = 'theme'; |
---|
| 26 | |
---|
[0] | 27 | /** |
---|
| 28 | This method registers a theme in modules list. You should use this to |
---|
| 29 | register a new theme. |
---|
[2566] | 30 | |
---|
[0] | 31 | <var>$parent</var> is a optional value to indicate them inheritance. |
---|
[2566] | 32 | If <var>$parent</var> is null / not set, we simply fall back to |
---|
[0] | 33 | the standard behavior, by using 'default'. |
---|
[2566] | 34 | |
---|
[0] | 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. |
---|
[2566] | 38 | |
---|
[0] | 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 |
---|
[2566] | 43 | @param properties <b>array</b> extra properties |
---|
[2945] | 44 | (currently available keys : parent, priority, standalone_config, type, tplset) |
---|
[0] | 45 | */ |
---|
[464] | 46 | public function registerModule($name,$desc,$author,$version,$properties = array()) |
---|
[0] | 47 | { |
---|
[2492] | 48 | # Fallback to legacy registerModule parameters |
---|
[464] | 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 | } |
---|
[2492] | 59 | # Themes specifics properties |
---|
[464] | 60 | $properties = array_merge( |
---|
[2607] | 61 | array('parent' => null, 'tplset' => DC_DEFAULT_TPLSET), |
---|
[2492] | 62 | $properties, |
---|
| 63 | array('permissions' => 'admin') // force themes perms |
---|
[464] | 64 | ); |
---|
[2239] | 65 | |
---|
[2492] | 66 | parent::registerModule($name, $desc, $author, $version, $properties); |
---|
[2566] | 67 | } |
---|
| 68 | |
---|
[0] | 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. |
---|
[2566] | 73 | |
---|
[0] | 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 | } |
---|