Created
September 1, 2012 06:19
-
-
Save tylerwillingham/3565449 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); | |
/** | |
* ExpressionEngine - by EllisLab | |
* | |
* @package ExpressionEngine | |
* @author ExpressionEngine Dev Team | |
* @copyright Copyright (c) 2003 - 2011, EllisLab, Inc. | |
* @license http://expressionengine.com/user_guide/license.html | |
* @link http://expressionengine.com | |
* @since Version 2.0 | |
* @filesource | |
*/ | |
// ------------------------------------------------------------------------ | |
/** | |
* Slide checker Plugin | |
* | |
* @package ExpressionEngine | |
* @subpackage Addons | |
* @category Plugin | |
* @author Justin Long | |
* @link | |
*/ | |
$plugin_info = array( | |
'pi_name' => 'Slide checker', | |
'pi_version' => '1.0', | |
'pi_author' => 'Justin Long', | |
'pi_author_url' => '', | |
'pi_description'=> 'Allows for users to be directed to the last slide they viewed on a category level', | |
'pi_usage' => Slide_checker::usage() | |
); | |
class Slide_checker { | |
public $return_data; | |
public $cookie_prefix = 'trts_session_'; | |
public $this->cookie_name = $this->cookie_prefix . $this->EE->uri->segment(3); | |
/** | |
* Constructor | |
*/ | |
public function __construct() | |
{ | |
$this->EE =& get_instance(); | |
$this->CI =& get_instance(); | |
// we need the CI cookie helper to set the cookie | |
// $this->CI->load->helper('cookie'); | |
// if the URL looks like /sessions/slides/session-two/P1 | |
if ( $this->EE->uri->segment(1) == 'sessions' AND $this->EE->uri->segment(3) AND $this->EE->uri->segment(4) ) | |
{ | |
// if the cookie is not set, lets set one. | |
if ( ! $this->_check_for_cookie($this->cookie_name) ) | |
{ | |
$url = $this->EE->uri->uri_string(); | |
// build the cookie data | |
$cookie_data = array( | |
'name' => $this->cookie_name, | |
'value' => $url, | |
'expire' => '604800' | |
); | |
// set the cookie | |
$this->CI->input->set_cookie($cookie_data); | |
} | |
} | |
} | |
public function url() | |
{ | |
if ( $this->_check_for_cookie($this->cookie_name) ) | |
{ | |
return $this->EE->input->cookie($this->cookie_name); | |
} | |
else | |
{ | |
return FALSE; | |
} | |
} | |
public function status() | |
{ | |
// check to see if we're looking at a url such as /sessions/slides/session-two | |
if ( $this->EE->uri->segment(1) == 'sessions' AND $this->EE->uri->segment(3) ) | |
{ | |
if ( ! $this->_check_for_cookie($this->cookie_name) ) | |
{ | |
return 'No cookie set'; | |
} | |
else | |
{ | |
return 'Cookie is set'; | |
} | |
} | |
} | |
// returns TRUE if the cookie is set | |
public function find_cookie() | |
{ | |
// check to see if we're looking at a url such as /sessions/slides/session-two | |
if ( $this->EE->uri->segment(1) == 'sessions' AND $this->EE->uri->segment(3) ) | |
{ | |
$this->cookie_name = $this->cookie_prefix . $this->EE->uri->segment(3); | |
if ( ! $this->_check_for_cookie($this->cookie_name) ) | |
{ | |
return FALSE; | |
} | |
else | |
{ | |
return TRUE; | |
} | |
} | |
} | |
private function _check_for_cookie($cookie_name) | |
{ | |
if ( ! $this->EE->input->cookie($cookie_name) ) | |
{ | |
return FALSE; | |
} | |
else | |
{ | |
return TRUE; | |
} | |
} | |
// ---------------------------------------------------------------- | |
/** | |
* Plugin Usage | |
*/ | |
public static function usage() | |
{ | |
ob_start(); | |
?> | |
Since you did not provide instructions on the form, make sure to put plugin documentation here. | |
<?php | |
$buffer = ob_get_contents(); | |
ob_end_clean(); | |
return $buffer; | |
} | |
} | |
/* End of file pi.slide_checker.php */ | |
/* Location: /system/expressionengine/third_party/slide_checker/pi.slide_checker.php */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment