<?php

/**
 * Snippet to draw a list of tags and link to the tag results.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 *
 * @package clearFusionCMS\module\search
 * @copyright Copyright (c) 2013 clearFusionCMS. All rights reserved.
 * @link http://clearfusioncms.com
 */

/* @var $tplEngine cfTemplateEngine */
$controller = $tplEngine->controller;

// Deal with parameters
$tagPage = isset($tagPage) ? $tagPage : 0;

// Draw the list of tags
if(isset($tags)) {
	$route = $tagPage ? $controller->content->getContainerRoute($tagPage, ':page') : new flRouterRoute(':page');

	$r = array();
	foreach(explode(',', $tags) as $tag) {
		$tag = trim($tag);
		if(!empty($tag))
			$r[] = '<a href="' . $route->assemble(array('page' => $tag)) . '">' . fusionLib::htmlChars($tag) . '</a>';
	}

	echo join(', ', $r);
}
