Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
Class.DocumentSelection.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  * Selction Document Object Definition
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  */
15 /**
16  */
17 include_once ("DATA/Class.Document.php");
18 /**
19  * Document selection Class
20  *
21  */
23 {
24  function __construct($config)
25  {
26  foreach ($config as $k => $v) $this->$k = $v;
27  $this->dbaccess = getParam("FREEDOM_DB");
28  }
29  /**
30  * return document identificators from selection
31  * @return array
32  */
33  function getIdentificators()
34  {
35  if (strtolower($this->mainSelector) != "all") {
36  if (is_array($this->selectionItems)) {
37  return $this->selectionItems;
38  } else return array();
39  } else {
40  $cc = $this->getRawDocuments();
41  if (is_array($cc)) return array_keys($cc);
42  else return array();
43  }
44  }
45  /**
46  * return document data from selection
47  * @return array
48  */
49  function getRawDocuments()
50  {
51 
52  if (strtolower($this->mainSelector) != "all") {
53  if (is_array($this->selectionItems)) {
54  return getDocsFromIds($this->dbaccess, $this->selectionItems);
55  }
56  } else {
57  $idc = $this->collectionId;
58  $c = new Fdl_Collection($idc);
59  if ($c->isAlive()) {
60  $idoc = $c->getInternalDocument();
61  $filter = array();
62  $famid = "";
63  if ($this->filter) {
64  $err = $c->object2SqlFilter($this->filter, $famid, $sql);
65  if ($err == "") {
66  if ($sql) $filter[] = $sql;
67  } else return null;
68  }
69  if (is_array($this->selectionItems)) {
70  $cc = $idoc->getContent(true, $filter, $famid);
71  foreach ($this->selectionItems as $eid) {
72  if (isset($cc[$eid])) unset($cc[$eid]);
73  else {
74  $err = simpleQuery($this->dbaccess, sprintf("select initid from docread where id=%d", $eid) , $ids, true, true);
75  if (isset($cc[$ids])) unset($cc[$ids]);
76  }
77  }
78  return $cc;
79  } else {
80  return $idoc->getContent(true, $filter, $famid);
81  }
82  }
83  }
84  return array();
85  }
86 }
87 ?>
← centre documentaire © anakeen - published under CC License - Dynacase