<commit_before><?php

class Indira{


	/**
	 * Run it in start.php
	 * $configs string|array|null
	 *
	 * @return void
	 */
	public static function start($configs = null){

		if($configs){
			self::set($configs);
		}

		static::set_languages();
		static::set_template();
		static::load_modules();
	}

	/**
	 * Run it in 'before' route filter
	 *
	 * @return void
	 */
	public static function before(){

		static::set_language();
		static::set_admin();
		static::set_user();
	}


	/**
	 * Set config from FileDB Settings table 
	 *
	 * @param string|array $prefix application, auth, session, etc.
	 * @return void
	 */
	public static function set($paths){

		if(!is_array($paths)){

			if(stripos($paths, '.')){

				list($path, $param) = explode('.', $paths);

				$data = Settings::where('type', '=', $path)->and_where('param', '=', $param)->get();

			}else{

				$paths = array($paths);
			}

		}else{

			$data = Settings::where('type', '=', $paths)->get();
		}
			
		if($data){
			
			foreach($data as $id => $row){

				$row->value = ($row->value == 'false' || $row->value == 'true') ? ($row->value === 'true') : $row->value;

				$row->value = (is_object($row->value)) ? Filedb::object_to_array($row->value) : $row->value;

				Config::set($row->type.'.'.$row->param, $row->value);
			}
		}
	}


	/**
	 * Get value from 'indira.*' Config array
	 * Returns boolean value if string value is 'true' or 'false'
	 *
	 * @param string $param
	 * @return string|boolean
	 */
	public static function get($param){

		$data = (Config::has('indira.'.$param)) ? Config::get('indira.'.$param) : false;

		if($data == 'true'){

			return true;
		
		}elseif($data == 'false'){

			return false;
		
		}else{

			return $data;
		}
	}


	/**
	 * Set Modules link into config array
	 *
	 * @return void
	 */
	public static function load_modules(){

		foreach(Modules::get(array('link', 'name', 'active', 'access', 'view_access')) as $module){
			
			Config::set('indira.modules.'.$module->name.'.link', (isset($module->link)) ? $module->link : 'false' );
			Config::set('indira.modules.'.$module->name.'.access', (int) (isset($module->access)) ? $module->access : 777 );
			Config::set('indira.modules.'.$module->name.'.view_access', (int) (isset($module->view_access)) ? $module->view_access : 777 );
			Config::set('indira.modules.'.$module->name.'.active', (bool) (isset($module->active)) ? ($module->active == 'true') : false );
		}
	}


	/**
	 * Set languages array to config
	 *
	 * @return void
	 */
	public static function set_languages(){

		$languages = Langtable::init();

		if($languages->count() > 1){

			foreach($languages->get(array('lang')) as $lang){

				$langs[] = $lang->lang;
			}

			Config::set('application.languages', $langs);
		}
	}


	/**
	 * Template name to config - 'indira.template'
	 * And register Bundle's name
	 *
	 * @var    $id 	template id
	 * @return void
	 */
	public static function set_template($id = null){

		$template = Templates::init();
		
		if($id){

			$desktop = $mobile = Templates::where_id($id)->only('name');
		
		}else{<commit_msg>Load full info from Lang table into Config<commit_after><?php

class Indira{


	/**
	 * Run it in start.php
	 * $configs string|array|null
	 *
	 * @return void
	 */
	public static function start($configs = null){

		if($configs){
			self::set($configs);
		}

		static::set_languages();
		static::set_template();
		static::load_modules();
	}

	/**
	 * Run it in 'before' route filter
	 *
	 * @return void
	 */
	public static function before(){

		static::set_language();
		static::set_admin();
		static::set_user();
	}


	/**
	 * Set config from FileDB Settings table 
	 *
	 * @param string|array $prefix application, auth, session, etc.
	 * @return void
	 */
	public static function set($paths){

		if(!is_array($paths)){

			if(stripos($paths, '.')){

				list($path, $param) = explode('.', $paths);

				$data = Settings::where('type', '=', $path)->and_where('param', '=', $param)->get();

			}else{

				$paths = array($paths);
			}

		}else{

			$data = Settings::where('type', '=', $paths)->get();
		}
			
		if($data){
			
			foreach($data as $id => $row){

				$row->value = ($row->value == 'false' || $row->value == 'true') ? ($row->value === 'true') : $row->value;

				$row->value = (is_object($row->value)) ? Filedb::object_to_array($row->value) : $row->value;

				Config::set($row->type.'.'.$row->param, $row->value);
			}
		}
	}


	/**
	 * Get value from 'indira.*' Config array
	 * Returns boolean value if string value is 'true' or 'false'
	 *
	 * @param string $param
	 * @return string|boolean
	 */
	public static function get($param){

		$data = (Config::has('indira.'.$param)) ? Config::get('indira.'.$param) : false;

		if($data == 'true'){

			return true;
		
		}elseif($data == 'false'){

			return false;
		
		}else{

			return $data;
		}
	}


	/**
	 * Set Modules link into config array
	 *
	 * @return void
	 */
	public static function load_modules(){

		foreach(Modules::get(array('link', 'name', 'active', 'access', 'view_access')) as $module){
			
			Config::set('indira.modules.'.$module->name.'.link', (isset($module->link)) ? $module->link : 'false' );
			Config::set('indira.modules.'.$module->name.'.access', (int) (isset($module->access)) ? $module->access : 777 );
			Config::set('indira.modules.'.$module->name.'.view_access', (int) (isset($module->view_access)) ? $module->view_access : 777 );
			Config::set('indira.modules.'.$module->name.'.active', (bool) (isset($module->active)) ? ($module->active == 'true') : false );
		}
	}


	/**
	 * Set languages array to config
	 *
	 * @return void
	 */
	public static function set_languages(){

		$languages = Langtable::init();

		if($languages->count() > 1){

			foreach($languages->get(array('lang', 'text_lang', 'ietf')) as $lang){

				$langs[] = $lang->lang;

				Config::set('indira.language.'.$lang->lang.'.params.ietf', $lang->ietf);
				Config::set('indira.language.'.$lang->lang.'.params.text', $lang->text_lang);
				Config::set('indira.language.'.$lang->lang.'.params.lang', $lang->lang);
			}

			Config::set('application.languages', $langs);
		}
	}


	/**
	 * Template name to config - 'indira.template'
	 * And register Bundle's name
	 *
	 * @var    $id 	template id
	 * @return void
	 */
	public static function set_template($id = null){

		$template = Templates::init();
		
		if($id){

			$desktop = $mobile = Templates::where_id($id)->only('name');
		
		}else{
{'fraction_non_alphanumeric': 0.21469628709025942, 'fraction_numerical': 0.0021749262078608047, 'mean_word_length': 3.480167014613779, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 75, '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': '5427404', 'n_tokens_mistral': 2505, 'n_tokens_neox': 2120, 'n_words': 452}