1<?php
2/**
3 * Input tag component for the Ad Hoc Forms plugin
4 *
5 * Defines  <input /> syntax
6 * More info: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input
7 *
8 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
9 * @author     Sascha Leib <sascha.leib(at)kolmio.com>
10 */
11
12class syntax_plugin_adhocmathml_abstract extends syntax_plugin_adhoctags_abstractinline {
13
14	protected $pluginName = 'adhocmathml';
15
16	protected function registerTag() { return true;}
17
18    function getPType(){ return 'normal';}
19
20	/* sub-classes can overwrite this function: */
21	protected function allowSpecificAttribute(&$name, &$value) { return false; }
22
23	/* allow link attributes: */
24	function allowAttribute(&$name, &$value) {
25		//dbg('<td>:allowAttribute(' . $name . ', "' . $value . '")');
26
27		switch (trim($name)) {
28
29			case 'displaystyle':
30				return (substr($value, 0, 11) !== 'javascript:');
31				break;
32
33			case 'mathbackground': /* colours */
34			case 'mathcolor':
35				return preg_match('/^[\w\d,\(\)#\% \/]+$/', trim($value));
36				break;
37
38			case 'mathsize':	/* font size specification */
39				return preg_match('/^[\w\d\%]+$/', trim($value));
40				break;
41
42			case 'mathvariant':	/* font variant flag */
43				return in_array(strtolower($value), array('normal','bold','italic','bold-italic','double-struck','bold-fraktur','script','bold-script','fraktur','sans-serif','bold-sans-serif','sans-serif-italic','sans-serif-bold-italic','monospace','initial','tailed','looped','stretched'));
44				break;
45
46			case 'scriptlevel':	/* sets the math-depth of an element  */
47				return preg_match('/^[+-]?[\d]+$/', trim($value));
48				break;
49
50			case 'href':
51				return in_array(strtolower($value), array('true','false'));
52				break;
53
54			default:
55				return $this->allowSpecificAttribute($name, $value);
56		}
57	}
58
59}