216 $this->propsKeys = self::getAvailableProperties();
221 $this->singleDocument =
true;
228 $keys[] = self::propFamily;
229 $keys[] = self::propLastAccessDate;
230 $keys[] = self::propLastModificationDate;
231 $keys[] = self::propCreationDate;
232 $keys[] = self::propCreatedBy;
233 $keys[] = self::propRevisionData;
234 $keys[] = self::propViewController;
235 $keys[] = self::propWorkflow;
236 $keys[] = self::propTags;
237 $keys[] = self::propSecurity;
238 $keys[] = self::propAffected;
239 $keys[] = self::propStatus;
240 $keys[] = self::propNote;
241 $keys[] = self::propUsage;
242 $keys[] = self::propType;
287 $this->ncAttribute =
$s;
307 $this->decimalSeparator =
$s;
317 $this->stripHtmlTag = $strip;
329 if (!in_array($style, array(
335 throw new \Dcp\Fmtc\Exception(
"FMTC0003", $style);
337 $this->dateStyle = $style;
349 if ((!in_array($props, $this->propsKeys) && ($props != self::propUrl))) {
350 throw new \Dcp\Fmtc\Exception(
"FMTC0001", $props);
352 $this->fmtProps[$props] = $props;
364 $this->fmtAttrs[$attrid] = $attrid;
375 $this->hookStatus = $hookFunction;
386 $this->renderAttributeHook = $hookFunction;
397 $this->renderDocumentHook = $hookFunction;
408 $this->renderPropertyHook = $hookFunction;
413 if ($this->hookStatus) {
428 if ($this->renderAttributeHook) {
430 return $h(
$info, $oa, $doc);
441 if ($this->renderDocumentHook) {
443 return $h($info, $doc);
455 if ($this->renderPropertyHook) {
457 return $h(
$info, $propId, $doc);
473 $countDoc = count($this->dl);
476 if ($kdoc % 10 == 0) $this->
callHookStatus(sprintf(_(
"Doc Render %d/%d") , $kdoc, $countDoc));
477 $renderDoc = array();
478 foreach ($this->fmtProps as $propName) {
482 foreach ($this->fmtAttrs as $attrid) {
483 $oa =
$doc->getAttribute($attrid);
485 if (($oa->type ==
"array") || ($oa->type ==
"tab") || ($oa->type ==
"frame"))
throw new \Dcp\Fmtc\Exception(
"FMTC0002", $attrid);
489 if ($this->verifyAttributeAccess ===
true && !\Dcp\VerifyAttributeAccess::isAttributeAccessGranted(
$doc, $oa)) {
492 if ($this->useShowEmptyOption && $empty = $oa->getOption(
"showempty")) {
494 $attributeInfo->displayValue = $empty;
496 $attributeInfo = null;
520 return $doc->
getIcon(
'', $this->familyIconSize);
522 return intval($doc->id);
523 case self::propInitid:
524 return intval($doc->initid);
525 case self::propRevision:
526 return intval($doc->revision);
527 case self::propLocked:
528 return intval($doc->locked);
529 case self::propState:
532 return sprintf(
"?app=FDL&action=OPENDOC&mode=view&id=%d", $doc->id);
534 return $this->
getFormatDate(date(
"Y-m-d H:i:s", intval($doc->$propName)) , $this->propDateStyle);
537 return $this->
getFormatDate($doc->$propName, $this->propDateStyle);
538 case self::propFamily:
540 case self::propLastAccessDate:
541 return $this->
getFormatDate($doc->adate, $this->propDateStyle);
542 case self::propLastModificationDate:
543 return $this->
getFormatDate(date(
"Y-m-d H:i:s", $doc->revdate) , $this->propDateStyle);
544 case self::propCreationDate:
545 if ($doc->revision == 0) {
546 return $this->
getFormatDate($doc->cdate, $this->propDateStyle);
548 $sql = sprintf(
"select cdate from docread where initid=%d and revision = 0", $doc->initid);
552 case self::propCreatedBy:
554 case self::propRevisionData:
556 case self::propViewController:
558 case self::propWorkflow:
562 case self::propSecurity:
564 case self::propAffected:
566 case self::propStatus:
570 case self::propUsage:
575 return $doc->$propName;
581 if ($doc->revision == 0) {
582 $ownerId = $doc->owner;
584 $sql = sprintf(
"select owner from docread where initid=%d and revision = 0", $doc->initid);
592 if ($doc->doctype ==
"Z") {
594 } elseif ($doc->locked == - 1) {
603 if (strstr($doc->usefor,
"S")) {
611 switch ($doc->defDoctype) {
625 return $doc->defDoctype;
631 if ($doc->postitid > 0) {
632 $note = new_doc($doc->dbaccess, $doc->postitid);
634 "id" => intval($note->initid) ,
635 "title" => $note->getTitle() ,
636 "icon" => $note->getIcon(
"", $this->familyIconSize)
648 $workflow = new_doc($doc->dbaccess, $doc->wid);
650 "id" => intval($workflow->initid) ,
651 "title" => $workflow->getTitle() ,
652 "icon" => $workflow->getIcon(
"", $this->familyIconSize)
664 return explode(
"\n", $doc->atags);
672 if ($doc->allocated > 0) {
684 $sql = sprintf(
"select initid, icon, title from doc128 where us_whatid='%d' and locked != -1", $accountId);
688 "id" => intval($result[
"initid"]) ,
689 "title" => $result[
"title"],
690 "icon" => $doc->
getIcon($result[
"icon"], $this->familyIconSize)
704 if ($doc->locked == - 1) {
705 $info[
"lock"] = array(
710 $info[
"lock"] = array(
712 "temporary" => ($doc->locked < - 1)
716 $info[
"lock"] = array(
721 $info[
"fixed"] = ($doc->locked == - 1);
722 if ($doc->profid != 0) {
724 if ($doc->profid == $doc->id) {
725 $info[
"profil"] = array(
726 "id" => intval($doc->initid) ,
727 "icon" => $doc->
getIcon(
"", $this->familyIconSize) ,
733 if ($doc->dprofid > 0) {
734 $profil = new_doc($doc->dbaccess, $doc->dprofid);
735 $info[
"profil"][
"reference"] = array(
736 "id" => intval($profil->initid) ,
737 "icon" => $profil->getIcon(
"", $this->familyIconSize) ,
738 "activated" => ($profil->id == $profil->profid) ,
739 "title" => $profil->getTitle()
741 $info[
"profil"][
"type"] =
"dynamic";
744 $profil = new_doc($doc->dbaccess, abs($doc->profid));
745 $info[
"profil"] = array(
746 "id" => intval($profil->initid) ,
747 "icon" => $profil->getIcon(
"", $this->familyIconSize) ,
749 "activated" => ($profil->id == $profil->profid) ,
750 "title" => $profil->getTitle()
754 $info[
"profil"] = array(
760 $info[
"confidentiality"] = ($doc->confidential > 0) ?
"private" :
"public";
766 if ($doc->cvid > 0) {
767 $cv = new_doc($doc->dbaccess, $doc->cvid);
769 "id" => intval($cv->initid) ,
771 "title" => $cv->getTitle() ,
772 "icon" => $cv->getIcon(
"", $this->familyIconSize)
784 "isModified" => ($doc->lmodify ==
"Y") ,
785 "id" => intval($doc->id) ,
786 "number" => intval($doc->revision) ,
787 "createdBy" => $this->getAccountData(abs($doc->owner) , $doc)
795 "title" => $family->getTitle() ,
796 "name" => $family->name,
797 "id" => intval($family->id) ,
798 "icon" => $family->getIcon(
"", $this->familyIconSize)
812 if (strlen($v) < 11)
return substr($ldate, 0, strlen($v));
821 $s->reference = $doc->state;
822 $s->stateLabel = _($doc->state);
824 if ($doc->locked != - 1) {
826 if (
$s->activity)
$s->displayValue =
$s->activity;
827 else $s->displayValue =
$s->stateLabel;
829 $s->displayValue =
$s->stateLabel;
844 for ($k = $i; $k >= 0; $k--) {
845 if ($t[$k] === null) unset($t[$k]);
857 if (count($tv) == 1 && $tv[0] ==
"\t") {
860 foreach ($tv as $k => $av) {
865 $tvv = explode(
'<BR>', $av);
868 if (count($tvv) == 0) {
871 foreach ($tvv as $avv) {
882 if ($oa->
inArray() && count($tv) == 1 && $tv[0] ==
"\t") {
886 foreach ($tv as $k => $av) {
902 if ($this->verifyAttributeAccess ===
true && !\Dcp\VerifyAttributeAccess::isAttributeAccessGranted(
$doc, $oa)) {
977 $average = $cost = $sum = array();
978 foreach ($this->debug as
$type => $time) {
979 $average[
$type] = sprintf(
"%0.3fus", array_sum($time) / count($time) * 1000000);
980 $cost[
$type] = sprintf(
"%0.3fms", array_sum($time) * 1000);
981 $sum[
$type] = sprintf(
"%d", count($time));
985 "average" => $average,
999 $attrInArray = ($oAttr->inArray());
1000 $attrIsMultiple = ($oAttr->getOption(
'multiple') ==
'yes');
1001 $sepRow = isset($configuration[
'multipleSeparator'][0]) ? $configuration[
'multipleSeparator'][0] :
"\n";
1002 $sepMulti = isset($configuration[
'multipleSeparator'][1]) ? $configuration[
'multipleSeparator'][1] :
", ";
1003 $displayDocId = (isset($configuration[
'displayDocId']) && $configuration[
'displayDocId'] ===
true) && (!isset(
$info->visible));
1005 if (is_array(
$info) && $index >= 0) {
1010 if ($displayDocId && is_array(
$info) && count(
$info) > 0) {
1011 $displayDocId = (!isset(
$info[0]->visible));
1014 if (!$attrInArray) {
1015 if ($attrIsMultiple) {
1016 $multiList = array();
1021 $multiList[] = $displayDocId ? $data->value : $data->displayValue;
1023 $result = join($sepMulti, $multiList);
1025 $result = $displayDocId ?
$info->value :
$info->displayValue;
1029 if ($attrIsMultiple) {
1033 foreach (
$info as $multiData) {
1034 $multiList = array();
1035 foreach ($multiData as
$data) {
1036 $multiList[] = $displayDocId ? $data->value : $data->displayValue;
1038 $rowList[] = join($sepMulti, $multiList);
1041 if (!is_array(
$info)) {
1047 $rowList[] = $displayDocId ? $data->value : $data->displayValue;
1050 $result = join($sepRow, $rowList);
1066 $this->value = ($v ===
'') ? null : $v;
1067 $this->displayValue = $v;
1078 $this->value = ($v ===
'') ? null : $v;
1079 $this->displayValue = $v;
1092 $this->displayValue = $v;
1109 $this->value = ($v ===
'') ? null : $v;
1110 if ($oa->format) $this->displayValue = sprintf($oa->format, $v);
1111 else $this->displayValue = $v;
1124 $v = str_replace(
"<BR>", $multipleLongtextCr, $v);
1126 parent::__construct($oa, $v);
1134 parent::__construct($oa, $v);
1135 $this->value = intval($v);
1153 parent::__construct($oa, $v);
1154 if ($oa->format !=
"") {
1158 else if ($dateStyle === self::isoStyle) $this->displayValue =
stringDateToIso($v,
false,
true);
1159 else if ($dateStyle === self::isoWTStyle) $this->displayValue =
stringDateToIso($v,
false,
false);
1160 else if ($dateStyle === self::frenchStyle) {
1163 if (strlen($v) < 11) $this->displayValue = substr($ldate, 0, strlen($v));
1164 else $this->displayValue = $ldate;
1178 parent::__construct($oa, $v);
1179 if ($stripHtmlTag) {
1180 $this->displayValue = html_entity_decode(strip_tags($this->displayValue) , ENT_NOQUOTES,
'UTF-8');
1189 parent::__construct($oa, $v);
1191 if (
$lang ==
"fr_FR") {
1192 if (is_array($this->displayValue)) {
1193 foreach ($this->displayValue as $k => $v) {
1194 $this->displayValue[$k] = str_replace(
'.', $decimalSeparator, $v);
1197 $this->displayValue = str_replace(
'.', $decimalSeparator, $this->displayValue);
1200 if (is_array($this->value)) {
1202 foreach ($this->value as $k => $v) {
1203 $this->value[$k] = doubleval($v);
1206 $this->value = doubleval($this->value);
1216 parent::__construct($oa, $v);
1219 if (
$lang ==
"fr_FR") {
1221 if (is_array($this->displayValue)) {
1222 foreach ($this->displayValue as $k => $dv) {
1223 $this->displayValue[$k] = money_format(
'%!.2n', doubleval($dv));
1225 $this->displayValue[$k] = sprintf($oa->format, $this->displayValue[$k]);
1229 $this->displayValue = money_format(
'%!.2n', doubleval($v));
1231 $this->displayValue = sprintf($oa->format, $this->displayValue);
1235 if (is_array($this->value)) {
1237 foreach ($this->value as $k => $v) {
1238 $this->value[$k] = doubleval($v);
1241 $this->value = doubleval($this->value);
1250 $this->value = ($v ===
'') ? null : $v;
1251 if ($v !== null && $v !==
'') {
1253 $this->exists = $oa->
existEnum($v,
false);
1270 $this->value = ($v ===
'') ? null : $v;
1274 $this->size = $finfo->size;
1275 $this->creationDate = $finfo->cdate;
1276 $this->fileName = $finfo->name;
1277 $this->mime = $finfo->mime_s;
1281 if ($iconFile) $this->icon = $doc->
getIcon($iconFile, $iconMimeSize);
1282 $this->url = $doc->
getFileLink($oa->id, $index,
false,
true, $v, $finfo);
1292 parent::__construct($oa, $v, $doc, $index);
1293 $fileLink = $doc->
getFileLink($oa->id, $index,
false,
true, $v);
1295 if ($thumbnailSize > 0) {
1296 $this->thumbnail = sprintf(
'%s&width=%d', $fileLink, $thumbnailSize);
1298 $this->thumbnail = $fileLink;
1302 $localImage = $action->parent->getImageLink($v);
1304 $this->displayValue = basename($v);
1305 $this->url = $localImage;
1306 if ($thumbnailSize > 0) {
1307 $this->thumbnail = $action->parent->getImageLink($v, null, $thumbnailSize);
1309 $this->thumbnail = $localImage;
1328 $this->familyRelation = $oa->format;
1329 $this->value = ($v ===
'') ? null : $v;
1331 $docRevOption = $oa->
getOption(
"docrev",
"latest");
1333 if ($this->displayValue !==
false) {
1334 if ($v !==
'' && $v !== null) {
1335 if ($iconsize > 0) {
1336 if (!empty(
$info[
"icon"])) {
1339 $this->icon = $doc->
getIcon(
"doc.png", $iconsize);
1342 $this->url = $this->
getDocUrl($v, $docRevOption);
1343 if ($docRevOption ===
"fixed") {
1345 }
else if (preg_match(
'/^state\(([^\)]+)\)/', $docRevOption, $matches)) {
1347 "state" => $matches[1]
1350 if (isset(
$info[
"initid"])) {
1351 $this->initid = intval(
$info[
"initid"]);
1353 if (isset(
$info[
"fromid"])) {
1354 $this->fromid = intval(
$info[
"fromid"]);
1358 $this->visible =
false;
1359 if ($relationNoAccessText) $this->displayValue = $relationNoAccessText;
1360 else $this->displayValue = $oa->
getOption(
"noaccesstext", _(
"information access deny"));
1367 $ul =
"?app=FDL&action=OPENDOC&mode=view&id=" . $v;
1369 if ($docrev ==
"latest" || $docrev ==
"" || !$docrev) $ul.=
"&latest=Y";
1370 elseif ($docrev !=
"fixed") {
1372 if (preg_match(
'/^state\(([a-zA-Z0-9_:-]+)\)/', $docrev, $matches)) {
1373 $ul.=
"&state=" . $matches[1];
1385 parent::__construct($oa, $v, $doc, $iconsize, $relationNoAccessText);
1386 if ($this->visible) {
1387 if (isset(self::$thcDocTitle[$this->value])) {
1389 $this->displayValue = self::$thcDocTitle[
$this->value];
1391 if (self::$thcDoc === null) {
1394 $rawValue =
getTDoc(
"", $this->value);
1395 self::$thcDoc->affect($rawValue);
1396 $this->displayValue = self::$thcDoc->getTitle();
__construct(NormalAttribute $oa, $v, $decimalSeparator= ',')
getTDoc($dbaccess, $id, $sqlfilters=array(), $result=array())
stringDateToIso($date, $format=false, $withT=false)
static rawValueToArray($v)
stringDateToLocaleDate($fdate, $format= '')
__construct(NormalAttribute $oa, $v, Doc $doc, $index, $iconMimeSize=24)
__construct(NormalAttribute $oa, $v, $stripHtmlTag=false)
canEdit($verifyDomain=true)
__construct(NormalAttribute $oa, $v)
getIcon($idicon="", $size=null, $otherId=null)
getEnumLabel($enumid=null, $returnDisabled=true)
__construct(NormalAttribute $oa, $v, Doc &$doc, $iconsize=24, $relationNoAccessText= '')
static getRelationTitle($docid, $latest=true, Doc $doc, $docrevOption="", array &$info=array())
getIconMimeFile($sysmime)
__construct(NormalAttribute $oa, $v)
__construct(NormalAttribute $oa, $v, $multipleLongtextCr="\n")
__construct(NormalAttribute $oa, $v)
getParam($name, $def="")
must be in core or global type
revision(Action &$action)
getFileLink($attrid, $index=-1, $cache=false, $inline=false, $otherValue= '', $info=null)
getTitle($id="-1", $def="", $latest=false)
getFileInfo($filesvalue, $key="", $returnType="array")
existEnum($key, $completeKey=true)
stringDateToUnixTs($isodate, $utc=false)
__construct(NormalAttribute $oa, $v, Doc $doc, $index, $thumbnailSize=48)
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
getStateActivity($def="")
__construct(NormalAttribute $oa, $v, Doc &$doc, $iconsize=24, $relationNoAccessText= '')
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
__construct(NormalAttribute $oa, $v, $dateStyle=self::defaultStyle)