Hoa central
Heading.php
Go to the documentation of this file.
1 <?php
2 
37 namespace Hoa\Xyl\Interpreter\Html;
38 
39 use Hoa\Xyl;
40 
50 {
56  protected static $_attributes = [
57  'for' => parent::ATTRIBUTE_TYPE_LIST
58  ];
59 
65  protected static $_attributesMapping = null;
66 
72  public function preExecute()
73  {
74  $this->computeFor();
75 
76  return;
77  }
78 
84  public function postExecute()
85  {
86  return;
87  }
88 
94  protected function computeFor()
95  {
96  if (false === $this->abstract->attributeExists('for')) {
97  return;
98  }
99 
100  $tocs = $this->xpath(
101  '//__current_ns:tableofcontents[@id="' .
102  implode('" or @id="', $this->abstract->readAttributeAsList('for')) .
103  '"]'
104  );
105 
106  if (empty($tocs)) {
107  return;
108  }
109 
110  foreach ($tocs as $toc) {
111  $this->getConcreteElement($toc)->addHeading($this);
112  }
113 
114  return;
115  }
116 
122  public function getLevel()
123  {
124  return (int) substr($this->getName(), -1);
125  }
126 }