21 private $oattr = null;
27 private $cFormat =
'';
47 $this->oattr = $oattr;
48 $this->index = $index;
49 $this->cFormat = $this->oattr->format;
50 $atype = $this->oattr->type;
52 if (($this->oattr->repeat) && ($this->index <= 0)) {
53 $tvalues = explode(
"\n",
$value);
55 $tvalues[$this->index] =
$value;
57 $this->attrid = $this->oattr->id;
60 foreach ($tvalues as $kvalue => $avalue) {
155 if (($this->cFormat !=
"") && ($atype !=
"doc") && ($atype !=
"array") && ($atype !=
"option")) {
157 $oooval = sprintf($this->
xmlEncode($this->cFormat) , $oooval);
160 $thtmlval[$kvalue] = $oooval;
162 return implode(
"<text:tab/>", $thtmlval);
179 return str_replace(array(
216 $oooval = $this->doc->vault_filename_fromvalue($avalue,
true);
229 $oooval = $this->doc->vault_filename_fromvalue($avalue,
false);
241 $oooval = str_replace(
"&",
"&", $avalue);
242 $oooval = str_replace(array(
249 $oooval = str_replace(
"\n",
"<text:line-break/>", $oooval);
250 $oooval = str_replace(
"<BR>",
"<text:line-break/>", $oooval);
251 $oooval = str_replace(
"\r",
"", $oooval);
277 $enumlabel = $this->oattr->getEnumlabel();
278 $colors = $this->oattr->getOption(
"boolcolor");
280 if (isset($enumlabel[$avalue])) {
282 $tcolor = explode(
",", $colors);
283 if (current($enumlabel) == $enumlabel[$avalue]) {
285 $oooval = sprintf(
'<pre style="background-color:%s;display:inline"> - </pre>', $color);
288 $oooval = sprintf(
'<pre style="background-color:%s;display:inline"> • </pre>', $color);
290 }
else $oooval = $avalue;
292 if (isset($enumlabel[$avalue])) $oooval = $enumlabel[$avalue];
293 else $oooval = $avalue;
332 if (!$this->oattr->format) $this->oattr->format =
"x";
344 if ($this->oattr->format !=
"") {
347 $isLatest = $this->oattr->getOption(
"docrev",
"latest") ==
"latest";
349 $multiple = ($this->oattr->getOption(
"multiple") ==
"yes");
352 $avalue = str_replace(
"\n",
"<BR>", $avalue);
353 $tval = explode(
"<BR>", $avalue);
355 foreach ($tval as $kv => $vv) {
356 if (trim($vv) ==
"") $thval[] = $vv;
357 else $thval[] = $this->doc->getDocAnchor(trim($vv) ,
'',
false);
359 $oooval = implode(
"<text:tab/>", $thval);
361 if ($avalue ==
"") $oooval = $avalue;
364 if (
$title ===
false)
$title = $this->doc->htmlEncode($this->oattr->getOption(
"noaccesstext", _(
"information access deny")));
365 $oooval = $this->doc->htmlEncode(
$title);
368 }
else $oooval = $avalue;
381 $multiple = ($this->oattr->getOption(
"multiple") ==
"yes");
383 $avalue = str_replace(
"\n",
"<BR>", $avalue);
384 $tval = explode(
"<BR>", $avalue);
386 foreach ($tval as $kv => $vv) {
387 if (trim($vv) ==
"") $thval[] = $vv;
389 $thc = new_doc($this->doc->dbaccess, trim($vv));
390 if ($thc->isAlive()) $thval[] = $thc->getCustomTitle();
391 else $thval[] =
"th error $vv";
394 $oooval = implode(
"<text:tab/>", $thval);
396 if ($avalue ==
"") $oooval = $avalue;
398 $thc = new_doc($this->doc->dbaccess, $avalue);
399 if ($thc->isAlive()) $oooval = $thc->getCustomTitle();
400 else $oooval =
"th error $avalue";
428 $oooval = money_format(
'%!.2n', doubleval($avalue));
440 $attrid = $this->oattr->id;
441 $html_body = trim($avalue);
442 if (!$html_body)
return '';
443 $html_body = \Dcp\Utils\htmlclean::normalizeHTMLFragment($html_body, $error);
445 addWarningMsg(sprintf(_(
"Malformed HTML in attribute '%s' from document '%s': %s") , $this->oattr->id, $this->doc->title, $error));
447 if ($html_body ===
false) {
450 $xhtml_body = \Dcp\Utils\htmlclean::convertHTMLFragmentToXHTMLDocument($html_body, $error);
452 addWarningMsg(sprintf(_(
"Error converting HTML from attribute '%s' from document '%s': %s") , $this->oattr->id, $this->doc->title, $error));
454 if ($xhtml_body ===
false) {
458 $xhtml_body = preg_replace(
"/<!--.*?-->/ums",
"", $xhtml_body);
459 $xhtml_body = preg_replace_callback(
'/(<\/?)([^\s>]+)([^>]*)(>)/u',
function ($matches)
461 return $this->
_fixupStyle($matches[1], $matches[2], $matches[3], $matches[4]);
464 $xhtml_body = $this->
cleanhtml($xhtml_body);
466 $domHtml = new \Dcp\Utils\XDOMDocument();
468 $xslt =
new xsltProcessor;
469 $xslt->importStyleSheet($domHtml);
473 $dom = new \Dcp\Utils\XDOMDocument();
474 $dom->loadXML($xhtml_body);
476 catch(Exception $e) {
477 addWarningMsg(sprintf(_(
"possible incorrect conversion HTML to ODT %s: %s") , $this->doc->title, $e->getMessage()));
495 $xmlout = $xslt->transformToXML($dom);
497 $dxml = new \Dcp\Utils\XDOMDocument();
498 $dxml->loadXML($xmlout);
500 $ot = $dxml->getElementsByTagNameNS(
"urn:oasis:names:tc:opendocument:xmlns:office:1.0",
"text");
502 $officetext = $ot1->ownerDocument->saveXML($ot1);
503 $oooval = str_replace(array(
507 ) ,
"", $officetext);
509 $oooval = preg_replace(
'!(<text:p>\s*<table:table )!u',
"<table:table ", $oooval);
510 $oooval = preg_replace(
'!(</table:table>\s*</text:p>)!u',
"</table:table> ", $oooval);
512 $oooval = sprintf(
'<text:section text:style-name="Sect%s" text:name="Section%s" aid="%s">%s</text:section>', $attrid, $attrid, $attrid, $oooval);
514 addWarningMsg(sprintf(_(
"incorrect conversion HTML to ODT %s") , $this->doc->title));
530 $attr = str_replace(
':=',
'=', $attr);
531 $inlineStyle = array();
532 if (preg_match(
'/\s+style\s*=\s*"(?P<style>[^"]*)"/u', $attr, $m)) {
535 if ($tag ===
"img") {
536 if (isset($inlineStyle[
'width']) && preg_match(
'/^(?P<width>[0-9\.]+)(?P<unit>[a-z]*)$/u', $inlineStyle[
'width'], $m)) {
538 switch ($m[
'unit']) {
540 $width = intval($m[
'width']) * $px2mm;
544 $width = floatval($m[
'width']) * 10;
548 $width = intval($m[
'width']);
552 $width = intval($m[
'width']);
554 $attr = sprintf(
' width="%d" ', $width) . $attr;
556 if (isset($inlineStyle[
'height']) && preg_match(
'/^(?P<height>[0-9\.]+)(?P<unit>[a-z]*)$/u', $inlineStyle[
'height'], $m)) {
558 switch ($m[
'unit']) {
560 $height = intval($m[
'height']) * $px2mm;
564 $height = floatval($m[
'height']) * 10;
568 $height = intval($m[
'height']);
572 $height = intval($m[
'height']);
574 $attr = sprintf(
' height="%d" ', $height) . $attr;
577 return ($lt . $tag . $attr . $gt);
582 $html = preg_replace(
':</?span[^>]*>:us',
"", $html);
583 $html = preg_replace(
':</?font[^>]*>:us',
"", $html);
584 $html = preg_replace(
':</?meta[^>]*>:us',
"", $html);
585 $html = preg_replace(
':<style[^>]*>.*?</style>:us',
"", $html);
586 $html = preg_replace(
':<([^>]*) style=\"[^\"]*\":us',
"<\\1", $html);
587 $html = preg_replace(
':<([^>]*) class=\"[^\"]*\":us',
"<\\1", $html);
599 if (($this->cFormat !=
"") && (trim($avalue) !=
"")) {
601 else $oooval = $avalue;
602 } elseif (trim($avalue) ==
"") {
619 if ($this->cFormat !=
"") {
620 if ($avalue) $oooval = strftime($this->cFormat, strtotime($avalue));
621 else $oooval = $avalue;
624 $oooval = substr($avalue, 0, 5);
638 if (($this->cFormat !=
"") && (trim($avalue) !=
"")) {
640 else $oooval = $avalue;
641 } elseif (trim($avalue) ==
"") {
660 $lay =
new Layout(
"FDL/Layout/viewifile.xml", $action);
661 $lay->set(
"aid", $this->oattr->id);
662 $lay->set(
"id", $this->doc->id);
663 $lay->set(
"iheight", $this->oattr->getOption(
"height",
"200px"));
664 $oooval = $lay->gen();
676 $oooval = sprintf(
"<span style=\"background-color:%s\">%s</span>", $avalue, $avalue);
691 preg_match_all(
'/(?P<propName>[\w-]+)\s*:\s*(?P<propValue>[^;]*)(;|$)/u', $str, $matches, PREG_SET_ORDER);
692 foreach ($matches as $m) {
693 $rules[strtolower($m[
'propName']) ] = $m[
'propValue'];
Layout is a template generator.
stringDateToLocaleDate($fdate, $format= '')
static getRelationTitle($docid, $latest=true, Doc $doc, $docrevOption="", array &$info=array())
stringDateToUnixTs($isodate, $utc=false)