<commit_before><?php
	namespace core\modules;
	
	
	use core\App;
	use core\functions\ChaineCaractere;
	
	class RouterModule {
		//varaibles de base de config
		private $controller;
		private $erreur;
		private $parametre;
		private $module; //varialbe qui contiendra le nom d'un module
		private $page;
		private $admin; //permet de savoir si on est dans l'administration du site ou pas et de charger lebon router
		
		
		//-------------------------- GETTER ----------------------------------------------------------------------------//
		//pour les parametres du getUrl ++ getAction ++ getController
		public function getParametre() {
			return $this->parametre;
		}
		public function getPage() {
			return $this->page;
		}
		public function getModule() {
			return $this->module;
		}
		public function getController() {
			return $this->controller;
		}
		public function getErreur() {
			return $this->erreur;
		}
		
		private function getAllModules() {
			$dbc = App::getDb();
			$module = "";
			
			$query = $dbc->select()->from("module")->get();
			
			if ((is_array($query)) && (count($query) > 0)) {
				foreach ($query as $obj) {
					$module[] = str_replace("/", "", $obj->url);
				}
			}
			
			return $module;
		}
		
		/**
		 * @param $url
		 * @param null $admin
		 * @return string
		 * Permets de générer l'url pour aller charger la page concernee pour le module blog
		 * appele également l'actoin à effectur dans la page
		 */
		public function getUrl($url, $admin = "app") {
			$explode = explode("/", $url);
			$count = count($explode);
			$debut_url = "";
			$centre_url = "";
			
			for ($i = 0; $i < $count; $i++) {
				if (in_array($explode[$i], $this->getAllModules())) {
					$this->module = $explode[$i];
					$debut_url = $explode[$i];
				}
				else if ($i >= 1) {
					$centre_url[] = $explode[$i];
				}
			}
			$centre_url = $this->setPathFile($debut_url, $centre_url, $admin);
			$this->admin = $admin;
			$this->setActionPage();
			
			return $centre_url."/".$this->parametre;
		}
		
		/**
		 * fonction qui permet de tester qu'une route existe bien
		 * appellee dans redirectError.class.php
		 * @param $url
		 */
		public function getRouteModuleExist($url) {
			$dbc = \core\App::getDb();
			$query = $dbc->select()->from("module")->where("activer", "=", 1)->get();
			
			if (count($query) > 0) {
				foreach ($query as $obj) {
					if ($this->getTestUrlExist($url, $obj->url) === true) {
						return true;
					}
				}
			}
			
			return false;
		}
		
		/**
		 * @param $url
		 * @param $url_test
		 * @return bool
		 */
		private function getTestUrlExist($url, $url_test) {
			$test_module = ChaineCaractere::FindInString($url_test, $url);
			$test_module_1 = ChaineCaractere::FindInString($url_test, explode("/", $url)[0]);
			
			if ($test_module === true || $test_module_1 == true) {
				return true;
			}
			
			return false;
		}
		//-------------------------- FIN GETTER ----------------------------------------------------------------------------//
		
		
		
		//-------------------------- SETTER ----------------------------------------------------------------------------//
		/**
		 * @param $debut_url
		 * @param $centre_url
		 * @param $admin<commit_msg>hotfix condition<commit_after><?php
	namespace core\modules;
	
	
	use core\App;
	use core\functions\ChaineCaractere;
	
	class RouterModule {
		//varaibles de base de config
		private $controller;
		private $erreur;
		private $parametre;
		private $module; //varialbe qui contiendra le nom d'un module
		private $page;
		private $admin; //permet de savoir si on est dans l'administration du site ou pas et de charger lebon router
		
		
		//-------------------------- GETTER ----------------------------------------------------------------------------//
		//pour les parametres du getUrl ++ getAction ++ getController
		public function getParametre() {
			return $this->parametre;
		}
		public function getPage() {
			return $this->page;
		}
		public function getModule() {
			return $this->module;
		}
		public function getController() {
			return $this->controller;
		}
		public function getErreur() {
			return $this->erreur;
		}
		
		private function getAllModules() {
			$dbc = App::getDb();
			$module = "";
			
			$query = $dbc->select()->from("module")->get();
			
			if ((is_array($query)) && (count($query) > 0)) {
				foreach ($query as $obj) {
					$module[] = str_replace("/", "", $obj->url);
				}
			}
			
			return $module;
		}
		
		/**
		 * @param $url
		 * @param null $admin
		 * @return string
		 * Permets de générer l'url pour aller charger la page concernee pour le module blog
		 * appele également l'actoin à effectur dans la page
		 */
		public function getUrl($url, $admin = "app") {
			$explode = explode("/", $url);
			$count = count($explode);
			$debut_url = "";
			$centre_url = "";
			
			for ($i = 0; $i < $count; $i++) {
				if (in_array($explode[$i], $this->getAllModules())) {
					$this->module = $explode[$i];
					$debut_url = $explode[$i];
				}
				else if ($i >= 1) {
					$centre_url[] = $explode[$i];
				}
			}
			$centre_url = $this->setPathFile($debut_url, $centre_url, $admin);
			$this->admin = $admin;
			$this->setActionPage();
			
			return $centre_url."/".$this->parametre;
		}
		
		/**
		 * fonction qui permet de tester qu'une route existe bien
		 * appellee dans redirectError.class.php
		 * @param $url
		 */
		public function getRouteModuleExist($url) {
			$dbc = \core\App::getDb();
			$query = $dbc->select()->from("module")->where("activer", "=", 1)->get();
			
			if (count($query) > 0) {
				foreach ($query as $obj) {
					if ($this->getTestUrlExist($url, $obj->url) === true) {
						return true;
					}
				}
			}
			
			return false;
		}
		
		/**
		 * @param $url
		 * @param $url_test
		 * @return bool
		 */
		private function getTestUrlExist($url, $url_test) {
			$test_module = ChaineCaractere::FindInString($url_test, $url);
			$test_module_1 = ChaineCaractere::FindInString($url_test, explode("/", $url)[0]);
			
			if ($test_module === true || $test_module_1 === true) {
				return true;
			}
			
			return false;
		}
		//-------------------------- FIN GETTER ----------------------------------------------------------------------------//
		
		
		
		//-------------------------- SETTER ----------------------------------------------------------------------------//
		/**
		 * @param $debut_url
		 * @param $centre_url
		 * @param $admin
{'fraction_non_alphanumeric': 0.24555659494855003, 'fraction_numerical': 0.002494543186778921, 'mean_word_length': 2.0060918462980317, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 51, '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': '749832', 'n_tokens_mistral': 2493, 'n_tokens_neox': 1992, 'n_words': 490}