Skip to content

Instantly share code, notes, and snippets.

@tylerwillingham
Created September 1, 2012 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tylerwillingham/3565669 to your computer and use it in GitHub Desktop.
Save tylerwillingham/3565669 to your computer and use it in GitHub Desktop.
<?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_';
/**
* Constructor
*/
public function __construct()
{
$this->EE =& get_instance();
$this->cookie_name = $this->cookie_prefix . $this->EE->uri->segment(3);
// 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) )
{
// set the cookie
$url = $this->EE->uri->uri_string();
$this->EE->functions->set_cookie($this->cookie_name, $url, 604800);
}
// set the {file_checker:cookie_found} global var to TRUE or FALSE
if ( ! $this->_check_for_cookie($this->cookie_name) )
{
$this->EE->config->_global_vars['file_checker:cookie_found'] = FALSE;
$this->EE->config->_global_vars['file_checker:url'] = FALSE;
}
else
{
$this->EE->config->_global_vars['file_checker:cookie_found'] = TRUE;
$this->EE->config->_global_vars['file_checker:url'] = $this->EE->input->cookie($this->cookie_name);
}
}
public function url()
{
$cookie_name = $this->cookie_prefix . $this->EE->TMPL->fetch_param('name');
return $this->EE->input->cookie($cookie_name);
}
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';
}
}
}
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