*/ WBClass::load('patI18n'); /** * patTemplate modifier Wxml * * Convert Wombat XML format to HTML * * Parameter: * - tmpldir * - gettext: use gettext for translation * - domain: gettext domain * * @package patTemplate * @package Modifiers * @author gERD Schaufelberger */ class patTemplate_Modifier_Wxml extends patTemplate_Modifier { /** * modify the value * * @param string value * @param array list of parameter * @return string modified value */ public function modify($value, $params = array()) { $params = array_merge(array( 'domain' => '', 'gettext' => '', 'tmpldir' => '' ), $params); $scan = WBClass::create( 'WBMarkup_Scanner' ); /* @var $scan WBMarkup_Scanner */ $hdl = WBClass::create( 'WBMarkup_Handler_Xml2Html' ); /* @var $hdl WBMarkup_Handler_Xml2Html */ if (!empty($params['tmpldir'])) { $hdl->setTmplDir($params['tmpldir']); } $value = $this->translate($value, $params); $scan->setHandler($hdl); $scan->scan($value); return $hdl->getParsedContent();; } /** * Translate the value * * @param string value * @param array list of parameter * @return string translated value */ private function translate($value, $params) { if (empty($params['gettext'])) { return $value; } if (!empty($params['domain'])) { return patI18n::dgettext($params['domain'], $value); } return patI18n::gettext($value); } }