public function test_emptyfield()
 {
     global $ID;
     $ID = 'no:data';
     $lines = array("schema    : bar", "cols      : %pageid%, data", "filter    : %pageid% = \$STRUCT.foo.pages\$");
     $configParser = new meta\ConfigParser($lines);
     $actual_config = $configParser->getConfig();
     $search = new meta\SearchConfig($actual_config);
     $result = $search->execute();
     $this->assertEquals(0, count($result), 'if no pages a given, then none should be shown');
 }
Пример #2
0
 /**
  * Render xhtml output or metadata
  *
  * @param string $mode Renderer mode (supported modes: xhtml)
  * @param Doku_Renderer $renderer The renderer
  * @param array $data The data from the handler() function
  * @return bool If rendering was successful.
  */
 public function render($mode, Doku_Renderer $renderer, $data)
 {
     if (!$data) {
         return false;
     }
     global $ID;
     global $conf;
     try {
         $search = new SearchConfig($data);
         /** @var AggregationTable $table */
         $table = new $this->tableclass($ID, $mode, $renderer, $search);
         $table->render();
         if ($mode == 'metadata') {
             /** @var Doku_Renderer_metadata $renderer */
             $renderer->meta['plugin']['struct']['hasaggregation'] = $search->getCacheFlag();
         }
     } catch (StructException $e) {
         msg($e->getMessage(), -1, $e->getLine(), $e->getFile());
         if ($conf['allowdebug']) {
             msg('<pre>' . hsc($e->getTraceAsString()) . '</pre>', -1);
         }
     }
     return true;
 }
 public function determineCacheFlag($filters)
 {
     return parent::determineCacheFlag($filters);
 }
 public function test_sort()
 {
     $data = array('schemas' => array(array('schema1', 'alias1'), array('schema2', 'alias2')), 'cols' => array('%pageid%', 'first', 'second', 'third', 'fourth', 'afirst', 'asecond', 'athird', 'afourth'));
     $searchConfig = new meta\SearchConfig($data);
     $dynamic = $searchConfig->getDynamicParameters();
     $dynamic->setSort('%pageid%', true);
     $conf = $dynamic->updateConfig($data);
     $param = $dynamic->getURLParameters();
     $this->assertEquals(array(array('%pageid%', true)), $conf['sort']);
     $this->assertArrayHasKey(meta\SearchConfigParameters::$PARAM_SORT, $param);
     $this->assertEquals('%pageid%', $param[meta\SearchConfigParameters::$PARAM_SORT]);
     $dynamic->setSort('%pageid%', false);
     $conf = $dynamic->updateConfig($data);
     $param = $dynamic->getURLParameters();
     $this->assertEquals(array(array('%pageid%', false)), $conf['sort']);
     $this->assertArrayHasKey(meta\SearchConfigParameters::$PARAM_SORT, $param);
     $this->assertEquals('^%pageid%', $param[meta\SearchConfigParameters::$PARAM_SORT]);
     $dynamic->removeSort();
     $conf = $dynamic->updateConfig($data);
     $param = $dynamic->getURLParameters();
     $this->assertArrayNotHasKey('sort', $conf);
     $this->assertArrayNotHasKey(meta\SearchConfigParameters::$PARAM_SORT, $param);
 }