9 namespace Fossology\Lib\View;
17 const PLACEHOLDER =
" # ";
20 private $elementStack;
22 private $highlightRenderer;
26 private $insertBacklink;
28 public function __construct(
HighlightRenderer $highlightRenderer, $insertBacklink =
false)
30 $this->highlightRenderer = $highlightRenderer;
31 $this->insertBacklink = $insertBacklink;
32 $this->elementStack = array();
40 $this->elementStack[] = $splitPosition;
48 return array_pop($this->elementStack);
56 return $this->elementStack;
64 foreach ($entries as $entry) {
65 switch ($entry->getAction()) {
66 case SplitPosition::START:
70 case SplitPosition::END:
83 foreach ($entries as $entry) {
84 switch ($entry->getAction()) {
85 case SplitPosition::START:
87 $result->appendMetaText($this->
startSpan($entry));
89 case SplitPosition::ATOM:
90 $result->appendMetaText($this->
startSpan($entry));
91 $result->appendMetaText(
92 self::PLACEHOLDER . $this->highlightRenderer->createSpanEnd($entry));
95 case SplitPosition::END:
98 $this->highlightRenderer->createSpanEnd($entry));
109 foreach ($this->elementStack as $splitPosition) {
110 $result->appendMetaText(
111 $this->highlightRenderer->createSpanEnd($splitPosition));
120 foreach ($this->elementStack as $entry) {
121 $result->appendMetaText($this->highlightRenderer->createSpanStart($entry));
132 ?
"<a id=\"highlight\"" . ($this->insertBacklink ?
" href=\"#top\"> ↑ " :
">") .
"</a>"
135 return $anchorText . $this->highlightRenderer->createSpanStart($entry);
144 $shouldShowAnchor = !$this->anchorDrawn && $entry->
getHighlight()->getType() != Highlight::KEYWORD;
145 if ($shouldShowAnchor) {
146 $this->anchorDrawn =
true;
148 return $shouldShowAnchor;
openExistingElements(PagedResult $result)
checkForAnchor(SplitPosition $entry)
closeOpenElements(PagedResult $result)
processSplitEntries($entries)
push(SplitPosition $splitPosition)
startSpan(SplitPosition $entry)
insertElements($entries, PagedResult $result)