CMS  Version 3.9
ComponentPageListView Class Reference

Public Member Functions

 ComponentPageListView ($component=null)
 
 formatComponent ($page)
 
 formatEnabled ($page)
 
 formatTemplate ($page)
 
 formatRole ($page)
 
 writeScript ()
 
 drawView ()
 
 readTemplates ()
 

Public Attributes

 $table
 
 $pages
 
 $templates
 

Detailed Description

Definition at line 41 of file component_page_list.inc.

Member Function Documentation

◆ ComponentPageListView()

ComponentPageListView::ComponentPageListView (   $component = null)

Definition at line 47 of file component_page_list.inc.

48  {
49  if ($component)
50  {
51  $this->pages = $component->ComponentPages();
52  }
53  else
54  {
55  $this->pages = Query::create(ComponentPage, "ORDER BY component, identifier")->execute();
56  }
57 
58  $this->table = new DataListView($this->pages, "component_pages");
59  $this->table->selector();
60 
61  $contextMenu = $this->table->commandMenu();
62  $contextMenu->command("component_enable", "Enable Pages", "new ComponentPageList().setEnabled(1)", false)
63  ->command("component_disable", "Disable Pages", "new ComponentPageList().setEnabled(0)", false);
64  //->command("component_site", "Set Page Template", "new ComponentPageList().templatePopup(document.id('component_pages').getSelectedValues())", false)
65  //->command("component_roles", "Set Page Roles", "new ComponentPageList().rolePopupMulti(document.id('component_pages').getSelectedValues())", false)
66  //->command("component_site", "Set Page Site", "new ComponentPageList().sitePopup(document.id('component_pages').getSelectedValues())", false);
67 
68  if (!$component)
69  {
70  $this->table->column("Component", array($this, formatComponent), true);
71  }
72 
73  $this->table->column("Page", "<a href='/admin/component_page_form?component_page_id={component_page_id}'>{identifier}</a>", true, "width: 50%")
74  ->column("Page Title", "{page_title}")
75  ->column("Enabled", array($this, formatEnabled), false, "width: 10%; text-align: center");
76  $this->table->sortable = true;
77  $this->table->filter = true;
78  $this->table->pageSize = 20;
79 
80  //$this->templates = $this->readTemplates();
81  }
$component
Definition: help.inc:38

◆ drawView()

ComponentPageListView::drawView ( )

Definition at line 207 of file component_page_list.inc.

208  {
209  return $this->table->drawView();
210  }

◆ formatComponent()

ComponentPageListView::formatComponent (   $page)

Definition at line 83 of file component_page_list.inc.

84  {
86  $component = $components[$page->component];
87  return "<a href='/admin/component_form?component_id={$component->component_id}'>{$component->name}</a>";
88  }
$page
Definition: help.inc:39
$components
Definition: tree.inc:41
static getComponents()
Retrieve an array of all the currently enabled components, indexed by component name.
Definition: core.inc:206

◆ formatEnabled()

ComponentPageListView::formatEnabled (   $page)

Definition at line 90 of file component_page_list.inc.

91  {
92  $img = $page->enabled ? "on.png" : "off.png";
93  $alt = $page->enabled ? "Enabled" : "Disabled";
94 
95  return "<img src='/fakoli/images/$img' id='enable_{$page->component_page_id}' alt='$alt' style='display: inline-block; vertical-align: middle; border: none; cursor: pointer' onclick='new ComponentPageList().toggleEnabled(this, {$page->component_page_id})'/>";
96  }

◆ formatRole()

ComponentPageListView::formatRole (   $page)

Definition at line 116 of file component_page_list.inc.

117  {
118  $out = "<button onclick=\"new ComponentPageList().rolePopup('roles_{$page->component_page_id}', {$page->component_page_id}, this); return false\" class='button small' style='float: right'>...</button>";
119  $out .= "<span id=\"roles_{$page->component_page_id}\">$page->role</span>";
120 
121  return $out;
122  }
$out
Definition: page.inc:66

◆ formatTemplate()

ComponentPageListView::formatTemplate (   $page)

Definition at line 98 of file component_page_list.inc.

99  {
100  $out = "<select onchange='new ComponentPageList().changeTemplate(this.value, {$page->component_page_id})' id='template_{$page->component_page_id}'>\n";
101  $out .= "<option value=''></option>\n";
102  foreach($this->templates as $template)
103  {
104  $out .= "<option value='$template'";
105  if ($page->template == $template)
106  {
107  $out .= " selected";
108  }
109  $out .= ">$template</option>";
110  }
111  $out .= "</select>";
112 
113  return $out;
114  }

◆ readTemplates()

ComponentPageListView::readTemplates ( )

Definition at line 212 of file component_page_list.inc.

213  {
214  global $config;
215 
216  $home = $config["homedir"] . DIRECTORY_SEPARATOR . "templates";
217 
218  trace("Scanning Templates", 3);
219 
220  $options = array();
221 
222  $folders = array("$dir");
223 
224  while(($dir = array_shift($folders)) !== null)
225  {
226  $path = "$home/$dir";
227 
228  trace("Reading $path", 3);
229 
230  $handle = opendir($path);
231  if (!$handle)
232  {
233  trace("Directory read failed for $path", 3);
234  continue;
235  }
236 
237  while(false !== ($file = readdir($handle)))
238  {
239  trace("Checking $file", 4);
240 
241  if ($file != "." &&
242  $file != ".." &&
243  $file != ".svn" &&
244  $file != "CVS")
245  {
246  $f = "$path/$file";
247  $l = ($dir != '') ? "$dir/$file" : $file;
248 
249  if (is_dir($f))
250  {
251  array_push($folders, $l);
252  }
253  else if (preg_match('/.tpl$/i', $file))
254  {
255  $options[] = $l;
256  }
257  }
258  }
259  closedir($handle);
260  }
261  return $options;
262  }
if(! $page) $path
Definition: page.inc:57
$dir
Definition: delete.inc:44
$file
Definition: delete.inc:47
$f
Definition: download.inc:46
global $config
Definition: import.inc:4
if(php_sapi_name() !="cli") $home
Definition: run.php:39

◆ writeScript()

ComponentPageListView::writeScript ( )

Definition at line 124 of file component_page_list.inc.

125  {
128 
129  global $dialogs;
130  ob_start();
131 ?>
132 <div class="dialog" id="rolePopup" style="width: 200px">
133  <div class="dialog_header" id="rolePopupHeader">
134  <div style="padding: 4px;">
135  <div style="float: right">&nbsp;<a id='closeRolePopup'">Close &times;</a></div>
136  <span"style="font-weight: bold">Roles</span>
137  </div>
138  </div>
139  <div class="dialog_body">
140 <?
141 foreach($roles as $role => $name)
142 {
143 ?>
144  <input type="checkbox" id="role_<?echo $role?>" value="<?echo $role?>"/>&nbsp;<?echo $name?><br/>
145 <?
146 }
147 ?>
148  <button class='button' style='float: right; margin-bottom: 4px' onclick='new ComponentPageList().updateRoles()'>Update Roles</button>
149  </div>
150 </div>
151 <div class="dialog" id="sitePopup" style="width: 200px">
152  <div class="dialog_header" id="sitePopupHeader">
153  <div style="padding: 4px;">
154  <div style="float: right">&nbsp;<a id='closeSitePopup'">Close &times;</a></div>
155  <span"style="font-weight: bold">Sites</span>
156  </div>
157  </div>
158  <div class="dialog_body">
159  <label for="site_id">Select Site: </label>
160  <select id="site_id" name="site_id">
161 <?
162  foreach($sites as $s)
163  {
164  option($s->site_id, $s->site_name, 0);
165  }
166 ?>
167  </select><br/>
168  <button class='button' style='float: right; margin-bottom: 4px' onclick='new ComponentPageList().updateSites()'>Update Templates</button>
169  </div>
170 </div>
171 <div class="dialog" id="templatePopup" style="width: 200px">
172  <div class="dialog_header" id="templatePopupHeader">
173  <div style="padding: 4px;">
174  <div style="float: right">&nbsp;<a id='closeTemplatePopup'">Close &times;</a></div>
175  <span"style="font-weight: bold">Templates</span>
176  </div>
177  </div>
178  <div class="dialog_body">
179  <label for="template_id">Select Template: </label>
180  <select id='template_id'>
181  <option value=''></option>
182 <?
183 
184  foreach($this->templates as $template)
185  {
186  option($template, $template, "");
187  }
188 ?>
189  </select><br/>
190  <button class='button' style='float: right; margin-bottom: 4px' onclick='new ComponentPageList().updateTemplates()'>Update Templates</button>
191  </div>
192 </div>
193 <?
194  $dialogs .= ob_get_contents();
195  ob_end_clean();
196 
197  ob_start();
198 ?>
199 <script type='text/javascript' src="/components/component/js/component_page_list.js"></script>
200 <?
201  $script = ob_get_contents();
202  ob_end_clean();
203  $script .= $this->table->writeScript();
204  return $script;
205  }
& nbsp
Definition: index.inc:49
$helpTree style
Definition: tree.inc:46
$name
Definition: upload.inc:54
Definition: site.inc:40
static getSites()
Definition: site.inc:141
static getRolesArray()
Retrieves the array of roles and their names for the current site for use in a CMS form.
Definition: role.inc:75
$sites
Definition: event_edit.inc:83
$role
Definition: role_form.inc:41

Member Data Documentation

◆ $pages

ComponentPageListView::$pages

Definition at line 44 of file component_page_list.inc.

◆ $table

ComponentPageListView::$table

Definition at line 43 of file component_page_list.inc.

◆ $templates

ComponentPageListView::$templates

Definition at line 45 of file component_page_list.inc.


The documentation for this class was generated from the following file: