-
Notifications
You must be signed in to change notification settings - Fork 8
/
pi.copyright.php
154 lines (135 loc) · 3.72 KB
/
pi.copyright.php
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
<?php
/**
* ExpressionEngine
*
* LICENSE
*
* ExpressionEngine by EllisLab is copyrighted software
* The licence agreement is available here http://expressionengine.com/docs/license.html
*
* Copyright
*
* @category Plugins
* @package Copyright
* @version 1.0.0
* @since 1.0.0
* @author George Ornbo <george@shapeshed.com>
* @see {@link http://github.com/shapeshed/copyright.ee_addon/}
* @license {@link http://opensource.org/licenses/bsd-license.php}
*/
/**
* Plugin information used by ExpressionEngine
* @global array $plugin_info
*/
$plugin_info = array(
'pi_name' => 'Copyright',
'pi_version' => '1.0.0',
'pi_author' => 'George Ornbo',
'pi_author_url' => 'http://shapeshed.com/',
'pi_description' => 'Prints a copyright notice',
'pi_usage' => Copyright::usage()
);
class Copyright{
/**
* Data sent back to calling function
* @access public
* @var string
*/
public $return_data = "";
/**
* The start year for the notice.
* Set to a default of the current year in __construct
* @access public
* @see __construct
* @var string
*/
public $start_year = "";
/**
* The end year for the notice.
* Set to a default of the current year in __construct
* @access public
* @see __construct
* @var string
*/
public $end_year = "";
/**
* The delimiter for the two years
* Set to a default of the "-" in __construct
* @access public
* @see __construct
* @var string
*/
public $delimiter = "";
/**
* The copyright symbol
* Set to a default of the "©" in __construct
* @access public
* @see __construct
* @var string
*/
public $copyright_symbol = "";
/**
* Error message is start date is after end date
* @access public
* @see show()
* @var string
*/
public $error_message = "Start date is after end date. Please check your settings.";
/**
* ExpressionEngine needs this as it is PHP4 based so doesn't get __construct()
* @access public
*/
public function Unit_converter()
{
$this->__construct();
}
/**
* Constructor. Fetches template data using the Template class
* Sets defaults if nothing is specified in templates
* @access public
*/
public function __construct()
{
$this->EE =& get_instance();
$this->start_year = ( ! $this->EE->TMPL->fetch_param('start_year')) ? date("Y") : $this->EE->TMPL->fetch_param('start_year');
$this->end_year = ( ! $this->EE->TMPL->fetch_param('end_year')) ? date("Y") : $this->EE->TMPL->fetch_param('end_year');
$this->delimiter = ( ! $this->EE->TMPL->fetch_param('delimiter')) ? "–" : $this->EE->TMPL->fetch_param('delimiter');
$this->copyright_symbol = ( ! $this->EE->TMPL->fetch_param('copyright_symbol')) ? "©" : $this->EE->TMPL->fetch_param('copyright_symbol');
}
/**
* Shows the copyright notice
* The function evaluates the dates and returns a string for display in templates
* @access public
* @return string
*/
public function show()
{
if ($this->start_year == $this->end_year)
{
$this->return_data = $this->copyright_symbol .' '. $this->start_year;
}
elseif ($this->start_year < $this->end_year)
{
$this->return_data = $this->copyright_symbol .' '. $this->start_year . $this->delimiter . $this->end_year;
}
elseif ($this->start_year > $this->end_year)
{
$this->return_data = $this->error_message;
}
else
{
return false;
}
return $this->return_data;
}
/**
* Plugin usage documentation
*
* @return string Plugin usage instructions
*/
public function usage()
{
return "Documentation is available here http://shapeshed.github.com/expressionengine/plugins/copyright/";
}
}
?>