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

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
  header("location: index.php");
  exit;
}

/* params
 * - link_on_section
 * - css = use suckerfish menu
 * - type = vert|horiz
 * - id = menu ID (mandatory)
 * - translate = y|n , n means no option translation (default y)
 * - menu_cookie=y|n (default y) n, it will automatically open the submenu the url is in
 * - sectionLevel: displays from this level only
 * - toLevel : displays to this level only
 * - drilldown ??
 * - bootstrap : navbar|basic (equates to horiz or vert in old menus)
 * - setSelected=y|n (default=y) processes all menu items to show currently selected item, also sets open states, sectionLevel, toLevel etc
 * 								so menu_cookie, sectionLevel and toLevel will be ignored if this is set to n
 */
function smarty_function_menu($params, $smarty)
{
	global $prefs;
	$headerlib = TikiLib::lib('header');

	$default = array('css' => 'y');
	if (isset($params['params'])) {
		$params = array_merge($params, $params['params']);
		unset($params['params']);
	}
	$params = array_merge($default, $params);
	extract($params, EXTR_SKIP);

	if ($prefs['javascript_enabled'] !== 'y') {
		// cssmenu actually uses JavaScript. cssmenu should surely be removed. 2017-06-04
		$params['css'] = 'y';
		$params['bootstrap'] = 'n';
		$params['type'] = 'horiz';
	}

	if (empty($link_on_section) || $link_on_section == 'y') {
		$smarty->assign('link_on_section', 'y');
	} else {
		 $smarty->assign('link_on_section', 'n');
	}
	if (empty($translate)) {
		$translate = 'y';
	}
	$smarty->assignByRef('translate', $translate);
	if (empty($menu_cookie)) {
		$menu_cookie = 'y';
	}
	$smarty->assignByRef('menu_cookie', $menu_cookie);
	if (empty($drilldown)) {
		$drilldown = 'n';
	}
	if ($params['css'] !== 'n' && $prefs['feature_cssmenus'] == 'y') {
		static $idCssmenu = 0;
		if (empty($params['type'])) {
			$params['type'] = 'vert';
		}
		$headerlib->add_jsfile('lib/menubuilder/menu.js');
		$tpl = 'tiki-user_cssmenu.tpl';
		$smarty->assign('menu_type', $params['type']);
		if (! isset($css_id)) {//adding $css_id parameter to customize menu id and prevent automatic id renaming when a menu is removed
			$smarty->assign('idCssmenu', $idCssmenu++);
		} else {
			$smarty->assign('idCssmenu', $css_id);
		}
		if ($drilldown == 'y') {
			$smarty->assign('drilldownmenu', $drilldown);
		}
	} else {
		$tpl = 'tiki-user_menu.tpl';
	}

	list($menu_info, $channels) = get_menu_with_selections($params);
	$smarty->assign('menu_channels', $channels['data']);
	$smarty->assign('menu_info', $menu_info);

	if (isset($params['bootstrap']) && $params['bootstrap'] !== 'n') {
		$structured = array();
		$activeSection = null;
		foreach ($channels['data'] as $element) {
			if ($element['type'] == 's') {
				if ($activeSection) {
					$structured[] = $activeSection;
				}

				$activeSection = $element;
				$activeSection['children'] = array();
			} elseif ($element['type'] == 'o') {
				if ($activeSection) {
					$activeSection['children'][] = $element;
				} else {
					$structured[] = $element;
				}
			} elseif($element['type'] == '-') {
				if ($activeSection) {
					$structured[] = $activeSection;
				}
				$activeSection = null;
			}
		}

		if ($activeSection) {
			$structured[] = $activeSection;<commit_msg>[REF] Clarify<commit_after><?php
// (c) Copyright 2002-2016 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$

//this script may only be included - so its better to die if called directly.
if (strpos($_SERVER["SCRIPT_NAME"], basename(__FILE__)) !== false) {
  header("location: index.php");
  exit;
}

/* params
 * - link_on_section
 * - css = use suckerfish menu
 * - type = vert|horiz
 * - id = menu ID (mandatory)
 * - translate = y|n , n means no option translation (default y)
 * - menu_cookie=y|n (default y) n, it will automatically open the submenu the url is in
 * - sectionLevel: displays from this level only
 * - toLevel : displays to this level only
 * - drilldown ??
 * - bootstrap : navbar|basic (equates to horiz or vert in old menus)
 * - setSelected=y|n (default=y) processes all menu items to show currently selected item, also sets open states, sectionLevel, toLevel etc
 * 								so menu_cookie, sectionLevel and toLevel will be ignored if this is set to n
 */
function smarty_function_menu($params, $smarty)
{
	global $prefs;
	$headerlib = TikiLib::lib('header');

	$default = array('css' => 'y');
	if (isset($params['params'])) {
		$params = array_merge($params, $params['params']);
		unset($params['params']);
	}
	$params = array_merge($default, $params);
	extract($params, EXTR_SKIP);

	if ($prefs['javascript_enabled'] !== 'y') {
		// cssmenu actually uses JavaScript. cssmenu should surely be removed. 2017-06-04
		$params['css'] = 'y';
		$params['bootstrap'] = 'n';
		$params['type'] = 'horiz';
	}

	if (empty($link_on_section) || $link_on_section == 'y') {
		$smarty->assign('link_on_section', 'y');
	} else {
		 $smarty->assign('link_on_section', 'n');
	}

	if (empty($translate)) {
		$translate = 'y';
	}
	$smarty->assignByRef('translate', $translate);

	if (empty($menu_cookie)) {
		$menu_cookie = 'y';
	}
	$smarty->assignByRef('menu_cookie', $menu_cookie);

	if (empty($drilldown)) {
		$drilldown = 'n';
	}

	list($menu_info, $channels) = get_menu_with_selections($params);
	$smarty->assign('menu_channels', $channels['data']);
	$smarty->assign('menu_info', $menu_info);

	if ($params['css'] !== 'n' && $prefs['feature_cssmenus'] == 'y') {
		static $idCssmenu = 0;
		if (empty($params['type'])) {
			$params['type'] = 'vert';
		}
		$headerlib->add_jsfile('lib/menubuilder/menu.js');
		$tpl = 'tiki-user_cssmenu.tpl';
		$smarty->assign('menu_type', $params['type']);
		if (! isset($css_id)) {//adding $css_id parameter to customize menu id and prevent automatic id renaming when a menu is removed
			$smarty->assign('idCssmenu', $idCssmenu++);
		} else {
			$smarty->assign('idCssmenu', $css_id);
		}
		if ($drilldown == 'y') {
			$smarty->assign('drilldownmenu', $drilldown);
		}
	} else {
		$tpl = 'tiki-user_menu.tpl';
	}
	if (isset($params['bootstrap']) && $params['bootstrap'] !== 'n') {
		$structured = array();
		$activeSection = null;
		foreach ($channels['data'] as $element) {
			if ($element['type'] == 's') {
				if ($activeSection) {
					$structured[] = $activeSection;
				}

				$activeSection = $element;
				$activeSection['children'] = array();
			} elseif ($element['type'] == 'o') {
				if ($activeSection) {
					$activeSection['children'][] = $element;
				} else {
					$structured[] = $element;
				}
			} elseif($element['type'] == '-') {
				if ($activeSection) {
					$structured[] = $activeSection;
				}
				$activeSection = null;
			}
		}

		if ($activeSection) {
			$structured[] = $activeSection;
{'fraction_non_alphanumeric': 0.18032111980238782, 'fraction_numerical': 0.00466584328255798, 'mean_word_length': 4.12878254750176, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 27, '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': '6867171', 'n_tokens_mistral': 2728, 'n_tokens_neox': 2472, 'n_words': 630}