CMS  Version 3.9
document_view.inc
Go to the documentation of this file.
1 <?php
7 Fakoli::using("document");
8 Fakoli::usingFeature("facet_manager");
9 
11 {
12  var $mgr;
13  var $library;
14  var $table;
16 
17  function __construct($mgr)
18  {
19  $this->mgr = $mgr;
20  $this->library = $mgr->library;
21  $this->table = $this->buildDocumentTable();
22 
23  $this->facetManager = new FacetManager('facet_manager', $this->table);
24  TaxonomyManager::addFacets($this->facetManager, Document, true, "160px", "200px", "200px");
25 
26  if (Settings::getValue("document", "show_upload_details"))
27  {
28  $this->facetManager->addFacet("Uploaded By", $this->createUploadedByFacet());
29  }
30  }
31 
32  function buildDocumentTable()
33  {
34  $showUploadDetails = Settings::getValue("document", "show_upload_details");
35 
36  $docWidth = $showUploadDetails ? "40%" : "80%";
37 
38  $table = new DataListView($this->mgr->documents, "document_library");
39  $table->column("Document", array($this, formatDocumentTitle), true, "width: {$docWidth}", String, null, "{title:lower}")
40  ->column("Author", "{author}", true, "width: 20%");
41 
42  if ($showUploadDetails)
43  {
44  $table->column("Uploaded By", "{Owner.first_name} {Owner.last_name}", false, "width: 20%; text-align: center")
45  ->column("Last Modified", "{last_modified:short}", false, "width: 30%; text-align: center");
46  }
47 
48  $table->pageSize = 10;
49  $table->emptyMessage = "There are no matching documents";
50  $table->sortable = true;
51  $table->filter = Settings::getValue("document", "show_table_filter") ? true : false;
52 
53  $table->writeIdTag = true;
54 
55  return $table;
56  }
57 
59  {
60  $file = $document->file;
61 
62  $type = getDocType($file);
63  $icon = getDocIcon($file);
64 
65  $size = $this->library->getFileSize($document);
66 
67  if(checkRole($this->library->upload_files))
68  {
69  $details_icon = "icon_edit.png";
70  $fn = "editDocumentDetailsDialog";
71  }
72  else
73  {
74  $details_icon = "icon_view.png";
75  $fn = "showDocumentDetailsDialog";
76  }
77 
78  $titleText = Settings::getValue("document", "link_to_details") ? "<a class='document_title' href='document_details?document_id={document_id}'>{title}</a>" :
79  "<span class='document_title'>{title}</span>";
80 
81  $details_link = "<a href=\"edit_document?document_id={document_id}\" onclick=\"documentMgr.{$fn}({document_id}); return false;\"><img src=\"/fakoli/images/{$details_icon}\" style=\"border: none;display: inline-block;vertical-align: middle;padding-right: 4px\"></a>\n";
82 
83  if(checkRole($this->library->delete_files))
84  {
85  $delete_link .= "<a href=\"delete_document?document_id={document_id}\" onclick=\"documentMgr.deleteFile({document_id}); return false;\"><img alt=\"delete\" src=\"/fakoli/images/icon_delete_trash.png\"></a>\n";
86  }
87 
88  return $document->format("$titleText<br/><img style='display:inline-block;vertical-align: middle' src='$icon' alt='$type'/> <a href='/action/document/download?document_id={document_id}'>Download</a>&nbsp;$size&nbsp;<span style='display: inline-block'>&nbsp;{$details_link}&nbsp;{$delete_link}</span>");
89  }
90 
91  function writeScript()
92  {
93  $script .= $this->facetManager->writeScript();
94  $script .= $this->table->writeScript();
95 
96  ob_start();
97  ?>
98  <script type="text/javascript" src="/components/document/js/document_manager.js"></script>
99  <script type="text/javascript">
100  var documentMgr;
101 
102  window.addEvent('domready', function()
103  {
104  documentMgr = new DocumentManager(<?php echo $this->library->document_library_id ?>);
105  });
106 
107  // For compatibility with tree view - this function called from edit.inc
108  function editResult(result)
109  {
110  documentMgr.editResult(result);
111  }
112 
113  // For compatibility with tree view - this function called from upload.inc
114  function uploadResult(responseText)
115  {
116  documentMgr.uploadResult(responseText);
117  }
118  </script>
119  <?
120  $script .= ob_get_contents();
121  ob_end_clean();
122 
123  return $script;
124  }
125 
126  function drawView()
127  {
128  $this->facetManager->drawForm();
129  $this->table->drawView();
130 
131  $this->drawButtons();
132  }
133 
134  function drawButtons()
135  {
136  if(!checkRole("admin") && !checkRole($this->library->upload_files))
137  {
138  return;
139  }
140 
141  echo "<div id='document_library_button_row'>\n";
142  if (checkRole($this->library->upload_files))
143  {
144  echo "<button id='upload' class='button' onclick='documentMgr.uploadFile()'>Upload a File...</button>\n";
145  }
146 
147  if (checkRole("admin"))
148  {
149  echo "<button id='rescan' class='button' onclick='documentMgr.rescanLibrary()'>Rescan</button>\n";
150  }
151 
152  echo "</div>\n";
153  }
154 
156  {
157  $facet = new MultiSelectFacetFilter("owner_id", array(Document => "{Owner.first_name} {Owner.last_name}"));
158 
159  $facet->dropdownMaxWidth = "160px";
160  $facet->width = "200px";
161  $facet->height = "240px";
162 
163  return $facet;
164  }
165 
166 }
167 
169 {
170  var $table;
171 
173  {
174  $this->table = $this->buildTable($libraries);
175  }
176 
178  {
179  $table = new DataListView($libraries, "libraries");
180  $table->column("Library", array($this, formatTitleLink), true, "width: 50%")
181  ->column("Identifier", "{identifier}", true, "width: 15%")
182  ->column("Owner", "{getOwnerName()}", true, "width: 20%")
183  ->column("# Docs", "{countDocuments()}", true, "width: 15%;text-align: right");
184 
185  $table->sortable = true;
186  $table->filter = true;
187  $table->pageSize = 10;
188  $table->emptyMessage = "No Document Libraries have been created.";
189 
190  return $table;
191  }
192 
194  {
195  return $library->format("<a href='document_library_form?document_library_id={document_library_id}'>{name}</a>{description}");
196  }
197 
198  function writeScript()
199  {
200  return $this->table->writeScript();
201  }
202 
203  function drawView()
204  {
205  $this->table->drawView();
206  }
207 }
208 
210 {
212  {
213  parent::DocumentLibraryListView($libraries);
214  }
215 
217  {
218  return $library->format("<a href='/admin/document_library_form?document_library_id={document_library_id}'>{name}</a>{description}");
219  }
220 
221 }?>
if(! $document_library_id) $library
$file
Definition: delete.inc:47
$size
Definition: download.inc:47
$icon
Definition: upload.inc:92
AdminDocumentLibraryListView($libraries)
This class maps the publication table.
Definition: document.inc:43
DocumentLibraryListView($libraries)
formatDocumentTitle($document)
The DocumentManager class provides the core API and management functions for uploading documents and ...
static usingFeature()
Uses the specified framework feature(s).
Definition: core.inc:388
static using()
Import the datamodels, views and manifest for the specified component(s).
Definition: core.inc:116
static getValue($component, $name)
Retrieve the value of the specified Setting.
Definition: settings.inc:104
static addFacets($manager, $classes, $dropdown=true, $max_width="200px", $width="200px", $height="120px")
if(! $document_id) $document
Definition: delete.inc:43
$table column("Redirect From", "<a href='redirect_form?redirect_id={redirect_id}'>{redirect_from}</a>", true, "width: 30%") -> column("Redirect To", "<a href='{redirect_to}' target='_blank'>{redirect_to}</a>", true, "width: 30%") ->column("Last Modified", "{last_modified}", true, "width: 20%; text-align: center") ->column("Override", "{ override true
Definition: redirects.inc:9