* @license PHP License * @package wb * @subpackage Markup */ WBClass::load('WBMarkup_Converter'); /** * Table * * Generic tables * * @version 0.1.1 * @package wb * @subpackage Markup */ class WBMarkup_Converter_Wb_Tablesheet extends WBMarkup_Converter { /** * @var WBDatasource_Table_Sheet */ private $ds; /** * constructor * * start up end set temüplate dir */ public function __construct() { parent::__construct(); $this->ds = WBClass::create('WBDatasource_Table_Sheet'); } /** * transform Wxml Tags to XML * * @todo solve problem with internal but SSL links * @todo implement VFSFile links * @param array $node to be modified document node * @return bool true on success */ public function toXml(&$node) { $cData = $node['attributes']['wb:value']; $cData = trim($cData); $node = array(); $node['ns'] = 'wb'; $node['tag'] = 'tablesheet'; $node['isEmpty'] = false; $node['attributes'] = array(); $node['cData'] = array($cData); return true; } /** * transform Xml to Wxml (html) tags * * @todo not implemented * @param array $node to be modified document node * @return bool true on success */ public function toWxml(&$node) { $id = trim(implode('', $node['cData'])); $table = $this->ds->get($id); if (empty($table)) { $node = array(); return true; } $atts = array( 'wb:dialog' => 'Tablesheet', 'wb:value' => $id, 'class' => 'wb-wxml wb-wxml-tablesheet', 'ondblclick' => 'return WB.Wxml.Dialog.editTag(this);', 'title' => 'double click to change' ); $node['ns'] = ''; $node['tag'] = 'div'; $node['attributes'] = $atts; $node['cData'] = array($table['title']); return true; } /** * Transform XML to Html * * @param array $node to be modified document node * @return bool true on success */ public function toHtml(&$node) { $id = trim(implode('', $node['cData'])); $table = $this->ds->get($id); if (empty($table)) { throw WBClass::create('WBException', array( 'msg' => 'Could not load TableSheet' . $id, 'code' => 1, 'class' => __CLASS__ )); $node = array(); return true; } if (!$this->loadTemplates($table['template'])) { throw WBClass::create('WBException', array( 'msg' => 'Could not load template for ' . $table['template'] . ' TableSheet ' . $id, 'code' => 2, 'class' => __CLASS__ )); return true; } $rows = $this->ds->getRows(); foreach ($rows as $r) { $this->tmpl->addVars('table_row', $r[0]); $this->tmpl->addRows('table_cell', $r); $this->tmpl->parseTemplate('table_row', 'a'); $this->tmpl->clearTemplate('table_cell'); } $this->template2HtmlNode($node, $table); return true; } }