17 include_once (
"FDL/Class.SearchDoc.php");
18 include_once (
"FDL/Class.DocAttr.php");
19 include_once (
"FDL/freedom_util.php");
20 include_once (
"FDL/Class.QueryDir.php");
38 $dirid = GetHttpVars(
"dirid");
39 $refresh = GetHttpVars(
"refresh",
"no");
44 $startpage = GetHttpVars(
"page",
"0");
45 $target = GetHttpVars(
"target",
"fdoc");
46 $sqlorder = GetHttpVars(
"sqlorder", null);
47 $viewone = (GetHttpVars(
"viewone",
"N") ==
"Y");
52 if (
$slice ==
"-")
$slice = $action->GetParam(
"FDL_FOLDERMAXITEM", 1000);
55 $baseurl = $action->GetParam(
"CORE_BASEURL");
56 $standurl = $action->GetParam(
"CORE_STANDURL");
64 $action->lay->set(
"RSS", (
$dir->getRawValue(
"gui_isrss") ==
"yes" ?
true :
false));
65 if ($action->lay->get(
"RSS")) {
66 $action->lay->set(
"rsslink",
$dir->getRssLink());
68 $action->lay->set(
"foldername",
$dir->getHtmlTitle());
70 if (
$dir->defDoctype ==
'S') {
72 if ($sqlorder ==
"") $sqlorder =
$dir->getRawValue(
"se_orderby");
73 }
else $aclctrl =
"open";
76 $action->lay->
Set(
"dirtitle", stripslashes(
$dir->getHtmlTitle()));
77 $action->lay->eSet(
"dirid",
$dirid);
79 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/subwindow.js");
80 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/resizeimg.js");
81 $action->parent->AddJsRef($action->GetParam(
"CORE_JSURL") .
"/geometry.js");
83 $action->lay->set(
"VALTERN", ($action->GetParam(
"FDL_VIEWALTERN",
"yes") ==
"yes"));
86 $action->
exitError(_(
"cannot see unknow folder"));
92 if (count($terr) > 0) {
93 if (
$dir->defDoctype ==
'S') {
94 redirect($action,
"FDL",
"IMPCARD&zone=FREEDOM:PARAMDSEARCH:T&id=$dirid", $action->GetParam(
"CORE_STANDURL") ,
true);
97 redirect($action,
"FDL",
"FDL_CARD&id=$dirid", $action->GetParam(
"CORE_STANDURL") ,
true);
102 $sd->setSlice($slice + 1);
105 $sd->excludeConfidential();
106 $sd->distinct = $distinct;
109 $orderbyLabel = preg_replace(
'/^-/',
'', $sqlorder);
112 if ($sqlorder !=
"") {
113 $sqlorder =
"fromid,$sqlorder";
115 $sqlorder =
"fromid,title";
118 if ($sqlorder === null) {
121 $sd->setOrder($sqlorder, $orderbyLabel);
122 if ($sqlfilters)
foreach ($sqlfilters as
$filter) $sd->addFilter($filter);
123 $sd->setObjectReturn();
128 $searchError = $sd->searchError();
130 catch(Dcp\Db\Exception $e) {
131 $searchError = sprintf(_(
"This search cannot be executed"));
133 $count = $sd->count();
134 $hasNext = ($count >
$slice);
137 $doc1 = $sd->getNextDoc();
139 if ($doc1->doctype ==
"D") redirect($action,
"FREEDOM",
"OPENFOLIO&id=" . $doc1->initid, $action->GetParam(
"CORE_STANDURL"));
140 else redirect($action,
"FDL",
"FDL_CARD&latest=Y&id=" . $doc1->id, $action->GetParam(
"CORE_STANDURL"));
146 include_once (
"FDL/popup_util.php");
168 if ($action->GetParam(
"CORE_LANG") ==
"fr_FR") {
180 while (
$doc = $sd->getNextDoc()) {
182 if (
$doc->isConfidential())
continue;
194 if (
$doc->doctype ==
"C")
$tdoc[$k][
"title"] =
"<B>" .
$title .
"</B>";
196 if (strlen(
$doc->getTitle()) > 20) {
197 $tdoc[$k][
"abrvtitle"] = htmlspecialchars(mb_substr(
$doc->getTitle() , 0, 12) .
" ... " . mb_substr(
$doc->getTitle() , -5) , ENT_QUOTES);
202 if (isset(
$doc->_highlight) &&
$doc->_highlight !=
"") {
204 $tdoc[$k][
"highlight"] =
$doc->_highlight;
206 $tdoc[$k][
"icontitle"] =
$tdoc[$k][
"highlight"];
209 $tdoc[$k][
"revdate"] = strftime($fdate, intval(
$doc->revdate));
213 $tdoc[$k][
"divid"] = $kdiv;
215 $tdoc[$k][
"locked"] =
"";
216 $tdoc[$k][
"emblem"] = $action->parent->getImageLink(
"1x1.png");
217 $tdoc[$k][
"emblemt"] =
"";
218 $tdoc[$k][
"emblemw"] =
"0";
219 $tdoc[$k][
"canedit"] = 1;
220 $tdoc[$k][
"postitid"] = (
$doc->postitid > 0) ?
$doc->postitid :
false;
221 $tdoc[$k][
"inDomain"] =
$doc->isInDomain();
224 if (
$doc->confidential > 0) {
226 $tdoc[$k][
"emblemt"] = _(
"confidential");
228 $tdoc[$k][
"canedit"] =
false;
229 $tdoc[$k][
"locked"] = sprintf(
"<img src=\"%s\" title=\"%s\" width=\"20px\">",
$tdoc[$k][
"emblem"],
$tdoc[$k][
"emblemt"]);
230 }
else if (
$doc->locked == - 1) {
232 $tdoc[$k][
"emblemt"] = _(
"fixed");
234 $tdoc[$k][
"canedit"] =
false;
235 $tdoc[$k][
"locked"] = sprintf(
"<img src=\"%s\" title=\"%s\" width=\"20px\">",
$tdoc[$k][
"emblem"],
$tdoc[$k][
"emblemt"]);
236 }
else if (
$doc->lockdomainid > 0) {
238 $tdoc[$k][
"emblemt"] = _(
"domain locked");
240 $tdoc[$k][
"locked"] = sprintf(
"<img src=\"%s\" title=\"%s\" width=\"20px\">",
$tdoc[$k][
"emblem"],
$tdoc[$k][
"emblemt"]);
241 }
else if ((abs(
$doc->locked) == $action->parent->user->id)) {
243 $tdoc[$k][
"emblemt"] = _(
"locked");
245 $tdoc[$k][
"locked"] = sprintf(
"<img src=\"%s\" title=\"%s\" width=\"20px\">",
$tdoc[$k][
"emblem"],
$tdoc[$k][
"emblemt"]);
246 }
else if (
$doc->locked != 0) {
248 $tdoc[$k][
"emblemt"] = _(
"locked");
250 $tdoc[$k][
"canedit"] =
false;
251 $tdoc[$k][
"locked"] = sprintf(
"<img src=\"%s\" title=\"%s\" width=\"20px\">",
$tdoc[$k][
"emblem"],
$tdoc[$k][
"emblemt"]);
252 }
else if (
$doc->archiveid != 0) {
254 $tdoc[$k][
"emblemt"] = _(
"archived");
256 $tdoc[$k][
"canedit"] =
false;
257 $tdoc[$k][
"locked"] = sprintf(
"<img src=\"%s\" title=\"%s\" width=\"20px\">",
$tdoc[$k][
"emblem"],
$tdoc[$k][
"emblemt"]);
258 }
else if (
$doc->control(
"edit") !=
"") {
260 $tdoc[$k][
"emblemt"] = _(
"read-only");
262 $tdoc[$k][
"canedit"] =
false;
263 $tdoc[$k][
"locked"] = sprintf(
"<img src=\"%s\" title=\"%s\" width=\"20px\">",
$tdoc[$k][
"emblem"],
$tdoc[$k][
"emblemt"]);
283 if (
$doc->doctype ==
'C') {
286 $cud = (
$doc->CanLockFile() ==
"");
294 if (
$dir->defDoctype !=
'D') {
301 if (
$doc->isRevisable())
$tdoc[$k][
"revision"] =
$doc->revision;
302 else $tdoc[$k][
"revision"] =
"";
304 if (
$doc->locked == - 1) {
305 $tdoc[$k][
"state"] = $action->Text(
$doc->getState());
308 $tdoc[$k][
"state"] = $action->Text(
$doc->getStateActivity(
$doc->getState()));
311 $tdoc[$k][
"statecolor"] =
$doc->getStateColor(
"transparent");
313 $tdoc[$k][
"state"] =
"";
314 $tdoc[$k][
"statecolor"] =
"transparent";
317 if ((
$doc->doctype ==
'D') || (
$doc->doctype ==
'S'))
$tdoc[$k][
"isfld"] =
"true";
318 else $tdoc[$k][
"isfld"] =
"false";
322 if ($with_abstract) {
323 if (!
$doc->isConfidential()) {
326 if ($with_abstract === 2) {
329 $tdoc[$k][
"ABSTRACTVALUES"] =
$doc->viewDoc(
$doc->defaultabstract, $target,
true, $abstract =
false);
330 $tdoc[$k][
"LOrR"] = ($k % 2 == 0) ?
"left" :
"right";
332 }
else $tdoc[$k][
"ABSTRACTVALUES"] =
"";
339 $adoc =
$doc->getFamilyDocument();
341 $famdocAlreadyExists =
false;
342 foreach ($tfamdoc as $famdoc) {
343 if ($famdoc[
'fid'] ==
$doc->fromid) {
344 $famdocAlreadyExists =
true;
348 if (!$famdocAlreadyExists) {
351 "iconfamsrc" =>
$tdoc[$k][
"iconsrc"],
352 "ftitle" => htmlspecialchars($adoc->title, ENT_QUOTES) ,
353 "fid" =>
$doc->fromid,
354 "blockattr" =>
"BATT" .
$doc->fromid,
355 "blockvalue" =>
"BVAL" .
$doc->fromid
359 $lattr[
$doc->fromid] = $adoc->GetAbstractAttributes();
361 $emptytableabstract = array();
362 foreach ($lattr[
$doc->fromid] as $ka => $attr) {
363 if (($attr->mvisibility ==
'H') || ($attr->mvisibility ==
'I')) unset($lattr[
$doc->fromid][$ka]);
368 foreach ($lattr[
$doc->fromid] as $ka => $attr) {
369 $emptytableabstract[$attr->id][
"value"] =
"-";
370 $taname[$attr->id][
"aname"] = $attr->getLabel();
372 $action->lay->SetBlockData(
"BATT" .
$doc->fromid, $taname);
377 if (
$doc->isConfidential()) {
378 foreach ($lattr[
$doc->fromid] as $ka => $attr) {
382 foreach ($lattr[
$doc->fromid] as $ka => $attr) {
384 $dAttr =
$doc->getAttribute($attr->id);
385 if ($dAttr->mvisibility ===
"I") {
387 } elseif ($attr->type ==
"image") $tvalues[] =
'<img src="' .
$doc->getHtmlValue($attr,
$doc->getRawValue($attr->id,
"-") , $target) .
'&height=30" height="30">';
388 else $tvalues[] = (
$doc->getRawValue($attr->id) ?
$doc->getHtmlValue($attr,
$doc->getRawValue($attr->id) , $target) :
'-');
391 $tdoc[$k][
"values"] = implode(
'</td><td class="tlist">', $tvalues);
401 $nbdoc = $nbseedoc = count(
$tdoc);
404 $collator =
new Collator($action->GetParam(
"CORE_LANG",
"fr_FR"));
405 usort(
$tdoc,
function (
$a, $b) use ($collator)
410 $cmp = (
$a[
'fromid'] - $b[
'fromid']);
411 return ($cmp == 0) ? $collator->compare(
$a[
'title'], $b[
'title']) : $cmp;
414 if ((GetHttpVars(
"sqlorder") ==
"") && ($slice >= $action->GetParam(
"FDL_FOLDERMAXITEM", 1000))) uasort(
$tdoc,
"orderbytitle");
419 addLogMsg($sd->getSearchInfo());
424 $tboo[0][
"boo"] =
"";
425 $action->lay->SetBlockData(
"VIEWPROP", $tboo);
427 $action->lay->
Set(
"nbdiv", $kdiv - 1);
432 $tdocByFromId = array();
434 $tdocByFromId[$doc[
'fromid']][] =
$doc;
440 foreach ($tdocByFromId as $fromid => $documentList) {
441 $action->lay->SetBlockData(
"BVAL" . $fromid, $documentList);
444 $collator =
new Collator($action->GetParam(
"CORE_LANG",
"fr_FR"));
445 usort($tfamdoc,
function (
$a, $b) use ($collator)
450 return $collator->compare(
$a[
'ftitle'], $b[
'ftitle']);
452 $action->lay->setBlockData(
"TABLEBODY", $tfamdoc);
454 $action->lay->setBlockData(
"TABLEBODY",
$tdoc);
462 if ($with_popup || $column) {
465 $licon->Set(
"nbdiv", $kdiv - 1);
466 $action->parent->AddJsCode($licon->gen());
469 $pagefolder[$startpage + 1] = $nbseedoc +
$start;
470 $action->
Register(
"pagefolder", $pagefolder);
471 $action->lay->
Set(
"next", $startpage + 1);
472 $action->lay->
Set(
"prev", $startpage - 1);
475 if ($paginationType ===
'none' && ($start != 0 || ($start == 0 && $hasNext))) {
477 $sd->setSlice(
'ALL');
479 $count = $sd->onlyCount();
482 $action->lay->set(
"count", $count);
483 $action->lay->
Set(
"nbdoc", $nbdoc);
484 $action->lay->
Set(
"hasNext", $hasNext);
485 $action->lay->eSet(
"wtarget", $target);
488 $rangeTo = $start + $count;
490 if ($paginationType !=
"" && preg_match(
"/(^pageNumber$|^documentNumber$|%f|%l|%er|%np|%nd)/", $paginationType) && ($start != 0 || ($start == 0 && $hasNext))) {
492 $sd->setSlice(
'ALL');
494 $count = $sd->onlyCount();
495 $last = intval($count / $slice) - 1;
496 if ($count % $slice != 0) $last++;
499 $searchConfig = array(
500 "next" => $startpage + 1,
501 "prev" => $startpage - 1,
503 "numberofpage" => $last + 1,
504 "pagenumber" => $startpage + 1,
505 "numberofdocuments" => $count,
506 "rangefrom" => ($rangeTo > 0) ? $start + 1 : 0,
507 "rangeto" => $rangeTo,
508 "hasnext" => $hasNext
510 $action->parent->setVolatileParam(
"searchConfig", $searchConfig);
516 $cmp = (
$a[
'fromid'] - $b[
'fromid']);
517 return ($cmp == 0) ? strcasecmp(
$a[
'title'], $b[
'title']) : $cmp;
522 return strcasecmp(
$a[
"title"], $b[
"title"]);
528 $lattr = $doc->GetAbstractAttributes();
529 foreach ($lattr as $ka => $attr) {
530 $val = $doc->GetHtmlAttrValue($ka, $target, 2, -1,
true,
true);
532 if ($val)
$tout[] = $val;
534 return implode(
" - ",
$tout);
Layout is a template generator.
getAbstractDetail(Doc &$doc, $target)
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
viewfolder(Action &$action, $with_abstract=false, $with_popup=true, $column=false, $slice="-", $sqlfilters=array(), $famid="", $paginationType="none")
orderbyfromidtitle($a, $b)
exitError($texterr, $exit=true, $code="")
getChildDocError($dbaccess, $dirid)
new_Doc($dbaccess, $id= '', $latest=false)
static getArgument($k, $def= '')
if($file) if($subject==""&&$file) if($subject=="") $err