Core  3.2
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  * @package FDL
5 */
6 /**
7  * Selction Document Object Definition
8  *
9  * @author Anakeen
10  * @version $Id: $
11  * @package FDL
12  */
13 /**
14  */
15 include_once ("FDL/Class.Document.php");
16 /**
17  * Document selection Class
18  *
19  */
21 {
22  private $mainSelector;
23  private $selectionItems;
24  function __construct($config)
25  {
26  foreach ($config as $k => $v) $this->$k = $v;
27  $this->dbaccess = getDbAccess();
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  /*
61  * @var DocCollection $idoc
62  */
63  $idoc = $c->getInternalDocument();
64  $filter = array();
65  $famid = "";
66  if ($this->filter) {
67  $err = $idoc->object2SqlFilter($this->filter, $famid, $sql);
68  if ($err == "") {
69  if ($sql) $filter[] = $sql;
70  } else return null;
71  }
72  if (is_array($this->selectionItems)) {
73  $cc = $idoc->getContent(true, $filter, $famid);
74  foreach ($this->selectionItems as $eid) {
75  if (isset($cc[$eid])) unset($cc[$eid]);
76  else {
77  $err = simpleQuery($this->dbaccess, sprintf("select initid from docread where id=%d", $eid) , $ids, true, true);
78  if (isset($cc[$ids])) unset($cc[$ids]);
79  }
80  }
81  return $cc;
82  } else {
83  return $idoc->getContent(true, $filter, $famid);
84  }
85  }
86  }
87  return array();
88  }
89 }
getDocsFromIds($dbaccess, $ids, $userid=0)
Definition: Lib.Dir.php:1034
$idoc
Definition: csv2sql.php:34
getDbAccess()
Definition: Lib.Common.php:368
$cc
simpleQuery($dbaccess, $query, &$result=array(), $singlecolumn=false, $singleresult=false, $useStrict=null)
Definition: Lib.Common.php:484
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen