parent
289aed8420
commit
cb17590b71
|
@ -143,17 +143,17 @@ class DocParser
|
||||||
}
|
}
|
||||||
$path[] = $title;
|
$path[] = $title;
|
||||||
$id = implode('-', $path);
|
$id = implode('-', $path);
|
||||||
$nofollow = true;
|
$noFollow = true;
|
||||||
} else {
|
} else {
|
||||||
$nofollow = false;
|
$noFollow = false;
|
||||||
}
|
}
|
||||||
if ($stack->isEmpty()) {
|
if ($stack->isEmpty()) {
|
||||||
$chapterId = $id;
|
$chapterId = $id;
|
||||||
$section = new Section($id, $title, $level, $nofollow, $chapterId);
|
$section = new Section($id, $title, $level, $noFollow, $chapterId);
|
||||||
$tree->addRoot($section);
|
$tree->addRoot($section);
|
||||||
} else {
|
} else {
|
||||||
$chapterId = $stack->bottom()->getId();
|
$chapterId = $stack->bottom()->getId();
|
||||||
$section = new Section($id, $title, $level, $nofollow, $chapterId);
|
$section = new Section($id, $title, $level, $noFollow, $chapterId);
|
||||||
$tree->addChild($section, $stack->top());
|
$tree->addChild($section, $stack->top());
|
||||||
}
|
}
|
||||||
$stack->push($section);
|
$stack->push($section);
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Section implements Identifiable
|
||||||
*
|
*
|
||||||
* @var bool
|
* @var bool
|
||||||
*/
|
*/
|
||||||
protected $nofollow;
|
protected $noFollow;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ID of the chapter the section is part of
|
* The ID of the chapter the section is part of
|
||||||
|
@ -59,15 +59,15 @@ class Section implements Identifiable
|
||||||
* @param string $id The ID of the section
|
* @param string $id The ID of the section
|
||||||
* @param string $title The title of the section
|
* @param string $title The title of the section
|
||||||
* @param int $level The header level
|
* @param int $level The header level
|
||||||
* @param bool $nofollow Whether to instruct search engines to not index the link to the section
|
* @param bool $noFollow Whether to instruct search engines to not index the link to the section
|
||||||
* @param string $chapterId The ID of the chapter the section is part of
|
* @param string $chapterId The ID of the chapter the section is part of
|
||||||
*/
|
*/
|
||||||
public function __construct($id, $title, $level, $nofollow, $chapterId)
|
public function __construct($id, $title, $level, $noFollow, $chapterId)
|
||||||
{
|
{
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
$this->level = $level;
|
$this->level = $level;
|
||||||
$this->nofollow = $nofollow;
|
$this->noFollow = $noFollow;
|
||||||
$this->chapterId= $chapterId;
|
$this->chapterId= $chapterId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,9 +106,9 @@ class Section implements Identifiable
|
||||||
*
|
*
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function isNofollow()
|
public function isNoFollow()
|
||||||
{
|
{
|
||||||
return $this->nofollow;
|
return $this->noFollow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -69,7 +69,7 @@ class Callback
|
||||||
return sprintf(
|
return sprintf(
|
||||||
'<a %s%shref="%s"',
|
'<a %s%shref="%s"',
|
||||||
strlen($match['attribs']) ? trim($match['attribs']) . ' ' : '',
|
strlen($match['attribs']) ? trim($match['attribs']) . ' ' : '',
|
||||||
$section->isNofollow() ? 'rel="nofollow" ' : '',
|
$section->isNoFollow() ? 'rel="nofollow" ' : '',
|
||||||
$url->getAbsoluteUrl()
|
$url->getAbsoluteUrl()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,7 +96,7 @@ class TocRenderer extends Renderer
|
||||||
$url->setAnchor($this->encodeAnchor($section->getId()));
|
$url->setAnchor($this->encodeAnchor($section->getId()));
|
||||||
$this->content[] = sprintf(
|
$this->content[] = sprintf(
|
||||||
'<li><a %shref="%s">%s</a>',
|
'<li><a %shref="%s">%s</a>',
|
||||||
$section->isNofollow() ? 'rel="nofollow" ' : '',
|
$section->isNoFollow() ? 'rel="nofollow" ' : '',
|
||||||
$url->getAbsoluteUrl(),
|
$url->getAbsoluteUrl(),
|
||||||
$view->escape($section->getTitle())
|
$view->escape($section->getTitle())
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue