Platform
3.1
PHP API documentation
Main Page
Related Pages
Namespaces
Data Structures
Files
File List
Globals
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
* @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
5
* @package FDL
6
*/
7
/**
8
* List document of a category
9
*
10
* @author Anakeen 2000
11
* @version $Id: generic_tab.php,v 1.29 2008/02/20 16:55:05 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/Class.DocSearch.php"
);
20
include_once (
"FDL/Lib.Dir.php"
);
21
22
include_once (
"FDL/freedom_util.php"
);
23
include_once (
"GENERIC/generic_util.php"
);
24
include_once (
"GENERIC/generic_list.php"
);
25
// -----------------------------------
26
function
generic_tab
(&
$action
)
27
{
28
// Get all the params
29
$keyword
=
GetHttpVars
(
"keyword"
);
// keyword to search
30
$dirid =
GetHttpVars
(
"catg"
, -1);
// folder where search
31
$tab =
GetHttpVars
(
"tab"
, 1);
// tab index
32
$dbaccess
=
$action
->GetParam(
"FREEDOM_DB"
);
33
34
$famid
=
getDefFam
(
$action
);
35
$emptyfld =
false
;
36
if
(
$famid
==
"0"
)
$action
->exitError(_(
"cookies seem to be blocked"
));
37
if
((
$famid
!=
""
) && (!is_numeric(
$famid
)))
$famid
=
getFamIdFromName
(
$dbaccess
,
$famid
);
38
39
$fdoc
=
new
DocFam
(
$dbaccess
,
$famid
);
40
41
if
($dirid == - 1) $dirid =
$fdoc
->dfldid;
42
if
($dirid == 0) {
43
$dirid =
getDefU
(
$action
,
"GENE_PREFSEARCH"
);
44
if
(!is_numeric($dirid)) {
45
$dirid =
getIdFromName
(
$action
->getParam(
'FREEDOM_DB'
) , $dirid);
46
}
47
}
48
if
($dirid == 0) {
49
if
(
$fdoc
->cfldid > 0) {
50
$dirid =
$fdoc
->cfldid;
51
}
else
{
52
$dirid =
$fdoc
->dfldid;
53
}
54
}
55
// hightlight the selected part (ABC, DEF, ...)
56
$tabletter = array(
57
""
,
58
"ABC"
,
59
"DEF"
,
60
"GHI"
,
61
"JKL"
,
62
"MNO"
,
63
"PQRS"
,
64
"TUV"
,
65
"WXYZ"
66
);
67
68
$dir
=
new_Doc
(
$dbaccess
, $dirid);
69
// control open
70
if
(
$dir
->defDoctype ==
'S'
) $aclctrl =
"execute"
;
71
else
$aclctrl =
"open"
;
72
if
((
$err
=
$dir
->Control($aclctrl)) !=
""
)
$action
->exitError(
$err
);
73
74
if
((
$dir
->defDoctype ==
'S'
) && ($tab == 0)) {
75
// parmeters for redirect in case of parametrizable search
76
setHttpVar(
"dirid"
,
$dir
->initid);
77
setHttpVar(
"sapp"
,
$action
->getParam(
"APPNAME"
,
"GENERIC"
));
78
setHttpVar(
"saction"
, urlencode(
"GENERIC_LIST&famid=$famid"
));
79
setHttpVar(
"sid"
,
"dirid"
);
80
setHttpVar(
"id"
,
$dir
->initid);
81
}
else
{
82
$sdoc =
createTmpDoc
(
$dbaccess
, 5);
// new DocSearch
83
if
(
$dir
->id ==
$fdoc
->dfldid) {
84
$sdoc->title = sprintf(_(
"%s all "
) , $tabletter[$tab]);
85
$sdirid = 0;
// search in all DB
86
87
}
else
{
88
$sdoc->title = sprintf(
"%s %s "
, $tabletter[$tab],
$dir
->title);
89
$sdirid =
$dir
->id;
90
}
91
92
$sdoc->setValue(
'se_famid'
,
$famid
);
93
94
$sdoc->Add();
95
// $sqlfilter[]= "locked != -1";
96
$wkdoc =
createDoc
(
$dbaccess
,
$famid
,
false
);
97
// $sqlfilter[]= "doctype='".$wkdoc->defDoctype."'";
98
// $sqlfilter[] = "usefor != 'D'";
99
if
($tabletter[$tab] !=
""
) $sqlfilter[] =
"title ~* '^["
. $tabletter[$tab] .
"].*'"
;
100
101
$only = (
getInherit
(
$action
,
$famid
) ==
"N"
);
102
103
$query
=
getSqlSearchDoc
(
$dbaccess
, $sdirid, ($only) ? -(abs(
$famid
)) : abs(
$famid
) , $sqlfilter);
104
105
$sdoc->AddQuery(
$query
);
106
107
setHttpVar(
"tab"
, $tab);
108
if
(!$emptyfld) setHttpVar(
"dirid"
, $sdoc->id);
109
setHttpVar(
"catg"
, $dirid);
110
}
111
112
generic_list
(
$action
);
113
// redirect($action,GetHttpVars("app"),"GENERIC_LIST&tab=$tab&dirid=".$sdoc->id."&catg=$dirid");
114
115
116
}
117
?>
← centre documentaire
© anakeen
- published under
CC License
-
Dynacase