-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathext.current.php
More file actions
129 lines (105 loc) · 3.06 KB
/
Copy pathext.current.php
File metadata and controls
129 lines (105 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* Current Extension
*
* Gets some information on current URL as Global Variables.
*
* @package current_ext
* @category Extension
* @author Adam Fairholm (Green Egg Media)
* @link https://github.com/green-egg-media/Current
*/
class Current_ext {
public $name = 'Current';
public $version = '1.1';
public $description = 'Adds some variables about the current page as global variables';
public $settings_exist = 'n';
public $docs_url = 'https://github.com/green-egg-media/Current';
public $settings = array();
// --------------------------------------------------------------------------
function Current_ext($settings='')
{
$this->EE =& get_instance();
$this->settings = $settings;
}
// --------------------------------------------------------------------------
/**
* Set some current data.
*
* @param $session_data
* @return array The session data.
*/
function set_current( $session_data )
{
$this->EE->load->helper('url');
// Current URL
$this->EE->config->_global_vars['current_url'] = current_url();
// Total URL Segments
$this->EE->config->_global_vars['total_url_segments'] = $this->EE->uri->total_segments();
// URI String
$this->EE->config->_global_vars['uri_string'] = $this->EE->uri->uri_string();
// Last URL Segment
$this->EE->config->_global_vars['last_url_segment'] = end( $this->EE->uri->segment_array() );
// Tracker Segments 1 - 6. tracker_1 being the last EE page visited, tracker_2 the page before that, etc.
$tracker = $session_data->tracker;
for ( $i = 0; $i < 6; $i++ )
{
$this->EE->config->_global_vars['tracker_'.($i + 1)] = ( isset( $tracker[$i] ) ) ? $tracker[$i] : '';
}
}
// --------------------------------------------------------------------------
/**
* Activate Extension
*
* @return void
*/
function activate_extension()
{
$data = array(
'class' => __CLASS__,
'method' => 'set_current',
'hook' => 'sessions_end',
'settings' => '',
'priority' => 6,
'version' => $this->version,
'enabled' => 'y'
);
$this->EE->db->insert('extensions', $data);
}
// --------------------------------------------------------------------------
/**
* Update Extension
*
* @return void
*/
function update_extension($current = '')
{
if ($current == '' or $current == $this->version) return false;
// If this is 1.1 and up, update the
// extension hook used from sessions_start
// to sessions_end
if ($current <= '1.0')
{
$this->EE->db->where('class', __CLASS__);
$this->EE->db->update('extensions',
array(
'hook' => 'session_end',
'version' => $this->version
)
);
}
}
// --------------------------------------------------------------------------
/**
* Disable Extension
*
* @return void
*/
function disable_extension()
{
$this->EE->db->where('class', __CLASS__);
$this->EE->db->delete('extensions');
}
}
/* End of file ext.current.php */
/* Location: ./system/expressionengine/third_party/ext.current.php */