コード例 #1
0
ファイル: Builder.php プロジェクト: hurcane/tiki-azure
 private function handleOutput($output)
 {
     $arguments = $this->parser->parse($output->getArguments());
     if (isset($arguments['template'])) {
         if ($arguments['template'] == 'table') {
             $arguments['template'] = dirname(__FILE__) . '/../../../../templates/table.tpl';
         } else {
             if (!file_exists($arguments['template'])) {
                 TikiLib::lib('errorreport')->report(tr('Missing template "%0"', $arguments['template']));
                 return '';
             }
         }
         $abuilder = new Search_Formatter_ArrayBuilder();
         $templateData = $abuilder->getData($output->getBody());
         $plugin = new Search_Formatter_Plugin_SmartyTemplate($arguments['template']);
         $plugin->setData($templateData);
         $plugin->setFields($this->findFields($templateData));
     } elseif (isset($arguments['wiki']) && TikiLib::lib('tiki')->page_exists($arguments['wiki'])) {
         $wikitpl = "tplwiki:" . $arguments['wiki'];
         $wikicontent = TikiLib::lib('smarty')->fetch($wikitpl);
         $plugin = new Search_Formatter_Plugin_WikiTemplate($wikicontent);
     } else {
         $plugin = new Search_Formatter_Plugin_WikiTemplate($output->getBody());
     }
     if (isset($arguments['pagination'])) {
         $plugin = new WikiPlugin_List_AppendPagination($plugin, $this->paginationArguments);
     }
     $this->formatterPlugin = $plugin;
 }
コード例 #2
0
ファイル: Factory.php プロジェクト: jkimdon/cohomeals
 function fromMatch($match)
 {
     $parser = new WikiParser_PluginArgumentParser();
     $arrayBuilder = new Search_Formatter_ArrayBuilder();
     $arguments = $parser->parse($match->getArguments());
     if (!empty($arguments['name'])) {
         $sequence = $this->build($arguments['name'], $arrayBuilder->getData($match->getBody()));
         if (isset($arguments['group'])) {
             $sequence->setRequiredGroup($arguments['group']);
         }
         return $sequence;
     }
 }
コード例 #3
0
ファイル: Builder.php プロジェクト: rjsmelo/tiki
 private function handleOutput($output)
 {
     $smarty = TikiLib::lib('smarty');
     $arguments = $this->parser->parse($output->getArguments());
     if (isset($arguments['template'])) {
         if ($arguments['template'] == 'table') {
             $arguments['template'] = dirname(__FILE__) . '/../../../../templates/search/list/table.tpl';
             $arguments['pagination'] = true;
         } elseif ($arguments['template'] == 'medialist') {
             $arguments['template'] = dirname(__FILE__) . '/../../../../templates/search/list/medialist.tpl';
         } elseif ($arguments['template'] == 'carousel') {
             $arguments['template'] = dirname(__FILE__) . '/../../../../templates/search/list/carousel.tpl';
         } elseif ($arguments['template'] == 'count') {
             $arguments['template'] = dirname(__FILE__) . '/../../../../templates/search/list/count.tpl';
         } elseif (!file_exists($arguments['template'])) {
             $temp = $smarty->get_filename($arguments['template']);
             if (empty($temp)) {
                 //if get_filename cannot find template, return error
                 TikiLib::lib('errorreport')->report(tr('Missing template "%0"', $arguments['template']));
                 return '';
             }
             $arguments['template'] = $temp;
         }
         $abuilder = new Search_Formatter_ArrayBuilder();
         $outputData = $abuilder->getData($output->getBody());
         foreach ($this->paginationArguments as $k => $v) {
             $outputData[$k] = $this->paginationArguments[$k];
         }
         $templateData = file_get_contents($arguments['template']);
         $plugin = new Search_Formatter_Plugin_SmartyTemplate($arguments['template']);
         $plugin->setData($outputData);
         $plugin->setFields($this->findFields($outputData, $templateData));
     } elseif (isset($arguments['wiki']) && TikiLib::lib('tiki')->page_exists($arguments['wiki'])) {
         $wikitpl = "tplwiki:" . $arguments['wiki'];
         $wikicontent = $smarty->fetch($wikitpl);
         $plugin = new Search_Formatter_Plugin_WikiTemplate($wikicontent);
     } else {
         $plugin = new Search_Formatter_Plugin_WikiTemplate($output->getBody());
     }
     if (isset($arguments['pagination'])) {
         $plugin = new Search_Formatter_AppendPagination($plugin, $this->paginationArguments);
     }
     $this->formatterPlugin = $plugin;
 }
コード例 #4
0
function wikiplugin_list($data, $params)
{
	$unifiedsearchlib = TikiLib::lib('unifiedsearch');

	$alternate = null;
	$output = null;
	$subPlugins = array();

	$query = new Search_Query;
	$query->setWeightCalculator($unifiedsearchlib->getWeightCalculator());

	if (isset($_REQUEST['maxRecords'])) {
		if (isset($_REQUEST['offset'])) {
			$query->setRange($_REQUEST['offset'], $_REQUEST['maxRecords']);
		} else {
			$query->setRange(0, $_REQUEST['maxRecords']);
		}
	} elseif (isset($_REQUEST['offset'])) {
		$query->setRange($_REQUEST['offset']);
	}

	$matches = WikiParser_PluginMatcher::match($data);
	$argumentParser = new WikiParser_PluginArgumentParser;

	$onclick = '';
	$offset_jsvar = '';

	foreach ($matches as $match) {
		$name = $match->getName();
		$arguments = $argumentParser->parse($match->getArguments());

		foreach ($arguments as $key => $value) {
			$function = "wpquery_{$name}_{$key}";

			if (function_exists($function)) {
				$function($query, $value, $arguments);
			}

			$function = "wpformat_{$name}_{$key}";

			if (function_exists($function)) {
				$function($subPlugins, $value, $match->getBody());
			}
		}

		if ($name == 'output') {
			$output = $match;
		}

		if ($name == 'alternate') {
			$alternate = $match->getBody();
		}

		if ($name == 'pagination' && isset($arguments['onclick'])) {
			$onclick = $arguments['onclick'];
		}
		if ($name == 'pagination' && isset($arguments['offset_jsvar'])) {
			$offset_jsvar = $arguments['offset_jsvar'];
		}
	}

	if (! Perms::get()->admin) {
		$query->filterPermissions(Perms::get()->getGroups());
	}

	if (!empty($_REQUEST['sort_mode'])) {
		$query->setOrder($_REQUEST['sort_mode']);
	}

	$index = $unifiedsearchlib->getIndex();

	$result = $query->search($index);

	if (count($result)) {
		if (!empty($output)) {
			$arguments = $argumentParser->parse($output->getArguments());

			if (isset($arguments['template'])) {
				if ($arguments['template'] == 'table') {
					$arguments['template'] = dirname(__FILE__) . '/../../templates/table.tpl';
				} else if (!file_exists($arguments['template'])) {
					TikiLib::lib('errorreport')->report(tr('Missing template "%0"', $arguments['template']));
					return '';
				}
				$builder = new Search_Formatter_ArrayBuilder;
				$templateData = $builder->getData($output->getBody());

				$plugin = new Search_Formatter_Plugin_SmartyTemplate($arguments['template']);
				$plugin->setData($templateData);
				$plugin->setFields(wp_list_findfields($templateData));
			} elseif (isset($arguments['wiki']) && TikiLib::lib('tiki')->page_exists($arguments['wiki'])) {	
				$wikitpl = "tplwiki:" . $arguments['wiki'];
				$wikicontent = TikiLib::lib('smarty')->fetch($wikitpl);
				$plugin = new Search_Formatter_Plugin_WikiTemplate($wikicontent);
			} else {
				$plugin = new Search_Formatter_Plugin_WikiTemplate($output->getBody());
			}

			if (isset($arguments['pagination'])) {
				$plugin = new WikiPlugin_List_AppendPagination($plugin, $onclick, $offset_jsvar);
			}
		} else {
			$plugin = new Search_Formatter_Plugin_WikiTemplate("* {display name=title format=objectlink}\n");
		}

		$formatter = new Search_Formatter($plugin);
		$formatter->setDataSource($unifiedsearchlib->getDataSource());

		foreach ($subPlugins as $key => $plugin) {
			$formatter->addSubFormatter($key, $plugin);
		}

		$out = $formatter->format($result);
	} elseif (!empty($alternate)) {
		$out = $alternate;
	} else {
		$out = '^' . tra('No results for query.') . '^';
	}

	return $out;
}