Hoa central
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Hoa\Xyl\Interpreter\Html\Tableofcontents Class Reference
Inheritance diagram for Hoa\Xyl\Interpreter\Html\Tableofcontents:

Public Member Functions

 addHeading (Heading $heading)
 
 getHeadings ()
 
- Public Member Functions inherited from Hoa\File\Generic
 getBasename ()
 
 getDirname ()
 
 getSize ()
 
 getStatistic ()
 
 getATime ()
 
 getCTime ()
 
 getMTime ()
 
 getGroup ()
 
 getOwner ()
 
 getPermissions ()
 
 getReadablePermissions ()
 
 isReadable ()
 
 isWritable ()
 
 isExecutable ()
 
 clearStatisticCache ()
 
 touch ($time=-1, $atime=-1)
 
 copy ($to, $force=Stream\IStream\Touchable::DO_NOT_OVERWRITE)
 
 move ($name, $force=Stream\IStream\Touchable::DO_NOT_OVERWRITE, $mkdir=Stream\IStream\Touchable::DO_NOT_MAKE_DIRECTORY)
 
 delete ()
 
 changeGroup ($group)
 
 changeMode ($mode)
 
 changeOwner ($user)
 
 isFile ()
 
 isLink ()
 
 isDirectory ()
 
 isSocket ()
 
 isFIFOPipe ()
 
 isCharacterSpecial ()
 
 isBlockSpecial ()
 
 isUnknown ()
 
 getMode ()
 
 getINode ()
 
 getRealPath ()
 
 getExtension ()
 
 getFilename ()
 
- Public Member Functions inherited from Hoa\Stream\Stream
 __construct ($streamName, $context=null, $wait=false)
 
 open ()
 
 close ()
 
 getStreamName ()
 
 getStreamContext ()
 
 _setStream ($stream)
 
 isOpened ()
 
 setStreamTimeout ($seconds, $microseconds=0)
 
 setStreamBlocking ($mode)
 
 setStreamBuffer ($buffer)
 
 disableStreamBuffer ()
 
 getStreamBufferSize ()
 
 getStreamWrapperName ()
 
 getStreamMetaData ()
 
 isBorrowing ()
 
 on ($listenerId, $callable)
 
 _notify ($ncode, $severity, $message, $code, $transferred, $max)
 
 __toString ()
 
 __destruct ()
 

Protected Member Functions

 paint (Stream\IStream\Out $out)
 
- Protected Member Functions inherited from Hoa\File\Generic
 setMode ($mode)
 
- Protected Member Functions inherited from Hoa\Stream\Stream
_open ($streamName, Context $context=null)
 
 _close ()
 
 getStream ()
 

Protected Attributes

 $_headings = []
 
- Protected Attributes inherited from Hoa\File\Generic
 $_mode = null
 
- Protected Attributes inherited from Hoa\Stream\Stream
 $_bucket = []
 
 $_bufferSize = 8192
 
 $_streamName = null
 
 $_context = null
 
 $_hasBeenDiffered = false
 
 $_on = null
 
 $_borrowed = false
 

Additional Inherited Members

- Static Public Member Functions inherited from Hoa\File\Generic
static clearAllStatisticCaches ()
 
static umask ($umask=null)
 
static isCaseSensitive ()
 
- Static Public Member Functions inherited from Hoa\Stream\Stream
static getStreamHandler ($streamName)
 
static _Hoa_Stream ()
 
- Public Attributes inherited from Hoa\Stream\Stream
const NAME = 0
 
const HANDLER = 1
 
const RESOURCE = 2
 
const CONTEXT = 3
 
- Public Attributes inherited from Hoa\Stream\IStream\Statable
const SIZE_UNDEFINED = -1
 
- Public Attributes inherited from Hoa\Stream\IStream\Touchable
const OVERWRITE = true
 
const DO_NOT_OVERWRITE = false
 
const MAKE_DIRECTORY = true
 
const DO_NOT_MAKE_DIRECTORY = false
 

Detailed Description

Class .

The <tableofcontents> component.

Definition at line 49 of file Tableofcontents.php.

Member Function Documentation

Hoa\Xyl\Interpreter\Html\Tableofcontents::addHeading ( Heading  $heading)

Add a heading in the table of content.

Parameters
\Hoa\Xyl\Interpreter\Html\Heading$headingHeading.
Returns
void

Definition at line 143 of file Tableofcontents.php.

144  {
145  $this->_headings[] = $heading;
146 
147  return;
148  }
Hoa\Xyl\Interpreter\Html\Tableofcontents::getHeadings ( )

Get headings.

Returns
array

Definition at line 155 of file Tableofcontents.php.

Hoa\Xyl\Interpreter\Html\Tableofcontents::paint ( Stream\IStream\Out  $out)
protected

Paint the element.

Parameters
\Hoa\Stream\IStream\Out$outOut stream.
Returns
void

Definition at line 66 of file Tableofcontents.php.

67  {
68  $this->writeAttribute('class', 'toc');
69  $out->writeAll('<ol' . $this->readAttributesAsString() . '>');
70 
71  $links = $this->selectChildElements('a');
72 
73  if (!empty($links)) {
74  foreach ($links as $link) {
75  $out->writeAll('<li>');
76  $this->getConcreteElement($link)->render($out);
77  $out->writeAll('</li>');
78  }
79 
80  $out->writeAll('</ol>');
81 
82  return;
83  }
84 
85  if (empty($this->_headings)) {
86  $out->writeAll('</ol>');
87 
88  return;
89  }
90 
91  $n = 1;
92  $first = true;
93 
94  foreach ($this->_headings as $heading) {
95  $ni = $heading->getLevel();
96 
97  if (true === $first) {
98  $n = $ni;
99  }
100 
101  if ($n < $ni) {
102  for ($i = $ni - $n - 1; $i >= 0; --$i) {
103  $out->writeAll('<ol class="toc toc-depth-' . $ni . '">');
104  }
105  } elseif ($n > $ni) {
106  $out->writeAll('</li>');
107 
108  for ($i = $n - $ni - 1; $i >= 0; --$i) {
109  $out->writeAll('</ol></li>');
110  }
111  } elseif (false === $first) {
112  $out->writeAll('</li>');
113  } else {
114  $first = false;
115  }
116 
117  $n = $ni;
118 
119  $out->writeAll('<li>');
120 
121  if (true === $heading->attributeExists('id')) {
122  $out->writeAll('<a href="#' . $heading->readAttribute('id') . '">');
123  $heading->computeTransientValue($out);
124  $out->writeAll('</a>');
125  } else {
126  $heading->computeTransientValue($out);
127  }
128  }
129 
130  for ($i = $n - 2; $i >= 0; --$i) {
131  $out->writeAll('</li></ol>');
132  }
133 
134  return;
135  }

Member Data Documentation

Hoa\Xyl\Interpreter\Html\Tableofcontents::$_headings = []
protected

Definition at line 56 of file Tableofcontents.php.


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