function etempl2grid($etempl, &$root, &$embeded_too) { if (is_array($embeded_too)) { if (isset($embeded_too[$etempl->name])) { return; // allready embeded } } else { $embeded_too = array(); } $embeded_too[$etempl->name] = True; $xul_grid = new xmlnode('grid'); $xul_grid->set_attribute('id', $etempl->name); $xul_grid->set_attribute('template', $etempl->template); $xul_grid->set_attribute('lang', $etempl->lang); $xul_grid->set_attribute('group', $etempl->group); $xul_grid->set_attribute('version', $etempl->version); $this->set_attributes($xul_grid, 'width,height,border,class,spacing,padding', $etempl->size); $xul_columns = new xmlnode('columns'); $xul_rows = new xmlnode('rows'); reset($etempl->data); list(, $opts) = each($etempl->data); // read over options-row while (list($r, $row) = each($etempl->data)) { $xul_row = new xmlnode('row'); $this->set_attributes($xul_row, 'class,valign', $opts["c{$r}"]); $this->set_attributes($xul_row, 'height,disabled', $opts["h{$r}"]); $spanned = 0; while (list($c, $cell) = each($row)) { if ($r == '1') { $xul_column = new xmlnode('column'); $this->set_attributes($xul_column, 'width,disabled', $opts[$c]); $xul_columns->add_node($xul_column); } if ($spanned) { --$spanned; continue; // spanned cells are not written } $xul_row->add_node($this->cell2widget($cell, $spanned, $etempl, $root, $embeded_too)); } $xul_rows->add_node($xul_row); } $xul_grid->add_node($xul_columns); $xul_grid->add_node($xul_rows); if ($etempl->style != '') { $styles = new xmlnode('styles'); $styles->set_value($etempl->style); $xul_grid->add_node($styles); } $root->add_node($xul_grid); return ''; }
function export($name = '', $lang = '', $modified = 0) { if (!$name) { $name = $_GET['page']; } if (!$lang) { $lang = $_GET['lang']; } if (!is_array($lang)) { $lang = $lang ? explode(',', $lang) : False; } if (!$modified) { $modified = (int) $_GET['modified']; } header('Content-Type: text/xml; charset=utf-8'); $xml_doc = new xmldoc(); $xml_doc->add_comment('$' . 'Id$'); // to be able to comit the file $xml_doc->add_comment("eGroupWare wiki-pages matching '{$name}%'" . ($lang ? " and lang in(" . implode(',', $lang) . ')' : '') . ($modified ? " modified since " . date('Y-m-d H:m:i', $modified) : '') . ", exported " . date('Y-m-d H:m:i', $exported = time()) . " from {$_SERVER['HTTP_HOST']}"); $xml_wiki = new xmlnode('wiki'); foreach ($this->find($name . '%', 'name') as $page) { if ($lang && !in_array($page['lang'], $lang)) { //echo "continue as page[lang]=$page[lang] not in ".print_r($lang,True)."<br>\n"; continue; // wrong language or not modified since $modified } $page = $this->page($page); // read the complete page $page->read(); $page = $page->as_array(); unset($page['wiki_id']); // we dont export the wiki-id if ($modified && $modified > $page['time']) { //echo "continue as page[time]=$page[time] < $modified<br>\n"; continue; // not modified since $modified } $page = $GLOBALS['phpgw']->translation->convert($page, $GLOBALS['phpgw']->translation->charset(), 'utf-8'); $xml_page = new xmlnode('page'); foreach ($page as $attr => $val) { if ($attr != 'text') { $xml_page->set_attribute($attr, $val); } else { $xml_page->set_value($val); } } $xml_wiki->add_node($xml_page); } $xml_wiki->set_attribute('exported', $exported); if ($lang) { $xml_wiki->set_attribute('languages', implode(',', $lang)); } if ($name) { $xml_wiki->set_attribute('matching', $name . '%'); } if ($modified) { $xml_wiki->set_attribute('modified', $modified); } $xml_doc->add_root($xml_wiki); $xml = $xml_doc->export_xml(); //echo "<pre>\n" . htmlentities($xml) . "\n</pre>\n"; echo $xml; return $xml; }