<commit_before><?php
// (c) Copyright 2002-2015 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 Services_ActivityStream_Controller
{
	private $lib;

	function setUp()
	{
		$this->lib = TikiLib::lib('unifiedsearch');
		Services_Exception_Disabled::check('wikiplugin_activitystream');
	}

	function action_render(JitFilter $request)
	{
		$encoded = $request->stream->none();
		$page = $request->page->int() ?: 1;

		if (! $baseQuery = Tiki_Security::get()->decode($encoded)) {
			throw new Services_Exception_Denied('Invalid request performed.');
		}

		$query = new Search_Query;
		$this->lib->initQuery($query);
		$query->filterType('activity');

		$matches = WikiParser_PluginMatcher::match($baseQuery['body']);

		$builder = new Search_Query_WikiBuilder($query);
		$builder->enableAggregate();
		$builder->apply($matches);

		if ($builder->isNextPossible()) {
			$query->setPage($page);
		}

		$query->setOrder('modification_date_desc');

		if (! $index = $this->lib->getIndex()) {
			throw new Services_Exception_NotAvailable(tr('Activity stream currently unavailable.'));
		}

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

		$paginationArguments = $builder->getPaginationArguments();

		$resultBuilder = new Search_ResultSet_WikiBuilder($result);
		$resultBuilder->setPaginationArguments($paginationArguments);
		$resultBuilder->apply($matches);

		try {
			$plugin = new Search_Formatter_Plugin_SmartyTemplate('templates/activity/activitystream.tpl');
			$plugin->setFields(array(
				'like_list' => true,
				'user_groups' => true,
				'contributors' => true,
			));
			$formatter = new Search_Formatter($plugin);
			$out = $formatter->format($result);
		} catch (SmartyException $e) {
			throw new Services_Exception_NotAvailable($e->getMessage());
		}

		return array(
			'autoScroll' => $request->autoscroll->int(),
			'pageNumber' => $page,
			'nextPossible' => $builder->isNextPossible(),
			'stream' => $encoded,
			'body' => TikiLib::lib('parser')->parse_data($out, array('is_html' => true)),
		);
	}
}
<commit_msg>[FIX] Fixed tpl path so that it fetches tpl from themes folder if there is one<commit_after><?php
// (c) Copyright 2002-2015 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 Services_ActivityStream_Controller
{
	private $lib;

	function setUp()
	{
		$this->lib = TikiLib::lib('unifiedsearch');
		Services_Exception_Disabled::check('wikiplugin_activitystream');
	}

	function action_render(JitFilter $request)
	{
		$encoded = $request->stream->none();
		$page = $request->page->int() ?: 1;

		if (! $baseQuery = Tiki_Security::get()->decode($encoded)) {
			throw new Services_Exception_Denied('Invalid request performed.');
		}

		$query = new Search_Query;
		$this->lib->initQuery($query);
		$query->filterType('activity');

		$matches = WikiParser_PluginMatcher::match($baseQuery['body']);

		$builder = new Search_Query_WikiBuilder($query);
		$builder->enableAggregate();
		$builder->apply($matches);

		if ($builder->isNextPossible()) {
			$query->setPage($page);
		}

		$query->setOrder('modification_date_desc');

		if (! $index = $this->lib->getIndex()) {
			throw new Services_Exception_NotAvailable(tr('Activity stream currently unavailable.'));
		}

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

		$paginationArguments = $builder->getPaginationArguments();

		$resultBuilder = new Search_ResultSet_WikiBuilder($result);
		$resultBuilder->setPaginationArguments($paginationArguments);
		$resultBuilder->apply($matches);

		try {
			$plugin = new Search_Formatter_Plugin_SmartyTemplate('activity/activitystream.tpl');
			$plugin->setFields(array(
				'like_list' => true,
				'user_groups' => true,
				'contributors' => true,
			));
			$formatter = new Search_Formatter($plugin);
			$out = $formatter->format($result);
		} catch (SmartyException $e) {
			throw new Services_Exception_NotAvailable($e->getMessage());
		}

		return array(
			'autoScroll' => $request->autoscroll->int(),
			'pageNumber' => $page,
			'nextPossible' => $builder->isNextPossible(),
			'stream' => $encoded,
			'body' => TikiLib::lib('parser')->parse_data($out, array('is_html' => true)),
		);
	}
}

{'fraction_non_alphanumeric': 0.1601518874246147, 'fraction_numerical': 0.0040205494750949295, 'mean_word_length': 5.0269179004037685, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 75, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '406839', 'n_tokens_mistral': 1566, 'n_tokens_neox': 1377, 'n_words': 283}