Skip to content
This repository has been archived by the owner on Jan 9, 2021. It is now read-only.

Commit

Permalink
Closes #43
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmomathieu committed Dec 7, 2016
1 parent 4af2ea5 commit 9750ad6
Show file tree
Hide file tree
Showing 4 changed files with 169 additions and 50 deletions.
59 changes: 32 additions & 27 deletions application/plugins/helper.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* CMS Canvas
* PageStudio
*
* @author Mark Price
* @copyright Copyright (c) 2012
* A web application for managing website content. For use with PHP 5.4+
*
* This application is based on CMS Canvas, a CodeIgniter based application,
* http://cmscanvas.com/. It has been greatly altered to work for the
* purposes of our development team. Additional resources and concepts have
* been borrowed from PyroCMS http://pyrocms.com, for further improvement
* and reliability.
*
* @package PageStudio
* @author Cosmo Mathieu <[email protected]>
* @copyright Copyright (c) 2015, Cosmo Interactive, LLC
* @license MIT License
* @link http://cmscanvas.com
* @link http://pagestudiocms.com
*/

// ------------------------------------------------------------------------

/**
* Helper Plugin Class
*
* @author Mark Price
* @author Cosmo Mathieu <[email protected]>
*/
class Helper_plugin extends Plugin
{
public function date()
Expand All @@ -22,21 +39,6 @@ public function date()
}
}

public function site_url()
{
return site_url($this->attribute('path', ''));
}

public function base_url()
{
return base_url($this->attribute('path', ''));
}

public function current_url()
{
return current_url();
}

/**
* Creates and image with <img /> tags
* http://stackoverflow.com/questions/138313/how-to-extract-img-src-title-and-alt-from-html-using-php
Expand Down Expand Up @@ -82,12 +84,6 @@ public function image_thumb()
return image_thumb($image, $this->attribute('width', 0), $this->attribute('height', 0), $this->attribute('crop', FALSE));
}

public function uri_segment()
{
$CI =& get_instance();
return $CI->uri->segment($this->attribute('segment'));
}

/**
* Update: Added support for content found in template tags / {{ braces }}
* Allows for usage of:
Expand Down Expand Up @@ -134,5 +130,14 @@ public function code($data)
$content = str_replace('}}', '&#125;&#125;', $content);
return $content;
}

public function config()
{
$atts = $this->attributes(); // the tag parameters

$CI =& get_instance();
$CI->config->load($atts['file']);

return $CI->config->item($atts['item']);
}
}

29 changes: 22 additions & 7 deletions application/plugins/secure.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,34 @@
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* CMS Canvas
* PageStudio
*
* @author Mark Price
* @copyright Copyright (c) 2012
* A web application for managing website content. For use with PHP 5.4+
*
* This application is based on CMS Canvas, a CodeIgniter based application,
* http://cmscanvas.com/. It has been greatly altered to work for the
* purposes of our development team. Additional resources and concepts have
* been borrowed from PyroCMS http://pyrocms.com, for further improvement
* and reliability.
*
* @package PageStudio
* @author Cosmo Mathieu <[email protected]>
* @copyright Copyright (c) 2015, Cosmo Interactive, LLC
* @license MIT License
* @link http://cmscanvas.com
* @link http://pagestudiocms.com
*/

// ------------------------------------------------------------------------

/**
* Secure Plugin Class
*
* @author Mark Price
* @author Cosmo Mathieu <[email protected]>
*/
class Secure_plugin extends Plugin
{
public function is_auth()
{
return ($this->secure->is_auth()) ? 1 : 0;
}
}


16 changes: 0 additions & 16 deletions application/plugins/template.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,4 @@ public function xml_output()
{
return xml_output();
}

// --------------------------------------------------------------------

/**
* Returns the URI segment to the caller
*
* @since 1.2.0
* @access public
* @param int $part
* @return int
*/
public function segment($part)
{
$CI =& get_instance();
return $CI->uri->segment($part);
}
}
115 changes: 115 additions & 0 deletions application/plugins/url.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<?php defined('BASEPATH') OR exit('No direct script access allowed');
/**
* PageStudio
*
* A web application for managing website content. For use with PHP 5.4+
*
* This application is based on CMS Canvas, a CodeIgniter based application,
* http://cmscanvas.com/. It has been greatly altered to work for the
* purposes of our development team. Additional resources and concepts have
* been borrowed from PyroCMS http://pyrocms.com, for further improvement
* and reliability.
*
* @package PageStudio
* @author Cosmo Mathieu <[email protected]>
* @copyright Copyright (c) 2015, Cosmo Interactive, LLC
* @license MIT License
* @link http://pagestudiocms.com
*/

// ------------------------------------------------------------------------

/**
* Url Plugin
*
* Brings the features of the url helper to the templates in the form of a plugin.
*
* @package PageStudio
* @subpackage codeigniter
* @category Helper
* @author Cosmo Mathieu <[email protected]>
* @link http://pagestudiocms.com/docs/
* @license MIT License
* @since Version 1.3.0
*/
class Url_plugin extends Plugin
{
/**
* Returns the base url of a provided path
*
* @return string
*/
public function base_url()
{
return base_url($this->attribute('path', ''));
}

// --------------------------------------------------------------------

/**
*
*
* @return string
*/
public function current_url()
{
return current_url();
}

// --------------------------------------------------------------------

/**
*
*
* @return string
*/
public function site_url()
{
return site_url($this->attribute('path', ''));
}

// --------------------------------------------------------------------

/**
* Returns part of the URI segment or a URL query parameter
*
* Usage:
*
* {{ url:get segment="[int]" }}
*
* {{ url:get param="[string]" }}
*
* @since 1.3.0
* @access public
* @return string
*/
public function get()
{
if($this->attribute('segment'))
{
return ci()->uri->segment($this->attribute('segment'));
}
elseif($this->attribute('param'))
{
return ci()->input->get($this->attribute('param'), TRUE);
}

return FALSE;
}

// --------------------------------------------------------------------

/**
* Send the visitor to another location
*
* Usage:
*
* {{ url:redirect to="[string]" }}
*
* @return void
*/
public function redirect()
{
redirect($this->attribute('to'));
}
}

0 comments on commit 9750ad6

Please sign in to comment.