Core  3.2
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
generic_tab.php
Go to the documentation of this file.
1 <?php
2 /*
3  * @author Anakeen
4  * @package FDL
5 */
6 /**
7  * List document of a category
8  *
9  * @author Anakeen
10  * @version $Id: generic_tab.php,v 1.29 2008/02/20 16:55:05 eric Exp $
11  * @package FDL
12  * @subpackage
13  */
14 /**
15  */
16 
17 require_once "FDL/Lib.Dir.php";
18 
19 require_once "FDL/freedom_util.php";
20 require_once "GENERIC/generic_util.php";
21 require_once "GENERIC/generic_list.php";
22 
24 {
25  // Get all the params
26  $dirid = GetHttpVars("catg", -1); // folder where search
27  $tab = GetHttpVars("tab", 1); // tab index
28  $dbaccess = $action->dbaccess;
29 
30  $famid = getDefFam($action);
31  $emptyfld = false;
32  if ($famid == "0") {
33  $action->exitError(_("cookies seem to be blocked"));
34  }
35  if (($famid != "") && (!is_numeric($famid))) $famid = getFamIdFromName($dbaccess, $famid);
36 
37  $fdoc = new DocFam($dbaccess, $famid);
38 
39  if ($dirid == - 1) {
40  $dirid = $fdoc->dfldid;
41  }
42  if ($dirid == 0) {
43  $dirid = getDefU($action, "GENE_PREFSEARCH");
44  if (!is_numeric($dirid)) {
45  $dirid = getIdFromName($action->dbaccess, $dirid);
46  }
47  if ($dirid > 0) {
49  if (!$dir->isAlive() || $dir->control("execute") != '') {
50  $dirid = 0;
51  }
52  }
53  }
54  if ($dirid == 0) {
55  if ($fdoc->cfldid > 0) {
56  $dirid = $fdoc->cfldid;
57  } else {
58  $dirid = $fdoc->dfldid;
59  }
60  }
61  // hightlight the selected part (ABC, DEF, ...)
62  $tabletter = array(
63  "",
64  "ABC",
65  "DEF",
66  "GHI",
67  "JKL",
68  "MNO",
69  "PQRS",
70  "TUV",
71  "WXYZ"
72  );
73  $sqlfilter = array();
75  // control open
76  if ($dir->defDoctype == 'S') {
77  $aclctrl = "execute";
78  } else {
79  $aclctrl = "open";
80  }
81  if (($err = $dir->Control($aclctrl)) != "") {
82  $action->exitError($err);
83  }
84 
85  if (($dir->defDoctype == 'S') && ($tab == 0)) {
86  // parmeters for redirect in case of parametrizable search
87  setHttpVar("dirid", $dir->initid);
88  setHttpVar("sapp", $action->getParam("APPNAME", "GENERIC"));
89  setHttpVar("saction", urlencode("GENERIC_LIST&famid=$famid"));
90  setHttpVar("sid", "dirid");
91  setHttpVar("id", $dir->initid);
92  } else {
93  /*
94  * @var DocSearch $sdoc
95  */
96  $sdoc = createTmpDoc($dbaccess, 5); // new DocSearch
97  if ($dir->id == $fdoc->dfldid) {
98  $sdoc->title = sprintf(_("%s all of %s") , $tabletter[$tab], $fdoc->getHTMLTitle());
99  $sdirid = 0; // search in all DB
100 
101  } else {
102  $sdoc->title = sprintf("%s %s ", $tabletter[$tab], $dir->title);
103  $sdirid = $dir->id;
104  }
105 
106  $sdoc->setValue('se_famid', $famid);
107 
108  $sdoc->Add();
109 
110  if ($tabletter[$tab] != "") {
111  $sqlfilter[] = "title ~* '^[" . $tabletter[$tab] . "].*'";
112  }
113 
114  $only = (getInherit($action, $famid) == "N");
115 
116  $query = getSqlSearchDoc($dbaccess, $sdirid, ($only) ? -(abs($famid)) : abs($famid) , $sqlfilter);
117 
118  $sdoc->AddQuery($query);
119 
120  setHttpVar("tab", $tab);
121  if (!$emptyfld) setHttpVar("dirid", $sdoc->id);
122  setHttpVar("catg", $dirid);
123  }
124 
125  generic_list($action);
126 }
global $action
getSqlSearchDoc($dbaccess, $dirid, $fromid, $sqlfilters=array(), $distinct=false, $latest=true, $trash="", $simplesearch=false, $folderRecursiveLevel=2, $join= '', $only="")
Definition: Lib.Dir.php:108
generic_tab(Action &$action)
Definition: generic_tab.php:23
getDefFam(Action &$action)
exitError($texterr, $exit=true, $code="")
getFamIdFromName($dbaccess, $name)
new_Doc($dbaccess, $id= '', $latest=false)
$dir
Definition: resizeimg.php:144
getParam($name, $def="")
getDefU(Action &$action, $key)
generic_list(&$action)
$dbaccess
Definition: checkVault.php:17
if(($docid!==0)&&(!is_numeric($docid))) $query
getIdFromName($dbaccess, $name)
createTmpDoc($dbaccess, $fromid, $defaultvalue=true)
getInherit(Action &$action, $famid="")
if($file) if($subject==""&&$file) if($subject=="") $err
← centre documentaire © anakeen