<commit_before><?php
// (c) Copyright 2002-2014 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$

function wikiplugin_bloglist_info()
{
	return array(
		'name' => tra('Blog List'),
		'documentation' => 'PluginBlogList',
		'description' => tra('Display posts from a site blog'),
		'prefs' => array( 'feature_blogs', 'wikiplugin_bloglist' ),
		'icon' => 'img/icons/text_list_bullets.png',
		'params' => array(
			'Id' => array(
				'required' => true,
				'name' => tra('Blog ID'),
				'description' => tra('The ID number of the blog on the site you wish to list posts from'),
				'filter' => 'digits',
				'default' => '',
				'profile_reference' => 'blog',
			),
			'Items' => array(
				'required' => false,
				'name' => tra('Maximum Items'),
				'description' => tra('Maximum number of entries to list (no maximum set by default)'),
				'filter' => 'digits',
				'default' => '',
			),
			'author' => array(
				'required' => false,
				'name' => tra('Author'),
				'description' => tra('Only display posts created by this user (all posts listed by default)'),
				'default' => '',
			),
			'simpleList' => array(
				'required' => false,
				'name' => tra('Simple List'),
				'description' => tra('Show simple list of date, title and author (default=y) or formatted list of blog posts (n)'),
				'default' => 'y',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
			),
			'charCount' => array(
				'required' => false,
				'name' => tra('Char Count'),
				'description' => tra('Number of characters to display if not a simple list. (defaults to all)'),
				'filter' => 'digits',
				'parent' => array('name' => 'simpleList', 'value' => 'n'),
				'default' => '',
			),
			'wordBoundary' => array(
				'required' => false,
				'name' => tra('Word Boundary'),
				'description' => tra('If not a simple list and Char Count is non-zero, then marking this as yes will break on word boundaries only.'),
				'default' => 'y',
				'options' => array(
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
				'parent' => array('name' => 'simpleList', 'value' => 'n'),
			),
			'ellipsis' => array(
				'required' => false,
				'name' => tra('Ellipsis'),
				'description' => tra('If not a simple list and Char Count is non-zero, then marking this as yes will put ellipsis (...) at end of text (default=y).'),
				'default' => 'y',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
				'parent' => array('name' => 'simpleList', 'value' => 'n'),
			),
			'more' => array(
				'required' => false,
				'name' => tra('More'),
				'description' => tra('If not a simple list and Char Count is non-zero, then marking this as yes will put a More link to the full entry (default=y).'),
				'default' => 'y',
				'options' => array(
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
				'parent' => array('name' => 'simpleList', 'value' => 'n'),
			),
			'showIcons' => array(
				'required' => false,
				'name' => tra('Show Icons'),
				'description' => tra('If not a simple list marking this as no will prevent the "edit" and "print" type icons from displaying (default=y)'),
				'default' => 'y',
				'options' => array(
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
				'parent' => array('name' => 'simpleList', 'value' => 'n'),
			),
			'dateStart' => array(
				'required' => false,
				'name' => tra('Start Date'),
				'description' => tra('Earliest date to select posts from.') . ' (YYYY-MM-DD)',
				'filter' => 'date',
				'default' => '',
			),
			'dateEnd' => array(
				'required' => false,
				'name' => tra('End Date'),
				'description' => tra('Latest date to select posts from.') . ' (YYYY-MM-DD)',
				'filter' => 'date',
				'default' => '',
			),
			'containerClass' => array(
				'required' => false,
				'name' => tra('Container Class'),
				'description' => tra('CSS Class to add to the container DIV.article. (Default="wikiplugin_bloglist")'),
				'filter' => 'striptags',
				'default' => 'wikiplugin_bloglist',
			),
			'useExcerpt' => array(
				'required' => false,
				'name' => tra('Use Excerpt'),
				'description' => tra('If the blog has "Use post excerpt" enabled then use excerpts where available') . ' ' . tra('(default=y)'),
				'default' => 'y',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
			),
		),
	);
}

function wikiplugin_bloglist($data, $params)
{
	global $user;
	$tikilib = TikiLib::lib('tiki');
	$smarty = TikiLib::lib('smarty');

	if (!isset($params['Id'])) {
		TikiLib::lib('errorreport')->report(tra('missing blog Id for BLOGLIST plugins'));
		return '';
	}

	if (!isset($params['Items'])) $params['Items'] = -1;
	if (!isset($params['offset'])) $params['offset'] = 0;
	if (!isset($params['sort_mode'])) $params['sort_mode'] = 'created_desc';
	if (!isset($params['find'])) $params['find'] = '';
	if (!isset($params['author'])) $params['author'] = '';
	if (!isset($params['simpleList'])) $params['simpleList'] = 'y';
	if (!isset($params['isHtml'])) $params['isHtml'] = 'n';
	if (!isset($params['useExcerpt'])) $params['useExcerpt'] = 'y';

	if (isset($params['dateStart'])) {
		$dateStartTS = strtotime($params['dateStart']);
	}<commit_msg>[FIX] bloglist: New param useExcerpt was in the wrong place and not dependant on simpleList=n as it should have been<commit_after><?php
// (c) Copyright 2002-2014 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$

function wikiplugin_bloglist_info()
{
	return array(
		'name' => tra('Blog List'),
		'documentation' => 'PluginBlogList',
		'description' => tra('Display posts from a site blog'),
		'prefs' => array( 'feature_blogs', 'wikiplugin_bloglist' ),
		'icon' => 'img/icons/text_list_bullets.png',
		'params' => array(
			'Id' => array(
				'required' => true,
				'name' => tra('Blog ID'),
				'description' => tra('The ID number of the blog on the site you wish to list posts from'),
				'filter' => 'digits',
				'default' => '',
				'profile_reference' => 'blog',
			),
			'Items' => array(
				'required' => false,
				'name' => tra('Maximum Items'),
				'description' => tra('Maximum number of entries to list (no maximum set by default)'),
				'filter' => 'digits',
				'default' => '',
			),
			'author' => array(
				'required' => false,
				'name' => tra('Author'),
				'description' => tra('Only display posts created by this user (all posts listed by default)'),
				'default' => '',
			),
			'simpleList' => array(
				'required' => false,
				'name' => tra('Simple List'),
				'description' => tra('Show simple list of date, title and author (default=y) or formatted list of blog posts (n)'),
				'default' => 'y',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
			),
			'charCount' => array(
				'required' => false,
				'name' => tra('Char Count'),
				'description' => tra('Number of characters to display if not a simple list. (defaults to all)'),
				'filter' => 'digits',
				'parent' => array('name' => 'simpleList', 'value' => 'n'),
				'default' => '',
			),
			'wordBoundary' => array(
				'required' => false,
				'name' => tra('Word Boundary'),
				'description' => tra('If not a simple list and Char Count is non-zero, then marking this as yes will break on word boundaries only.'),
				'default' => 'y',
				'options' => array(
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
				'parent' => array('name' => 'simpleList', 'value' => 'n'),
			),
			'ellipsis' => array(
				'required' => false,
				'name' => tra('Ellipsis'),
				'description' => tra('If not a simple list and Char Count is non-zero, then marking this as yes will put ellipsis (...) at end of text (default=y).'),
				'default' => 'y',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
				'parent' => array('name' => 'simpleList', 'value' => 'n'),
			),
			'more' => array(
				'required' => false,
				'name' => tra('More'),
				'description' => tra('If not a simple list and Char Count is non-zero, then marking this as yes will put a More link to the full entry (default=y).'),
				'default' => 'y',
				'options' => array(
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
				'parent' => array('name' => 'simpleList', 'value' => 'n'),
			),
			'showIcons' => array(
				'required' => false,
				'name' => tra('Show Icons'),
				'description' => tra('If not a simple list marking this as no will prevent the "edit" and "print" type icons from displaying (default=y)'),
				'default' => 'y',
				'options' => array(
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
				'parent' => array('name' => 'simpleList', 'value' => 'n'),
			),
			'useExcerpt' => array(
				'required' => false,
				'name' => tra('Use Excerpt'),
				'description' => tra('If the blog has "Use post excerpt" enabled then use excerpts where available') . ' ' . tra('(default=y)'),
				'default' => 'y',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n')
				),
				'parent' => array('name' => 'simpleList', 'value' => 'n'),
			),
			'dateStart' => array(
				'required' => false,
				'name' => tra('Start Date'),
				'description' => tra('Earliest date to select posts from.') . ' (YYYY-MM-DD)',
				'filter' => 'date',
				'default' => '',
			),
			'dateEnd' => array(
				'required' => false,
				'name' => tra('End Date'),
				'description' => tra('Latest date to select posts from.') . ' (YYYY-MM-DD)',
				'filter' => 'date',
				'default' => '',
			),
			'containerClass' => array(
				'required' => false,
				'name' => tra('Container Class'),
				'description' => tra('CSS Class to add to the container DIV.article. (Default="wikiplugin_bloglist")'),
				'filter' => 'striptags',
				'default' => 'wikiplugin_bloglist',
			),
		),
	);
}

function wikiplugin_bloglist($data, $params)
{
	global $user;
	$tikilib = TikiLib::lib('tiki');
	$smarty = TikiLib::lib('smarty');

	if (!isset($params['Id'])) {
		TikiLib::lib('errorreport')->report(tra('missing blog Id for BLOGLIST plugins'));
		return '';
	}

	if (!isset($params['Items'])) $params['Items'] = -1;
	if (!isset($params['offset'])) $params['offset'] = 0;
	if (!isset($params['sort_mode'])) $params['sort_mode'] = 'created_desc';
	if (!isset($params['find'])) $params['find'] = '';
	if (!isset($params['author'])) $params['author'] = '';
	if (!isset($params['simpleList'])) $params['simpleList'] = 'y';
	if (!isset($params['isHtml'])) $params['isHtml'] = 'n';
	if (!isset($params['useExcerpt'])) $params['useExcerpt'] = 'y';

	if (isset($params['dateStart'])) {
		$dateStartTS = strtotime($params['dateStart']);
	}
{'fraction_non_alphanumeric': 0.22663034224416823, 'fraction_numerical': 0.0017027073046143367, 'mean_word_length': 3.5531007751937986, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 266, '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': '5615841', 'n_tokens_mistral': 4634, 'n_tokens_neox': 3913, 'n_words': 1092}