Platform  3.1
PHP API documentation
 All Data Structures Namespaces Files Functions Variables Pages
folders.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  * Generated Header (not documented yet)
9  *
10  * @author Anakeen 2000
11  * @version $Id: folders.php,v 1.18 2005/06/28 08:37:46 eric Exp $
12  * @license http://creativecommons.org/licenses/by-nc-sa/2.0/fr/ Anakeen - licence CC
13  * @package FDL
14  * @subpackage GED
15  */
16 /**
17  */
18 // ---------------------------------------------------------------
19 // $Id: folders.php,v 1.18 2005/06/28 08:37:46 eric Exp $
20 // $Source: /home/cvsroot/anakeen/freedom/freedom/Action/Freedom/folders.php,v $
21 // ---------------------------------------------------------------
22 
23 include_once ("FDL/Lib.Dir.php");
24 include_once ("FDL/Class.QueryDir.php");
25 include_once ("FDL/freedom_util.php");
26 // -----------------------------------
27 function folders(&$action)
28 {
29  // -----------------------------------
30  global $nbfolders, $dbaccess, $pexport;
31  $nbfolders = 0;
32  // Get all the params
33  $dirid = GetHttpVars("dirid", 0); // root directory
34  $dbaccess = $action->GetParam("FREEDOM_DB");
35 
36  include_once ("FDL/popup_util.php");
37  //barmenu($action); // describe bar menu
38  $homefld = new Dir($dbaccess);
39  $homefld = $homefld->GetHome();
40 
41  $action->lay->Set("homename", $homefld->title);
42  $action->lay->Set("homeid", $homefld->id);
43 
44  $tmenuaccess = array(); // to define action an each icon
45 
46  if ($dirid == 0) $dirid = $action->getParam("ROOTFLD", getFirstDir($dbaccess));
47 
48  $doc = new_Doc($dbaccess, $dirid);
49  $action->lay->Set("dirid", $dirid);
50  $action->lay->Set("reptitle", str_replace('"', '\"', $doc->title));
51  $action->lay->Set("icon", $doc->getIcon());
52  // ------------------------------------------------------
53  // definition of popup menu
54  popupInit("popfld", array(
55  'vprop',
56  'mkdir',
57  'export',
58  'refresh',
59  'cancel'
60  ));
61  popupInit("poppaste", array(
62  'staticpaste',
63  'pastelatest',
64  'cancel2'
65  ));
66  // for the first (top) folder
67  popupActive("popfld", $nbfolders, 'cancel');
68  popupActive("popfld", $nbfolders, 'vprop');
69  // get export permission
70  $appfld = new Application();
71  $appfld->Set("FDL", $action->parent->parent);
72  $pexport = $appfld->HasPermission("EXPORT");
73 
74  if ($pexport) popupActive("popfld", $nbfolders, 'export');
75  else popupInvisible("popfld", $nbfolders, 'export');
76 
77  popupActive("popfld", $nbfolders, 'mkdir');
78  popupInvisible("popfld", $nbfolders, 'refresh');
79  popupActive("poppaste", $nbfolders, 'staticpaste');
80  popupActive("poppaste", $nbfolders, 'pastelatest');
81  popupActive("poppaste", $nbfolders, 'cancel2');
82 
83  $nbfolders++; // one for the top
84  // define icon from style
85  $iconfolder = $action->GetImageUrl("ftv2folderopen1.gif");
86  $pathicon = explode("/", $iconfolder);
87  if (count($pathicon) == 4) $action->lay->set("iconFolderPath", $pathicon[0] . "/" . $pathicon[1]);
88  else $action->lay->set("iconFolderPath", "FREEDOM");
89  // define sub trees
90  $stree = addfolder($doc, -1, "fldtop", false);
91  $action->lay->Set("subtree", $stree);
92 
93  $action->lay->Set("idHomeFolder", $nbfolders);
94 
95  $htree = addfolder($homefld, 0, "fldtop");
96  $action->lay->Set("hometree", $htree);
97  //-------------- pop-up menu ----------------
98  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/subwindow.js");
99  // display popup js
100 
101  // display popup js
102  popupGen($nbfolders);
103 }
104 // -----------------------------------
105 function addfolder($doc, $level, $treename, $thisfld = true)
106 {
107  // -----------------------------------
108  global $dbaccess;
109  global $tmenuaccess;
110  global $nbfolders;
111  global $action;
112  global $pexport;
113 
114  if ($thisfld) {
115  if ($level == 0) $levelp = "";
116  else $levelp = $level - 1;
117  if ($doc->owner < 0) $ftype = 3;
118  else if ($doc->id == 14) $ftype = 5;
119  else if ($doc->doctype == 'D') $ftype = 1;
120  else if ($doc->doctype == 'S') $ftype = 2;
121 
122  $hasChild = 'false';
123  // if ($doc->doctype != 'S') {
124  // no child for a search
125  if (hasChildFld($dbaccess, $doc->initid, ($doc->doctype == 'S'))) $hasChild = 'true';
126  //}
127  $ftype = $doc->getIcon();
128  $ltree = "$treename$level = insFld(" . $treename . $levelp . ", gFld(\"" . str_replace('"', '\"', $doc->title) . "\", \"#\"," . $doc->initid . ",\"$ftype\", $hasChild))\n";
129 
130  popupActive("popfld", $nbfolders, 'cancel');
131  popupActive("popfld", $nbfolders, 'vprop');
132  if ($pexport) popupActive("popfld", $nbfolders, 'export');
133  else popupInvisible("popfld", $nbfolders, 'export');
134  if ($doc->doctype == 'D') {
135  popupActive("popfld", $nbfolders, 'mkdir');
136  popupActive("popfld", $nbfolders, 'refresh');
137  } else {
138  popupInvisible("popfld", $nbfolders, 'mkdir');
139  popupInvisible("popfld", $nbfolders, 'refresh');
140  }
141  popupActive("poppaste", $nbfolders, 'staticpaste');
142  popupActive("poppaste", $nbfolders, 'pastelatest');
143  popupActive("poppaste", $nbfolders, 'cancel2');
144  $nbfolders++;
145  } else $ltree = "";
146  if ($doc->doctype == 'D') {
147 
148  if ($level < 0) {
149  $ldir = getChildDir($dbaccess, $action->user->id, $doc->id);
150 
151  if (count($ldir) > 0) {
152 
153  while (list($k, $v) = each($ldir)) {
154  $ltree.= addfolder($v, $level + 1, $treename);
155  }
156  }
157  }
158  }
159  return $ltree;
160 }
161 ?>
← centre documentaire © anakeen - published under CC License - Dynacase