* @license PHP License * @package WB * @subpackage base */ WBClass::load('WBXinha_Dialog'); /** * Xinha Dialog Module Specialchar * * * * @version 0.1.0 * @package WB * @subpackage base */ class WBXinha_Dialog_Specialchar extends WBXinha_Dialog { /** * list of greek character * @var array */ protected $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 */ protected $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 */ protected $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 */ protected $charCombining = array(); /** * Run dialog * * @param bool $submit * @return bool whehther dialog was successful and may be closed */ public function run($submit = true) { if ($submit && $this->onSubmit()) { return true; } $this->makeCharCombination(); $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); return false; } /** * select proper value on submit * * Prepare to-be-inserted HTML snippet, or return false when * selection was not successful * * @return bool sucess */ protected function onSubmit() { $this->makeCharCombination(); $this->insert = ''; $char = $this->req->get('char'); $all = array_merge($this->charGreek, $this->charMath, $this->charCommon, $this->charCombining); if (!in_array($char, $all)) { return false; } $this->loadTemplates('insert'); $this->tmpl->addGlobalVar('value', '&'. $char . ';'); $this->insert = $this->tmpl->getParsedTemplate('snippet'); return true; } /** * 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; } } } ?>