Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
editchangestate.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  * Display interface to change state
9  *
10  * @author Anakeen 2007
11  * @version $Id: editchangestate.php,v 1.8 2008/10/02 15:41:45 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 
19 include_once ("FDL/Lib.Dir.php");
20 include_once ("FDL/editutil.php");
21 include_once ("FDL/editcard.php");
22 /**
23  * Display editor to fix a document version
24  * @param Action &$action current action
25  * @global id Http var : document id
26  * @global nstate Http var : next state id
27  */
29 {
30  $docid = GetHttpVars("id");
31  $nextstate = GetHttpVars("nstate");
32  $viewext = GetHttpVars("viewext");
33 
34  $dbaccess = $action->GetParam("FREEDOM_DB");
35 
37  $doc = new_doc($dbaccess, $docid, true);
38  if (!$doc->isAlive()) $action->exitError(sprintf(_("Document %s is not alive") , $docid));
39  if ($doc->wid > 0) {
40  $tneed = array();
41  $err = $doc->lock(true); // autolock
42  if ($err == "") $action->AddActionDone("LOCKDOC", $doc->id);
43 
44  $wdoc = new_Doc($dbaccess, $doc->wid);
45  $wdoc->Set($doc);
46  $action->lay->set("noreason", false);
47  $action->lay->set("realtransition", true);
48  $fstate = $wdoc->GetFollowingStates();
49  foreach ($fstate as $k => $v) {
50  if ($v == $nextstate) {
51  $tr = $wdoc->getTransition($doc->state, $v);
52  $tinputs = array();
53  if (is_array($tr["ask"])) {
54  foreach ($tr["ask"] as $ka => $va) {
55  $oa = $wdoc->getAttribute($va);
56  if ($oa) {
57  if ($oa->needed) $tneed[$oa->id] = $oa->getLabel();
58  if ($oa->usefor == 'Q') {
59  $wval = $wdoc->getParamValue($oa->id);
60  $wval = $wdoc->getValueMethod($wval);
61  } else {
62  $wval = $wdoc->getValue($oa->id);
63  }
64  if ($edittpl = $oa->getOption("edittemplate")) {
65  $input = sprintf("[ZONE FDL:EDITTPL?id=%d&famid=%d&wiid=%d&zone=%s]", $wdoc->id, $wdoc->fromid, $doc->id, $edittpl);
66  } else {
67  $input = getHtmlInput($wdoc, $oa, $wval, "", "", true);
68  }
69  $tinputs[] = array(
70  "alabel" => $oa->getLabel() ,
71  "labelclass" => ($oa->needed) ? "FREEDOMLabelNeeded" : "FREEDOMLabel",
72  "avalue" => $input,
73  "aid" => $oa->id,
74  "idisplay" => ($oa->visibility == "H") ? "none" : ""
75  );
76  if ($oa->needed) $tneed[$oa->id] = $oa->getLabel();
77  }
78  }
79  }
80  $action->lay->set("noreason", ($tr["nr"] == true));
81  $action->lay->set("viewext", $viewext);
82  $action->lay->setBlockData("FINPUTS", $tinputs);
83  }
84  }
85 
87  $action->lay->set("tonewstate", sprintf(_("to the %s state") , _($nextstate)));
88  if ($tr) {
89  if (_($tr["id"]) == $tr["id"]) $lnextstate = sprintf(_("to %s") , _($nextstate));
90  else $lnextstate = _($tr["id"]);
91  } else {
92  $action->lay->set("realtransition", false);
93  $lnextstate = sprintf(_("to %s") , _($nextstate));
94  }
95 
96  $action->lay->set("tostate", ucfirst($lnextstate));
97  $action->lay->set("wcolor", $wdoc->getColor($nextstate));
98  $action->lay->Set("Wattrntitle", json_encode(array_values($tneed)));
99  $action->lay->Set("Wattrnid", json_encode(array_keys($tneed)));
100  $action->lay->set("docid", $doc->id);
101  $action->lay->set("thetitle", sprintf(_("Change state to %s") , _($nextstate)));
102  $action->lay->set("nextstate", $nextstate);
103 
104  $style = $action->parent->getParam("STYLE");
105 
106  $action->parent->AddCssRef("STYLE/DEFAULT/Layout/EXT-ADAPTER-SYSTEM.css");
107  if (file_exists($action->parent->rootdir . "/STYLE/$style/Layout/EXT-ADAPTER-USER.css")) {
108  $action->parent->AddCssRef("STYLE/$style/Layout/EXT-ADAPTER-USER.css");
109  } else {
110  $action->parent->AddCssRef("STYLE/DEFAULT/Layout/EXT-ADAPTER-USER.css");
111  }
112  }
113 }
114 ?>
← centre documentaire © anakeen - published under CC License - Dynacase