CMS  Version 3.9
site_manager.inc
Go to the documentation of this file.
1 <?php
7 /**************************************************************
8 
9  Copyright (c) 2010 Sonjara, Inc
10 
11  Permission is hereby granted, free of charge, to any person
12  obtaining a copy of this software and associated documentation
13  files (the "Software"), to deal in the Software without
14  restriction, including without limitation the rights to use,
15  copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the
17  Software is furnished to do so, subject to the following
18  conditions:
19 
20  The above copyright notice and this permission notice shall be
21  included in all copies or substantial portions of the Software.
22 
23  Except as contained in this notice, the name(s) of the above
24  copyright holders shall not be used in advertising or otherwise
25  to promote the sale, use or other dealings in this Software
26  without prior written authorization.
27 
28  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  OTHER DEALINGS IN THE SOFTWARE.
36 
37 *****************************************************************/
38 
39 Fakoli::using("site");
40 
42 {
43  static $themes = null;
44 
45  function SiteManager()
46  {
47 
48  }
49 
50  static function registerTheme($component, $name, $description)
51  {
53 
54  SiteManager::$themes[$component->name] = array("name" => $name,
55  "description" => $description,
56  "directory" => $component->component_path);
57  }
58 
59  static function registerThemes()
60  {
61  SiteManager::$themes = array();
62  ComponentManager::fireEvent("RegisterTheme");
63  Cache::put("registered_themes", SiteManager::$themes);
64  return SiteManager::$themes;
65  }
66 
67  static function getThemes()
68  {
69  $themes = Cache::get("registered_themes");
70 
71  if (!$themes)
72  {
74  }
75  return $themes;
76  }
77 
78  static function getThemeDirectory($theme = "")
79  {
80  global $config;
81 
82  if ($theme == "")
83  {
84  return $config['homedir'] . DIRECTORY_SEPARATOR . "templates";
85  }
86 
88 
89  if (!array_key_exists($theme, $themes))
90  {
91  trace("Unknown theme '$theme' - using default", 2);
92  return $config['homedir'] . DIRECTORY_SEPARATOR . "templates";
93  }
94  return $themes[$theme]["directory"];
95  }
96 
97  static function getThemeOptions()
98  {
100 
101  $options = array("" => "Default");
102  foreach($themes as $component => $theme)
103  {
104  $options[$component] = $theme["name"];
105  }
106 
107  return $options;
108  }
109 
110  static function formatThemeName($site)
111  {
112  if (!$site->theme) return "Default";
114 
115  if (!array_key_exists($site->theme, $themes))
116  {
117  return "ERROR";
118  }
119 
120  return $themes[$site->theme]["name"];
121  }
122 
123  static function upgradeComponent($version)
124  {
125  $mgr = new SiteUpgradeManager();
126  $mgr->upgrade($version);
127  }
128 }?>
$component
Definition: help.inc:38
$name
Definition: upload.inc:54
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
getComponent($component)
Retrieve the component definition record for the specified component.
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
static formatThemeName($site)
static getThemeOptions()
static getThemes()
static getThemeDirectory($theme="")
static $themes
static registerTheme($component, $name, $description)
static registerThemes()
static upgradeComponent($version)
global $config
Definition: import.inc:4