26
26
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27
27
* THE SOFTWARE.
28
28
*
29
- * @package CodeIgniter
30
- * @author EllisLab Dev Team
31
- * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
- * @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (http://bcit.ca/)
33
- * @license http://opensource.org/licenses/MIT MIT License
34
- * @link https://codeigniter.com
35
- * @since Version 1.0.0
29
+ * @package CodeIgniter
30
+ * @author EllisLab Dev Team
31
+ * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32
+ * @copyright Copyright (c) 2014 - 2019, British Columbia Institute of Technology (http://bcit.ca/)
33
+ * @license http://opensource.org/licenses/MIT MIT License
34
+ * @link https://codeigniter.com
35
+ * @since Version 1.0.0
36
36
* @filesource
37
37
*/
38
- defined ('BASEPATH ' ) OR exit ('No direct script access allowed ' );
38
+ defined ('BASEPATH ' ) or exit ('No direct script access allowed ' );
39
39
40
40
/**
41
41
* CodeIgniter Smiley Helpers
42
42
*
43
- * @package CodeIgniter
44
- * @subpackage Helpers
45
- * @category Helpers
46
- * @author EllisLab Dev Team
47
- * @link https://codeigniter.com/user_guide/helpers/smiley_helper.html
48
- * @deprecated 3.0.0 This helper is too specific for CI.
43
+ * @package CodeIgniter
44
+ * @subpackage Helpers
45
+ * @category Helpers
46
+ * @author EllisLab Dev Team
47
+ * @link https://codeigniter.com/user_guide/helpers/smiley_helper.html
48
+ * @deprecated 3.0.0 This helper is too specific for CI.
49
49
*/
50
50
51
51
// ------------------------------------------------------------------------
52
52
53
- if ( ! function_exists ('smiley_js ' ))
54
- {
53
+ if (!function_exists ('smiley_js ' )) {
55
54
/**
56
55
* Smiley Javascript
57
56
*
58
57
* Returns the javascript required for the smiley insertion. Optionally takes
59
58
* an array of aliases to loosely couple the smiley array to the view.
60
59
*
61
- * @param mixed alias name or array of alias->field_id pairs
62
- * @param string field_id if alias name was passed in
63
- * @param bool
64
- * @return array
60
+ * @param mixed alias name or array of alias->field_id pairs
61
+ * @param string field_id if alias name was passed in
62
+ * @param bool
63
+ *
64
+ * @return array
65
65
*/
66
- function smiley_js ($ alias = '' , $ field_id = '' , $ inline = TRUE )
66
+ function smiley_js ($ alias = '' , $ field_id = '' , $ inline = true )
67
67
{
68
- static $ do_setup = TRUE ;
68
+ static $ do_setup = true ;
69
69
$ r = '' ;
70
70
71
- if ($ alias !== '' && ! is_array ($ alias ))
72
- {
71
+ if ($ alias !== '' && !is_array ($ alias )) {
73
72
$ alias = array ($ alias => $ field_id );
74
73
}
75
74
76
- if ($ do_setup === TRUE )
77
- {
78
- $ do_setup = FALSE ;
79
- $ m = array ();
75
+ if ($ do_setup === true ) {
76
+ $ do_setup = false ;
77
+ $ m = array ();
80
78
81
- if (is_array ($ alias ))
82
- {
83
- foreach ($ alias as $ name => $ id )
84
- {
85
- $ m [] = '" ' .$ name .'" : " ' .$ id .'" ' ;
79
+ if (is_array ($ alias )) {
80
+ foreach ($ alias as $ name => $ id ) {
81
+ $ m [] = '" ' . $ name . '" : " ' . $ id . '" ' ;
86
82
}
87
83
}
88
84
89
- $ m = '{ ' . implode (', ' , $ m ). '} ' ;
85
+ $ m = '{ ' . implode (', ' , $ m ) . '} ' ;
90
86
91
87
$ r .= <<<EOF
92
88
var smiley_map = {$ m };
@@ -117,64 +113,56 @@ function insert_smiley(smiley, field_id) {
117
113
}
118
114
}
119
115
EOF ;
120
- }
121
- elseif (is_array ($ alias ))
122
- {
123
- foreach ($ alias as $ name => $ id )
124
- {
125
- $ r .= 'smiley_map[" ' .$ name .'"] = " ' .$ id ."\"; \n" ;
116
+ } elseif (is_array ($ alias )) {
117
+ foreach ($ alias as $ name => $ id ) {
118
+ $ r .= 'smiley_map[" ' . $ name . '"] = " ' . $ id . "\"; \n" ;
126
119
}
127
120
}
128
121
129
122
return ($ inline )
130
- ? '<script type="text/javascript" charset="utf-8">/*<![CDATA[ */ ' . $ r . '// ]]></script> '
123
+ ? '<script type="text/javascript" charset="utf-8">/*<![CDATA[ */ ' . $ r . '// ]]></script> '
131
124
: $ r ;
132
125
}
133
126
}
134
127
135
128
// ------------------------------------------------------------------------
136
129
137
- if ( ! function_exists ('get_clickable_smileys ' ))
138
- {
130
+ if (!function_exists ('get_clickable_smileys ' )) {
139
131
/**
140
132
* Get Clickable Smileys
141
133
*
142
134
* Returns an array of image tag links that can be clicked to be inserted
143
135
* into a form field.
144
136
*
145
- * @param string the URL to the folder containing the smiley images
146
- * @param array
147
- * @return array
137
+ * @param string the URL to the folder containing the smiley images
138
+ * @param array
139
+ *
140
+ * @return array
148
141
*/
149
142
function get_clickable_smileys ($ image_url , $ alias = '' )
150
143
{
151
144
// For backward compatibility with js_insert_smiley
152
- if (is_array ($ alias ))
153
- {
145
+ if (is_array ($ alias )) {
154
146
$ smileys = $ alias ;
155
- }
156
- elseif (FALSE === ($ smileys = _get_smiley_array ()))
157
- {
158
- return FALSE ;
147
+ } elseif (false === ($ smileys = _get_smiley_array ())) {
148
+ return false ;
159
149
}
160
150
161
151
// Add a trailing slash to the file path if needed
162
- $ image_url = rtrim ($ image_url , '/ ' ). '/ ' ;
152
+ $ image_url = rtrim ($ image_url , '/ ' ) . '/ ' ;
163
153
164
154
$ used = array ();
165
- foreach ($ smileys as $ key => $ val )
166
- {
155
+ foreach ($ smileys as $ key => $ val ) {
167
156
// Keep duplicates from being used, which can happen if the
168
157
// mapping array contains multiple identical replacements. For example:
169
158
// :-) and :) might be replaced with the same image so both smileys
170
159
// will be in the array.
171
- if (isset ($ used [$ smileys [$ key ][0 ]]))
172
- {
160
+ if (isset ($ used [$ smileys [$ key ][0 ]])) {
173
161
continue ;
174
162
}
175
163
176
- $ link [] = '<a href="javascript:void(0);" onclick="insert_smiley( \'' . $ key. '\', \'' . $ alias. '\')"><img src=" ' . $ image_url. $ smileys [$ key ][0 ]. '" alt=" ' . $ smileys [$ key ][3 ]. '" style="width: ' . $ smileys [$ key ][1 ]. '; height: ' . $ smileys [$ key ][2 ]. '; border: 0;" /></a> ' ;
177
- $ used [$ smileys [$ key ][0 ]] = TRUE ;
164
+ $ link [] = '<a href="javascript:void(0);" onclick="insert_smiley( \'' . $ key . '\', \'' . $ alias . '\')"><img src=" ' . $ image_url . $ smileys [$ key ][0 ] . '" alt=" ' . $ smileys [$ key ][3 ] . '" style="width: ' . $ smileys [$ key ][1 ] . '; height: ' . $ smileys [$ key ][2 ] . '; border: 0;" /></a> ' ;
165
+ $ used [$ smileys [$ key ][0 ]] = true ;
178
166
}
179
167
180
168
return $ link ;
@@ -183,31 +171,29 @@ function get_clickable_smileys($image_url, $alias = '')
183
171
184
172
// ------------------------------------------------------------------------
185
173
186
- if ( ! function_exists ('parse_smileys ' ))
187
- {
174
+ if (!function_exists ('parse_smileys ' )) {
188
175
/**
189
176
* Parse Smileys
190
177
*
191
178
* Takes a string as input and swaps any contained smileys for the actual image
192
179
*
193
- * @param string the text to be parsed
194
- * @param string the URL to the folder containing the smiley images
195
- * @param array
196
- * @return string
180
+ * @param string the text to be parsed
181
+ * @param string the URL to the folder containing the smiley images
182
+ * @param array
183
+ *
184
+ * @return string
197
185
*/
198
- function parse_smileys ($ str = '' , $ image_url = '' , $ smileys = NULL )
186
+ function parse_smileys ($ str = '' , $ image_url = '' , $ smileys = null )
199
187
{
200
- if ($ image_url === '' OR ( ! is_array ($ smileys ) && FALSE === ($ smileys = _get_smiley_array ())))
201
- {
188
+ if ($ image_url === '' or (!is_array ($ smileys ) && false === ($ smileys = _get_smiley_array ()))) {
202
189
return $ str ;
203
190
}
204
191
205
192
// Add a trailing slash to the file path if needed
206
- $ image_url = rtrim ($ image_url , '/ ' ). '/ ' ;
193
+ $ image_url = rtrim ($ image_url , '/ ' ) . '/ ' ;
207
194
208
- foreach ($ smileys as $ key => $ val )
209
- {
210
- $ str = str_replace ($ key , '<img src=" ' .$ image_url .$ smileys [$ key ][0 ].'" alt=" ' .$ smileys [$ key ][3 ].'" style="width: ' .$ smileys [$ key ][1 ].'; height: ' .$ smileys [$ key ][2 ].'; border: 0;" /> ' , $ str );
195
+ foreach ($ smileys as $ key => $ val ) {
196
+ $ str = str_replace ($ key , '<img src=" ' . $ image_url . $ smileys [$ key ][0 ] . '" alt=" ' . $ smileys [$ key ][3 ] . '" style="width: ' . $ smileys [$ key ][1 ] . '; height: ' . $ smileys [$ key ][2 ] . '; border: 0;" /> ' , $ str );
211
197
}
212
198
213
199
return $ str ;
@@ -216,35 +202,31 @@ function parse_smileys($str = '', $image_url = '', $smileys = NULL)
216
202
217
203
// ------------------------------------------------------------------------
218
204
219
- if ( ! function_exists ('_get_smiley_array ' ))
220
- {
205
+ if (!function_exists ('_get_smiley_array ' )) {
221
206
/**
222
207
* Get Smiley Array
223
208
*
224
209
* Fetches the config/smiley.php file
225
210
*
226
- * @return mixed
211
+ * @return mixed
227
212
*/
228
213
function _get_smiley_array ()
229
214
{
230
215
static $ _smileys ;
231
216
232
- if ( ! is_array ($ _smileys ))
233
- {
234
- if (file_exists (APPPATH .'config/smileys.php ' ))
235
- {
236
- include (APPPATH .'config/smileys.php ' );
217
+ if (!is_array ($ _smileys )) {
218
+ if (file_exists (__DIR__ . '/../../config/smileys.php ' )) {
219
+ include (__DIR__ . '/../../config/smileys.php ' );
237
220
}
238
221
239
- if (file_exists (APPPATH .'config/ ' .ENVIRONMENT .'/smileys.php ' ))
240
- {
241
- include (APPPATH .'config/ ' .ENVIRONMENT .'/smileys.php ' );
222
+ if (file_exists (APPPATH . 'config/ ' . ENVIRONMENT . '/smileys.php ' )) {
223
+ include (APPPATH . 'config/ ' . ENVIRONMENT . '/smileys.php ' );
242
224
}
243
225
244
- if (empty ($ smileys ) OR ! is_array ($ smileys ))
245
- {
226
+ if (empty ($ smileys ) or !is_array ($ smileys )) {
246
227
$ _smileys = array ();
247
- return FALSE ;
228
+
229
+ return false ;
248
230
}
249
231
250
232
$ _smileys = $ smileys ;
0 commit comments