v1.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. namespace zin;
  3. require_once dirname(__DIR__) . DS . 'pagebase' . DS . 'v1.php';
  4. require_once dirname(__DIR__) . DS . 'header' . DS . 'v1.php';
  5. require_once dirname(__DIR__) . DS . 'heading' . DS . 'v1.php';
  6. require_once dirname(__DIR__) . DS . 'main' . DS . 'v1.php';
  7. class page extends pageBase
  8. {
  9. /**
  10. * @var mixed[]
  11. */
  12. protected static $defaultProps = array('zui' => true);
  13. /**
  14. * @var mixed[]
  15. */
  16. protected static $defineBlocks = array(
  17. 'head' => array(),
  18. 'header' => array('map' => 'header'),
  19. 'heading' => array('map' => 'heading'),
  20. 'dropmenu' => array('map' => 'dropmenu'),
  21. 'main' => array('map' => 'main'),
  22. 'footer' => array()
  23. );
  24. /**
  25. * @return mixed[]|\zin\node
  26. */
  27. protected function buildHeader()
  28. {
  29. if($this->hasBlock('header')) return $this->block('header');
  30. $headingBlock = $this->block('heading');
  31. if(!empty($headingBlock)) return new header($headingBlock);
  32. $dropmenuBlock = $this->block('dropmenu');
  33. return new header(new heading($dropmenuBlock));
  34. }
  35. protected function buildBody()
  36. {
  37. if($this->hasBlock('main'))
  38. {
  39. return array
  40. (
  41. $this->buildHeader(),
  42. $this->block('main'),
  43. $this->children(),
  44. $this->block('footer')
  45. );
  46. }
  47. return array
  48. (
  49. $this->buildHeader(),
  50. new main($this->children()),
  51. $this->block('footer')
  52. );
  53. }
  54. }