PageRenderTime 58ms CodeModel.GetById 30ms RepoModel.GetById 0ms app.codeStats 0ms

/components/P2Helper.php

http://phundament.googlecode.com/
PHP | 681 lines | 538 code | 43 blank | 100 comment | 50 complexity | 6333220226185f3f445852bdb4f5555d MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0
  1. <?php
  2. /**
  3. * Class File
  4. *
  5. * @author Tobias Munk <schmunk@usrbin.de>
  6. * @link http://www.phundament.com/
  7. * @copyright Copyright &copy; 2005-2010 diemeisterei GmbH
  8. * @license http://www.phundament.com/license/
  9. */
  10. /**
  11. * Helper class
  12. *
  13. * Detailed info
  14. * <pre>
  15. * $var = code_example();
  16. * </pre>
  17. * {@link DefaultController}
  18. *
  19. * @author Tobias Munk <schmunk@usrbin.de>
  20. * @version $Id: P2Helper.php 547 2010-03-31 22:54:57Z schmunk $
  21. * @package p2.components
  22. * @since 2.0
  23. */
  24. class P2Helper {
  25. const MODULE_NAME = 'p2';
  26. const MODULE_VERSION = '2.1-b9';
  27. public static function return_url($encode = false) {
  28. // fixme? REQUEST, GET or POST?
  29. if (isset($_REQUEST['return_url'])) {
  30. if ($encode)
  31. return $_REQUEST['return_url'];
  32. else
  33. return base64_decode(urldecode($_REQUEST['return_url']));
  34. }
  35. else {
  36. return false;
  37. }
  38. }
  39. /**
  40. * Return the current requestUri
  41. *
  42. * @return string
  43. */
  44. public static function uri() {
  45. return urlencode(base64_encode(Yii::app()->request->requestUri));
  46. }
  47. public static function cleanUrlString($str) {
  48. $str = strtr(utf8_decode($str),
  49. utf8_decode('ŠŒŽšœžŸĽľŔÁÂĂÄĹĆÇČÉĘËĚÍÎĎĐŃŇÓÔŐÖŘŮÚŰÜÝßŕáâăäĺćçčéęëěíîďđńňóôőöřůúűüý˙'),
  50. 'SOZsozYYuAAAAAAACEEEEIIIIDNOOOOOOUUUUYsaaaaaaaceeeeiiiionoooooouuuuyy');
  51. return preg_replace("/[^a-zA-Z0-9_-]+/", "-", $str);
  52. }
  53. public static function xmlspecialchars($text) {
  54. return str_replace('&#039;', '&apos;', htmlspecialchars($text, ENT_QUOTES));
  55. }
  56. public static function numeric_entities($string) {
  57. $mapping_hex = array();
  58. $mapping_dec = array();
  59. foreach (get_html_translation_table(HTML_ENTITIES, ENT_QUOTES) as $char => $entity) {
  60. $mapping_hex[html_entity_decode($entity, ENT_QUOTES, "UTF-8")] = '&#x' . strtoupper(dechex(ord(html_entity_decode($entity, ENT_QUOTES)))) . ';';
  61. $mapping_dec[html_entity_decode($entity, ENT_QUOTES, "UTF-8")] = '&#' . ord(html_entity_decode($entity, ENT_QUOTES)) . ';';
  62. }
  63. $string = str_replace(array_values($mapping_hex), array_keys($mapping_hex), $string);
  64. $string = str_replace(array_values($mapping_dec), array_keys($mapping_dec), $string);
  65. return $string;
  66. }
  67. /**
  68. * Returns a clearfloat HTML snip
  69. *
  70. * @return string
  71. */
  72. public static function clearfloat() {
  73. Yii::app()->clientScript->registerCss('P2Helper.clearfloat', '.clearfloat{ clear:both; height:0; font-size: 1px; line-height: 0px; }');
  74. return "<div class='clearfloat'></div>";
  75. }
  76. public static function writeFileLogs() {
  77. $logger = Yii::getLogger();
  78. foreach (Yii::app()->log->routes as $route) {
  79. if ($route->enabled && $route instanceof CFileLogRoute) {
  80. $route->collectLogs($logger, true);
  81. }
  82. }
  83. }
  84. /**
  85. * Return HTML markup for a key value pair array.
  86. *
  87. * @param <type> $data
  88. * @return string
  89. */
  90. public static function table($data) {
  91. if (!is_array($data)) {
  92. return 'Empty table.';
  93. }
  94. $return = '<table class="simpleTable">';
  95. foreach ($data AS $key => $value) {
  96. $return .= "<tr>";
  97. $return .= "<th>" . $key . "</th>";
  98. $return .= "<td>" . $value . "</td>";
  99. $return .= "</tr>";
  100. }
  101. $return .= "</table>";
  102. return $return;
  103. }
  104. public static function juiButtonCssClass($icon = false) {
  105. ob_start();
  106. Yii::app()->controller->widget("P2JuiTheme");
  107. ob_end_clean();
  108. $return = 'button ui-state-default ui-corner-all ';
  109. $return .= ( $icon) ? ' ui-icon-container' : '';
  110. return $return;
  111. }
  112. public static function juiIcon($icon, $applyStyle = true) {
  113. ob_start();
  114. Yii::app()->controller->widget("P2JuiTheme");
  115. ob_end_clean();
  116. $style = ($applyStyle) ? 'style="margin-right: 0.5em; display: inline-block; float:left"' : 'style=" float:left; display: inline-block;"';
  117. return '<span class="ui-icon ui-icon-' . $icon . '" ' . $style . '>&nbsp;</span>';
  118. }
  119. public static function icon($key, $type = null) {
  120. if ($type == 'flag')
  121. return Yii::app()->theme->baseUrl . "/flags/" . $key . ".gif";
  122. else
  123. return Yii::app()->theme->baseUrl . "/icons/" . $key . ".png";
  124. }
  125. public static function language($type = null) {
  126. if ($type == 'UC_ALL') {
  127. return str_replace(' ', '', ucwords(str_replace('_', ' ', Yii::app()->language)));
  128. } else {
  129. return Yii::app()->language;
  130. }
  131. }
  132. /**
  133. * A wrapper for Yii::t(), you may use this method for special translations, like dynamic values.
  134. *
  135. * @param <type> $category
  136. * @param <type> $message
  137. * @param <type> $params
  138. * @param <type> $source
  139. * @param <type> $language
  140. * @return <type>
  141. */
  142. public static function t($category, $message, $params = array(), $source = null, $language = null) {
  143. return Yii::t($category, $message, $params, $source, $language);
  144. }
  145. public static function widget($className, $properties) {
  146. ob_start();
  147. Yii::app()->controller->widget($className, $properties);
  148. return ob_get_clean();
  149. }
  150. // FIXME
  151. public static function relation($relation, $property) {
  152. if ($relation !== null)
  153. return CHtml::link($relation->$property, array(P2Helper::lcfirst(get_class($relation)) . "/show", "id" => $relation->id));
  154. else
  155. return "";
  156. }
  157. // FIXME
  158. public static function hasMany($relation) {
  159. if (!isset($relation[0]))
  160. return;
  161. else
  162. $controller = P2Helper::lcfirst(get_class($relation[0]));
  163. $return = "";
  164. foreach (CHtml::listData($relation, 'id', 'title') AS $id => $name) {
  165. $return .= CHtml::link($name, array($controller . '/update', 'id' => $id)) . ', ';
  166. };
  167. return $return;
  168. }
  169. /**
  170. *
  171. * @return <type>
  172. */
  173. public static function powered() {
  174. return 'Powered by <a class="poweredByPhundament" href="http://phundament.com">phundament</a>.';
  175. }
  176. /**
  177. *
  178. * @param <type> $relativePath
  179. * @return <type>
  180. */
  181. public static function publishAsset($relativePath = null) {
  182. if ($relativePath === null) {
  183. Yii::log('Relative path can not be null', CLogger::LEVEL_WARNING, "p2.helper");
  184. } else {
  185. return Yii::app()->assetManager->publish(Yii::app()->basePath . DS . $relativePath);
  186. }
  187. }
  188. public static function registerJsExtension($path = null) {
  189. if ($path === null) {
  190. throw new Exception('No plugin path specified!');
  191. }
  192. $script = self::findModule()->basePath . DS . "extensions" . DS . $path;
  193. $url = Yii::app()->assetManager->publish($script);
  194. Yii::app()->clientScript->registerScriptFile($url);
  195. }
  196. /**
  197. * Addiditional config string parsing
  198. *
  199. * @param <type> $key
  200. * @return <type>
  201. */
  202. public static function configure($key) {
  203. $args = func_get_args();
  204. $data = null;
  205. switch ($args[0]) {
  206. case 'jquery:loadingStart':
  207. $data = '$("' . $args[1] . '").fadeTo("fast", 0.5);';
  208. break;
  209. case 'jquery:loadingEnd':
  210. $data = '$("' . $args[1] . '").fadeTo("normal", 1);';
  211. break;
  212. case 'cTabView:cssFile':
  213. if (Yii::app()->theme) {
  214. $url = Yii::app()->theme->baseUrl . DS . 'css' . DS . 'jquery.yiitab.css';
  215. $path = Yii::app()->theme->basePath . DS . 'css' . DS . 'jquery.yiitab.css';
  216. $data = (is_file($path)) ? $url : null;
  217. }
  218. break;
  219. case 'ckeditor:config':
  220. // FIXME: ckeditor-3.0.1 no baseUrl, bodyId
  221. if (Yii::app()->theme) {
  222. if (is_array($args[1]['contentsCss'])) {
  223. foreach ($args[1]['contentsCss'] AS $css) {
  224. $parse['contentsCss'][] = "http://" . $_SERVER['SERVER_NAME'] . "/" . Yii::app()->theme->baseUrl . "/" . $css . "";
  225. }
  226. } else {
  227. $parse['contentsCss'] = "http://" . $_SERVER['SERVER_NAME'] . "/" . Yii::app()->theme->baseUrl . "/" . $args[1]['contentsCss'];
  228. }
  229. }
  230. #exit;
  231. // parse assets
  232. $parse['stylesCombo_stylesSet'] = 'default:' . Yii::app()->assetManager->publish(Yii::app()->basePath . DS . $args[1]['stylesCombo_stylesSet']);
  233. $parse['templates'] = 'default';
  234. $parse['templates_files'] = array(Yii::app()->assetManager->publish(Yii::app()->basePath . DS . $args[1]['templates_files']));
  235. // parse URLs
  236. $parse['filebrowserBrowseUrl'] = Yii::app()->controller->createUrl($args[1]['filebrowserBrowseUrl']);
  237. $parse['filebrowserImageBrowseUrl'] = Yii::app()->controller->createUrl($args[1]['filebrowserImageBrowseUrl']);
  238. $parse['filebrowserFlashBrowseUrl'] = Yii::app()->controller->createUrl($args[1]['filebrowserFlashBrowseUrl']);
  239. $data = array_merge($args[1], $parse);
  240. break;
  241. default:
  242. throw new Exception('Config key not found!');
  243. }
  244. return $data;
  245. }
  246. /**
  247. * Finds a module by id, returns 'p2' if no id given
  248. *
  249. * @param string $id
  250. * @return CModule
  251. */
  252. public static function findModule($id = null) {
  253. if ($id === null)
  254. $id = self::MODULE_NAME;
  255. return Yii::app()->findModule($id);
  256. }
  257. // BIG TODO here - how to check classes ?
  258. public static function classExists($classPath) {
  259. $class = Yii::import($classPath);
  260. #echo $class; exit;
  261. if (class_exists($class) == true) {
  262. return $class;
  263. } else {
  264. return false;
  265. throw new CException();
  266. }
  267. }
  268. /**
  269. * Lowercases only the first character of a string
  270. *
  271. * @param <type> $string
  272. * @return string
  273. */
  274. public static function lcfirst($string) {
  275. return strtolower(substr($string, 0, 1)) . substr($string, 1);
  276. }
  277. /**
  278. * Retrieves $_POST variable by array values
  279. *
  280. * @param array $array "the key-chain"
  281. * @return string
  282. */
  283. public static function getPostVar($array) {
  284. switch (count($array)) {
  285. case 0:
  286. $msg = "Unable to determine POST vars!";
  287. throw new Exception($msg);
  288. break;
  289. case 1:
  290. $return = $_POST[$array[0]];
  291. break;
  292. case 2:
  293. $return = $_POST[$array[0]][$array[1]];
  294. break;
  295. case 3:
  296. $return = $_POST[$array[0]][$array[1]][$array[2]];
  297. break;
  298. default:
  299. $msg = "Too many POST fields specified!";
  300. throw new Exception($msg);
  301. break;
  302. }
  303. return $return;
  304. }
  305. public static function hash($input) {
  306. return md5($input);
  307. }
  308. public static function getClassProperties($classPath) {
  309. $class = self::classExists($classPath);
  310. if ($class) {
  311. return get_class_vars($class);
  312. }
  313. }
  314. public static function getModules() {
  315. $dir = Yii::app()->basePath;
  316. foreach (scandir($dir . DS . "modules") AS $module) {
  317. if ((($module != ".") && ($module != "..")) && (is_dir($dir . DS . "modules" . DS . $module) && strstr($module, ".") === false)) {
  318. Yii::import("application.modules." . $module . ".controllers.*");
  319. $return[] = $module;
  320. }
  321. }
  322. return $return;
  323. }
  324. public static function getControllers($module = null) {
  325. $return = array();
  326. if ($module === null) {
  327. $dir = Yii::app()->basePath . DS . "controllers";
  328. } else {
  329. $dir = Yii::app()->basePath . DS . "modules" . DS . $module . DS . "controllers";
  330. }
  331. foreach (scandir($dir) AS $controller) {
  332. if (!is_dir($dir . DS . $controller)) {
  333. if (substr($controller, 0, 1) == ".")
  334. continue;
  335. Yii::import("application.controllers.*");
  336. #self::getActions(str_replace(".php","",$controller));
  337. $trans = array("Controller.php" => "", "\\" => "/");
  338. if ($module !== null)
  339. $return[strtr($controller, $trans)] = $module . "/" . P2Helper::lcfirst(strtr($controller, $trans));
  340. else
  341. $return[strtr($controller, $trans)] = P2Helper::lcfirst(strtr($controller, $trans));
  342. }
  343. }
  344. return $return;
  345. }
  346. public static function getActions($controller) {
  347. $return = array();
  348. Yii::trace("Scanning actions for $controller ...");
  349. $methods = get_class_methods(ucfirst(basename($controller) . "Controller"));
  350. foreach ($methods AS $method) {
  351. if ($method == "actions")
  352. continue;
  353. if ($method == "actionDelete")
  354. continue;
  355. if ($method == "actionShow")
  356. continue;
  357. if ($method == "actionUpdate")
  358. continue;
  359. if (substr($method, 0, 6) == "action") {
  360. $key = P2Helper::lcfirst(str_replace("action", "", $method));
  361. $trans = array("action" => "", "\\" => "/");
  362. $value = strtr(Yii::app()->createUrl($controller . DS . $method), $trans);
  363. $return[$key] = $value;
  364. }
  365. }
  366. return $return;
  367. }
  368. public static function html_convert_entities($string) {
  369. return preg_replace_callback('/&([a-zA-Z][a-zA-Z0-9]+);/',
  370. array('P2Helper','convert_entity'), $string);
  371. }
  372. /**
  373. *
  374. * from http://inanimatt.com/php-convert-entities.php
  375. *
  376. * @staticvar <type> $table
  377. * @param <type> $matches
  378. * @return <type>
  379. */
  380. public static function convert_entity($matches) {
  381. static $table = array('quot' => '&#34;',
  382. 'amp' => '&#38;',
  383. 'lt' => '&#60;',
  384. 'gt' => '&#62;',
  385. 'OElig' => '&#338;',
  386. 'oelig' => '&#339;',
  387. 'Scaron' => '&#352;',
  388. 'scaron' => '&#353;',
  389. 'Yuml' => '&#376;',
  390. 'circ' => '&#710;',
  391. 'tilde' => '&#732;',
  392. 'ensp' => '&#8194;',
  393. 'emsp' => '&#8195;',
  394. 'thinsp' => '&#8201;',
  395. 'zwnj' => '&#8204;',
  396. 'zwj' => '&#8205;',
  397. 'lrm' => '&#8206;',
  398. 'rlm' => '&#8207;',
  399. 'ndash' => '&#8211;',
  400. 'mdash' => '&#8212;',
  401. 'lsquo' => '&#8216;',
  402. 'rsquo' => '&#8217;',
  403. 'sbquo' => '&#8218;',
  404. 'ldquo' => '&#8220;',
  405. 'rdquo' => '&#8221;',
  406. 'bdquo' => '&#8222;',
  407. 'dagger' => '&#8224;',
  408. 'Dagger' => '&#8225;',
  409. 'permil' => '&#8240;',
  410. 'lsaquo' => '&#8249;',
  411. 'rsaquo' => '&#8250;',
  412. 'euro' => '&#8364;',
  413. 'fnof' => '&#402;',
  414. 'Alpha' => '&#913;',
  415. 'Beta' => '&#914;',
  416. 'Gamma' => '&#915;',
  417. 'Delta' => '&#916;',
  418. 'Epsilon' => '&#917;',
  419. 'Zeta' => '&#918;',
  420. 'Eta' => '&#919;',
  421. 'Theta' => '&#920;',
  422. 'Iota' => '&#921;',
  423. 'Kappa' => '&#922;',
  424. 'Lambda' => '&#923;',
  425. 'Mu' => '&#924;',
  426. 'Nu' => '&#925;',
  427. 'Xi' => '&#926;',
  428. 'Omicron' => '&#927;',
  429. 'Pi' => '&#928;',
  430. 'Rho' => '&#929;',
  431. 'Sigma' => '&#931;',
  432. 'Tau' => '&#932;',
  433. 'Upsilon' => '&#933;',
  434. 'Phi' => '&#934;',
  435. 'Chi' => '&#935;',
  436. 'Psi' => '&#936;',
  437. 'Omega' => '&#937;',
  438. 'alpha' => '&#945;',
  439. 'beta' => '&#946;',
  440. 'gamma' => '&#947;',
  441. 'delta' => '&#948;',
  442. 'epsilon' => '&#949;',
  443. 'zeta' => '&#950;',
  444. 'eta' => '&#951;',
  445. 'theta' => '&#952;',
  446. 'iota' => '&#953;',
  447. 'kappa' => '&#954;',
  448. 'lambda' => '&#955;',
  449. 'mu' => '&#956;',
  450. 'nu' => '&#957;',
  451. 'xi' => '&#958;',
  452. 'omicron' => '&#959;',
  453. 'pi' => '&#960;',
  454. 'rho' => '&#961;',
  455. 'sigmaf' => '&#962;',
  456. 'sigma' => '&#963;',
  457. 'tau' => '&#964;',
  458. 'upsilon' => '&#965;',
  459. 'phi' => '&#966;',
  460. 'chi' => '&#967;',
  461. 'psi' => '&#968;',
  462. 'omega' => '&#969;',
  463. 'thetasym' => '&#977;',
  464. 'upsih' => '&#978;',
  465. 'piv' => '&#982;',
  466. 'bull' => '&#8226;',
  467. 'hellip' => '&#8230;',
  468. 'prime' => '&#8242;',
  469. 'Prime' => '&#8243;',
  470. 'oline' => '&#8254;',
  471. 'frasl' => '&#8260;',
  472. 'weierp' => '&#8472;',
  473. 'image' => '&#8465;',
  474. 'real' => '&#8476;',
  475. 'trade' => '&#8482;',
  476. 'alefsym' => '&#8501;',
  477. 'larr' => '&#8592;',
  478. 'uarr' => '&#8593;',
  479. 'rarr' => '&#8594;',
  480. 'darr' => '&#8595;',
  481. 'harr' => '&#8596;',
  482. 'crarr' => '&#8629;',
  483. 'lArr' => '&#8656;',
  484. 'uArr' => '&#8657;',
  485. 'rArr' => '&#8658;',
  486. 'dArr' => '&#8659;',
  487. 'hArr' => '&#8660;',
  488. 'forall' => '&#8704;',
  489. 'part' => '&#8706;',
  490. 'exist' => '&#8707;',
  491. 'empty' => '&#8709;',
  492. 'nabla' => '&#8711;',
  493. 'isin' => '&#8712;',
  494. 'notin' => '&#8713;',
  495. 'ni' => '&#8715;',
  496. 'prod' => '&#8719;',
  497. 'sum' => '&#8721;',
  498. 'minus' => '&#8722;',
  499. 'lowast' => '&#8727;',
  500. 'radic' => '&#8730;',
  501. 'prop' => '&#8733;',
  502. 'infin' => '&#8734;',
  503. 'ang' => '&#8736;',
  504. 'and' => '&#8743;',
  505. 'or' => '&#8744;',
  506. 'cap' => '&#8745;',
  507. 'cup' => '&#8746;',
  508. 'int' => '&#8747;',
  509. 'there4' => '&#8756;',
  510. 'sim' => '&#8764;',
  511. 'cong' => '&#8773;',
  512. 'asymp' => '&#8776;',
  513. 'ne' => '&#8800;',
  514. 'equiv' => '&#8801;',
  515. 'le' => '&#8804;',
  516. 'ge' => '&#8805;',
  517. 'sub' => '&#8834;',
  518. 'sup' => '&#8835;',
  519. 'nsub' => '&#8836;',
  520. 'sube' => '&#8838;',
  521. 'supe' => '&#8839;',
  522. 'oplus' => '&#8853;',
  523. 'otimes' => '&#8855;',
  524. 'perp' => '&#8869;',
  525. 'sdot' => '&#8901;',
  526. 'lceil' => '&#8968;',
  527. 'rceil' => '&#8969;',
  528. 'lfloor' => '&#8970;',
  529. 'rfloor' => '&#8971;',
  530. 'lang' => '&#9001;',
  531. 'rang' => '&#9002;',
  532. 'loz' => '&#9674;',
  533. 'spades' => '&#9824;',
  534. 'clubs' => '&#9827;',
  535. 'hearts' => '&#9829;',
  536. 'diams' => '&#9830;',
  537. 'nbsp' => '&#160;',
  538. 'iexcl' => '&#161;',
  539. 'cent' => '&#162;',
  540. 'pound' => '&#163;',
  541. 'curren' => '&#164;',
  542. 'yen' => '&#165;',
  543. 'brvbar' => '&#166;',
  544. 'sect' => '&#167;',
  545. 'uml' => '&#168;',
  546. 'copy' => '&#169;',
  547. 'ordf' => '&#170;',
  548. 'laquo' => '&#171;',
  549. 'not' => '&#172;',
  550. 'shy' => '&#173;',
  551. 'reg' => '&#174;',
  552. 'macr' => '&#175;',
  553. 'deg' => '&#176;',
  554. 'plusmn' => '&#177;',
  555. 'sup2' => '&#178;',
  556. 'sup3' => '&#179;',
  557. 'acute' => '&#180;',
  558. 'micro' => '&#181;',
  559. 'para' => '&#182;',
  560. 'middot' => '&#183;',
  561. 'cedil' => '&#184;',
  562. 'sup1' => '&#185;',
  563. 'ordm' => '&#186;',
  564. 'raquo' => '&#187;',
  565. 'frac14' => '&#188;',
  566. 'frac12' => '&#189;',
  567. 'frac34' => '&#190;',
  568. 'iquest' => '&#191;',
  569. 'Agrave' => '&#192;',
  570. 'Aacute' => '&#193;',
  571. 'Acirc' => '&#194;',
  572. 'Atilde' => '&#195;',
  573. 'Auml' => '&#196;',
  574. 'Aring' => '&#197;',
  575. 'AElig' => '&#198;',
  576. 'Ccedil' => '&#199;',
  577. 'Egrave' => '&#200;',
  578. 'Eacute' => '&#201;',
  579. 'Ecirc' => '&#202;',
  580. 'Euml' => '&#203;',
  581. 'Igrave' => '&#204;',
  582. 'Iacute' => '&#205;',
  583. 'Icirc' => '&#206;',
  584. 'Iuml' => '&#207;',
  585. 'ETH' => '&#208;',
  586. 'Ntilde' => '&#209;',
  587. 'Ograve' => '&#210;',
  588. 'Oacute' => '&#211;',
  589. 'Ocirc' => '&#212;',
  590. 'Otilde' => '&#213;',
  591. 'Ouml' => '&#214;',
  592. 'times' => '&#215;',
  593. 'Oslash' => '&#216;',
  594. 'Ugrave' => '&#217;',
  595. 'Uacute' => '&#218;',
  596. 'Ucirc' => '&#219;',
  597. 'Uuml' => '&#220;',
  598. 'Yacute' => '&#221;',
  599. 'THORN' => '&#222;',
  600. 'szlig' => '&#223;',
  601. 'agrave' => '&#224;',
  602. 'aacute' => '&#225;',
  603. 'acirc' => '&#226;',
  604. 'atilde' => '&#227;',
  605. 'auml' => '&#228;',
  606. 'aring' => '&#229;',
  607. 'aelig' => '&#230;',
  608. 'ccedil' => '&#231;',
  609. 'egrave' => '&#232;',
  610. 'eacute' => '&#233;',
  611. 'ecirc' => '&#234;',
  612. 'euml' => '&#235;',
  613. 'igrave' => '&#236;',
  614. 'iacute' => '&#237;',
  615. 'icirc' => '&#238;',
  616. 'iuml' => '&#239;',
  617. 'eth' => '&#240;',
  618. 'ntilde' => '&#241;',
  619. 'ograve' => '&#242;',
  620. 'oacute' => '&#243;',
  621. 'ocirc' => '&#244;',
  622. 'otilde' => '&#245;',
  623. 'ouml' => '&#246;',
  624. 'divide' => '&#247;',
  625. 'oslash' => '&#248;',
  626. 'ugrave' => '&#249;',
  627. 'uacute' => '&#250;',
  628. 'ucirc' => '&#251;',
  629. 'uuml' => '&#252;',
  630. 'yacute' => '&#253;',
  631. 'thorn' => '&#254;',
  632. 'yuml' => '&#255;'
  633. );
  634. // Entity not found? Destroy it.
  635. return isset($table[$matches[1]]) ? $table[$matches[1]] : '';
  636. }
  637. }
  638. ?>