Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ application/cache/*

application/logs/*
!application/logs/index.html
!application/logs/.htaccess
!application/logs/.htaccess
/nbproject
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is it? If it's only for your machine, should it be in your global .gitignore instead of here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, to work with netbeans, you need to mention this in the gitignore,
I am checking the test cases, will update the request with the tests working.

/nbproject/private/
27 changes: 27 additions & 0 deletions application/libraries/CSS.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

(defined('BASEPATH')) OR exit('No direct script access allowed');

class CSS {

protected $_css = array();

/**
* Add css file path
*
* @access public
* @param string $css
* @return void
*/
public function add($css) {
$this->_css[$css] = $css;
}

public function get() {
$css = array();
foreach ($this->_css as $css_file) {
$css[] = '<link rel="stylesheet" href="' . assets_url('css/' . $css_file) . '">';
}
return implode('', $css);
}
}
27 changes: 27 additions & 0 deletions application/libraries/Description.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

(defined('BASEPATH')) OR exit('No direct script access allowed');

class Description {

protected $_description = FALSE;

/**
* Set page description
*
* @access public
* @param string $description
* @return void
*/
public function set($description) {
$this->_description = $description;
}

public function get() {
if (empty($this->_description)) {
$this->_description = '';
}
return $this->_description;
}

}
27 changes: 27 additions & 0 deletions application/libraries/JS.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

(defined('BASEPATH')) OR exit('No direct script access allowed');

class JS {

protected $_js = array();

/**
* Add js file path
*
* @access public
* @param string $js
* @return void
*/
public function add($js) {
$this->_js[$js] = $js;
}

public function get() {
$js = array();
foreach ($this->_js as $js_file) {
$js[] = '<script src="' . assets_url('js/' . $js_file) . '"></script>';
}
return implode('', $js);
}
}
26 changes: 26 additions & 0 deletions application/libraries/Layout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

(defined('BASEPATH')) OR exit('No direct script access allowed');

class Layout {

protected $_layout;

/**
* Set page layout view (1 column, 2 column...)
*
* @access public
* @param string $layout
* @return void
*/
public function set($_layout) {
$this->_layout = $_layout;
}

public function get() {
if (empty($this->_layout)) {
$this->_layout = 'default';
}
return $this->_layout;
}
}
36 changes: 36 additions & 0 deletions application/libraries/MetaData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

(defined('BASEPATH')) OR exit('No direct script access allowed');

class MetaData {

protected $_metadata = array();

/**
* Add metadata
*
* @access public
* @param string $name
* @param string $content
* @return void
*/
public function add($name, $content) {
$name = htmlspecialchars(strip_tags($name));
$content = htmlspecialchars(strip_tags($content));

$this->_metadata[$name] = $content;
}

public function get() {
$metadata = array();
foreach ($this->_metadata as $name => $content) {
if (strpos($name, 'og:') === 0) {
$metadata[] = '<meta property="' . $name . '" content="' . $content . '">';
} else {
$metadata[] = '<meta name="' . $name . '" content="' . $content . '">';
}
}
return implode('', $metadata);
}

}
143 changes: 22 additions & 121 deletions application/libraries/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,99 +9,26 @@ class Template {

private $_ci;

protected $brand_name = 'CodeIgniter Skeleton';
protected $title_separator = ' - ';

protected $ga_id = FALSE; // UA-XXXXX-X

protected $layout = 'default';

protected $title = FALSE;
protected $description = FALSE;

protected $metadata = array();

protected $js = array();
protected $css = array();
public $layout;
public $title;
public $description;
public $metadata;
public $js;
public $css;

function __construct()
{
$this->_ci =& get_instance();
}

/**
* Set page layout view (1 column, 2 column...)
*
* @access public
* @param string $layout
* @return void
*/
public function set_layout($layout)
{
$this->layout = $layout;
}

/**
* Set page title
*
* @access public
* @param string $title
* @return void
*/
public function set_title($title)
{
$this->title = $title;
}

/**
* Set page description
*
* @access public
* @param string $description
* @return void
*/
public function set_description($description)
{
$this->description = $description;
}

/**
* Add metadata
*
* @access public
* @param string $name
* @param string $content
* @return void
*/
public function add_metadata($name, $content)
{
$name = htmlspecialchars(strip_tags($name));
$content = htmlspecialchars(strip_tags($content));

$this->metadata[$name] = $content;
}

/**
* Add js file path
*
* @access public
* @param string $js
* @return void
*/
public function add_js($js)
{
$this->js[$js] = $js;
}

/**
* Add css file path
*
* @access public
* @param string $css
* @return void
*/
public function add_css($css)
{
$this->css[$css] = $css;
$this->layout = new Layout();
$this->css = new CSS();
$this->js = new JS();
$this->title = new Title();
$this->description = new Description();
$this->metadata = new MetaData();
}

/**
Expand All @@ -123,54 +50,28 @@ public function load_view($view, $data = array(), $return = FALSE)
}

// Title
if (empty($this->title))
{
$title = $this->brand_name;
}
else
{
$title = $this->title . $this->title_separator . $this->brand_name;
}
$title = $this->title->get();

// Description
$description = $this->description;
$description = $this->description->get();

// Metadata
$metadata = array();
foreach ($this->metadata as $name => $content)
{
if (strpos($name, 'og:') === 0)
{
$metadata[] = '<meta property="' . $name . '" content="' . $content . '">';
}
else
{
$metadata[] = '<meta name="' . $name . '" content="' . $content . '">';
}
}
$metadata = implode('', $metadata);
$metadata = $this->metadata->get();

// Javascript
$js = array();
foreach ($this->js as $js_file)
{
$js[] = '<script src="' . assets_url('js/' . $js_file) . '"></script>';
}
$js = implode('', $js);
$js = $this->css->get();

// CSS
$css = array();
foreach ($this->css as $css_file)
{
$css[] = '<link rel="stylesheet" href="' . assets_url('css/' . $css_file) . '">';
}
$css = implode('', $css);
$css = $this->js->get();

// Layout
$layout = $this->layout->get();

$header = $this->_ci->load->view('header', array(), TRUE);
$footer = $this->_ci->load->view('footer', array(), TRUE);
$main_content = $this->_ci->load->view($view, $data, TRUE);

$body = $this->_ci->load->view('layout/' . $this->layout, array(
$body = $this->_ci->load->view('layout/' . $layout, array(
'header' => $header,
'footer' => $footer,
'main_content' => $main_content,
Expand Down
32 changes: 32 additions & 0 deletions application/libraries/Title.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

(defined('BASEPATH')) OR exit('No direct script access allowed');

class Title {

protected $_brand_name = 'CodeIgniter Skeleton';
protected $_title_separator = ' - ';
protected $_title = FALSE;

/**
* Set page title
*
* @access public
* @param string $title
* @return void
*/
public function set($title) {
$this->_title = $title;
}

public function get() {
if (empty($this->_title)) {
$this->_title = $this->_brand_name;
;
} else {
$this->_title = $this->_title . $this->_title_separator . $this->_brand_name;
}
return $this->_title;
}

}
6 changes: 3 additions & 3 deletions application/modules/addons/controllers/addons.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ public function index()
{
$this->load->library('template');

$this->template->set_title('Add-ons');
$this->template->add_js('modules/skeleton.js');
$this->template->add_css('modules/skeleton.css');
$this->template->title->set('Add-ons');
$this->template->js->add('modules/skeleton.js');
$this->template->css->add('modules/skeleton.css');

$addons = $this->load->config('addons/addons', TRUE);
$data = array(
Expand Down
4 changes: 2 additions & 2 deletions application/modules/addons/data/ion_auth/controllers/auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -767,12 +767,12 @@ function _render_page($view, $data=null, $render=false)

if ( ! in_array($view, array('auth/index')))
{
$this->template->set_layout('pagelet');
$this->template->layout->set('pagelet');
}

if ( ! empty($data['title']))
{
$this->template->set_title($data['title']);
$this->template->title->set($data['title']);
}

$this->template->load_view($view, $data);
Expand Down
Loading