* @license PHP License * @package wb * @subpackage Markup */ WBClass::load('WBMarkup_Handler_Xml2Wxml'); /** * Markup Scanner Handler: Wxml2Xml * * Convert Wxml html data to Wombat XML * * @version 0.1.0 * @package wb * @subpackage Markup */ class WBMarkup_Handler_Wxml2Xml extends WBMarkup_Handler_Xml2Wxml { /** * Cunstructor * * Flip mapping array */ public function __construct() { $this->stdTagMap = array_flip($this->stdTagMap); } /** * Handler on start element * * @param string $ns The used namespace, if set. otherwise null * @param string $tag the tag itself * @param array $attributes the attributes of the found element * @param bool $isEmpty true if it is a start- and closing-Element (e.g.
) * @return bool usually true, false to stop the scanner */ public function onStartElement($ns, $tag, $attributes, $isEmpty) { if (empty($ns)) { if (isset($this->stdTagMap[$tag])) { $tag = $this->stdTagMap[$tag]; } if (isset($attributes['wb:dialog'])) { $ns = 'wb'; $tag = $attributes['wb:dialog']; } } return parent::onStartElement($ns, $tag, $attributes, $isEmpty); } /** * Convert node * * transform namespaced tags to HTML * * @todo convert empty namespace (standard HTML) to known WB namespace, if possible * @param string $ns * @param string $tag * @param array $node */ protected function convert($ns, $tag, &$node) { $con = $this->getConverter($ns, $tag); if (!$con) { return ''; } return $con->toXml($node); } /** * Serialize document node * * Strip nodes with whitespace content only. Clean up rubish from WYSIWIG editor. * * @param array $node * @return string serialized attributes */ protected function node2String($node) { if ($node['isEmpty']) { return parent::node2String($node); } if (!empty($node['ns'])) { return parent::node2String($node); } // strip BR-Tags bofore closing tag $end = end($node['cData']); if ('
' == $end) { array_pop($node['cData']); } // empty cData? $cData = trim(implode("\n", $node['cData'])); if (0 == strlen($cData)) { return ''; } return parent::node2String($node); } }