<?php
// (c) Copyright 2002-2013 by authors of the Tiki Wiki CMS Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

class Search_Formatter_ValueFormatter_Snippet extends Search_Formatter_ValueFormatter_Abstract
{
	private $length = 240;
	private $suffix = '...';

	function __construct($arguments)
	{
		if (isset($arguments['length'])) {
			$this->length = (int) $arguments['length'];
		}

		if (isset($arguments['suffix'])) {
			$this->suffix = $arguments['suffix'];
		}
	}

	function render($name, $value, array $entry)
	{
		$snippet = TikiLib::lib('tiki')->get_snippet($value, 'n', '', $this->length + 1);

		if (function_exists('mb_strlen')) {
			if (mb_strlen($snippet) > $this->length) {
				$snippet = mb_substr($snippet, 0, -1) . $this->suffix;
			}
		} else {
			if (strlen($snippet) > $this->length) {
				$snippet = substr($snippet, 0, -1) . $this->suffix;
			}
		}

		return '~np~' . $snippet . '~/np~';
	}
}


<?php
// (c) Copyright 2002-2013 by authors of the Tiki Wiki CMS Groupware Project
// 
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id$

class Search_Formatter_ValueFormatter_Snippet extends Search_Formatter_ValueFormatter_Abstract
{
	private $length = 240;
	private $suffix = '...';

	function __construct($arguments)
	{
		if (isset($arguments['length'])) {
			$this->length = (int) $arguments['length'];
		}

		if (isset($arguments['suffix'])) {
			$this->suffix = $arguments['suffix'];
		}
	}

	function render($name, $value, array $entry)
	{
		$snippet = TikiLib::lib('tiki')->get_snippet($value, 'n', '', $this->length + 1);

		if (function_exists('mb_strlen')) {
			if (mb_strlen($snippet) > $this->length) {
				$snippet = mb_substr($snippet, 0, -1) . $this->suffix;
			}
		} else {
			if (strlen($snippet) > $this->length) {
				$snippet = substr($snippet, 0, -1) . $this->suffix;
			}
		}

		return $snippet;
	}
}


Revert r49045 which caused rogue ~np~ tags to appear in searchindex results. Still looking for a better fix for the original {list} plugin double-parsing issues... (thanks Nelson)
[FIX] Revert r49045 which caused rogue ~np~ tags to appear in searchindex results. Still looking for a better fix for the original {list} plugin double-parsing issues... (thanks Nelson)

git-svn-id: fe65cb8b726aa1bab0c239f321eb4f822d15ce08@49435 b456876b-0849-0410-b77d-98878d47e9d5
