Hoa central
Tabs.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Xyl\Interpreter\Html;
38 
39 use Hoa\Xyl;
40 
49 class Tabs extends Generic implements Xyl\Element\Executable
50 {
56  public function preExecute()
57  {
58  $this->writeAttribute('data-tabs', 'true');
59 
60  foreach ($this->xpath('//__current_ns:tab[@for]') as $tab) {
61  $id = $tab->readAttribute('for');
62  $tabpanel = $this->xpath(
63  '//__current_ns:tabpanel[@id="' . $id . '"]'
64  );
65 
66  if (empty($tabpanel)) {
67  continue;
68  }
69 
70  $tabpanel = $tabpanel[0];
71  $tabpanel->writeAttribute('aria-labelledby', $id . '__tab');
72 
73  if (false === $tab->attributeExists('selected')) {
74  continue;
75  }
76 
77  $tab->writeAttribute('aria-selected', 'true');
78  $tabpanel->writeAttribute('aria-hidden', 'false');
79  $tabpanel->writeAttribute('aria-expanded', 'true');
80  }
81 
82  return;
83  }
84 
90  public function postExecute()
91  {
92  return;
93  }
94 
100  public function getName()
101  {
102  return 'div';
103  }
104 }