<commit_before><?php

// $Id: /cvsroot/tikiwiki/tiki/lib/wiki-plugins/wikiplugin_trackerstat.php,v 1.14.2.5 2007-12-18 23:03:15 sylvieg Exp $
/* to have some statistiques about a tracker
 * will returns a table with for each tracker field, the list of values and the number of times the values occurs
 * trackerId = the id of the tracker
 * fields = the iof of the fields you wnat the stat - the fields must be public
 * show_percent : optionnal - to show a percent
 * show_bar : optionnal to show a bar(length 100 pixels)
 * status : optionnal to filter on the status ( a combinaison of letters c:close, o:open, p:pending)
 */
function wikiplugin_trackerstat_help()
{
	$help = tra("Displays some stat of a tracker content, fields are indicated with numeric ids.").":\n";
	$help.= "~np~{TRACKERSTAT(trackerId=>1,fields=>2:4:5,show_percent=>y,show_bar=>n,status=>o|c|p|op|oc|pc|opc,show_link=n)}Title{TRACKERSTAT}~/np~";
	return $help;
}

function wikiplugin_trackerstat_info()
{
	return array(
		'name' => tra('Tracker Stats'),
		'documentation' => 'PluginTrackerStat',
		'description' => tra("Displays some stat of a tracker content, fields are indicated with numeric ids."),
		'prefs' => array( 'feature_trackers', 'wikiplugin_trackerstat' ),
		'body' => tra('Title'),
		'icon' => 'pics/icons/database_lightning.png',
		'params' => array(
			'trackerId' => array(
				'required' => true,
				'name' => tra('Tracker ID'),
				'description' => tra('Tracker ID'),
			),
			'fields' => array(
				'required' => true,
				'name' => tra('Fields'),
				'description' => tra('Colon-separated list of field IDs to be displayed. Example: 2:4:5'),
			),
			'show_percent' => array(
				'required' => false,
				'name' => tra('Show Percentage'),
				'description' => 'y|n',
			),
			'show_bar' => array(
				'required' => false,
				'name' => tra('Show Bar'),
				'description' => 'y|n',
			),
			'status' => array(
				'required' => false,
				'name' => tra('Status Filter'),
				'description' => 'o|p|c|op|oc|pc|opc'.' '.tra('Which item status to list. o = open, p = pending, c = closed.'),
			),
			'show_link' => array(
				'required' => false,
				'name' => tra('Show link to tiki-view_tracker'),
				'description' => 'y|n',
			),
		),
	);
}

function wikiplugin_trackerstat($data, $params)
{
	global $smarty, $prefs, $tiki_p_admin_trackers, $trklib, $tikilib;
	include_once('lib/trackers/trackerlib.php');
	extract ($params,EXTR_SKIP);

	if ($prefs['feature_trackers'] != 'y' || !isset($trackerId) || !($tracker_info = $trklib->get_tracker($trackerId))) {
		return $smarty->fetch("wiki-plugins/error_tracker.tpl");
	}
	$perms = Perms::get(array('type'=>'tracker', 'object'=>$trackerId));
	if (!$perms->view_trackers) {
		return tra('Permission denied');
	}

	if (!isset($status)) {
		$status = 'o';
	} elseif (!$trklib->valid_status($status)) {
		return "invalid status";
	}
	if (isset($show_percent) && $show_percent == 'y') {
		$average = 'y';
		$smarty->assign('show_percent', 'y');
	} else {
		$smarty->assign('show_percent', 'n');
	}<commit_msg>[NEW]TRACKERSTAT: new param show_lastmodif that show the lastmodif date of the items of a tracker. Note it does not respect perms - all the items are considered<commit_after><?php

// $Id: /cvsroot/tikiwiki/tiki/lib/wiki-plugins/wikiplugin_trackerstat.php,v 1.14.2.5 2007-12-18 23:03:15 sylvieg Exp $
/* to have some statistiques about a tracker
 * will returns a table with for each tracker field, the list of values and the number of times the values occurs
 * trackerId = the id of the tracker
 * fields = the iof of the fields you wnat the stat - the fields must be public
 * show_percent : optionnal - to show a percent
 * show_bar : optionnal to show a bar(length 100 pixels)
 * status : optionnal to filter on the status ( a combinaison of letters c:close, o:open, p:pending)
 */
function wikiplugin_trackerstat_help()
{
	$help = tra("Displays some stat of a tracker content, fields are indicated with numeric ids.").":\n";
	$help.= "~np~{TRACKERSTAT(trackerId=>1,fields=>2:4:5,show_percent=>y,show_bar=>n,status=>o|c|p|op|oc|pc|opc,show_link=n)}Title{TRACKERSTAT}~/np~";
	return $help;
}

function wikiplugin_trackerstat_info()
{
	return array(
		'name' => tra('Tracker Stats'),
		'documentation' => 'PluginTrackerStat',
		'description' => tra("Displays some stat of a tracker content, fields are indicated with numeric ids."),
		'prefs' => array( 'feature_trackers', 'wikiplugin_trackerstat' ),
		'body' => tra('Title'),
		'icon' => 'pics/icons/database_lightning.png',
		'params' => array(
			'trackerId' => array(
				'required' => true,
				'name' => tra('Tracker ID'),
				'description' => tra('Tracker ID'),
			),
			'fields' => array(
				'required' => true,
				'name' => tra('Fields'),
				'description' => tra('Colon-separated list of field IDs to be displayed. Example: 2:4:5'),
			),
			'show_percent' => array(
				'required' => false,
				'name' => tra('Show Percentage'),
				'description' => 'y|n',
			),
			'show_bar' => array(
				'required' => false,
				'name' => tra('Show Bar'),
				'description' => 'y|n',
			),
			'status' => array(
				'required' => false,
				'name' => tra('Status Filter'),
				'description' => 'o|p|c|op|oc|pc|opc'.' '.tra('Which item status to list. o = open, p = pending, c = closed.'),
			),
			'show_link' => array(
				'required' => false,
				'name' => tra('Show link to tiki-view_tracker'),
				'description' => 'y|n',
			),
			'show_lastmodif' => array(
				'required' => false,
				'name' => tra('Show last modification date of a tracker'),
				'description' => tra('Date format'),
				'filter' => 'text'
			),
		),
	);
}

function wikiplugin_trackerstat($data, $params)
{
	global $smarty, $prefs, $tiki_p_admin_trackers, $trklib, $tikilib;
	include_once('lib/trackers/trackerlib.php');
	extract ($params,EXTR_SKIP);

	if ($prefs['feature_trackers'] != 'y' || !isset($trackerId) || !($tracker_info = $trklib->get_tracker($trackerId))) {
		return $smarty->fetch("wiki-plugins/error_tracker.tpl");
	}
	$perms = Perms::get(array('type'=>'tracker', 'object'=>$trackerId));
	if (!$perms->view_trackers) {
		return tra('Permission denied');
	}
	if (!empty($show_lastmodif)) {
		$date = $trklib->lastModif($trackerId);
		if (!function_exists('smarty_modifier_tiki_date_format')) {
			include('lib/smarty_tiki/modifier.tiki_date_format.php');
		}
		if ($show_lastmodif == 'y') {
			$show_lastmodif = $prefs['short_date_format'];
		}
		return smarty_modifier_tiki_date_format($date, tra($show_lastmodif));
	}

	if (!isset($status)) {
		$status = 'o';
	} elseif (!$trklib->valid_status($status)) {
		return "invalid status";
	}

	if (isset($show_percent) && $show_percent == 'y') {
		$average = 'y';
		$smarty->assign('show_percent', 'y');
	} else {
		$smarty->assign('show_percent', 'n');
	}
{'fraction_non_alphanumeric': 0.18100147275405007, 'fraction_numerical': 0.008541973490427098, 'mean_word_length': 4.415470494417863, 'pattern_counts': {'":': 2, '<': 5, '<?xml version=': 0, '>': 97, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '359240', 'n_tokens_mistral': 2679, 'n_tokens_neox': 2424, 'n_words': 581}