Exemple #1
0
 public function __construct()
 {
     parent::__construct();
     // Load Session
     $this->session = Session::instance();
     // Load cache
     $this->cache = new Cache();
     // Load Header & Footer
     $this->template->header = new View('header');
     $this->template->footer = new View('footer');
     // Themes Helper
     $this->themes = new Themes();
     $this->themes->requirements();
     $this->themes->frontend = TRUE;
     $this->themes->api_url = Kohana::config('settings.api_url');
     $this->template->header->submit_btn = $this->themes->submit_btn();
     $this->template->header->languages = $this->themes->languages();
     $this->template->header->search = $this->themes->search();
     // Set Table Prefix
     $this->table_prefix = Kohana::config('database.default.table_prefix');
     // Retrieve Default Settings
     $site_name = Kohana::config('settings.site_name');
     // Get banner image and pass to the header
     if (Kohana::config('settings.site_banner_id') != NULL) {
         $banner = ORM::factory('media')->find(Kohana::config('settings.site_banner_id'));
         $this->template->set_global('banner', url::convert_uploaded_to_abs($banner->media_link));
     } else {
         $this->template->set_global('banner', NULL);
     }
     // Prevent Site Name From Breaking up if its too long
     // by reducing the size of the font
     $site_name_style = strlen($site_name) > 20 ? " style=\"font-size:21px;\"" : "";
     $this->template->header->private_deployment = Kohana::config('settings.private_deployment');
     $this->template->set_global('site_name', $site_name);
     $this->template->set_global('site_name_style', $site_name_style);
     $this->template->set_global('site_tagline', Kohana::config('settings.site_tagline'));
     // page_title is a special variable that will be overridden by other controllers to
     //    change the title bar contents
     $this->template->header->page_title = '';
     //pass the URI to the header so we can dynamically add css classes to the "body" tag
     $this->template->header->uri_segments = Router::$segments;
     $this->template->header->this_page = "";
     // add copyright info
     $this->template->footer->site_copyright_statement = '';
     $site_copyright_statement = trim(Kohana::config('settings.site_copyright_statement'));
     if ($site_copyright_statement != '') {
         $this->template->footer->site_copyright_statement = $site_copyright_statement;
     }
     // Display news feeds?
     $this->template->header->allow_feed = Kohana::config('settings.allow_feed');
     // Header Nav
     $header_nav = new View('header_nav');
     $this->template->header->header_nav = $header_nav;
     $this->template->header->header_nav->loggedin_user = FALSE;
     if (isset(Auth::instance()->get_user()->id)) {
         // Load User
         $this->template->header->header_nav->loggedin_role = Auth::instance()->get_user()->dashboard();
         $this->template->header->header_nav->loggedin_user = Auth::instance()->get_user();
     }
     $this->template->header->header_nav->site_name = Kohana::config('settings.site_name');
     Event::add('ushahidi_filter.view_pre_render.layout', array($this, '_pre_render'));
 }
Exemple #2
0
 public function __construct()
 {
     parent::__construct();
     $this->auth = new Auth();
     $this->auth->auto_login();
     // Load Session
     $this->session = Session::instance();
     if (Kohana::config('settings.private_deployment')) {
         if (!$this->auth->logged_in('login')) {
             url::redirect('login/front');
         }
     }
     // Load cache
     $this->cache = new Cache();
     // Load Header & Footer
     $this->template->header = new View('header');
     $this->template->footer = new View('footer');
     // Themes Helper
     $this->themes = new Themes();
     $this->themes->api_url = Kohana::config('settings.api_url');
     $this->template->header->submit_btn = $this->themes->submit_btn();
     $this->template->header->languages = $this->themes->languages();
     $this->template->header->search = $this->themes->search();
     // Set Table Prefix
     $this->table_prefix = Kohana::config('database.default.table_prefix');
     // Retrieve Default Settings
     $site_name = Kohana::config('settings.site_name');
     // Get banner image and pass to the header
     if (Kohana::config('settings.site_banner_id') != NULL) {
         $banner = ORM::factory('media')->find(Kohana::config('settings.site_banner_id'));
         $this->template->header->banner = url::convert_uploaded_to_abs($banner->media_link);
     } else {
         $this->template->header->banner = NULL;
     }
     // Prevent Site Name From Breaking up if its too long
     // by reducing the size of the font
     $site_name_style = strlen($site_name) > 20 ? " style=\"font-size:21px;\"" : "";
     $this->template->header->private_deployment = Kohana::config('settings.private_deployment');
     $this->template->header->loggedin_username = FALSE;
     $this->template->header->loggedin_userid = FALSE;
     if (isset(Auth::instance()->get_user()->username) and isset(Auth::instance()->get_user()->id)) {
         // Load User
         $this->user = Auth::instance()->get_user();
         $this->template->header->loggedin_username = html::specialchars(Auth::instance()->get_user()->username);
         $this->template->header->loggedin_userid = Auth::instance()->get_user()->id;
         $this->template->header->loggedin_role = Auth::instance()->logged_in('member') ? "members" : "admin";
     }
     $this->template->header->site_name = $site_name;
     $this->template->header->site_name_style = $site_name_style;
     $this->template->header->site_tagline = Kohana::config('settings.site_tagline');
     //pass the URI to the header so we can dynamically add css classes to the "body" tag
     $this->template->header->uri_segments = Router::$segments;
     $this->template->header->this_page = "";
     // Google Analytics
     $google_analytics = Kohana::config('settings.google_analytics');
     $this->template->footer->google_analytics = $this->themes->google_analytics($google_analytics);
     // Load profiler
     // $profiler = new Profiler;
     // Get tracking javascript for stats
     $this->template->footer->ushahidi_stats = Kohana::config('settings.allow_stat_sharing') == 1 ? Stats_Model::get_javascript() : '';
     // Enable CDN gradual upgrader
     $this->template->footer->cdn_gradual_upgrade = Kohana::config('cdn.cdn_gradual_upgrade') != false ? cdn::cdn_gradual_upgrade_js() : '';
     // add copyright info
     $this->template->footer->site_copyright_statement = '';
     $site_copyright_statement = trim(Kohana::config('settings.site_copyright_statement'));
     if ($site_copyright_statement != '') {
         $this->template->footer->site_copyright_statement = $site_copyright_statement;
     }
     // Display news feeds?
     $this->template->header->allow_feed = Kohana::config('settings.allow_feed');
 }