e107 /e107_plugins/tagwords/tagwords_shortcodes.php

Language PHP Lines 416
MD5 Hash 072e4d9a262d8f20b525b3e563d110b1
Repository https://github.com/CasperGemini/e107.git View Raw File View Project SPDX
  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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
<?php
/*
 * e107 website system
 *
 * Copyright (C) 2008-2013 e107 Inc (e107.org)
 * Released under the terms and conditions of the
 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
 *
 * Tagwords Shortcodes
 *
*/
if (!defined('e107_INIT')) { exit; }

/*
$codes = array(
'tag_search', 'tag_area_heading', 'tag_link', 'tag_cloud', 'tag_word', 'tag_number', 'tag_sort', 'tag_type', 'tag_area', 'tag_button', 'tag_options', 'tag_opt_min', 'tag_opt_class', 'tag_opt_default_sort', 'tag_opt_default_style', 'tag_opt_view_sort', 'tag_opt_view_style', 'tag_opt_view_area', 'tag_opt_view_search', 'tag_opt_view_freq', 'tag_opt_caption', 'tag_opt_seperator', 'tag_opt_activeareas', 'tag_opt_button'
);
*/

$codes = array();
/*
$tmp = get_class_methods('tagwords_shortcodes');
foreach($tmp as $c)
{
	if(strpos($c, 'sc_') === 0)
	{
		$codes[] = substr($c, 3);
	}
}
*/
// register_shortcode('tagwords_shortcodes', TRUE);

// initShortcodeClass('tagwords_shortcodes');

class tagwords_shortcodes extends e_shortcode
{
	var $e107;

	function tagwords_shortcodes()
	{
		$this->e107 = e107::getInstance();
	}

	function sc_tag_search($parm, $sc_mode)
	{
		global $tag;

		$value = (isset($_GET['q']) ? e107::getParser()->toForm($_GET['q']) : '');
		switch($sc_mode)
		{
			case 'menu':
				if(varsettrue($tag->pref['tagwords_menu_view_search'])!=1)
				{
					return;
				}
				$id = 'tagwords_searchform_menu';

				return "
				<form id='".$id."' method='get' action='".e_PLUGIN_ABS."tagwords/tagwords.php'>
				<div>
				<input class='tbox' style='width:100px;' type='text'  name='q' size='35' value='".$value."' maxlength='50' />
				<input class='btn btn-default button' type='submit' name='se' value='".LAN_TAG_SEARCH_2."' />
				</div>
				</form>";
				break;

			case 'search':
				if(varsettrue($tag->pref['tagwords_view_search'])!=1)
				{
					return;
				}
				$id = 'tagwords_searchform';
				return "
				<form id='".$id."' method='get' action='".e_PLUGIN_ABS."tagwords/tagwords.php'>
				<div>
				<input class='tbox' style='width:100px;' type='text'  name='q' size='35' value='".$value."' maxlength='50' />
				<input class='btn btn-default button' type='submit' name='s' value='".LAN_TAG_SEARCH_2."' />
				</div>
				</form>";
				break;

			default:
				if(varsettrue($tag->pref['tagwords_view_search'])!=1)
				{
					return;
				}
				return "
				<input class='tbox' style='width:100px;' type='text'  name='q' size='35' value='".$value."' maxlength='50' />
				<input class='btn btn-default button' type='submit' name='s' value='".LAN_TAG_SEARCH_2."' />";
				break;
		}
	}

	function sc_tag_area_heading()
	{
		global $tag;
		return (varsettrue($tag->area->settings['caption']) ? defset($tag->area->settings['caption'], $tag->area->settings['caption']) : '');
	}

	function sc_tag_link($parm, $sc_mode)
	{
		global $tag;
		switch($sc_mode)
		{
			case 'menu':
				return "<a href='".e107::getUrl()->create('tagwords')."'>".LAN_TAG_MENU_1."</a>";
				break;
			case 'home':
				return "<a href='".e107::getUrl()->create('tagwords')."'>".LAN_TAG_7."</a>";
				break;
			default:
				if(method_exists($tag->area, 'getLink'))
				{
					return $tag->area->getLink($tag->id);
				}
				break;
		}
	}

	function sc_tag_cloud($parm, $sc_mode)
	{
		global $tag;
		switch($sc_mode)
		{
			case 'menu':
				return $tag->TagCloud('menu');
				break;
			case 'list':
				return $tag->TagCloudList();
				break;
			default:
				return $tag->TagCloud();
				break;
		}
	}

	function sc_tag_word($parm, $sc_mode)
	{
		global $tag;
		switch($sc_mode)
		{
			case 'result':
				return "<b>".$tag->num."</b> ".($tag->num==1 ? LAN_TAG_8 : LAN_TAG_9)." '<b>".e107::getParser()->toHTML($_GET['q'],true)."</b>'";
				break;
			case 'form':
			default:
				return $tag->word;
				break;
		}
	}

	function sc_tag_number($parm, $sc_mode)
	{
		global $tag;
		switch($sc_mode)
		{
			case 'list':
				return $tag->number;
				break;
			case 'menu':
				if(varsettrue($tag->pref['tagwords_menu_view_freq'])==1)
				{
					return $tag->number;
				}
				break;
			default:
				if(varsettrue($tag->pref['tagwords_view_freq'])==1)
				{
					return $tag->number;
				}
				break;
		}
	}

	function sc_tag_sort()
	{
		global $tag;

		if(varsettrue($tag->pref['tagwords_view_sort'])==1)
		{
			$s = varset($_GET['sort'],'');
			switch($s)
			{
				case 'alpha':
					$sel = 'alpha';
					break;
				case 'freq':
					$sel = 'freq';
					break;
				default:
					$sel = '';
					break;
			}

			$text = "
			<select id='sort' name='sort' class='tbox'>
				<option value=''>".LAN_TAG_19."</option>
				<option value='alpha' ".($sel=='alpha' ? "selected='selected'" : '')." >".LAN_TAG_10."</option>
				<option value='freq' ".($sel=='freq' ? "selected='selected'" : '')." >".LAN_TAG_11."</option>
			</select>";
			return $text;
		}
		return;
	}

	function sc_tag_type()
	{
		global $tag;

		if(varsettrue($tag->pref['tagwords_view_style'])==1)
		{
			$t = varset($_GET['type'],'');
			switch($t)
			{
				case 'cloud':
					$sel = 'cloud';
					break;
				case 'list':
					$sel = 'list';
					break;
				default:
					$sel = '';
					break;
			}

			$text = "
			<select id='type' name='type' class='tbox'>
				<option value=''>".LAN_TAG_20."</option>
				<option value='cloud' ".($sel=='cloud' ? "selected='selected'" : '')." >".LAN_TAG_13."</option>
				<option value='list' ".($sel=='list' ? "selected='selected'" : '')." >".LAN_TAG_12."</option>
			</select>";
			return $text;
		}
		return;
	}

	function sc_tag_area()
	{
		global $tag;
		if(varsettrue($tag->pref['tagwords_view_area'])==1)
		{
			$text = "
			<select id='area' name='area' class='tbox'>
				<option value='' >".LAN_TAG_15."</option>";
				foreach($tag->tagwords as $area)
				{
					if(array_key_exists($area,$tag->pref['tagwords_activeareas']))
					{
						$name = "e_tagwords_{$area}";
						$selected = (varsettrue($_GET['area'])==$area ? "selected=selected" : '');
						$text .= "<option value='".$area."' ".$selected." >".defset($tag->$name->settings['caption'], $tag->$name->settings['caption'])."</option>";
					}
				}
			$text .= "
			</select>";
			return $text;
		}
		return;
	}

	function sc_tag_button()
	{
		global $tag;
		if(varsettrue($tag->pref['tagwords_view_sort']) || varsettrue($tag->pref['tagwords_view_style']) || varsettrue($tag->pref['tagwords_view_area']))
			return "<input class='btn btn-default button' type='submit' name='so' value='".LAN_TAG_SEARCH_3."' />";
		return '';
	}

	function sc_tag_options()
	{
		global $tag;
		if( varsettrue($tag->pref['tagwords_view_search'])==1 || varsettrue($tag->pref['tagwords_view_sort'])==1 || varsettrue($tag->pref['tagwords_view_style'])==1 || varsettrue($tag->pref['tagwords_view_area'])==1 )
		{
			return e107::getParser()->parseTemplate($tag->template['options'], true, $tag->shortcodes);
		}
	}

	function sc_tag_url($parm)
	{
		return e107::getUrl()->create('tagwords', $parm);
	}
	//##### ADMIN OPTIONS -------------------------

	function sc_tag_opt_min($parm, $sc_mode)
	{
		global $tag;
		$id = ($sc_mode=='menu' ? 'tagwords_menu_min' : 'tagwords_min');
		return "<input class='tbox' type='text' id='".$id."' name='".$id."' value='".$tag->pref[$id]."' size='3' maxlength='3' />";
	}

	function sc_tag_opt_class()
	{
		global $tag;
		$id = 'tagwords_class';
		return r_userclass($id,$tag->pref[$id],"","admin,public,guest,nobody,member,classes");
	}

	function sc_tag_opt_default_sort($parm, $sc_mode)
	{
		global $tag;
		$id = ($sc_mode=='menu' ? 'tagwords_menu_default_sort' : 'tagwords_default_sort');
		return "<label><input type='radio' name='".$id."' value='1' ".($tag->pref[$id] ? "checked='checked'" : "")." /> ".LAN_TAG_OPT_5."</label>&nbsp;&nbsp;
		<label><input type='radio' name='".$id."' value='0' ".($tag->pref[$id] ? "" : "checked='checked'")." /> ".LAN_TAG_OPT_6."</label>";
	}

	function sc_tag_opt_default_style()
	{
		global $tag;
		$id = 'tagwords_default_style';
		return "<label><input type='radio' name='".$id."' value='1' ".($tag->pref[$id] ? "checked='checked'" : "")." /> ".LAN_TAG_OPT_8."</label>&nbsp;&nbsp;
		<label><input type='radio' name='".$id."' value='0' ".($tag->pref[$id] ? "" : "checked='checked'")." /> ".LAN_TAG_OPT_9."</label>";
	}

	function sc_tag_opt_view_sort()
	{
		global $tag;
		$id = 'tagwords_view_sort';
		$sel = (isset($tag->pref[$id]) && $tag->pref[$id] ? "checked='checked'" : "");
		return "
		<label for='".$id."'>
			<input type='checkbox' name='".$id."' id='".$id."' value='1' ".$sel." /> ".LAN_TAG_OPT_12."
		</label>";
	}

	function sc_tag_opt_view_style()
	{
		global $tag;
		$id = 'tagwords_view_style';
		$sel = (isset($tag->pref[$id]) && $tag->pref[$id] ? "checked='checked'" : "");
		return "
		<label for='".$id."'>
			<input type='checkbox' name='".$id."' id='".$id."' value='1' ".$sel." /> ".LAN_TAG_OPT_13."
		</label>";
	}

	function sc_tag_opt_view_area()
	{
		global $tag;
		$id = 'tagwords_view_area';
		$sel = (isset($tag->pref[$id]) && $tag->pref[$id] ? "checked='checked'" : "");
		return "
		<label for='".$id."'>
			<input type='checkbox' name='".$id."' id='".$id."' value='1' ".$sel." /> ".LAN_TAG_OPT_14."
		</label>";
	}

	function sc_tag_opt_view_search($parm, $sc_mode)
	{
		global $tag;
		$id = ($sc_mode=='menu' ? 'tagwords_menu_view_search' : 'tagwords_view_search');
		$sel = (isset($tag->pref[$id]) && $tag->pref[$id] ? "checked='checked'" : "");
		return "
		<label for='".$id."'>
			<input type='checkbox' name='".$id."' id='".$id."' value='1' ".$sel." /> ".LAN_TAG_OPT_19."
		</label>";
	}

	function sc_tag_opt_view_freq($parm, $sc_mode)
	{
		global $tag;
		if($sc_mode=='menu')
		{
			$id = 'tagwords_menu_view_freq';
		}
		else
		{
			$id = 'tagwords_view_freq';
		}
		$sel = (isset($tag->pref[$id]) && $tag->pref[$id] ? "checked='checked'" : "");
		return "
		<label for='".$id."'>
			<input type='checkbox' name='".$id."' id='".$id."' value='1' ".$sel." /> ".LAN_TAG_OPT_20."
		</label>";
	}

	function sc_tag_opt_caption()
	{
		global $tag;
		$id = 'tagwords_menu_caption';
		return "<input class='tbox' type='text' id='".$id."' name='".$id."' value='".e107::getParser()->toForm($tag->pref[$id],"","defs")."' size='30' maxlength='100' />";
	}

	function sc_tag_opt_seperator()
	{
		global $tag;
		$id = 'tagwords_word_seperator';
		return "<input class='tbox' type='text' id='".$id."' name='".$id."' value='".e107::getParser()->toForm($tag->pref[$id])."' size='3' maxlength='10' />";
	}

	function sc_tag_opt_activeareas()
	{
		global $tag;
		$id = 'tagwords_activeareas';
		$text = "";
		foreach($tag->tagwords as $area)
		{
			$sel = (array_key_exists($area,$tag->pref[$id]) ? "checked='checked'" : '');
			$name = "e_tagwords_{$area}";

			$text .= "
			<label for='".$id."-".$area."'>
			<input type='checkbox' name='".$id."[".$area."]' id='".$id."-".$area."' value='1' ".$sel." />
			".defset($tag->$name->settings['caption'], $tag->$name->settings['caption'])."
			</label><br />";

		}
		return $text;
	}

	function sc_tag_opt_button()
	{
		return "<input class='btn btn-default button' type='submit' name='updatesettings' value='".LAN_UPDATE."' />";
	}

}
?>
Back to Top