1 | <?php |
---|
2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
---|
3 | # |
---|
4 | # This file is part of Dotclear 2. |
---|
5 | # |
---|
6 | # Copyright (c) 2003-2010 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 parent <b>string</b> Module parent |
---|
42 | @param priority <b>integer</b> Module priority |
---|
43 | */ |
---|
44 | public function registerModule($name,$desc,$author,$version,$parent = null,$priority = 1000) |
---|
45 | { |
---|
46 | if ($this->id) { |
---|
47 | $this->modules[$this->id] = array( |
---|
48 | 'root' => $this->mroot, |
---|
49 | 'name' => $name, |
---|
50 | 'desc' => $desc, |
---|
51 | 'author' => $author, |
---|
52 | 'version' => $version, |
---|
53 | 'parent' => $parent, |
---|
54 | 'priority' => 1000, |
---|
55 | 'root_writable' => is_writable($this->mroot) |
---|
56 | ); |
---|
57 | } |
---|
58 | } |
---|
59 | |
---|
60 | /** |
---|
61 | Loads namespace <var>$ns</var> specific file for module with ID |
---|
62 | <var>$id</var> |
---|
63 | Note : actually, only 'public' namespace is supported with themes. |
---|
64 | |
---|
65 | @param id <b>string</b> Module ID |
---|
66 | @param ns <b>string</b> Namespace name |
---|
67 | */ |
---|
68 | public function loadNsFile($id,$ns=null) |
---|
69 | { |
---|
70 | switch ($ns) { |
---|
71 | case 'public': |
---|
72 | $parent = $this->modules[$id]['parent']; |
---|
73 | if ($parent) { |
---|
74 | // This is not a real cascade - since we don't call loadNsFile -, |
---|
75 | // thus limiting inclusion process. |
---|
76 | // TODO : See if we have to change this. |
---|
77 | $this->loadModuleFile($this->modules[$parent]['root'].'/_public.php'); |
---|
78 | } |
---|
79 | $this->loadModuleFile($this->modules[$id]['root'].'/_public.php'); |
---|
80 | break; |
---|
81 | } |
---|
82 | } |
---|
83 | } |
---|
84 | ?> |
---|