<commit_before><?php

/**
 * The context object handles the current configuration file and different
 * useful functions associated to the current view state.
 */
class FreshRSS_Context {
	public static $user_conf = null;
	public static $system_conf = null;
	public static $categories = array();

	public static $name = '';
	public static $description = '';

	public static $total_unread = 0;
	public static $total_starred = array(
		'all' => 0,
		'read' => 0,
		'unread' => 0,
	);

	public static $get_unread = 0;
	public static $current_get = array(
		'all' => false,
		'starred' => false,
		'feed' => false,
		'category' => false,
	);
	public static $next_get = 'a';

	public static $state = 0;
	public static $order = 'DESC';
	public static $number = 0;
	public static $search;
	public static $first_id = '';
	public static $next_id = '';
	public static $id_max = '';

	/**
	 * Initialize the context.
	 *
	 * Set the correct configurations and $categories variables.
	 */
	public static function init() {
		// Init configuration.
		self::$system_conf = Minz_Configuration::get('system');
		self::$user_conf = Minz_Configuration::get('user');

		$catDAO = new FreshRSS_CategoryDAO();
		self::$categories = $catDAO->listCategories();
	}

	/**
	 * Returns if the current state includes $state parameter.
	 */
	public static function isStateEnabled($state) {
		return self::$state & $state;
	}

	/**
	 * Returns the current state with or without $state parameter.
	 */
	public static function getRevertState($state) {
		if (self::$state & $state) {
			return self::$state & ~$state;
		} else {
			return self::$state | $state;
		}
	}

	/**
	 * Return the current get as a string or an array.
	 *
	 * If $array is true, the first item of the returned value is 'f' or 'c' and
	 * the second is the id.
	 */
	public static function currentGet($array = false) {
		if (self::$current_get['all']) {
			return 'a';
		} elseif (self::$current_get['starred']) {
			return 's';
		} elseif (self::$current_get['feed']) {
			if ($array) {
				return array('f', self::$current_get['feed']);
			} else {
				return 'f_' . self::$current_get['feed'];
			}
		} elseif (self::$current_get['category']) {
			if ($array) {
				return array('c', self::$current_get['category']);
			} else {
				return 'c_' . self::$current_get['category'];
			}
		}
	}

	/**
	 * Return true iif the current requests target a feed and not a category or all articles.
	 */
	public static function isFeed() {
		return self::$current_get['feed'] != false;
	}

	/**
	 * Return true if $get parameter correspond to the $current_get attribute.
	 */
	public static function isCurrentGet($get) {
		$type = $get[0];
		$id = substr($get, 2);

		switch($type) {<commit_msg>Iff expanded to "true if ..., false otherwise"<commit_after><?php

/**
 * The context object handles the current configuration file and different
 * useful functions associated to the current view state.
 */
class FreshRSS_Context {
	public static $user_conf = null;
	public static $system_conf = null;
	public static $categories = array();

	public static $name = '';
	public static $description = '';

	public static $total_unread = 0;
	public static $total_starred = array(
		'all' => 0,
		'read' => 0,
		'unread' => 0,
	);

	public static $get_unread = 0;
	public static $current_get = array(
		'all' => false,
		'starred' => false,
		'feed' => false,
		'category' => false,
	);
	public static $next_get = 'a';

	public static $state = 0;
	public static $order = 'DESC';
	public static $number = 0;
	public static $search;
	public static $first_id = '';
	public static $next_id = '';
	public static $id_max = '';

	/**
	 * Initialize the context.
	 *
	 * Set the correct configurations and $categories variables.
	 */
	public static function init() {
		// Init configuration.
		self::$system_conf = Minz_Configuration::get('system');
		self::$user_conf = Minz_Configuration::get('user');

		$catDAO = new FreshRSS_CategoryDAO();
		self::$categories = $catDAO->listCategories();
	}

	/**
	 * Returns if the current state includes $state parameter.
	 */
	public static function isStateEnabled($state) {
		return self::$state & $state;
	}

	/**
	 * Returns the current state with or without $state parameter.
	 */
	public static function getRevertState($state) {
		if (self::$state & $state) {
			return self::$state & ~$state;
		} else {
			return self::$state | $state;
		}
	}

	/**
	 * Return the current get as a string or an array.
	 *
	 * If $array is true, the first item of the returned value is 'f' or 'c' and
	 * the second is the id.
	 */
	public static function currentGet($array = false) {
		if (self::$current_get['all']) {
			return 'a';
		} elseif (self::$current_get['starred']) {
			return 's';
		} elseif (self::$current_get['feed']) {
			if ($array) {
				return array('f', self::$current_get['feed']);
			} else {
				return 'f_' . self::$current_get['feed'];
			}
		} elseif (self::$current_get['category']) {
			if ($array) {
				return array('c', self::$current_get['category']);
			} else {
				return 'c_' . self::$current_get['category'];
			}
		}
	}

	/**
	 * Return true if the current request targets a feed (and not a category or all articles), false otherwise.
	 */
	public static function isFeed() {
		return self::$current_get['feed'] != false;
	}

	/**
	 * Return true if $get parameter correspond to the $current_get attribute.
	 */
	public static function isCurrentGet($get) {
		$type = $get[0];
		$id = substr($get, 2);

		switch($type) {
{'fraction_non_alphanumeric': 0.15282573141922587, 'fraction_numerical': 0.0032709431219334908, 'mean_word_length': 3.6604572396274344, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 19, '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': '2060508', 'n_tokens_mistral': 1899, 'n_tokens_neox': 1747, 'n_words': 546}