CMS  Version 3.9
link_library_view.inc
Go to the documentation of this file.
1 <?php
9 {
10  var $table;
11 
13  {
14  $this->table = $this->buildTable($libraries);
15  }
16 
18  {
19  $table = new DataListView($libraries, "libraries");
20  $table->column("Library", array($this, formatTitleLink), true, "width: 55%")
21  ->column("Owner", "{getOwnerName()}", true, "width: 30%")
22  ->column("# Links", "{countLinks()}", true, "width: 15%;text-align: right");
23 
24  $table->sortable = true;
25  $table->filter = true;
26  $table->pageSize = 10;
27  $table->emptyMessage = "No Link Libraries have been created.";
28 
29  return $table;
30  }
31 
33  {
34  return $library->format("<a href='/link_library_form?link_library_id={link_library_id}'>{name}</a>{description}");
35  }
36 
37  function writeScript()
38  {
39  return $this->table->writeScript();
40  }
41 
42  function drawView()
43  {
44  $this->table->drawView();
45  }
46 }
47 
49 {
51  {
52  parent::LinkLibraryListView($libraries);
53  }
54 
56  {
57  return $library->format("<a href='/admin/link_library_form?link_library_id={link_library_id}'>{name}</a>{description}");
58  }
59 
60 }
61 
62 
63 
64 abstract class LinkLibraryView
65 {
66  var $library;
67  var $view;
68 
70  {
71  $this->library = $library;
72  $this->links = $this->library->Links("WHERE published=1 ORDER BY sort_order, title, url");
73  $this->view = $this->buildView();
74 
75  $this->facetManager = new FacetManager('facet_manager', $this->view);
76  TaxonomyManager::addFacets($this->facetManager, LinkRecord, true, "160px", "200px", "200px");
77  }
78 
79  static function create($library)
80  {
81  $format = Settings::getValue("link_library", "display_format");
82 
83  switch($format)
84  {
85  case "Tabular":
86  return new TabularLinkLibraryView($library);
87 
88  default:
89  return new ListLinkLibraryView($library);
90  }
91  }
92 
93  abstract function buildView();
94 
95  abstract function drawView();
96 }
97 
98 
100 {
102  {
103  parent::__construct($library);
104  }
105 
106  function buildView()
107  {
108  $table = new DataListView($this->links, "library_link_list");
109  $table->column("Link", array($this, formatLinkTitle), true, "width: 40%", String, null, "{title:lower}")
110  ->column("Description", "{description}", true, "width: 40%");
111  // ->column("Last Modified", "{last_modified:short}", false, "width: 20%; text-align: center"); fk:
112 
113  $table->pageSize = 10;
114  $table->emptyMessage = "No links have been added to this library.";
115  $table->sortable = true;
116  $table->filter = false;
117 
118  $table->writeIdTag = true;
119 
120  return $table;
121  }
122 
124  {
125  if(checkRole($this->library->write_access))
126  {
127  $details_icon = "icon_edit.png";
128  $fn = "LinkLibraryManager.editLink";
129  $details_link = "<a href=\"#\" onclick=\"LinkLibraryManager.editLink({link_id}); return false;\"><img src=\"/fakoli/images/{$details_icon}\" style=\"border: none;display: inline-block;vertical-align: middle;padding-right: 4px\"></a>\n";
130  }
131 
132  if(checkRole($this->library->write_access))
133  {
134  $delete_link .= "<a href=\"#\" onclick=\"LinkLibraryManager.deleteLink({link_id}); return false;\"><img alt=\"delete\" src=\"/fakoli/images/icon_delete_trash.png\"></a>\n";
135  }
136 
137  return $link->format("<span class='document_title'>{title}</span><br/><img style='display:inline-block;vertical-align: middle' src='/fakoli/images/file_icon.png' alt='External Link'/> <a target = '_new' href='{url}'> View Web Page </a><span style='display: inline-block'>&nbsp;{$details_link}&nbsp;{$delete_link}</span>");
138  }
139 
140  function drawView()
141  {
142  global $script;
143 
144  $script .= $this->facetManager->writeScript();
145  $script .= $this->view->writeScript();
146 
147  $this->facetManager->drawForm();
148  $this->view->drawView();
149 
150  $this->drawButtons();
151  }
152 
153  function drawButtons()
154  {
155  if(!checkRole("admin") && !checkRole($this->library->upload_files))
156  {
157  return;
158  }
159 
160  echo "<div id='document_library_button_row'>\n";
161  if (checkRole($this->library->upload_files))
162  {
163  echo "<button id='upload' class='button' onclick='LinkLibraryManager.addLink({$this->library->link_library_id});'>Add a Link...</button>\n";
164  }
165 
166  echo "</div>\n";
167  }
168 }
169 
171 {
173  {
174  parent::__construct($library);
175  }
176 
177  function buildView()
178  {
179  $list = new PagedList($this->links, "library_links", "{LinkLibraryManager::formatLink}");
180  $list->pageSize = 20;
181  $list->emptyList = "No links have been added to this library";
182 
183  return $list;
184  }
185 
186  function drawView()
187  {
188  global $script;
189 
190  $script .= $this->view->writeScript();
191  $this->view->drawList();
192  }
193 }
194 ?>
if(! $document_library_id) $library
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")
$list
Definition: list_images.inc:41