* @license PHP License * @package WB * @subpackage base */ WBClass::load('WBWxml_Dialog'); /** * Wxml Dialog Module * * TOC - Table of content * * @version 0.1.1 * @package WB * @subpackage base */ class WBWxml_Dialog_Specialchar extends WBWxml_Dialog { /** * list of greek character * @var array */ private $charGreek = array( 'alpha', 'beta', 'gamma', 'delta', 'epsilon', 'zeta', 'eta', 'theta', 'iota', 'kappa', 'lambda', 'mu', 'nu', 'xi', 'omicron', 'pi', 'rho', 'sigma', 'tau', 'upsilon', 'phi', 'chi', 'psi', 'omega', 'Alpha', 'Beta', 'Gamma', 'Delta', 'Epsilon', 'Zeta', 'Eta', 'Theta', 'Iota', 'Kappa', 'Lambda', 'Mu', 'Nu', 'Xi', 'Omicron', 'Pi', 'Rho', 'Sigma', 'Tau', 'Upsilon', 'Phi', 'Chi', 'Psi', 'Omega' ); /** * Math symbols * @var array */ private $charMath = array( 'laquo', 'raquo', 'lang', 'rang', 'loz', 'fnof', 'int', 'le', 'ge', 'lt', 'gt', 'ne', 'equiv', 'asymp', 'weierp', 'image', 'real', 'cap', 'cup', 'sub', 'sup', 'nsub', 'sube', 'supe', 'oplus', 'otimes', 'and', 'or', 'perp', 'ang', 'lceil', 'rceil', 'lfloor', 'rfloor', 'alefsym', 'infin', 'prop', 'radic', 'middot', 'plusmn', 'bull', 'sdot', 'frac14', 'frac12', 'frac34', 'not', 'tilde', 'ndash', 'mdash', 'hellip', 'dagger', 'Dagger', '#x1e40', '#x1e41' ); /** * common symbols * @var array */ private $charCommon = array( 'spades', 'clubs', 'hearts', 'diams', 'Oslash', 'oslash', 'larr', 'rarr', 'darr', 'harr', 'lArr', 'rArr', 'dArr', 'hArr', 'crarr', 'prime', 'Prime', 'copy', 'trade', 'reg', 'deg', 'para', 'quot', 'lsquo', 'rsquo', 'ldquo', 'rdquo', 'raquo', 'cent', 'pound', 'curren', 'yen', 'euro', 'permil', 'aelig', 'AElig', 'oelig', 'OElig' ); /** * combination characters * @var array */ private $charCombining = array(); /** * font list * @var array */ private $charFont = array(); /** * Submit * * @param array $values */ public function submit($values = array()) { $this->makeCharCombination(); $this->makeCharFont(); $char = $this->req->get('char', ''); if (empty($char)) { $this->showList(); return; } if (!in_array($char, $this->charGreek) && !in_array($char, $this->charMath) && !in_array($char, $this->charCommon) && !in_array($char, $this->charCombining) && !in_array($char, $this->charFont) ) { $this->showList(); return; } $this->loadTemplates('insert'); $this->tmpl->addGlobalVar('value', '&'. $char . ';'); } /** * Show all lists */ private function showList() { $this->loadTemplates('list'); $this->tmpl->addVar('greek_list_entry', 'value', $this->charGreek); $this->tmpl->addVar('math_list_entry', 'value', $this->charMath); $this->tmpl->addVar('common_list_entry', 'value', $this->charCommon); $this->tmpl->addVar('combining_list_entry', 'value', $this->charCombining); $this->tmpl->addVar('font_list_entry', 'value', $this->charFont); } private function makeCharFont() { if (!empty($this->charFont)) { return; } $char = array_merge(range('A', 'Z'), range('a', 'z')); $style = array('scr', 'fr', 'opf'); foreach ($style as $s) { foreach ($char as $c) { $this->charFont[] = $c . $s; } } } /** * create list of combination chars * * http://www.fileformat.info/info/unicode/block/combining_diacritical_marks/index.htm */ private function makeCharCombination() { if (!empty($this->charCombining) || empty($this->select)) { return; } $comb = range(0x300, 0x36f); foreach ($comb as $c) { $this->charCombining[] = '#'. $c; } } }