Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
generic_list.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  * View set of documents of same family
9  *
10  * @author Anakeen 2000
11  * @version $Id: generic_list.php,v 1.43 2008/10/30 09:23:46 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/viewfolder.php");
20 include_once ("GENERIC/generic_util.php");
21 /**
22  * View list of document from folder (or searches)
23  * @param Action &$action current action
24  * @global dirid Http var : folder identificator to see
25  * @global catg Http var :
26  * @global page Http var : page number
27  * @global tabs Http var : tab number 1 for ABC, 2 for DEF, if onglet=Y..
28  * @global onglet Http var : [Y|N] Y if want see alphabetics tabs
29  * @global famid Http var : main family identificator
30  * @global sqlorder Http var : order by attribute
31  * @global gview Http var : [abstract|column] view mode
32  */
34 {
35  // Set the globals elements
36  // Get all the params
37  $dirid = GetHttpVars("dirid"); // directory to see
38  $catgid = GetHttpVars("catg", $dirid); // category
39  $startpage = GetHttpVars("page", "0"); // page to see
40  $tab = GetHttpVars("tab", "0"); // tab to see 1 for ABC, 2 for DEF, ...
41  $onglet = GetHttpVars("onglet"); // if you want onglet
42  $famid = GetHttpVars("famid"); // family restriction
43  $clearkey = (GetHttpVars("clearkey", "N") == "Y"); // delete last user key search
44  $sqlorder = GetHttpVars("sqlorder"); // family restriction
45  $target = "finfo$famid";
46  setHttpVar("target", $target);
47  if (!($famid > 0)) $famid = getDefFam($action);
48 
49  $column = generic_viewmode($action, $famid); // choose the good view mode
50  $dbaccess = $action->GetParam("FREEDOM_DB");
51  $action->parent->addCssRef("GENERIC:generic_list.css", true);
52  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/AnchorPosition.js", false);
53  //change famid if it is a simplesearch
54  $sfamid = $famid;
55  if ($dirid) {
56  $dir = new_doc($dbaccess, $dirid);
57  if ($dir->isAlive() && ($dir->defDoctype == 'S')) {
58  $sfamid = $dir->getValue("se_famid");
59  }
60  }
61  if ($onglet) {
62  $wonglet = ($onglet != 'N');
63  } else {
64  $wonglet = (getTabLetter($action, $famid) == 'Y');
65  }
66 
67  $dir = new_Doc($dbaccess, $dirid);
68  $catg = new_Doc($dbaccess, $catgid);
69  $action->lay->set("folderid", "0");
70  if ($catg->doctype == 'D') $action->lay->set("folderid", $catg->id);
71  $action->lay->Set("pds", "");
72  if ($catgid) {
73  $catg = new_Doc($dbaccess, $catgid);
74  $action->lay->Set("pds", $catg->urlWhatEncodeSpec(""));
75 
76  $action->lay->Set("fldtitle", $dir->getHTMLTitle());
77  } else {
78  if ($dirid == 0) {
79  $action->lay->Set("fldtitle", _("precise search"));
80  $action->lay->Set("pds", "");
81  } else {
82  $action->lay->Set("fldtitle", $dir->getHTMLTitle());
83  }
84  }
85  $action->lay->Set("famtarget", $target);
86  $action->lay->Set("dirid", $dirid);
87  $action->lay->Set("tab", $tab);
88  $action->lay->Set("catg", $catgid);
89  $action->lay->Set("famid", $famid);
91  $action->lay->Set("FULLMODE", ($mode == "FULL"));
92  $slice = $action->GetParam("CARD_SLICE_LIST", 5);
93  // $action->lay->Set("next",$start+$slice);
94  //$action->lay->Set("prev",$start-$slice);
95  $action->lay->Set("nexticon", "");
96  $action->lay->Set("previcon", "");
97 
98  if ($sqlorder == "") {
99  $sqlorder = getDefUSort($action, "title", $sfamid);
100  setHttpVar("sqlorder", $sqlorder);
101  }
102 
103  if ($famid > 0) {
104  if ($sqlorder != "") {
105  $ndoc = createDoc($dbaccess, $sfamid, false);
106  if ($sqlorder[0] == "-") $sqlorder = substr($sqlorder, 1);
107  if (!in_array($sqlorder, $ndoc->fields)) setHttpVar("sqlorder", "");
108  }
109  }
110  if ($clearkey) {
111  $action->parent->param->Set("GENE_LATESTTXTSEARCH", setUkey($action, $famid, $keyword) , PARAM_USER . $action->user->id, $action->parent->id);
112  }
114  if ($dirid) {
115  if ($dir->fromid == 38) {
116  $famid = 0; // special researches
117  setHttpVar("sqlorder", "--"); // no sort possible
118 
119  }
120  $only = (getInherit($action, $famid) == "N");
121  if (viewfolder($action, true, false, $column, $slice, array() , ($only) ? -(abs($famid)) : abs($famid)) == $slice) {
122  // can see next
123  $action->lay->Set("nexticon", $action->GetIcon("next.png", N_("next") , 16));
124  }
125  }
126  if ($startpage > 0) {
127  // can see prev
128  $action->lay->Set("previcon", $action->GetIcon("prev.png", N_("prev") , 16));
129  }
130 
131  if ($dirid && $wonglet) {
132  // hightlight the selected part (ABC, DEF, ...)
133  $onglet = array(
134  array(
135  "onglabel" => "A B C",
136  "ongdir" => "1"
137  ) ,
138  array(
139  "onglabel" => "D E F",
140  "ongdir" => "2"
141  ) ,
142  array(
143  "onglabel" => "G H I",
144  "ongdir" => "3"
145  ) ,
146  array(
147  "onglabel" => "J K L",
148  "ongdir" => "4"
149  ) ,
150  array(
151  "onglabel" => "M N O",
152  "ongdir" => "5"
153  ) ,
154  array(
155  "onglabel" => "P Q R S",
156  "ongdir" => "6"
157  ) ,
158  array(
159  "onglabel" => "T U V",
160  "ongdir" => "7"
161  ) ,
162  array(
163  "onglabel" => "W X Y Z",
164  "ongdir" => "8"
165  ) ,
166  array(
167  "onglabel" => "A - Z",
168  "ongdir" => "0"
169  )
170  );
171 
172  while (list($k, $v) = each($onglet)) {
173  if ($v["ongdir"] == $tab) $onglet[$k]["ongclass"] = "onglets";
174  else $onglet[$k]["ongclass"] = "onglet";
175  $onglet[$k]["onglabel"] = str_replace(" ", "<BR>", $v["onglabel"]);
176  }
177 
178  $action->lay->SetBlockData("ONGLET", $onglet);
179  }
180 
181  $action->lay->Set("onglet", $wonglet ? "Y" : "N");
182 
183  $action->lay->set("tkey", str_replace('"', '&quot;', getDefUKey($action)));
184 }
185 
187 {
188  $prefview = getHttpVars("gview");
189 
190  $tmode = explode(",", $action->getParam("GENE_VIEWMODE"));
191  // explode parameters
192  while (list($k, $v) = each($tmode)) {
193  list($fid, $vmode) = explode("|", $v);
194  $tview[$fid] = $vmode;
195  }
196  switch ($prefview) {
197  case "column":
198  case "abstract":
199  $tview[$famid] = $prefview;
200  // implode parameters to change user preferences
201  $tmode = array();
202  while (list($k, $v) = each($tview)) {
203  if ($k > 0) $tmode[] = "$k|$v";
204  }
205  $pmode = implode(",", $tmode);
206  $action->parent->param->Set("GENE_VIEWMODE", $pmode, PARAM_USER . $action->user->id, $action->parent->id);
207 
208  break;
209  }
210 
211  switch ($tview[$famid]) {
212  case "column":
213  $action->layout = $action->GetLayoutFile("generic_listv.xml");
214  $action->lay = new Layout($action->layout, $action);
215  // $action->parent->AddJsRef($action->GetParam("CORE_PUBURL")."/FREEDOM/Layout/sorttable.js");
216  // $column=true;
217  $column = 2;
218  break;
219 
220  case "abstract":
221  default:
222  $action->layout = $action->GetLayoutFile("generic_list.xml");
223  $action->lay = new Layout($action->layout, $action);
224  $column = false;
225 
226  break;
227  }
228  return $column;
229 }
230 
232 {
233  // search searches in primary folder
235  $dirid = GetHttpVars("dirid"); // search
236  $catgid = GetHttpVars("catg", $dirid); // primary directory
237  if ($catgid == 0) $catgid = $dirid;
238  if ($fdoc->dfldid > 0) {
239  $homefld = new_Doc($dbaccess, $fdoc->dfldid);
240  $stree = array();
241  if ($homefld->id > 0) $stree = getChildDoc($dbaccess, $homefld->id, "0", "ALL", array() , $action->user->id, "TABLE", 5);
242 
243  $streeSearch = array();
244  foreach ($stree as $k => $v) {
245  if (($v["doctype"] == "S") && ($v["fromid"] != $fdoc->id)) {
246  $streeSearch[$v["id"]] = $v;
247  $streeSearch[$v["id"]]["selected"] = ($v["id"] == $catgid) ? "selected" : "";
248  $streeSearch[$v["id"]]["isreport"] = "0";
249  $streeSearch[$v["id"]]["isparam"] = "0";
250  $keys = getv($v, "se_keys");
251  if (preg_match('/\?/', $keys)) {
252  $streeSearch[$v["id"]]["title"] = "(P)" . $streeSearch[$v["id"]]["title"];
253  $streeSearch[$v["id"]]["isparam"] = "1";
254  }
255  if ($v["fromid"] == 25) {
256  $streeSearch[$v["id"]]["title"] = "(R)" . $streeSearch[$v["id"]]["title"];
257  $streeSearch[$v["id"]]["isreport"] = "1";
258  }
259  }
260  }
261  }
262 
263  $action->lay->set("ONESEARCH", (count($streeSearch) > 0));
264 
265  $action->lay->SetBlockData("SYSSEARCH", $streeSearch);
266  // search user searches for family
267  $filter[] = "owner=" . $action->user->id;
268  $filter[] = "se_famid='$famid'";
269  $filter[] = "usefor!='G'";
270  $filter[] = "doctype != 'T'";
271  $filter[] = "se_memo='yes'";
272  $action->lay->set("MSEARCH", false);
273  $stree = getChildDoc($dbaccess, "0", "0", "ALL", $filter, $action->user->id, "TABLE", 5);
274  $streeSearch = array();
275  foreach ($stree as $k => $v) {
276  if (!isset($streeSearch[$v["id"]])) $streeSearch[$v["id"]] = $v;
277  $streeSearch[$v["id"]]["selected"] = ($v["id"] == $catgid) ? "selected" : "";
278  $streeSearch[$v["id"]]["isreport"] = "0";
279  $streeSearch[$v["id"]]["isparam"] = "0";
280  $keys = getv($v, "se_keys");
281  if (preg_match('/\?/', $keys)) {
282  $streeSearch[$v["id"]]["title"] = "(P)" . $streeSearch[$v["id"]]["title"];
283  $streeSearch[$v["id"]]["isparam"] = "1";
284  }
285  if ($v["fromid"] == 25) {
286  $streeSearch[$v["id"]]["title"] = "(R)" . $streeSearch[$v["id"]]["title"];
287  $streeSearch[$v["id"]]["isreport"] = "1";
288  }
289  }
290  $action->lay->set("MSEARCH", (count($stree) > 0));
291  $action->lay->SetBlockData("USERSEARCH", $streeSearch);
292  if (count($streeSearch) > 0) $action->lay->set("ONESEARCH", true);
293 }
294 ?>
← centre documentaire © anakeen - published under CC License - Dynacase