17 require_once
"GENERIC/generic_util.php";
18 require_once
"FDL/Lib.Attr.php";
27 $dbaccess = $action->dbaccess;
31 $defaultMenu = array();
35 $fld =
new_Doc($dbaccess, $catg);
41 if ($fld->isAlive()) {
42 $sfamid = $fld->getRawValue(
"se_famid");
43 if ($sfamid && $sfamid != $fdoc->id) {
44 $sfdoc =
new_Doc($dbaccess, $sfamid);
45 if (!$sfdoc->isAlive()) {
51 $defaultMenuCreate = array();
52 if (($fdoc->control(
"create") ==
"") && ($fdoc->control(
"icreate") ==
"")) {
54 "title" => $fdoc->getTitle() ,
64 $child+= $fdoc->GetChildFam($fdoc->id,
true);
67 if ($action->HasPermission(
"GENERIC")) {
68 foreach ($child as $vid) {
69 $defaultMenuCreate[] = array(
72 "url" => sprintf(
"?app=GENERIC&action=GENERIC_EDIT&classid=%s", $vid[
"id"])
76 if (count($defaultMenuCreate)) {
77 $defaultMenu[
"create"] = array(
78 "label" => _(
"Creation") ,
79 "title" => _(
"Document creation") ,
80 "items" => $defaultMenuCreate
84 $lattr = $sfdoc->getNormalAttributes();
88 foreach ($lattr as
$a) {
89 if ((($a->type ==
"enum") || ($a->type ==
"enumlist")) && (($a->phpfile !=
"-") && ($a->getOption(
"bmenu") !=
"no"))) {
91 $enum = $a->getenum();
93 foreach ($enum as $kk => $ki) {
94 $klabel = $a->getenumLabel($kk);
95 $tmpArray = explode(
'/', $klabel, substr_count($kk,
'.') + 0);
96 $klabel = array_pop($tmpArray);
99 "data-level" => (substr_count($kk,
'.') - substr_count($kk,
'\.')) ,
100 "href" => sprintf(
"?app=GENERIC&action=GENERIC_SEARCH_KIND&onefam=%s&famid=%s&kid=%s&aid=%s&catg=%s%s", $onefamOrigin,
$famid, urlencode($kk) , $a->id, $catg, $pds)
102 $tmkind[] = $a->id . $kk;
104 $defaultMenu[$a->id] = array(
105 "title" => sprintf(_(
"Filter on %s") , $a->getLabel()) ,
106 "label" => $a->getLabel() ,
107 "items" => $enumItems
112 $toolsItemMenu = array();
113 if (empty($onefamOrigin) && $action->HasPermission(
"GENERIC")) {
114 $d = new_doc($dbaccess, 16);
115 if (
$d->control(
"create") ==
"" &&
$d->control(
"icreate") ==
"") {
116 $toolsItemMenu[
'newsearch'] = array(
117 "label" => _(
"New search") ,
119 "url" => sprintf(
'?app=GENERIC&action=GENERIC_EDIT&se_memo=yes&classid=16&onlysubfam=%s&sfamid=%s',
$famid,
$famid)
123 $d = new_doc($dbaccess, 25);
124 if (
$d->control(
"create") ==
"" &&
$d->control(
"icreate") ==
"") {
125 $toolsItemMenu[
'newreport'] = array(
126 "label" => _(
"New report") ,
128 "url" => sprintf(
'?app=GENERIC&action=GENERIC_EDIT&se_memo=yes&classid=25&onlysubfam=%s&sfamid=%s',
$famid,
$famid)
133 if (empty($onefamOrigin) && (
$dirid < 1000000000) && ($catg > 1)) {
134 $toolsItemMenu[
'memosearch'] = array(
135 "label" => _(
"memosearch") ,
136 "target" =>
"fhidden",
137 "url" => sprintf(
'?app=GENERIC&action=GENERIC_MEMOSEARCH&famid=%s&
138 psearchid=%s',
$famid, $catg)
142 if (empty($onefamOrigin)) {
143 $toolsItemMenu[
'viewsearch'] = array(
144 "label" => _(
"View my searches") ,
145 "target" =>
"_overlay",
146 "url" => sprintf(
'?app=GENERIC&action=GENERIC_SEARCH&catg=0&onefam=%s&mysearches=yes&famid=%s', $onefamOrigin,
$famid)
149 $toolsItemMenu[
'viewsearch'] = array(
150 "label" => _(
"Handle my searches") ,
151 "target" =>
"_overlay",
152 "url" => sprintf(
'?app=%s&action=ONEFAM_MANAGE_SEARCH&famId=%s', $onefamOrigin,
$famid)
156 if (empty($onefamOrigin) && $action->HasPermission(
"GED",
"FREEDOM")) {
157 $toolsItemMenu[
'folders'] = array(
158 "label" => _(
"folders") ,
159 "target" =>
"freedom$famid",
160 "url" => sprintf(
'?app=FREEDOM&action=FREEDOM_FRAME&dirid=%s&famid=%s',
getDefFld($action) ,
$famid)
164 $toolsItemMenu[
'prefs'] = array(
165 "label" => _(
"Preferences") ,
167 "url" => sprintf(
'?app=GENERIC&action=GENERIC_PREFS&dirid=%s&famid=%s&onefam=%s',
getDefFld($action) ,
$famid, $onefamOrigin)
170 $lmenu = $fdoc->GetMenuAttributes();
171 $firstGlobalMenu =
true;
172 foreach ($lmenu as $k => $v) {
173 if ($v->getOption(
"global") ==
"yes") {
174 $confirm = ($v->getOption(
"lconfirm") ==
"yes");
177 if ($v->precond !=
"") $vis = $fdoc->ApplyMethod($v->precond,
MENU_ACTIVE);
181 if ($firstGlobalMenu) {
182 $toolsItemMenu[
'family'] = array(
183 "label" => sprintf(
"%s", $fdoc->getHTMLTitle()) ,
184 "class" =>
"ui-widget-header"
186 $firstGlobalMenu =
false;
190 $textConfirm = $v->getOption(
"tconfirm");
191 if (!$textConfirm) $textConfirm = sprintf(_(
"Sure %s ?") , addslashes($v->getLabel()));
193 $toolsItemMenu[$v->id] = array(
194 "label" => $v->getLabel() ,
195 "target" => $v->getOption(
"mtarget", $v->getoption(
'ltarget', $v->id)) ,
196 "confirm" => $textConfirm,
197 "url" => $fdoc->urlWhatEncode($v->link)
207 "satitle" => _(
"no sort") ,
213 $props = $sfdoc->getSortProperties();
214 foreach ($props as $propName => $config) {
215 if ($config[
'sort'] !=
'asc' && $config[
'sort'] !=
'desc') {
220 if ($sfdoc->wid > 0) {
221 $tsort[
"state"] = array(
223 "satitle" => _(
"state") ,
230 $tsort[
"title"] = array(
232 "satitle" => _(
"doctitle") ,
238 $tsort[
"initid"] = array(
240 "satitle" => _(
"createdate") ,
250 $tsort[$propName] = array(
258 foreach ($tsort as $k => $v) {
259 $tmsort[$v[
"said"]] =
"sortdoc" . $v[
"said"];
261 $lattr = $sfdoc->GetSortAttributes();
262 foreach ($lattr as $k => $a) {
265 if ($pType[
'type'] ==
'docid') {
266 $doctitleAttr = $a->getOption(
'doctitle');
267 if ($doctitleAttr !=
'') {
271 $sortAttribute =
false;
272 if ($doctitleAttr ==
'auto') {
273 $sortAttribute = $sfdoc->getAttribute(sprintf(
"%s_title", $a->id));
275 $sortAttribute = $sfdoc->getAttribute($doctitleAttr);
277 if ($sortAttribute ===
false) {
278 $action->log->
error(sprintf(
"Could not find doctitle attribute '%s' for attribute '%s'", $doctitleAttr, $a->id));
281 $tsort[$sortAttribute->id] = array(
282 "said" => $sortAttribute->id,
283 "satitle" => $a->getLabel() ,
284 "aorder" =>
getAttributeOrder($action, $sortAttribute->id, $sortAttribute->getOption(
'sortable'))
286 $tmsort[$sortAttribute->id] =
"sortdoc" . $sortAttribute->id;
291 $tsort[$a->id] = array(
293 "satitle" => $a->getLabel() ,
296 $tmsort[$a->id] =
"sortdoc" . $a->id;
300 if ($csort ==
"") $csort =
getDefUSort($action,
"--");
302 if (($csort ==
'') || ($csort ==
'--')) {
305 }
else if ($csort[0] ==
'-') {
306 $csort = substr($csort, 1);
312 $sortTitle = _(
"Sort");
313 $sortItemMenu = array();
314 foreach ($tsort as $k => $v) {
315 $dsort = ($csort == $k) ? $cselect :
" ";
316 if ($csort == $k) $sortTitle = $v[
"satitle"] . $cselect;
317 $sortItemMenu[] = array(
318 "label" => $dsort .
' ' . $v[
"satitle"],
319 "href" => sprintf(
"javascript:sendSort('%s','%s','%s','%s','%s')", $onefamOrigin,
$dirid, $catg,
$famid, $v[
"aorder"])
322 $defaultMenu[
"sort"] = array(
323 "title" => _(
"Sort") ,
324 "label" => $sortTitle,
325 "items" => $sortItemMenu
327 $defaultMenu[
"tools"] = array(
328 "label" => _(
"Tools") ,
329 "items" => $toolsItemMenu
336 if ($usort !=
"__UNDEFINED") {
340 if ((!empty($usort)) && $usort[0] ==
"-") {
341 $invertedSortSign =
"";
342 $sortAttr = substr($usort, 1);
344 $invertedSortSign =
"-";
352 if ($sortAttr == $attrName) {
353 return $invertedSortSign . $attrName;
360 if ($orderBy ===
'desc') {
361 return "-" . $attrName;
print< H1 > Check Database< i > $dbaccess</i ></H1 > $a
getDefUSort(Action &$action, $def="-revdate", $famid="")
getDefFld(Action &$action)
getDefFam(Action &$action)
new_Doc($dbaccess, $id= '', $latest=false)
static getLangTitle($values)
static getArgument($k, $def= '')
getInherit(Action &$action, $famid="")