index.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. //include_once '../debug.php';
  3. include_once 'pquery.config.php';
  4. include_once PQUERY_ROOT.'pquery.php';
  5. __p::require_plugins('template', 'sql', 'url', 'js', 'css');
  6. __tpl::set_root('templates');
  7. __url::add_handlers(array(
  8. 'css/(.*)' => 'css_handler',
  9. 'js/(.*)' => 'js_handler',
  10. '' => 'layout',
  11. '(.*)' => 'content'
  12. ));
  13. header('Vary: Accept-Encoding');
  14. $handler = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false ? 'ob_gzhandler' : '';
  15. ob_start($handler);
  16. _url($_SERVER['QUERY_STRING'])->handler();
  17. ob_end_flush();
  18. /**
  19. *
  20. *
  21. * @param string $files One or more scripts separated by commas (',').
  22. */
  23. function js_handler($files) {
  24. $prepend_folder = create_function('$x', 'return "js/$x";');
  25. _js(array_map($prepend_folder, explode(',', $files)))->output();
  26. }
  27. function css_handler($files) {
  28. $prepend_folder = create_function('$x', 'return "css/$x";');
  29. _css(array_map($prepend_folder, explode(',', $files)))->output();
  30. }
  31. function content() {
  32. header('Content-Type: text/html; charset=utf-8');
  33. echo 'content';
  34. }
  35. function layout() {
  36. header('Content-Type: text/html; charset=utf-8');
  37. $menu = array(
  38. array('Pagina\'s', 'pages'),
  39. array('Nieuws', 'news'),
  40. array('Foto\'s', 'photos'),
  41. array('Accounts', 'accounts'),
  42. array('Instellingen', 'settings'),
  43. array('Uitloggen', 'logout')
  44. );
  45. $layout = _tpl('layout');
  46. foreach( $menu as $i => $item ) {
  47. list($title, $icon) = $item;
  48. $item = $layout->data->add('menu')->set(array('title' => $title, 'icon' => $icon));
  49. $i || $item->set('active', 'active');
  50. }
  51. echo $layout->parse();
  52. }
  53. ?>