1 | <?php |
||
17 | class OutlineResultPrinter extends ResultPrinter { |
||
18 | |||
19 | /** |
||
20 | * @see ResultPrinter::getName |
||
21 | * |
||
22 | * {@inheritDoc} |
||
23 | */ |
||
24 | public function getName() { |
||
27 | |||
28 | /** |
||
29 | * @see SMWResultPrinter::getParamDefinitions |
||
30 | * |
||
31 | * @since 1.8 |
||
32 | * |
||
33 | * {@inheritDoc} |
||
34 | */ |
||
35 | 2 | public function getParamDefinitions( array $definitions ) { |
|
65 | |||
66 | /** |
||
67 | * @see ResultPrinter::getResultText |
||
68 | * |
||
69 | * {@inheritDoc} |
||
70 | */ |
||
71 | 3 | protected function getResultText( QueryResult $res, $outputMode ) { |
|
72 | |||
73 | // for each result row, create an array of the row itself |
||
74 | // and all its sorted-on fields, and add it to the initial |
||
75 | // 'tree' |
||
76 | 3 | $outlineTree = new OutlineTree(); |
|
77 | |||
78 | 3 | while ( $row = $res->getNext() ) { |
|
79 | 2 | $outlineTree->addItem( $this->newOutlineItem( $row ) ); |
|
80 | } |
||
81 | |||
82 | // now, cycle through the outline properties, creating the |
||
83 | // tree |
||
84 | 3 | foreach ( $this->params['outlineproperties'] as $property ) { |
|
85 | 2 | $outlineTree->addProperty( $property ); |
|
86 | } |
||
87 | |||
88 | 3 | if ( $this->params['template'] !== '' ) { |
|
89 | 1 | $this->hasTemplates = true; |
|
90 | 1 | $templateBuilder = new TemplateBuilder( |
|
91 | 1 | $this->params |
|
92 | ); |
||
93 | |||
94 | 1 | $templateBuilder->setLinker( $this->mLinker ); |
|
95 | 1 | $result = $templateBuilder->build( $outlineTree ); |
|
96 | } else { |
||
97 | 2 | $listTreeBuilder = new ListTreeBuilder( |
|
98 | 2 | $this->params + [ 'showHeaders' => $this->mShowHeaders ] |
|
99 | ); |
||
100 | |||
101 | 2 | $listTreeBuilder->setLinker( $this->mLinker ); |
|
102 | 2 | $result = $listTreeBuilder->build( $outlineTree ); |
|
103 | } |
||
104 | |||
105 | 3 | if ( $this->linkFurtherResults( $res ) ) { |
|
106 | $link = $this->getFurtherResultsLink( |
||
107 | $res, |
||
108 | $outputMode |
||
109 | ); |
||
110 | |||
111 | $result .= $link->getText( $outputMode, $this->mLinker ) . "\n"; |
||
112 | } |
||
113 | |||
114 | 3 | return $result; |
|
115 | } |
||
116 | |||
117 | 2 | private function newOutlineItem( $row ) { |
|
138 | |||
139 | } |
||
140 |