CMS  Version 3.9
folder_select_field_renderer.inc
Go to the documentation of this file.
1 <?php
7 /**************************************************************
8 
9  Copyright (c) 2010 Sonjara, Inc
10 
11  Permission is hereby granted, free of charge, to any person
12  obtaining a copy of this software and associated documentation
13  files (the "Software"), to deal in the Software without
14  restriction, including without limitation the rights to use,
15  copy, modify, merge, publish, distribute, sublicense, and/or sell
16  copies of the Software, and to permit persons to whom the
17  Software is furnished to do so, subject to the following
18  conditions:
19 
20  The above copyright notice and this permission notice shall be
21  included in all copies or substantial portions of the Software.
22 
23  Except as contained in this notice, the name(s) of the above
24  copyright holders shall not be used in advertising or otherwise
25  to promote the sale, use or other dealings in this Software
26  without prior written authorization.
27 
28  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
29  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
30  OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
31  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
32  HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
33  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
34  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
35  OTHER DEALINGS IN THE SOFTWARE.
36 
37 *****************************************************************/
38 
39 Fakoli::usingFile("framework/field_renderers.inc");
40 
44 class FolderSelectFieldRenderer extends FieldRenderer
45 {
46  var $library;
47  var $docMgr;
48  var $tree;
49  var $field;
52 
54  {
55  global $config;
56 
57  $this->library = $library;
58  $this->docMgr = new DocumentManager($library);
59 
60  $this->tree = new DirectoryTreeControl("folder");
61  $this->tree->width = 320;
62  $this->tree->height = 150;
63  //$this->tree->onSelectionChanged = "checkFile";
64  $this->tree->permissionCallback = array($this->docMgr, folderPermission);
65 
66  $root = $this->library->getLibraryDirectory();
67 
68  $this->tree->buildFolderTree($config["uploaddir"], $root);
69 
70  $this->onPreProcess = null;
71  $this->onPostProcess = null;
72 
73  $this->FieldRenderer($form);
74  $this->field = $field;
75  if ($form->data->hasField($field))
76  {
77  $form->override($field, $label, $this);
78  }
79  else
80  {
81  $form->add($this, $field);
82  }
83  }
84 
85  function renderScript($field)
86  {
87  //Not necessary - tree control writes script automatically
88  //$this->tree->writeScript();
89  }
90 
91  function renderSearchField($field, $mode = "")
92  {
93  $this->renderField($field);
94  }
95 
96  function renderField($field = "")
97  {
98  if (!$field) $field = $this->field;
99 
100  $this->_startField($field);
101  $this->tree->writeHTML();
102  $this->_endField($field);
103  }
104 
106  {
107  //TODO: Implement this
108  }
109 
110  function preProcess($field = "")
111  {
112  if ($this->onPreProcess != null)
113  {
114  $callback = $this->onPreProcess;
115  call_user_func($callback, $this, $field);
116  }
117  }
118 
119  function postProcess($field = "")
120  {
121  if ($this->onPostProcess != null)
122  {
123  $callback = $this->onPostProcess;
124  call_user_func($callback, $this, $field);
125  }
126  }
127 }?>
$form
The DocumentManager class provides the core API and management functions for uploading documents and ...
static usingFile()
Uses the specified framework file(s) from the framework directory.
Definition: core.inc:369
Constructs a folder selection tree for the specified document library.
FolderSelectFieldRenderer(&$form, $field, $label, $library)
$root
$mode
global $config
Definition: import.inc:4
$openData field