From 07f5140771388c9e0c8a99b0dd2e5d950bdb173b Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Thu, 14 Oct 2021 15:16:42 +1100 Subject: moving h-source subdir out. --- Application/Include/distributions.php | 91 +++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 Application/Include/distributions.php (limited to 'Application/Include/distributions.php') diff --git a/Application/Include/distributions.php b/Application/Include/distributions.php new file mode 100644 index 0000000..e8c61f0 --- /dev/null +++ b/Application/Include/distributions.php @@ -0,0 +1,91 @@ +. + +if (!defined('EG')) die('Direct access not allowed!'); + +class Distributions +{ + + public static $allowed = array(); + + public static $allowed_active = array(); + + public static function getList() + { + return implode(' , ',array_keys(self::$allowed)); + } + + //fill the $allowed property with the list of allowed distros from the distros MySQL table + public static function setAllowedList() + { + $distros = new DistrosModel(); + + self::$allowed = $distros->clear()->toList("clean_name","full_name")->orderBy("id_order")->send(); + self::$allowed_active = $distros->clear()->where(array('active'=>'1'))->toList("clean_name","full_name")->orderBy("id_order")->send(); + } + + public static function getName($distList = '') + { + $returnString = null; + $returnArray = array(); + $distArray = explode(',',$distList); + foreach ($distArray as $dist) + { + $dist = trim($dist); + if (array_key_exists($dist,self::$allowed)) + { + $returnArray[] = self::$allowed[$dist]; + } + } + return implode("
",$returnArray); + } + + public static function check($distString) + { + $distArray = explode(',',$distString); + + $allowedArray = array_keys(self::$allowed); + + foreach ($distArray as $dist) + { + $dist = trim($dist); + if (!in_array($dist,$allowedArray)) return false; + } + + return true; + } + + public static function getFormHtml() + { + $str = "
"; + $str .= "
"; + foreach (self::$allowed_active as $value => $label) + { + $str .= "
$label
"; + } + $str .= "
"; + $str .= ""; + $str .= ""; + $str .= "
"; + + return $str; + } + +} -- cgit v1.2.3