<commit_before><?php
/**
 * This file is part of Rudolf.
 *
 * Navigation.
 *
 * @author <NAME> <<EMAIL>>
 * @package Rudolf\Html
 * @version 0.1
 */

namespace Rudolf\Html;

class Navigation {

	/**
	 * It create page navigation
	 * 
	 * @param array $items Array of navigation items
	 * @param int $current Id of current page
	 * @param array $classes
	 * @param int $nesting
	 * 
	 * @return string
	 */
	public function createPageNavigation($type, $items, $current, $classes, $nesting = 0) {
		$builder = new \Rudolf\Libs\MenuBuilder();
		foreach ($items as $key => $value) {
			if($type === $value['menu_type']) {
				$newItems[] = $items[$key];
			}
		}

		return $builder->getMenuHtml(0, $newItems, DIR.'/', $classes, $current, $nesting);
	}

	/**
	 * It create breadcrumb
	 *
	 * @param boolean $a create breadcrumb or only return array with breadrumb data
	 * @param array $menu array with menu elements<commit_msg>Add sort by `position` feature<commit_after><?php
/**
 * This file is part of Rudolf.
 *
 * Navigation.
 *
 * @author <NAME> <<EMAIL>>
 * @package Rudolf\Html
 * @version 0.1
 */

namespace Rudolf\Html;
use Rudolf\Libs\MenuBuilder;

class Navigation {

	/**
	 * It create page navigation
	 * 
	 * @param array $items Array of navigation items
	 * @param int $current Id of current page
	 * @param array $classes
	 * @param int $nesting
	 * 
	 * @return string
	 */
	public function createPageNavigation($type, $items, $current, $classes, $nesting = 0) {
		$builder = new MenuBuilder();
		foreach ($items as $key => $value) {
			if($type === $value['menu_type']) {
				$newItems[] = $items[$key];
			}
		}

		if(empty($newItems)) {
			return false;
		}

		usort($newItems, [$this, 'sortByPosition']);

		return $builder->getMenuHtml(0, $newItems, DIR.'/', $classes, $current, $nesting);
	}

	function sortByPosition($a, $b) {
	    return $a['position'] - $b['position'];
	}

	/**
	 * It create breadcrumb
	 *
	 * @param boolean $a create breadcrumb or only return array with breadrumb data
	 * @param array $menu array with menu elements
{'fraction_non_alphanumeric': 0.1533980582524272, 'fraction_numerical': 0.003883495145631068, 'mean_word_length': 3.4901960784313726, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, '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': '4298592', 'n_tokens_mistral': 740, 'n_tokens_neox': 659, 'n_words': 205}