Skip to content

Commit

Permalink
Bugfixes. Added EU cookie banner as static content
Browse files Browse the repository at this point in the history
  • Loading branch information
KHIT93 committed Feb 11, 2015
1 parent ac2bf55 commit 1c654f2
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 39 deletions.
4 changes: 2 additions & 2 deletions application/core/MY_Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public function __construct() {
$this->load->module($module->module);
}
}
protected function _invoke($method = NULL) {
protected function _invoke($method = NULL, $params = NULL) {
if($method) {
foreach ($this->db->select('module')->from('modules')->where('active', 1)->get()->result() as $module) {
if(method_exists($this->{$module->module}, $method)) {
Modules::run($module->module.'/'.$method);
Modules::run($module->module.'/'.$method, $params);
}
}
}
Expand Down
13 changes: 13 additions & 0 deletions application/core/MY_Model.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');

class MY_Model extends CI_Model {
protected function _invoke($method = NULL, $params = NULL) {
if($method) {
foreach ($this->db->select('module')->from('modules')->where('active', 1)->get()->result() as $module) {
if(method_exists($this->{$module->module}, $method)) {
Modules::run($module->module.'/'.$method, $params);
}
}
}
}
}
28 changes: 28 additions & 0 deletions application/helpers/ui_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,31 @@ function isJson($string) {
}
}
// ------------------------------------------------------------------------

/**
* Generates a valid html stylesheet link
*
* @param string $styles
* @param string $stylesheet
* @param string $media
*/
if(!function_exists('add_style')) {
function add_style(&$styles, $stylesheet, $media = 'screen') {
$styles .= '<link href="'.$stylesheet.'" rel="stylesheet" type="text/css" media="'.$media.'">'."\n";
}
}
// ------------------------------------------------------------------------

/**
* Generates a valid html output for rendering JS
*
* @param string $scripts
* @param string $script
* @param string $content
*/
if(!function_exists('add_script')) {
function add_script(&$scripts, $script, $content = '') {
$scripts .= '<script src="'.$script.'">'.$content.'</script>'."\n";
}
}
// ------------------------------------------------------------------------
5 changes: 4 additions & 1 deletion application/models/mdl_content.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Mdl_Content extends CI_Model {
class Mdl_Content extends MY_Model {
protected $_data;
protected $_return;
protected $_theme_data;
Expand Down Expand Up @@ -37,6 +37,7 @@ protected function _prepare_head() {
$head[] = '<meta charset="utf-8">';
$head[] = '<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />';
$head[] = '<meta name="viewport" content="width=device-width, initial-scale=1">';
$this->_invoke('_head_alter', $head);
return implode("\n\x20\x20\x20\x20", $head);
}
protected function _prepare_head_title() {
Expand All @@ -50,6 +51,7 @@ protected function _prepare_head_styles() {
$rendered_styles .= "\x20\x20\x20\x20".'<link href="'.base_url().$this->theme->path_to_theme().'/'.$data[$i].'" rel="stylesheet" type="text/css" media="'.$media.'">'."\n";
}
}
$this->_invoke('_styles_alter', $rendered_styles);
}
else {
$rendered_styles .= '';
Expand Down Expand Up @@ -117,6 +119,7 @@ protected function _prepare_scripts() {
if($this->config->config['load_wysiwyg'] == TRUE) {
$this->wysiwyg->implement($rendered_jscripts);
}
$rendered_jscripts .= $this->_invoke('_scripts_alter', $rendered_jscripts);
}
else {
$rendered_jscripts .= '';
Expand Down
18 changes: 15 additions & 3 deletions application/modules/cookies/controllers/cookies.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ class Cookies extends MY_Controller {
public function __construct() {
parent::__construct();
}
function _head_alter() {
function _head_alter(&$head) {
//add items to the header
}
function _styles_alter(&$styles) {
//add necessary css to page header
return add_style($styles, base_url().'frontend/core/css/cookies.css');
}

function _scripts_alter() {
function _scripts_alter(&$scripts) {
//add necessary JS
return add_script($scripts, base_url().'/frontend/core/js/cookiebanner.min.js');
}

function _widget() {
//contains information about the widget generated by this module
return '<p>Cookie compliance goes here</p>';
$uri_segment = $this->uri->segment(1);
$data = array();

return ($uri_segment != 'admin') ? $this->load->view('view_cookies', $data, TRUE) : '';
}

function _install() {
Expand All @@ -25,4 +33,8 @@ function _install() {
function _config() {
return 'This is the cookies module configuration page';
}

function accept() {
//Save the users choice to accept cookies
}
}
12 changes: 0 additions & 12 deletions application/modules/cookies/views/login_form.php

This file was deleted.

13 changes: 0 additions & 13 deletions application/modules/cookies/views/register_form.php

This file was deleted.

8 changes: 0 additions & 8 deletions application/modules/cookies/views/user.php

This file was deleted.

31 changes: 31 additions & 0 deletions application/modules/cookies/views/view_cookies.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!-- <script type="text/javascript" id="cookiebanner"
src="frontend/core/js/cookiebanner.min.js"
</script> -->

<!-- <div class="cookiebanner">
<div class="cookiebanner-close" >X</div>
<span>We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies. <a href="http://aboutcookies.org" target="_blank" class="cookiebanner-learnmore">Learn more</a></span>
</div> -->

<!-- <div class="cookiebanner" style="position: fixed; left: 0px; right: 0px; height: auto; min-height: 21px; z-index: 255; color: rgb(221, 221, 221); line-height: 21px; padding: 5px 16px; font-family: arial, sans-serif; font-size: 14px; bottom: 0px; opacity: 1; background: rgb(0, 0, 0);">
<div class="cookiebanner-close" style="float: right; padding-left: 5px; cursor: pointer;">✖</div>
<span>
We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies.
<a href="http://aboutcookies.org" target="_blank" style="text-decoration: none; color: rgb(170, 170, 170);">Learn more</a>
</span>
</div> -->

<!-- <div class="alert alert-info alert-dismissible navbar-fixed-bottom" role="alert">
<strong>Warning!</strong> Better check yourself, you're not looking too good.
<button type="button" class="" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div> -->

<div class="alert alert-dismissible fade in navbar-inverse navbar-fixed-bottom" role="alert" style="margin-bottom: 0px;">
<p style="color: #FFF;">We are using cookies to improve the experience on the website. You can read more <a href="cookiepolicy">HERE</a>
<?php print nbs(5); ?>
<a href="cookies/accept" class="btn btn-sm btn-info" >Accept cookies</a>
<button type="button" class="btn btn-sm btn-default" data-dismiss="alert" aria-label="Close">Close</button>
</p>
</div>

0 comments on commit 1c654f2

Please sign in to comment.