Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
freedom_refresh.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5  * @package FDL
6 */
7 /**
8  * Generated Header (not documented yet)
9  *
10  * @author Anakeen 2000
11  * @version $Id: freedom_refresh.php,v 1.22 2008/12/12 17:48:25 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage
15  */
16 /**
17  */
18 // refreah for a classname
19 // use this only if you have changed title attributes
20 include_once ("FDL/Class.Doc.php");
21 include_once ("FDL/Class.SearchDoc.php");
22 
23 $usage = new ApiUsage();
24 $usage->setText("Refresh documents");
25 $famId = $usage->addNeeded("famid", "family identifier (name or id)");
26 $docid = $usage->addOption("docid", "document identifier to apply refresh only on this document");
27 $method = $usage->addOption("method", "method to apply instead of refresh method");
28 $arg = $usage->addOption("arg", "option arg of the method");
29 $fldid = $usage->addOption("fldid", "collection identifier where apply refresh");
30 $allrev = (strtoupper(substr($usage->addOption("revision", "collection identifier where apply refresh", array(
31  "yes",
32  "no",
33  "Y",
34  "N"
35 )), 0, 1)) == "Y");
36 $usage->verify();
37 
39 $appl->Set("FDL", $core);
40 
41 $dbaccess = $appl->GetParam("FREEDOM_DB");
42 if ($dbaccess == "") {
43  print "Database not found : param FREEDOM_DB";
44  exit;
45 }
46 
47 if ($famId) {
48  $f = new_doc($dbaccess, $famId);
49  if (!$f->isAlive()) {
50  $action->exitError(sprintf("family %s not exists", $famId));
51  }
52  if ($f->doctype != 'C') {
53  $action->exitError(sprintf("document %s not a family", $famId));
54  }
55 }
56 
58 $s->setObjectReturn();
59 if ($docid) {
60  $d = new_doc($dbaccess, $docid);
61  if (!$d->isAlive()) {
62  $action->exitError(sprintf("document %s not exists", $docid));
63  } else $docid = $d->id;
64 }
65 if ($docid > 0) $s->addFilter("id = $docid");
66 if ($fldid != "") $s->useCollection($fldid);
67 if ($allrev) $s->latest = false;
68 $s->search();
69 
70 if ($s->searchError()) {
71  $action->exitError(sprintf("search error : %s", $s->getError()));
72 }
73 $targ = array();
74 if ($arg != "") $targ[] = $arg;
75 $card = $s->count();
76 printf("\n%d documents to refresh\n", $card);;
77 while ($doc = $s->nextDoc()) {
78  $usemethod = ($method && (method_exists($doc, $method)));
79  if ($usemethod) {
80  $ret = call_user_func_array(array(
81  $doc,
82  $method
83  ) , $targ);
84  } else $ret = '';
85  print $card . ")" . $doc->title . " " . (($usemethod) ? "(use $method($arg))" : "") . get_class($doc) . ":$ret\n";
86  //print $card-$k.")".$doc->title ." - ".$doc->fromid." - ".get_class($doc)." - " .round(memory_get_usage()/1024)."\n";
87  $doc->refresh();
88  $doc->refreshTitle();
89  $doc->Modify();
90  $card--;
91 }
92 ?>
← centre documentaire © anakeen - published under CC License - Dynacase