20 include_once (
"FDL/Class.Doc.php");
21 include_once (
"FDL/Class.SearchDoc.php");
24 if ($msg) $msg = chr(0x1b) .
"[1;31m" . $msg . chr(0x1b) .
"[0;39m";
30 if ($msg) $msg = chr(0x1b) .
"[1;32m" . $msg . chr(0x1b) .
"[0;39m";
36 if ($msg) $msg = chr(0x1b) .
"[1;33m" . $msg . chr(0x1b) .
"[0;39m";
41 $usage->setDefinitionText(
"Refresh documents ");
42 $famId =
$usage->addRequiredParameter(
"famid",
"the family identifier used to filter");
49 return sprintf(
"Invalid %s value for option --method=<methodName>", gettype(
$value));
52 return sprintf(
"Invalid empty value for option --method=<methodName>");
57 $arg =
$usage->addOptionalParameter(
"arg",
"optional method argument to set when calling method");
62 $docid =
$usage->addOptionalParameter(
"docid",
"use only for this document id");
63 $start =
$usage->addOptionalParameter(
"start",
"start from offset", array() , 0);
64 $slice =
$usage->addOptionalParameter(
"slice",
"limit from offset", array() ,
"all");
65 $fldid =
$usage->addOptionalParameter(
"fldid",
"use collection id to limit search");
66 $filter =
$usage->addOptionalParameter(
"filter",
"sql filter to limit search");
67 $save =
$usage->addOptionalParameter(
"save",
"store mode", array(
78 return sprintf(
"Invalid %s value for option --status-file=<statusFile>|'-'", gettype(
$value));
81 return sprintf(
"Invalid empty value for option --status-file=<statusFile>|'-'");
85 $stopOnError = (
$usage->addEmptyParameter(
"stop-on-error",
"Stop processing when a document returns an error or throws an exception") !==
false);
91 print "Database not found : action->dbaccess";
102 if (!$f->isAlive()) {
105 if ($f->doctype !=
'C') {
106 $action->exitError(sprintf(
"document %s not a family",
$famId));
113 $s->setObjectReturn();
114 $s->orderby =
'id desc';
118 if (!is_numeric(
$docid)) {
122 $action->exitError(sprintf(
"document with name '%s' not found", $docName));
133 if (@pg_prepare(
getDbid(
$dbaccess) ,
'refreshDocument', sprintf(
"select id from doc%d where %s",
$s->fromid,
$filter)) ==
false) {
134 $action->exitError(sprintf(
"filter not valid :%s", pg_last_error()));
141 if (
$s->searchError()) {
142 $action->exitError(sprintf(
"search error : %s",
$s->getError()));
155 while (
$doc =
$s->getNextDoc()) {
157 printf(
"\nmethod not exists '%s' \n",
$method);
169 $ret = call_user_func_array(array(
173 if (
$doc->isChanged()) {
174 $olds =
$doc->getOldRawValues();
175 foreach ($olds as $k => $v) {
176 $smod.= sprintf(
"\t- %s [%s]:[%s]\n", $k, $v,
$doc->getRawValue($k));
191 catch(\Exception $e) {
192 $err.= $e->getMessage();
204 if ($smod)
print $smod;
220 $err = sprintf(
"Error creating refresh's status file '%s'.",
$statusFile);
224 if (fwrite($fh,
$status) ===
false) {
225 $err = sprintf(
"Error writing refresh's status to file '%s'.",
$statusFile);
229 if ($fh !== STDOUT) {
243 printf(
"%s\n",
$err);
if($s->searchError()) $targ
if($dbaccess=="") if($statusFile=== '') $famtitle
while($doc=$s->getNextDoc()) $writeStatus
getIdFromName($dbaccess, $name)
if($file) if($subject==""&&$file) if($subject=="") $err
Verify arguments for wsh programs.