Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
grouprequest.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  * Grouped document requests
9  *
10  * @author Anakeen 2009
11  * @version $Id: $
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 ("DATA/document.php");
20 /**
21  * Retrieve and set documents
22  * @param Action &$action current action
23  * @global id Http var : document identificator
24  */
26 {
27 
28  $request = json_decode(getHttpVars("request"));
29  $out = array();
30  $docid = array();
31  foreach ($request as $kr => $rs) {
32  foreach ($rs as $varname => $r) {
33  $method = strtolower($r->method);
34  $config = $r->config;
35  setHttpVar("config", $config);
36  if ($config) {
37  foreach ($config as $k => $v) { // set http vars
38  if (is_object($v)) setHttpVar($k, json_encode($v));
39  else setHttpVar($k, ($v));
40  }
41  }
42 
43  $id = '';
44  if ($r->config && $r->config->id) $id = $r->config->id;
45  else if ($r->method == "getSelection") $id = 'selection';
46  else if ($r->variable && $docid[$r->variable]) $id = $docid[$r->variable];
47 
48  if ($id) {
49  if ($r->iterative) {
50  $ds = $out[$r->variable]->content;
51  $outi = array();
52  if (is_array($ds)) {
53  foreach ($ds as $k => $v) {
54  documentApplyMethod($action, $v["properties"]["id"], $method, $returntype, $outi[$k], $document);
55  }
56  }
57  $out[$varname] = array(
58  "iterative" => $outi
59  );
60  } else {
61  documentApplyMethod($action, $id, $method, $returntype, $out[$varname], $document);
62  if ($document) {
63  $docid[$varname] = $document->getProperty('id');
64  } else if ($id == "selection") $docid[$varname] = $id;
65  }
66  } else {
67  $out["error"] = sprintf(_("request empty reference"));
68  }
69  if ($config) {
70  foreach ($config as $k => $v) { // restore initial http vars
71  setHttpVar($k, "");
72  }
73  }
74  }
75  }
76 
77  $action->lay->template = json_encode($out);
78  $action->lay->noparse = true;
79 }
80 ?>
← centre documentaire © anakeen - published under CC License - Dynacase