Core  3.2
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  * @package FDL
5 */
6 /**
7  * Generated Header (not documented yet)
8  *
9  * @author Anakeen
10  * @version $Id: folders.php,v 1.18 2005/06/28 08:37:46 eric Exp $
11  * @package FDL
12  * @subpackage GED
13  */
14 /**
15  */
16 // ---------------------------------------------------------------
17 // $Id: folders.php,v 1.18 2005/06/28 08:37:46 eric Exp $
18 // $Source: /home/cvsroot/anakeen/freedom/freedom/Action/Freedom/folders.php,v $
19 // ---------------------------------------------------------------
20 include_once ("FDL/Lib.Dir.php");
21 include_once ("FDL/Class.QueryDir.php");
22 include_once ("FDL/freedom_util.php");
23 // -----------------------------------
24 function folders(Action & $action)
25 {
26  // -----------------------------------
27  global $nbfolders, $dbaccess, $pexport;
28  $nbfolders = 0;
29  // Get all the params
30  $dirid = GetHttpVars("dirid", 0); // root directory
31  $dbaccess = $action->dbaccess;
32 
33  include_once ("FDL/popup_util.php");
34  //barmenu($action); // describe bar menu
35  $homefld = new Dir($dbaccess);
36  $homefld = $homefld->GetHome();
37 
38  if ($dirid == 0) $dirid = $action->getParam("ROOTFLD", getFirstDir($dbaccess));
39 
40  $doc = new_Doc($dbaccess, $dirid);
41  $action->lay->rSet("dirid", urlencode($doc->id));
42  $action->lay->rSet("reptitle", json_encode(sprintf("<i>%s</i>", $doc->getHTMLTitle())));
43  $action->lay->rSet("icon", json_encode($doc->getIcon()));
44  // ------------------------------------------------------
45  // definition of popup menu
46  popupInit("popfld", array(
47  'vprop',
48  'mkdir',
49  'export',
50  'refresh',
51  'cancel'
52  ));
53  popupInit("poppaste", array(
54  'staticpaste',
55  'pastelatest',
56  'cancel2'
57  ));
58  // for the first (top) folder
59  popupActive("popfld", $nbfolders, 'cancel');
60  popupActive("popfld", $nbfolders, 'vprop');
61  // get export permission
62  $appfld = new Application();
63  $appfld->Set("FDL", $action->parent->parent);
64  $pexport = $appfld->HasPermission("EXPORT");
65 
66  if ($pexport) popupActive("popfld", $nbfolders, 'export');
67  else popupInvisible("popfld", $nbfolders, 'export');
68 
69  popupActive("popfld", $nbfolders, 'mkdir');
70  popupInvisible("popfld", $nbfolders, 'refresh');
71  popupActive("poppaste", $nbfolders, 'staticpaste');
72  popupActive("poppaste", $nbfolders, 'pastelatest');
73  popupActive("poppaste", $nbfolders, 'cancel2');
74 
75  $nbfolders++; // one for the top
76  // define icon from style
77  $iconfolder = $action->parent->getImageLink("ftv2folderopen1.gif");
78  $pathicon = explode("/", $iconfolder);
79  if (count($pathicon) == 4) $action->lay->rSet("iconFolderPath", json_encode($pathicon[0] . "/" . $pathicon[1]));
80  else $action->lay->rSet("iconFolderPath", json_encode("FREEDOM"));
81  // define sub trees
82  $stree = addfolder($doc, -1, "fldtop", false);
83  $action->lay->rSet("subtree", $stree);
84 
85  $action->lay->rSet("idHomeFolder", (int)$nbfolders);
86 
87  $htree = addfolder($homefld, 0, "fldtop");
88  $action->lay->rSet("hometree", $htree);
89  //-------------- pop-up menu ----------------
90  $action->parent->AddJsRef($action->GetParam("CORE_JSURL") . "/subwindow.js");
91  // display popup js
92  // display popup js
93  popupGen($nbfolders);
94 }
95 // -----------------------------------
96 function addfolder(Doc $doc, $level, $treename, $thisfld = true)
97 {
98  // -----------------------------------
99  global $dbaccess;
100  global $tmenuaccess;
101  global $nbfolders;
102  global $action;
103  global $pexport;
104 
105  if ($thisfld) {
106  if ($level == 0) $levelp = "";
107  else $levelp = $level - 1;
108  if ($doc->owner < 0) $ftype = 3;
109  else if ($doc->id == 14) $ftype = 5;
110  else if ($doc->doctype == 'D') $ftype = 1;
111  else if ($doc->doctype == 'S') $ftype = 2;
112 
113  $hasChild = false;
114  // if ($doc->doctype != 'S') {
115  // no child for a search
116  if (hasChildFld($dbaccess, $doc->initid, ($doc->doctype == 'S'))) $hasChild = true;
117  //}
118  $ftype = $doc->getIcon();
119  $ltree = sprintf("%s%s = insFld(%s, gFld(%s, \"#\", %d, %s, %s))\n", $treename, $level, $treename . $levelp, json_encode($doc->getHTMLTitle()) , $doc->initid, json_encode($ftype) , ($hasChild ? 'true' : 'false'));
120 
121  popupActive("popfld", $nbfolders, 'cancel');
122  popupActive("popfld", $nbfolders, 'vprop');
123  if ($pexport) popupActive("popfld", $nbfolders, 'export');
124  else popupInvisible("popfld", $nbfolders, 'export');
125  if ($doc->doctype == 'D') {
126  popupActive("popfld", $nbfolders, 'mkdir');
127  popupActive("popfld", $nbfolders, 'refresh');
128  } else {
129  popupInvisible("popfld", $nbfolders, 'mkdir');
130  popupInvisible("popfld", $nbfolders, 'refresh');
131  }
132  popupActive("poppaste", $nbfolders, 'staticpaste');
133  popupActive("poppaste", $nbfolders, 'pastelatest');
134  popupActive("poppaste", $nbfolders, 'cancel2');
135  $nbfolders++;
136  } else $ltree = "";
137  if ($doc->doctype == 'D') {
138 
139  if ($level < 0) {
140  $ldir = getChildDir($dbaccess, $action->user->id, $doc->id);
141 
142  if (count($ldir) > 0) {
143 
144  foreach ($ldir as $k => $v) {
145  $ltree.= addfolder($v, $level + 1, $treename);
146  }
147  }
148  }
149  }
150  return $ltree;
151 }
folders(Action &$action)
Definition: folders.php:24
global $action
$ldir
Definition: resizeimg.php:145
addfolder(Doc $doc, $level, $treename, $thisfld=true)
Definition: folders.php:96
getIcon($idicon="", $size=null, $otherId=null)
Definition: Class.Doc.php:5817
getFirstDir($dbaccess)
Definition: Lib.Dir.php:22
getChildDir($dbaccess, $userid, $dirid, $notfldsearch=false, $restype="LIST")
Definition: Lib.Dir.php:38
hasChildFld($dbaccess, $dirid, $issearch=false)
Definition: Lib.Dir.php:862
getHTMLTitle($id="-1", $def="", $latest=false)
Definition: Class.Doc.php:8754
new_Doc($dbaccess, $id= '', $latest=false)
getParam($name, $def="")
$dbaccess
Definition: checkVault.php:17
← centre documentaire © anakeen