18 private $target =
'_self';
22 private $oattr = null;
28 private $cFormat =
'';
29 private $cancelFormat =
false;
30 private $htmlLink =
true;
31 private $useEntities =
true;
32 private $abstractMode =
false;
36 private $vaultErrorSent =
false;
59 public function getHtmlValue($oattr,
$value, $target =
"_self", $htmlLink =
true, $index = - 1, $useEntities =
true, $abstractMode =
false)
63 $this->oattr = $oattr;
64 $this->target = $target;
65 $this->index = $index;
66 $this->cFormat = $this->oattr->format;
67 $this->cancelFormat =
false;
68 $atype = $this->oattr->type;
69 $this->htmlLink = $htmlLink;
70 $this->useEntities = $useEntities;
71 $this->abstractMode = $abstractMode;
73 $showEmpty = $this->oattr->getOption(
'showempty');
75 if (($this->oattr->repeat) && ($this->index < 0)) {
76 $tvalues = explode(
"\n",
$value);
78 $tvalues[$this->index] =
$value;
80 $this->attrid = $this->oattr->id;
82 foreach ($tvalues as $kvalue => $avalue) {
83 if ($abstractMode && empty($avalue) && !$showEmpty) {
84 $thtmlval[$kvalue] =
'';
93 $htmlval = $this->
formatFile($kvalue, $avalue);
109 $htmlval = $this->
formatEnum($kvalue, $avalue);
118 $htmlval = $this->
formatDoc($kvalue, $avalue);
151 $htmlval = $this->
formatDate($kvalue, $avalue);
156 $htmlval = $this->
formatTime($kvalue, $avalue);
161 $htmlval = $this->formatTimeStamp($kvalue, $avalue);
180 $abegin = $aend =
'';
182 if ($htmlval ===
'' && $showEmpty) {
186 if (!$oattr->inArray()) {
187 $htmlval = $showEmpty;
188 } elseif ((count($tvalues) > 1)) {
190 $htmlval = $showEmpty;
193 $htmlval = $showEmpty;
195 } elseif ($htmlval ===
"\t" && $oattr->inArray() && $showEmpty) {
197 $htmlval = $showEmpty;
198 } elseif (($this->cFormat !=
"" && $this->cancelFormat ===
false) && ($htmlval !==
'') && ($atype !=
"doc") && ($atype !=
"array") && ($atype !=
"option")) {
200 $htmlval = sprintf($this->cFormat, $htmlval);
203 if ($this->htmlLink && ($this->oattr->link !=
"")) {
205 $hlink = $this->oattr->link;
206 if ($hlink[0] ==
"[") {
207 if (preg_match(
'/\[(.*)\](.*)/', $hlink, $reg)) {
209 $ititle = str_replace(
"\"",
"'", $reg[1]);
212 if ($ulink = $this->doc->urlWhatEncode($hlink, $kvalue)) {
213 if ($this->target ==
"ext") {
214 if (preg_match(
"/FDL_CARD.*id=([0-9]+)/", $ulink, $reg)) {
216 $abegin = $this->doc->getDocAnchor($reg[1], $this->target,
true, html_entity_decode($htmlval, ENT_QUOTES,
'UTF-8'));
219 }
else if (
true || preg_match(
"/^http:/", $ulink, $reg)) {
223 $ec = str_replace(
"%V%", $ulink, $ec);
224 $ec = str_replace(
"%L%", $this->oattr->getLabel() , $ec);
225 $ecu = str_replace(
"'",
"\\'", $this->doc->urlWhatEncode($ec));
226 $abegin =
"<a onclick='parent.$ecu'>";
228 $ltarget = $this->oattr->getOption(
"ltarget");
229 $abegin =
"<a target=\"$ltarget\" href=\"$ulink\">";
234 }
else if ($this->target ==
"mail") {
236 if (preg_match(
"/^([[:alpha:]]*):(.*)/", $ulink, $reg)) {
239 $abegin =
"<a target=\"$this->target\" href=\"";
240 if ($scheme ==
"") $abegin.= $action->GetParam(
"CORE_URLINDEX", ($action->GetParam(
"CORE_ABSURL") .
"/")) . $ulink;
241 else $abegin.= $ulink;
245 $ltarget = $this->oattr->getOption(
"ltarget");
246 if ($ltarget !=
"") $this->target = $ltarget;
247 $ltitle = $this->oattr->getOption(
"ltitle");
248 if ($ltitle !=
"") $ititle = str_replace(
"\"",
"'", $ltitle);
249 $abegin =
"<a target=\"$this->target\" title=\"$ititle\" onmousedown=\"document.noselect=true;\" href=\"";
250 $abegin.= $ulink .
"\" ";
251 if ($this->htmlLink > 1) {
253 if (preg_match(
"/^([[:alpha:]]*):(.*)/", $ulink, $reg)) {
256 if (($scheme ==
"") || ($scheme ==
"http")) {
257 if ($scheme ==
"") $ulink.=
"&ulink=1";
258 $abegin.=
" oncontextmenu=\"popdoc(event,'$ulink');return false;\" ";
273 $thtmlval[$kvalue] = $abegin . $htmlval . $aend;
277 return implode(
"<BR>", $thtmlval);
287 if ($this->useEntities) $avalue = htmlentities(($avalue) , ENT_COMPAT,
"UTF-8");
288 else $avalue = ($avalue);
289 $htmlval = str_replace(array(
308 if ($this->target ==
"mail") {
309 $htmlval =
"cid:" . $this->oattr->id;
310 if ($this->index >= 0) $htmlval.=
"+$this->index";
312 if ($this->target ==
"te") {
313 $htmlval =
"file://" . $this->doc->vault_filename($this->oattr->id,
true, $kvalue);
318 if (
$vf->Show($reg[2], $fileInfo) ==
"") {
319 if (!file_exists($fileInfo->path)) {
320 if (!
$vf->storage->fs->isAvailable()) {
321 if (!$this->vaultErrorSent)
addWarningMsg(sprintf(_(
"cannot access to vault file system")));
322 $this->vaultErrorSent =
true;
324 addWarningMsg(sprintf(_(
"file %s not found") , $fileInfo->name));
328 if (($this->oattr->repeat) && ($this->index <= 0)) $idx = $kvalue;
329 else $idx = $this->index;
330 $inline = $this->oattr->getOption(
"inline");
331 $htmlval = $this->doc->getFileLink($this->oattr->id, $idx,
false, ($inline ==
"yes") , $avalue, $fileInfo);
333 if (empty($avalue)) {
334 $localImage = $this->oattr->getOption(
'showempty');
336 $htmlval = $action->parent->getImageLink($localImage);
338 $htmlval = $action->parent->getImageLink($avalue);
341 $htmlval = $action->parent->getImageLink($avalue);
361 $fname = _(
"no file");
367 include_once (
"FDL/Lib.Dir.php");
370 if (
$vf->Show($reg[2], $fileInfo) ==
"") {
371 $fname = $fileInfo->name;
372 if (!file_exists($fileInfo->path)) {
373 if (!
$vf->storage->fs->isAvailable()) {
374 if (!$this->vaultErrorSent)
addWarningMsg(sprintf(_(
"Cannot access to vault file system")));
375 $this->vaultErrorSent =
true;
377 addWarningMsg(sprintf(_(
"file %s not found") , $fileInfo->name));
380 $fname.=
' ' . _(
"(file not found)");
382 }
else $htmlval = _(
"vault file error");
384 if ($this->oattr->getOption(
'showempty')) {
385 $htmlval = $this->oattr->getOption(
'showempty');
386 $this->cancelFormat =
true;
388 $htmlval = _(
"no filename");
392 if ($this->target ==
"mail") {
393 $htmlval =
"<a target=\"_blank\" href=\"";
394 $htmlval.=
"cid:" . $this->oattr->id;
395 if ($this->index >= 0) $htmlval.=
"+$this->index";
396 $htmlval.=
"\">" . htmlspecialchars($fname, ENT_QUOTES) .
"</a>";
399 if ($fileInfo->teng_state < 0 || $fileInfo->teng_state > 1) {
401 if (\Dcp\Autoloader::classExists(
'Dcp\TransformationEngine\Client')) {
402 switch (intval($fileInfo->teng_state)) {
403 case \Dcp\TransformationEngine\Client::error_convert:
404 $textval = _(
"file conversion failed");
407 case \Dcp\TransformationEngine\Client::error_noengine:
408 $textval = _(
"file conversion not supported");
411 case \Dcp\TransformationEngine\Client::error_connect:
412 $textval = _(
"cannot contact server");
415 case \Dcp\TransformationEngine\Client::status_waiting:
416 $textval = _(
"waiting conversion file");
419 case \Dcp\TransformationEngine\Client::status_inprogress:
420 $textval = _(
"generating file");
424 $textval = sprintf(_(
"unknown file state %s") , $fileInfo->teng_state);
427 $textval = sprintf(_(
"unknown file state %s") , $fileInfo->teng_state);
429 if ($this->htmlLink) {
432 if ($fileInfo->teng_state > 1) $waiting =
"<img class=\"mime\" src=\"Images/loading.gif\">";
433 else $waiting =
"<img class=\"mime\" needresize=1 src=\"Images/bullet_error.png\">";
434 $htmlval = sprintf(
'<a _href_="%s" vid="%d" onclick="popdoc(event,this.getAttribute(\'_href_\')+\'&inline=yes\',\'%s\')">%s %s</a>', $this->doc->getFileLink($this->oattr->id, $this->index) , $fileInfo->id_file, str_replace(
"'",
"’", _(
"file status")) , $waiting, $textval);
435 if ($fileInfo->teng_state < 0) {
436 $htmlval.= sprintf(
'<a href="?app=FDL&action=FDL_METHOD&id=%d&method=resetConvertVaultFile(\'%s,%s)"><img class="mime" title="%s" src="%s"></a>', $this->doc->id, $this->oattr->id, $this->index, _(
"retry file conversion") ,
"Images/arrow_refresh.png");
441 } elseif ($this->htmlLink) {
443 $mimeicon =
getIconMimeFile($fileInfo->mime_s ==
"" ? $mime : $fileInfo->mime_s);
444 if (($this->oattr->repeat) && ($this->index <= 0)) $idx = $kvalue;
445 else $idx = $this->index;
446 $standardview =
true;
448 $viewfiletype = $this->oattr->getOption(
"viewfiletype");
451 if ($viewfiletype ==
"image" || $viewfiletype ==
"pdf") {
454 if (substr($fileInfo->mime_s, 0, 5) ==
"image") {
456 $viewfiletype =
'png';
458 } elseif (substr($fileInfo->mime_s, 0, 4) ==
"text") {
460 $viewfiletype =
'embed';
464 $err =
$vf->Show($vid, $infopdf,
'pdf');
465 if (
$err ==
"" && \Dcp\Autoloader::classExists(
'Dcp\TransformationEngine\Client')) {
466 if ($infopdf->teng_state == \Dcp\TransformationEngine\Client::status_done || $infopdf->teng_state == \Dcp\TransformationEngine\Client::status_waiting || $infopdf->teng_state == \Dcp\TransformationEngine\Client::status_inprogress) {
468 if ($viewfiletype ==
'image') $viewfiletype =
'png';
469 else if ($viewfiletype ==
'pdf') $viewfiletype =
'embed';
472 if ($infopdf->teng_state == \Dcp\TransformationEngine\Client::status_waiting || $infopdf->teng_state == \Dcp\TransformationEngine\Client::status_inprogress) $waiting =
true;
477 if ($imageview && (!$this->abstractMode)) {
478 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/widgetFile.js");
479 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/detectPdfPlugin.js");
480 $lay =
new Layout(
"FDL/Layout/viewfileimage.xml", $action);
481 $lay->set(
"docid", $this->doc->id);
482 $lay->set(
"waiting", ($waiting ?
'true' :
'false'));
483 $lay->set(
"attrid", $this->oattr->id);
484 $lay->set(
"index", $idx);
485 $lay->set(
"viewtype", $viewfiletype);
486 $lay->set(
"mimeicon", $mimeicon);
487 $lay->set(
"vid", ($infopdf ? $infopdf->id_file : $vid));
488 $lay->set(
"filetitle", json_encode((
string)$fname));
489 $lay->set(
"height", $this->oattr->getOption(
'viewfileheight',
'300px'));
490 $lay->set(
"filelink", $this->doc->getFileLink($this->oattr->id, $idx,
false,
false));
492 $lay->set(
"pdflink",
'');
493 if ($pdfattr = $this->oattr->getOption(
'pdffile')) {
495 if (!preg_match(
'/^(text|image)/', $fileInfo->mime_s)) {
497 if ($waiting || preg_match(
'/(pdf)/', $infopdf->mime_s)) {
498 $lay->set(
"pdflink", $this->doc->getFileLink($pdfattr, $idx,
false,
false));
502 $lay->set(
"pages", $pages);
503 $htmlval = $lay->gen();
504 $standardview =
false;
509 $size = self::human_size($fileInfo->size);
510 $utarget = ($action->Read(
"navigator",
"") ==
"NETSCAPE") ?
"_self" :
"_blank";
511 $inline = $this->oattr->getOption(
"inline");
512 $htmlval =
"<a onmousedown=\"document.noselect=true;\" title=\"$size\" target=\"$utarget\" type=\"$mime\" href=\"" . $this->doc->getFileLink($this->oattr->id, $idx,
false, ($inline ==
"yes") , $avalue, $fileInfo) .
"\">";
513 if ($mimeicon) $htmlval.=
"<img class=\"mime\" needresize=1 src=\"Images/$mimeicon\"> ";
514 $htmlval.= htmlspecialchars($fname, ENT_QUOTES) .
"</a>";
517 $htmlval = $fileInfo->name;
531 if ($this->useEntities) $bvalue = nl2br(htmlentities((str_replace(
"<BR>",
"\n", $avalue)) , ENT_COMPAT,
"UTF-8"));
532 else $bvalue = (str_replace(
"<BR>",
"\n", $avalue));
533 $shtmllink = $this->htmlLink ?
"true" :
"false";
534 $bvalue = preg_replace_callback(
'/(\[|[)ADOC ([^\]]*)\]/',
function ($matches) use ($shtmllink)
536 return $this->doc->getDocAnchor($matches[2], $this->target, $shtmllink);
539 $htmlval = str_replace(array(
556 if (strlen($avalue) > 0) {
571 $enumlabel = $this->oattr->getEnumlabel();
572 $colors = $this->oattr->getOption(
"boolcolor");
574 if (isset($enumlabel[$avalue])) {
576 $tcolor = explode(
",", $colors);
577 if (current($enumlabel) == $enumlabel[$avalue]) {
579 $htmlval = sprintf(
'<pre style="background-color:%s;display:inline"> - </pre>', $color);
582 $htmlval = sprintf(
'<pre style="background-color:%s;display:inline"> • </pre>', $color);
584 }
else $htmlval = $avalue;
586 if (array_key_exists($avalue, $enumlabel)) $htmlval = $enumlabel[$avalue];
587 else $htmlval = $avalue;
602 if (count($this->doc->getArrayRawValues($this->oattr->id)) == 0 && $this->oattr->getOption(
'showempty')) {
603 $htmlval = $this->oattr->getOption(
'showempty');
606 $viewzone = $this->oattr->getOption(
"rowviewzone");
607 $sort = $this->oattr->getOption(
"sorttable");
608 if ($sort ==
"yes") {
609 $action->parent->AddJsRef($action->GetParam(
"CORE_PUBURL") .
"/FREEDOM/Layout/sorttable.js");
611 $displayRowCount = $this->oattr->getOption(
"displayrowcount", 10);
612 if (!is_numeric($displayRowCount)) {
613 $displayRowCount = 10;
616 $lay =
new Layout(
"FDL/Layout/viewdocarray.xml", $action);
617 $lay->set(
"issort", ($sort ==
"yes"));
618 if (!method_exists($this->doc->attributes,
"getArrayElements")) {
621 $height = $this->oattr->getOption(
"height",
false);
622 $lay->set(
"tableheight", $height);
623 $lay->set(
"caption", $this->oattr->getLabel());
624 $lay->set(
"aid", $this->oattr->id);
626 if (($viewzone !=
"") && preg_match(
"/([A-Z_-]+):([^:]+):{0,1}[A-Z]{0,1}/", $viewzone, $reg)) {
628 $dxml =
new DomDocument();
630 if (!file_exists($rowlayfile)) {
631 $htmlval = sprintf(_(
"cannot open layout file : %s") , $rowlayfile);
632 AddwarningMsg(sprintf(_(
"cannot open layout file : %s") , $rowlayfile));
635 if (!@$dxml->load($rowlayfile)) {
636 AddwarningMsg(sprintf(_(
"cannot load xml template : %s") , print_r(libxml_get_last_error() ,
true)));
637 $htmlval = sprintf(_(
"cannot load xml layout file : %s") , $rowlayfile);
640 $theads = $dxml->getElementsByTagName(
'table-head');
641 if ($theads->length > 0) {
645 $thead = $theads->item(0);
646 $theadcells = $thead->getElementsByTagName(
'cell');
648 for ($i = 0; $i < $theadcells->length; $i++) {
652 $item = $theadcells->item($i);
654 $thstyle = $item->getAttribute(
"style");
655 $thclass = $item->getAttribute(
"class");
656 if ($thstyle !=
"") $thstyle =
"style=\"$thstyle\"";
657 if ($thclass) $thstyle.=
' class="' . $thclass .
'"';
660 "astyle" => $thstyle,
664 $lay->setBlockData(
"TATTR", $talabel);
667 $tbodies = $dxml->getElementsByTagName(
'table-body');
668 $tr = $tcellstyle = $tcellclass = array();
670 if ($tbodies->length > 0) {
674 $tbody = $tbodies->item(0);
675 $tbodycells = $tbody->getElementsByTagName(
'cell');
676 for ($i = 0; $i < $tbodycells->length; $i++) {
680 $item = $tbodycells->item($i);
682 $tcellstyle[] = $item->getAttribute(
"style");
683 $tcellclass[] = $item->getAttribute(
"class");
686 $ta = $this->doc->attributes->getArrayElements($this->oattr->id);
689 foreach ($ta as $k => $v) {
690 $tval[$k] = $this->doc->getMultipleRawValues($k);
691 $nbitem = max($nbitem, count($tval[$k]));
692 $lay->set(
"L_" . strtoupper($v->id) , $v->getLabel());
696 for ($k = 0; $k < $nbitem; $k++) {
698 "bevalue" =>
"bevalue_$k"
703 foreach ($tr as $kd => $vd) {
705 $hval = preg_replace_callback(
'/\[([^\]]*)\]/',
function ($matches) use ($k)
707 return $this->rowattrReplace($matches[1], $k);
712 "color" =>
"inherit",
713 "tdstyle" => $tcellstyle[$kd],
714 "tdclass" => $tcellclass[$kd],
715 "bgcolor" =>
"inherit",
719 $lay->setBlockData(
"bevalue_$k", $tivalue);
721 $lay->setBlockData(
"EATTR", $tvattr);
723 if ($this->oattr->getOption(
"vlabel") ==
"up") {
724 $caption = $this->oattr->getLabel();
727 if ($nbitem > 10) $caption.=
" ($nbitem)";
728 $lay->set(
"caption", $caption);
729 $htmlval = $lay->gen();
731 $ta = $this->doc->attributes->getArrayElements($this->oattr->id);
739 foreach ($ta as $k => $v) {
740 if (($v->mvisibility ==
"H") || ($v->mvisibility ==
"I") || ($v->mvisibility ==
"O"))
continue;
742 "alabel" => ucfirst($v->getLabel()) ,
743 "astyle" => $v->getOption(
"cellheadstyle") ,
744 "cwidth" => $v->getOption(
"cwidth",
"auto")
746 $tval[$k] = $this->doc->getMultipleRawValues($k);
747 $nbitem = max($nbitem, count($tval[$k]));
748 if ($emptyarray && ($this->doc->getRawValue($k) !=
"")) $emptyarray =
false;
751 if ($this->oattr->getOption(
"vlabel") ==
"up") {
752 $caption = $this->oattr->getLabel();
753 if ($nbitem > 10) $caption.=
" ($nbitem)";
756 if ($displayRowCount >= 0 && ($displayRowCount == 0 || $nbitem > $displayRowCount)) {
757 if (count($talabel) > 0) {
758 $talabel[0][
"alabel"].=
" ($nbitem)";
763 $lay->setBlockData(
"TATTR", $talabel);
764 $lay->set(
"caption", $caption);
766 for ($k = 0; $k < $nbitem; $k++) {
768 "bevalue" =>
"bevalue_$k"
774 foreach ($ta as $ka => $va) {
775 if (($va->mvisibility ==
"H") || ($va->mvisibility ==
"I") || ($va->mvisibility ==
"O"))
continue;
776 if (isset($tval[$ka][$k])) $hval = $this->doc->getHtmlValue($va, $tval[$ka][$k], $this->target, $this->htmlLink, $k);
778 if ($va->type ==
"image") {
779 $iwidth = $va->getOption(
"iwidth",
"80px");
780 if (empty($tval[$ka][$k])) $hval =
"";
781 else if ($va->link ==
"") {
782 if (strstr($hval,
'?')) $optwidth =
"&width=" . intval($iwidth);
784 $hval =
"<a href=\"$hval\"><img border='0' width=\"$iwidth\" src=\"" . $hval . $optwidth .
"\"></a>";
786 $hval = preg_replace(
"/>(.+)</",
"> <img class=\"button\" width=\"$iwidth\" src=\"\\1\"> <", $hval);
792 "atype" => $va->type,
793 "tdstyle" => $va->getOption(
"cellbodystyle") ,
794 "color" => $va->getOption(
"color",
"inherit") ,
795 "bgcolor" => $va->getOption(
"bgcolor",
"inherit") ,
796 "tdclass" => $va->getOption(
"className",
'') ,
797 "align" => $va->getOption(
"align",
"inherit")
800 $lay->setBlockData(
"bevalue_$k", $tivalue);
802 $lay->setBlockData(
"EATTR", $tvattr);
804 $htmlval = $lay->gen();
821 if ($kvalue > - 1) $idocid = $this->doc->getMultipleRawValues($this->cFormat,
"", $kvalue);
822 else $idocid = $this->doc->getRawValue($this->cFormat);
828 $htmlval =
$idoc->viewDoc(
"FDL:VIEWTHUMBCARD:T",
"finfo");
843 if (!$this->oattr->format) $this->oattr->format =
"x";
854 if ($this->oattr->format !=
"") {
856 $this->cancelFormat =
true;
857 $multiple = ($this->oattr->getOption(
"multiple") ==
"yes");
858 $dtarget = $this->target;
859 if ($this->target !=
"mail") {
860 $ltarget = $this->oattr->getOption(
"ltarget");
861 if ($ltarget !=
"") $dtarget = $ltarget;
863 $isLatest = $this->oattr->getOption(
"docrev",
"latest") ==
"latest";
865 $avalue = str_replace(
"\n",
"<BR>", $avalue);
866 $tval = explode(
"<BR>", $avalue);
868 foreach ($tval as $kv => $vv) {
869 if (trim($vv) ==
"") $thval[] = $vv;
872 if ($this->oattr->link !=
"" &&
$title) {
873 $link = $this->doc->urlWhatEncode($this->oattr->link, $kvalue);
874 if ($link) $thval[] =
'<a target="' . $dtarget .
'" href="' . $link .
'">' . $this->doc->htmlEncode(
$title) .
'</a>';
876 if (
$title ===
false)
$title = $this->doc->htmlEncode($this->oattr->getOption(
"noaccesstext", _(
"information access deny")));
877 $thval[] = $this->doc->htmlEncode(
$title);
881 if (
$title ===
false) $thval[] = $this->doc->htmlEncode($this->oattr->getOption(
"noaccesstext", _(
"information access deny")));
882 else $thval[] = $this->doc->getDocAnchor(trim($vv) , $dtarget, $this->htmlLink,
$title,
true, $this->oattr->getOption(
"docrev") ,
true);
886 if ($this->oattr->link) $this->htmlLink =
false;
887 $htmlval = implode(
"<br/>", $thval);
889 if ($avalue ==
"") $htmlval = $avalue;
890 elseif ($this->oattr->link !=
"") {
892 $htmlval = $this->doc->htmlEncode(
$title);
895 if (
$title ===
false) $htmlval = $this->doc->htmlEncode($this->oattr->getOption(
"noaccesstext", _(
"information access deny")));
896 else $htmlval = $this->doc->getDocAnchor(trim($avalue) , $dtarget, $this->htmlLink,
$title,
true, $this->oattr->getOption(
"docrev") ,
true);
899 }
else $htmlval = $avalue;
910 $this->cancelFormat =
true;
911 $multiple = ($this->oattr->getOption(
"multiple") ==
"yes");
913 $avalue = str_replace(
"\n",
"<BR>", $avalue);
914 $tval = explode(
"<BR>", $avalue);
916 foreach ($tval as $vv) {
917 if (trim($vv) ==
"") $thval[] = $vv;
919 $thc = new_doc($this->doc->dbaccess, trim($vv));
920 if ($thc->isAlive()) $thval[] = $this->doc->getDocAnchor(trim($vv) , $this->target, $this->htmlLink, $thc->getCustomTitle());
921 else $thval[] =
"th error1 $vv";
924 $htmlval = implode(
"<br/>", $thval);
926 if ($avalue ==
"") $htmlval = $avalue;
928 $avalue = trim($avalue);
929 $thc = new_doc($this->doc->dbaccess, $avalue);
930 if ($thc->isAlive()) $htmlval = $this->doc->getDocAnchor(trim($avalue) , $this->target, $this->htmlLink, $thc->getCustomTitle());
931 else $htmlval =
"th error2 [$avalue]";
947 $lay =
new Layout(
"FDL/Layout/viewdocoption.xml", $action);
950 if ($kvalue > - 1) $di = $this->doc->getMultipleRawValues($this->oattr->format,
"", $kvalue);
951 else $di = $this->doc->getRawValue($this->oattr->format);
953 $lay->set(
"said", $di);
954 $lay->set(
"uuvalue", urlencode($avalue));
956 $htmlval = $lay->gen();
970 if ($avalue ==
'' && $this->oattr->getOption(
'showempty')) {
971 $htmlval = $this->oattr->getOption(
'showempty');
972 $this->cancelFormat =
true;
974 if ($avalue !==
'') {
975 $htmlval = money_format(
'%!.2n', doubleval($avalue));
976 $htmlval = str_replace(
" ",
" ", $htmlval);
994 if ($avalue ==
'' && $this->oattr->getOption(
'showempty')) {
995 $avalue = $this->oattr->getOption(
'showempty');
996 $this->cancelFormat =
true;
998 $shtmllink = $this->htmlLink ?
"true" :
"false";
999 $avalue = preg_replace_callback(
'/(\[|[)ADOC ([^\]]*)\]/',
function ($matches) use ($shtmllink)
1001 return $this->doc->getDocAnchor($matches[2], $this->target, $shtmllink);
1004 if (stripos($avalue,
"data-initid") !==
false) {
1006 $domDoc =
new DOMDocument();
1008 $domDoc->loadHTML(mb_convert_encoding($avalue,
'HTML-ENTITIES',
'UTF-8'));
1010 $aElements = $domDoc->getElementsByTagName(
"a");
1014 foreach ($aElements as $currentA) {
1016 if ($currentA->hasAttribute(
"data-initid")) {
1017 $newA = $this->doc->getDocAnchor($currentA->getAttribute(
"data-initid") , $this->target, $shtmllink,
false,
true, $currentA->getAttribute(
"data-docrev"));
1018 $newAFragment = $domDoc->createDocumentFragment();
1019 $newAFragment->appendXML($newA);
1020 $currentA->parentNode->replaceChild($newAFragment, $currentA);
1024 $avalue = $domDoc->saveHTML();
1026 catch(Exception $e) {
1027 error_log(sprintf(
"%s unable to parse/create html width docLink elements(document :%s, error %)s", __METHOD__, $this->doc->id, $e->getMessage()));
1031 $avalue = str_replace(array(
1040 $avalue = \Dcp\Utils\htmlclean::normalizeHTMLFragment(mb_convert_encoding($avalue,
'HTML-ENTITIES',
'UTF-8') , $error);
1041 $avalue = str_replace(array(
1051 if ($avalue ===
false) {
1055 $htmlval =
'<div class="htmltext">' . str_replace(
"[",
"[", $avalue) .
'</div>';
1067 if (($this->cFormat !=
"") && (trim($avalue) !=
"")) {
1069 else $htmlval = $avalue;
1070 } elseif (trim($avalue) ==
"") {
1075 $this->cancelFormat =
true;
1088 if (($this->cFormat !=
"") && (trim($avalue) !=
"")) {
1089 if ($avalue) $htmlval = strftime($this->cFormat, strtotime($avalue));
1090 else $htmlval = $avalue;
1093 $htmlval = (string)substr($avalue, 0, 5);
1099 $this->cancelFormat =
true;
1112 if (($this->cFormat !=
"") && (trim($avalue) !=
"")) {
1114 else $htmlval = $avalue;
1115 } elseif (trim($avalue) ==
"") {
1120 $this->cancelFormat =
true;
1134 $lay =
new Layout(
"FDL/Layout/viewifile.xml", $action);
1135 $lay->set(
"aid", $this->oattr->id);
1136 $lay->set(
"id", $this->doc->id);
1137 $lay->set(
"iheight", $this->oattr->getOption(
"height",
"200px"));
1138 $htmlval = $lay->gen();
1152 $htmlval = sprintf(
"<span style=\"background-color:%s\">%s</span>", $avalue, $avalue);
1158 private function rowattrReplace(
$s, $index)
1160 if (substr(
$s, 0, 2) ==
"L_")
return "[$s]";
1161 if (substr(
$s, 0, 2) ==
"V_") {
1162 $sl = substr(strtolower(
$s) , 2);
1163 $vis = $this->doc->getAttribute($sl)->mvisibility;
1165 if (($vis ==
"H") || ($vis ==
"I") || ($vis ==
"O")) $v =
"";
1166 else $v = $this->doc->GetHtmlAttrValue($sl,
"_self", 2, $index);
1168 $sl = strtolower(
$s);
1169 if (!isset($this->doc->$sl))
return "[$s]";
1170 $v = $this->doc->getMultipleRawValues($sl,
"", $index);
1180 private static function human_size(
$size)
1182 if (abs(
$size) < 1000) {
1183 return sprintf(
"%d %s",
$size,
n___(
"unit:byte",
"unit:bytes", abs(
$size)));
1191 if (abs(
$size) < 1000) {
1192 return sprintf(
"%3.2f %s",
$size, $unit);
1196 return sprintf(
"%.2f %s",
$size, _(
"unit:TB"));
Layout is a template generator.
newFreeVaultFile($dbaccess)
stringDateToLocaleDate($fdate, $format= '')
getPdfNumberOfPages($file)
static getRelationTitle($docid, $latest=true, Doc $doc, $docrevOption="", array &$info=array())
getIconMimeFile($sysmime)
n___($message, $message_plural, $num, $context="")
getLayoutFile($app, $layfile)
getSessionValue($name, $def="")
new_Doc($dbaccess, $id= '', $latest=false)
stringDateToUnixTs($isodate, $utc=false)
if($file) if($subject==""&&$file) if($subject=="") $err