Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 67 lines (59 sloc) 1.967 kB
0bf85ca @dkobia * New Theming Functionality
dkobia authored
1 <?php defined('SYSPATH') or die('No direct script access.');
2 /**
3 * Register Themes Hook
4 *
5 * PHP version 5
6 * LICENSE: This source file is subject to LGPL license
7 * that is available through the world-wide-web at the following URI:
8 * http://www.gnu.org/copyleft/lesser.html
9 * @author Ushahidi Team <team@ushahidi.com>
10 * @package Ushahidi - http://source.ushahididev.com
11 * @module Register Themes Hook
12 * @copyright Ushahidi - http://www.ushahidi.com
13 * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License (LGPL)
14 */
15
16 class register_themes {
17 /**
18 * Adds the register method to load after system.ready
19 */
20 public function __construct()
21 {
22 // Hook into routing
23 if (file_exists(DOCROOT."application/config/database.php"))
24 {
25 Event::add('system.ready', array($this, 'register'));
26 }
27 }
28
29 /**
30 * Loads ushahidi themes
31 */
32 public function register()
33 {
34 // Array to hold all the CSS files
35 $theme_css = array();
36
37 // 1. Load the default theme
38 Kohana::config_set('core.modules', array_merge(array(THEMEPATH."default"),
39 Kohana::config("core.modules")));
e102cea @dkobia * Fixed theme issue
dkobia authored
40
41 $css_url = (Kohana::config("cache.cdn_css")) ?
42 Kohana::config("cache.cdn_css") : url::base();
43 $theme_css[] = $css_url."themes/default/css/style.css";
0bf85ca @dkobia * New Theming Functionality
dkobia authored
44
45 // 2. Extend the default theme
6357df5 @dkobia * Reducing the number of database calls made during initialization
dkobia authored
46 if ( Kohana::config("settings.site_style") != "default" )
0bf85ca @dkobia * New Theming Functionality
dkobia authored
47 {
6357df5 @dkobia * Reducing the number of database calls made during initialization
dkobia authored
48 $theme = THEMEPATH.Kohana::config("settings.site_style");
0bf85ca @dkobia * New Theming Functionality
dkobia authored
49 Kohana::config_set('core.modules', array_merge(array($theme),
50 Kohana::config("core.modules")));
51
52 if ( is_dir($theme.'/css') )
53 {
54 $css = dir($theme.'/css'); // Load all the themes css files
55 while (($css_file = $css->read()) !== FALSE)
56 if (preg_match('/\.css/i', $css_file))
57 {
6357df5 @dkobia * Reducing the number of database calls made during initialization
dkobia authored
58 $theme_css[] = url::base()."themes/".Kohana::config("settings.site_style")."/css/".$css_file;
0bf85ca @dkobia * New Theming Functionality
dkobia authored
59 }
60 }
61 }
62
63 Kohana::config_set('settings.site_style_css',$theme_css);
64 }
65 }
66
67 new register_themes;
Something went wrong with that request. Please try again.