CMS  Version 3.9
AdminPageView Class Reference

Public Member Functions

 AdminPageView ($identifier)
 
 drawView ()
 
 formatMenu ($admin_menu, $icons)
 

Public Attributes

 $identifier
 
 $page
 

Detailed Description

Definition at line 38 of file admin_page_view.inc.

Member Function Documentation

◆ AdminPageView()

AdminPageView::AdminPageView (   $identifier)

Definition at line 43 of file admin_page_view.inc.

44  {
45  if (!$identifier) $identifier = "index";
46  $this->identifier = $identifier;
47 
48  $this->page = Cache::get("fakoli_admin_pages_$identifier");
49  if ($this->page) return;
50 
51  $pages = Query::create(AdminPage, "WHERE identifier=:id")
52  ->bind(":id", $identifier)
53  ->execute();
54 
55  if (count($pages) != 1)
56  {
57  throw new FakoliException("Missing or ambiguous page identifier '$identifier'");
58  }
59 
60  $this->page = $pages[0];
61  Cache::put("fakoli_admin_pages_$identifier", $this->page);
62  }
$tabs page
FakoliException is the base exception class for all Fakoli errors.
Definition: core.inc:53
$pages
Definition: export.inc:38

◆ drawView()

AdminPageView::drawView ( )

Definition at line 65 of file admin_page_view.inc.

66  {
67  global $config;
68  global $method;
69  global $user;
70  global $script;
71  global $styles;
72  global $dialogs;
73  global $page;
74  global $menu_item;
75  global $isAdmin;
76  global $fontawesome;
77 
78  global $auto_form_defaults;
79  $auto_form_defaults["default_layout"] = "table";
80 
81  $page = $this->page; // Pass through to code include
82 
83  $template = file_get_contents(Fakoli::resolveResource("/fakoli/admin.tpl"));
84 
85  //$template = ComponentManager::fireEvent("PreProcessPage", $template);
86 
87  ob_start();
88 
89  try
90  {
91  include $page->server_path;
92  }
93  catch(Exception $e)
94  {
95  echo $e->getMessage();
96  }
97 
98  $content = ob_get_contents();
99  ob_end_clean();
100 
101  //$content = ComponentManager::fireEvent("PostProcessContent", $content);
102 
103  $admin_menu = Fakoli::getAdminMenu();
104  $icons = Fakoli::getAdminIcons();
105 
106  $menu = $this->formatMenu($admin_menu, $icons);
107 
108  // If the script didn't provide a title, guess a reasonable default.
109 
110  if (!$title) $title = prettify(basename(substr($page->server_path, 0, -4)));
111 
112  // Pull in the script and style dependencies defined by the components
113 
116 
117  // Populate variable references
118 
119  $vars = array();
120 
121  preg_match_all("/\{var:(.*?)\}/", $template, $vars, PREG_SET_ORDER);
122 
123  foreach($vars as $var)
124  {
125  $expr = $var[0];
126  $name = $var[1];
127  $template = str_replace($expr, $$name, $template);
128  }
129 
130  $charset = strtolower(ini_get("default_charset"));
131  $template = str_replace("{default_charset}", $charset, $template);
132 
133  preg_match_all("/\{config:(.*?)\}/", $template, $vars, PREG_SET_ORDER);
134 
135  foreach($vars as $var)
136  {
137  $expr = $var[0];
138  $name = $var[1];
139  $template = str_replace($expr, $config[$name], $template);
140  }
141 
142  $component = $page->Component();
143 
144  $help = "<a href='#' onclick='popup(\"/action/admin/help?src={$component->name}&page={$page->identifier}\", \"help\", 940, 500, \"toolbar=0,location=0,scrollbars=1,resizable=1\"); return false;'> Help </a>";
145 
146  $template = str_replace("{help}", $help, $template);
147 
148  if ($config['prettyURLs'] === false)
149  {
150  $template = preg_replace("/(href|src|action)=(['\"])\\/?([\\w\\d_]+?)\\?/i", "$1=$2/page.php?identifier=$3&", $template);
151  $template = preg_replace("/(href|src|action)=(['\"])\\/?([\\w\\d_]+?)[\"']/i", "$1=$2/page.php?identifier=$3$2", $template);
152  $template = preg_replace("/go\\(([\"'])\\/?([\\w\\d_]+?)\\?/", "go($1/page.php?identifier=$2&", $template);
153  $template = preg_replace("/go\\(([\"'])\\/?([\\w\\d_]+?)[\"']/", "go($1/page.php?identifier=$2$1", $template);
154 
155  }
156 
157  //$template = ComponentManager::fireEvent("PostProcessPage", $template);
158 
159  echo $template;
160 
161  ComponentManager::fireEvent("RequestComplete");
162  }
$menu_item
$component
Definition: help.inc:38
$menu
Definition: menu_form.inc:47
$name
Definition: upload.inc:54
formatMenu($admin_menu, $icons)
static fireEvent($event, $parameter=null, $mustBeConsumed=false)
Fire an event to all subscribers as detailed in their manifests.
static getStyles()
Returns the HTML link tags for CSS files specified by the registered components in their manifest fil...
Definition: core.inc:603
static resolveResource($resource, $component="")
Resolves the path to a web resource based on the PHP include path.
Definition: core.inc:850
static getScripts()
Returns the HTML scripts tags for Javascript files specified by the registered components in their ma...
Definition: core.inc:554
static getAdminIcons()
Builds the admin icon map.
Definition: core.inc:456
static getAdminMenu()
Builds the administration menu, combining menu items supplied by the registered components in their m...
Definition: core.inc:405
global $user
$fontawesome
Definition: core.inc:45
$method
Pull out a simple reference to the request method.
Definition: core.inc:1573
global $config
Definition: import.inc:4
$styles
if(array_key_exists("HTTP_IF_MODIFIED_SINCE", $_SERVER)) $content
Definition: styles.css.inc:24

◆ formatMenu()

AdminPageView::formatMenu (   $admin_menu,
  $icons 
)

Definition at line 180 of file admin_page_view.inc.

181  {
182  global $menu_item;
183 
184  if (!$admin_menu) return "";
185 
186  ob_start();
187 
188  if (!$menu_item) $menu_item = basename($_SERVER['PHP_SELF']);
189 ?>
190 <div id="menu">
191 <?
192  $menuSectionIdx = 0;
193 
194  foreach($admin_menu as $section => $items)
195  {
196  $found = false;
197 
198  $icon = $this->formatIcon($icons[$section]);
199 
200  $submenu = " <h4 class=\"toggler atStart\">{$icon} {$section}</h4>\n <div class=\"atStart\">\n";
201 
202  foreach($items as $item => $properties)
203  {
204  if ($item == $menu_item)
205  {
206  $class = 'selectedadminitem';
207  $selectedMenuSectionIdx = $menuSectionIdx;
208  }
209  else
210  {
211  $class = 'adminmenuitem';
212  }
213 
214  $icon = $icons[$item];
215  if (!$icon) $icon = $properties["icon"];
216 
217  $icon = $this->formatIcon($icon);
218 
219  if (checkRole($properties["role"]))
220  {
221  $submenu .= "<a class='$class' href='{$properties['page']}{$menu_params}'>{$icon} {$item}</a>\n";
222  $found = true;
223  }
224  }
225 
226  $submenu .= "</div>";
227 
228  if ($found)
229  {
230  ++$menuSectionIdx;
231  echo $submenu;
232  }
233  }
234 ?>
235 </div>
236 <?
237  if (!$selectedMenuSectionIdx) $selectedMenuSectionIdx = 0;
238 
239  global $script;
240 
241  $script .= <<<ENDSCRIPT
242 
243 <script type="text/javascript">
244 window.addEvent('domready', function() {
245 
246  var accordion = new Accordion('h4.atStart', 'div.atStart', {
247 
248  opacity: false,
249  initialDisplayFx: false,
250  display: $selectedMenuSectionIdx,
251  onActive: function(toggler, element){
252  toggler.addClass("active");
253  },
254 
255  onBackground: function(toggler, element){
256  toggler.removeClass("active");
257  }
258  }, document.id('accordion'));
259 
260  });
261 </script>
262 ENDSCRIPT;
263  $menu = ob_get_contents();
264  ob_end_clean();
265  return $menu;
266  }
$section
Definition: event_form.inc:44
$icon
Definition: upload.inc:92

Member Data Documentation

◆ $identifier

AdminPageView::$identifier

Definition at line 40 of file admin_page_view.inc.

◆ $page

AdminPageView::$page

Definition at line 41 of file admin_page_view.inc.


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