1<?php 2/** 3 * Math Table (matrix) Cell element for the Ad-Hoc MathML plugin 4 * 5 * Defines <mtd> ... </mtd> syntax 6 * More info: https://developer.mozilla.org/en-US/docs/Web/MathML/Element/mtd 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_mtd extends syntax_plugin_adhocmathml_abstract { 13 14 protected $tag = 'mtd'; 15 16 /* allow link attributes: */ 17 function allowSpecificAttribute(&$name, &$value) { 18 //dbg('MathML: <mtd> - allowSpecificAttribute(' . $name . ', "' . $value . '")'); 19 20 switch (trim($name)) { 21 case 'colspan': 22 case 'rowspan': 23 if (is_numeric(trim($value))) { 24 $value = intval($value); 25 return ($value > 0 && $value < 100); 26 } 27 break; 28 default: 29 return false; 30 } 31 } 32 33 /** 34 * ODT Renderer Functions 35 */ 36 function renderODTElementOpen($renderer, $HTMLelement, $data) { 37 38 $helper = $this->loadHelper('adhoctags', true); 39 $attr = $helper->getAttributes($data); 40 41 $rows = ( array_key_exists('rowspan', $attr) ? intval($attr['rowspan']) : 1 ); 42 $cols = ( array_key_exists('colspan', $attr) ? intval($attr['colspan']) : 1 ); 43 44 $renderer->tablecell_open($cols, null, $rows); 45 46 } 47 function renderODTElementClose($renderer, $element) { 48 $renderer->tablecell_close(); 49 } 50}