<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$

function wikiplugin_colorbox_info()
{
	return array(
		'name' => tra('Colorbox'),
		'documentation' => 'PluginColorBox',
		'description' => tra('Display a gallery of images in a popup slideshow'),
		'prefs' => array( 'feature_file_galleries', 'feature_shadowbox', 'wikiplugin_colorbox' ),
		'introduced' => 5,
		'icon' => 'img/icons/pictures.png',
		'tags' => array( 'basic' ),		
		'params' => array(
			'fgalId' => array(
				'required' => false,
				'name' => tra('File Gallery ID'),
				'description' => tra('ID number of the file gallery that contains the images to be displayed'),
				'filter' => 'digits',
				'accepted' => 'ID',
				'default' => '',
				'since' => '5.0',
				'profile_reference' => 'file_gallery',
				),
			'galId' => array(
				'required' => false,
				'name' => tra('Image Gallery ID'),
				'description' => tra('ID number of the image gallery that contains the images to be displayed'),
				'filter' => 'digits',
				'accepted' => 'ID',
				'default' => '',
				'since' => '5.0'
				),
			'fileId' => array(
				'required' => false,
				'name' => tra('File ID Filter'),
				'description' => tra('Filter on fileIds in a file gallery to only show those images. Separate each fileId with \':\''),
				'filter' => 'digits',
				'separator' => ':',
				'accepted' => 'ID separated with :',
				'default' => '',
				'since' => '6.0'
				),
			'thumb' => array(
				'required' => false,
				'name' => tra('Thumb'),
				'description' => tra('Display as a thumbnail (y) or full size (n)'),
				'filter' => 'alpha',
				'accepted' => 'y or n',
				'default' => 'y',
				'since' => '5.0',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n'),
					),
				),
			'sort_mode' => array(
				'required' => false,
				'name' => tra('Sort Mode'),
				'description' => tra('Sort by database table field name, ascending or descending. Examples: fileId_asc or name_desc.'),
				'filter' => 'word',
				'accepted' => 'fieldname_asc or fieldname_desc with actual table field name in place of \'fieldname\'.',
				'default' => 'created_desc',
				'since' => '5.0'
				),
			'showtitle' => array(
				'required' => false,
				'name' => tra('Show File Title'),
				'description' => tra('Show file title'),
				'filter' => 'alpha',
				'accepted' => 'y or n',
				'default' => 'n',
				'since' => '5.0',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n'),
				),
			),
			'showfilename' => array(
				'required' => false,
				'name' => tra('Show File Name'),
				'description' => tra('Show file name'),
				'filter' => 'alpha',
				'accepted' => 'y or n',
				'default' => 'n',
				'since' => '5.0',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n'),
				),
			),
			'showallthumbs' => array(
				'required' => false,
				'name' => tra('Show All Thumbs'),
				'description' => tra('Show thumbnails of all the images in the gallery'),
				'filter' => 'alpha',
				'accepted' => 'y or n',
				'default' => 'n',
				'since' => '5.0',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n'),
				),
			),
			'parsedescriptions' => array(
				'required' => false,
				'name' => tra('Parse Descriptions'),
				'description' => tra('Parse the file descriptions as wiki syntax'),
				'filter' => 'alpha',
				'accepted' => 'y or n',
				'default' => 'n',
				'since' => '5.0',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n'),
				),
			),
		),
	);
}
function wikiplugin_colorbox($data, $params)
{
	global $user, $prefs;
	static $iColorbox = 0;
	$default = array('showfilename' => 'n', 'showtitle'=>'n', 'thumb'=>'y', 'showallthumbs'=>'n', 'parsedescriptions'=>'n');
	$params = array_merge($default, $params);
	$smarty = TikiLib::lib('smarty');
	$tikilib = TikiLib::lib('tiki');

	if (!empty($params['fgalId'])) {
		if ($prefs['feature_file_galleries'] != 'y') {
			return tra('This feature is disabled') . ': feature_file_galleries';
		}
		if (!$tikilib->user_has_perm_on_object($user, $params['fgalId'], 'file gallery', 'tiki_p_view_file_gallery')) {
			return tra('Permission denied');
		}
		if (empty($params['sort_mode'])) $params['sort_mode'] = 'created_desc';
		$filter = empty($params['fileId'])? array(): array('fileId'=> $params['fileId']);
		if (!is_array($filter['fileId'])) {
			$filter['fileId'] = explode(':', $filter['fileId']);
		}
        if (!array_filter($filter["fileId"])) {
            $filter='';
        }

		$filegallib = TikiLib::lib('filegal');
		$files = $filegallib->get_files(0, -1, $params['sort_mode'], '', $params['fgalId'], false, false, false, true, false, false, false, false, '', true, false, false, $filter);
		$smarty->assign('colorboxUrl', 'tiki-download_file.php?fileId=');
		$smarty->assign('colorboxColumn', 'id');
		if ($params['thumb'] != 'n') {
			$smarty->assign('colorboxThumb', 'thumbnail');
		} else {
			$smarty->assign('colorboxThumb', 'display');
		}
	} elseif (!empty($params['galId'])) {
		if ($prefs['feature_galleries'] != 'y') {
			return tra('This feature is disabled') . ': feature_galleries';
		}
		if (!$tikilib->user_has_perm_on_object($user, $params['galId'], 'gallery', 'tiki_p_view_image_gallery')) {
			return tra('Permission denied');
		}
		$imagegallib = TikiLib::lib('imagegal');
		if (empty($params['sort_mode'])) $params['sort_mode'] = 'created_desc';
		$files = $imagegallib->get_images(0, -1, $params['sort_mode'], '', $params['galId']);
		$smarty->assign('colorboxUrl', 'show_image.php?id=');
		$smarty->assign('colorboxColumn', 'imageId');<commit_msg>[REF]Convert white spaces into tabs. thanks gezza (I wonder why phpstorm was inserting spaces)<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$

function wikiplugin_colorbox_info()
{
	return array(
		'name' => tra('Colorbox'),
		'documentation' => 'PluginColorBox',
		'description' => tra('Display a gallery of images in a popup slideshow'),
		'prefs' => array( 'feature_file_galleries', 'feature_shadowbox', 'wikiplugin_colorbox' ),
		'introduced' => 5,
		'icon' => 'img/icons/pictures.png',
		'tags' => array( 'basic' ),		
		'params' => array(
			'fgalId' => array(
				'required' => false,
				'name' => tra('File Gallery ID'),
				'description' => tra('ID number of the file gallery that contains the images to be displayed'),
				'filter' => 'digits',
				'accepted' => 'ID',
				'default' => '',
				'since' => '5.0',
				'profile_reference' => 'file_gallery',
				),
			'galId' => array(
				'required' => false,
				'name' => tra('Image Gallery ID'),
				'description' => tra('ID number of the image gallery that contains the images to be displayed'),
				'filter' => 'digits',
				'accepted' => 'ID',
				'default' => '',
				'since' => '5.0'
				),
			'fileId' => array(
				'required' => false,
				'name' => tra('File ID Filter'),
				'description' => tra('Filter on fileIds in a file gallery to only show those images. Separate each fileId with \':\''),
				'filter' => 'digits',
				'separator' => ':',
				'accepted' => 'ID separated with :',
				'default' => '',
				'since' => '6.0'
				),
			'thumb' => array(
				'required' => false,
				'name' => tra('Thumb'),
				'description' => tra('Display as a thumbnail (y) or full size (n)'),
				'filter' => 'alpha',
				'accepted' => 'y or n',
				'default' => 'y',
				'since' => '5.0',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n'),
					),
				),
			'sort_mode' => array(
				'required' => false,
				'name' => tra('Sort Mode'),
				'description' => tra('Sort by database table field name, ascending or descending. Examples: fileId_asc or name_desc.'),
				'filter' => 'word',
				'accepted' => 'fieldname_asc or fieldname_desc with actual table field name in place of \'fieldname\'.',
				'default' => 'created_desc',
				'since' => '5.0'
				),
			'showtitle' => array(
				'required' => false,
				'name' => tra('Show File Title'),
				'description' => tra('Show file title'),
				'filter' => 'alpha',
				'accepted' => 'y or n',
				'default' => 'n',
				'since' => '5.0',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n'),
				),
			),
			'showfilename' => array(
				'required' => false,
				'name' => tra('Show File Name'),
				'description' => tra('Show file name'),
				'filter' => 'alpha',
				'accepted' => 'y or n',
				'default' => 'n',
				'since' => '5.0',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n'),
				),
			),
			'showallthumbs' => array(
				'required' => false,
				'name' => tra('Show All Thumbs'),
				'description' => tra('Show thumbnails of all the images in the gallery'),
				'filter' => 'alpha',
				'accepted' => 'y or n',
				'default' => 'n',
				'since' => '5.0',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n'),
				),
			),
			'parsedescriptions' => array(
				'required' => false,
				'name' => tra('Parse Descriptions'),
				'description' => tra('Parse the file descriptions as wiki syntax'),
				'filter' => 'alpha',
				'accepted' => 'y or n',
				'default' => 'n',
				'since' => '5.0',
				'options' => array(
					array('text' => '', 'value' => ''),
					array('text' => tra('Yes'), 'value' => 'y'),
					array('text' => tra('No'), 'value' => 'n'),
				),
			),
		),
	);
}
function wikiplugin_colorbox($data, $params)
{
	global $user, $prefs;
	static $iColorbox = 0;
	$default = array('showfilename' => 'n', 'showtitle'=>'n', 'thumb'=>'y', 'showallthumbs'=>'n', 'parsedescriptions'=>'n');
	$params = array_merge($default, $params);
	$smarty = TikiLib::lib('smarty');
	$tikilib = TikiLib::lib('tiki');

	if (!empty($params['fgalId'])) {
		if ($prefs['feature_file_galleries'] != 'y') {
			return tra('This feature is disabled') . ': feature_file_galleries';
		}
		if (!$tikilib->user_has_perm_on_object($user, $params['fgalId'], 'file gallery', 'tiki_p_view_file_gallery')) {
			return tra('Permission denied');
		}
		if (empty($params['sort_mode'])) $params['sort_mode'] = 'created_desc';
		$filter = empty($params['fileId'])? array(): array('fileId'=> $params['fileId']);
		if (!is_array($filter['fileId'])) {
			$filter['fileId'] = explode(':', $filter['fileId']);
		}
		if (!array_filter($filter["fileId"])) {
			$filter='';
		}

		$filegallib = TikiLib::lib('filegal');
		$files = $filegallib->get_files(0, -1, $params['sort_mode'], '', $params['fgalId'], false, false, false, true, false, false, false, false, '', true, false, false, $filter);
		$smarty->assign('colorboxUrl', 'tiki-download_file.php?fileId=');
		$smarty->assign('colorboxColumn', 'id');
		if ($params['thumb'] != 'n') {
			$smarty->assign('colorboxThumb', 'thumbnail');
		} else {
			$smarty->assign('colorboxThumb', 'display');
		}
	} elseif (!empty($params['galId'])) {
		if ($prefs['feature_galleries'] != 'y') {
			return tra('This feature is disabled') . ': feature_galleries';
		}
		if (!$tikilib->user_has_perm_on_object($user, $params['galId'], 'gallery', 'tiki_p_view_image_gallery')) {
			return tra('Permission denied');
		}
		$imagegallib = TikiLib::lib('imagegal');
		if (empty($params['sort_mode'])) $params['sort_mode'] = 'created_desc';
		$files = $imagegallib->get_images(0, -1, $params['sort_mode'], '', $params['galId']);
		$smarty->assign('colorboxUrl', 'show_image.php?id=');
		$smarty->assign('colorboxColumn', 'imageId');
{'fraction_non_alphanumeric': 0.22980922098569156, 'fraction_numerical': 0.005087440381558029, 'mean_word_length': 3.7225975975975976, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 269, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '810201', 'n_tokens_mistral': 5137, 'n_tokens_neox': 4359, 'n_words': 1040}