254 lines
		
	
	
		
			9.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			254 lines
		
	
	
		
			9.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
    class ParserUtility
 | 
						|
    {
 | 
						|
        public static $_RUNNING_                    = "RUNNING";
 | 
						|
        public static $_RELAY_                      = "RELAY";
 | 
						|
        public static $_THROWING_                   = "THROWING";
 | 
						|
        public static $_JUMPING_                    = "JUMPING";
 | 
						|
        public static $_THROWING_TEAM_              = "THROWING-TEAM-EVENT";
 | 
						|
        public static $_JUMPING_TEAM_               = "JUMPING-TEAM-EVENT";
 | 
						|
        public static $_MIXED_EVENT_                = "MIXED-EVENT";
 | 
						|
        
 | 
						|
        public static $_ROUND_FINAL_                = "FINAL";
 | 
						|
        public static $_ROUND_SEMI_FINAL_           = "SEMI-FINAL";
 | 
						|
        public static $_ROUND_PRILIMINARY_          = "PRELIMINARY";
 | 
						|
        public static $_ROUND_TRIAL_                = "TRIAL";
 | 
						|
        
 | 
						|
        public static $_LEVEL_OPEN_                 = "OPEN";
 | 
						|
        public static $_LEVEL_FRESHMAN_             = "FRESHMAN";
 | 
						|
        public static $_LEVEL_SOPHOMORE_            = "SOPHOMORE";
 | 
						|
        public static $_LEVEL_FROS_SOPH_            = "FRESHMAN/SOPHOMORE";
 | 
						|
        public static $_LEVEL_JUNIOR_               = "JUNIOR";
 | 
						|
        public static $_LEVEL_SENIOR_               = "SENIOR";
 | 
						|
        public static $_LEVEL_UNIVARSITY_           = "VARSITY";
 | 
						|
        public static $_LEVEL_CONFERENCE_           = "CONFERENCE";
 | 
						|
        public static $_LEVEL_LEAGUE_               = "LEAGUE";
 | 
						|
        public static $_LEVEL_JV_                   = "JUNIOR-VARSITY";
 | 
						|
        public static $_LEVEL_SUB_MIDGET_           = "SUB-MIDGET";
 | 
						|
        public static $_LEVEL_MIDGET_               = "MIDGET";
 | 
						|
        public static $_LEVEL_JUNIOR_WEIGH_         = "JUNIOR-WEIGH";
 | 
						|
        public static $_LEVEL_NOVICE_               = "NOVICE";
 | 
						|
        public static $_LEVEL_CLASS_                = "CLASS";
 | 
						|
        public static $_LEVEL_DIVISION_             = "DIVISION";
 | 
						|
        public static $_LEVEL_CROSSOVER_            = "CROSSOVER";
 | 
						|
        public static $_LEVEL_INDIV_TEAM_           = "INDIVIDUAL-TEAM";
 | 
						|
        public static $_LEVEL_JR_SR_                = "JUNIOR-SENIOR";
 | 
						|
        public static $_LEVEL_UNSEEDED_             = "UNSEEDED";
 | 
						|
        public static $_LEVEL_CHAMPIONSHIP_         = "CHAMPIONSHIP";
 | 
						|
        public static $_LEVEL_ELITE_                = "ELITE";
 | 
						|
        public static $_LEVEL_SMALL_SCHOOL_         = "SMALL-SCHOOL";
 | 
						|
        public static $_LEVEL_LARGE_SCHOOL_         = "LARGE-SCHOOL";
 | 
						|
        public static $_LEVEL_INVITATIONAL_         = "INVITATIONAL";        
 | 
						|
        public static $_LEVEL_PSAL_                 = "PUBLIC-SCHOOL-ATHLETIC-LEAGUE";        
 | 
						|
        
 | 
						|
        public static $terms_headerStartsWith       = array("Licensed to");
 | 
						|
 | 
						|
        public static $terms_headerLicenseTos       = array("HY-TEK's");
 | 
						|
 | 
						|
        public static $terms_reportHeader_dType     = array("Name"=>"string",
 | 
						|
                                                            "Year"=>"int",
 | 
						|
                                                            "Seed"=>"float",
 | 
						|
                                                            "School"=>"string",
 | 
						|
                                                            "Finals"=>"float",
 | 
						|
                                                            "Comp#"=>"int",
 | 
						|
                                                            "H#"=>"int",
 | 
						|
                                                            "Points"=>"int",
 | 
						|
                                                            "SL"=>"int",
 | 
						|
                                                            "Prelims"=>"float",
 | 
						|
                                                            "Time"=>"float",
 | 
						|
                                                            "ROUND"=>"string");
 | 
						|
 | 
						|
        public static $keys_fld_Place			 	= array("SL");
 | 
						|
        public static $keys_fld_perform_time_char 	= array("Time","Prelim","Prelims","Final","Finals");
 | 
						|
        public static $keys_fld_school_name 		= array("School");
 | 
						|
        public static $keys_fld_athlete_name 		= array("Name");
 | 
						|
        public static $keys_fld_class_year 			= array("Year"); 
 | 
						|
        
 | 
						|
        static function startsWithOneOfThem($haystack, $needles) 
 | 
						|
        {
 | 
						|
            foreach($needles as $k=>$needle)
 | 
						|
            {
 | 
						|
                if(self::startsWith($haystack, $needle))
 | 
						|
                {
 | 
						|
                    return true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return false;
 | 
						|
        }
 | 
						|
 | 
						|
        static function startsWith ($haystack, $needle) 
 | 
						|
        { 
 | 
						|
            $len = strlen($needle); 
 | 
						|
            return (substr(strtolower($haystack), 0, $len) === strtolower($needle)); 
 | 
						|
        } 
 | 
						|
 | 
						|
        static function endsWithOneOfThem($haystack, $needles) 
 | 
						|
        {
 | 
						|
            foreach($needles as $k=>$needle)
 | 
						|
            {
 | 
						|
                if(self::endsWith($haystack, $needle))
 | 
						|
                {
 | 
						|
                    return true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return false;
 | 
						|
        }
 | 
						|
 | 
						|
        static function endsWith($haystack, $needle) 
 | 
						|
        { 
 | 
						|
            $len = strlen($needle); 
 | 
						|
            if ($len == 0) { 
 | 
						|
                return true; 
 | 
						|
            } 
 | 
						|
            return (substr(strtolower($haystack), -$len) === strtolower($needle)); 
 | 
						|
        } 
 | 
						|
 | 
						|
        static function containsWhichOneOfThem($haystack, $needles) 
 | 
						|
        {
 | 
						|
            foreach($needles as $k=>$needle)
 | 
						|
            {
 | 
						|
                if(self::contains($haystack, $needle))
 | 
						|
                {
 | 
						|
                    return $needle;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return false;
 | 
						|
        }
 | 
						|
 | 
						|
        static function containsOneOfThem($haystack, $needles) 
 | 
						|
        {
 | 
						|
            foreach($needles as $k=>$needle)
 | 
						|
            {
 | 
						|
                if(self::contains($haystack, $needle))
 | 
						|
                {
 | 
						|
                    return true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return false;
 | 
						|
        }
 | 
						|
 | 
						|
        static function contains($haystack, $needle) 
 | 
						|
        { 
 | 
						|
            foreach($haystack as $k=>$hay)
 | 
						|
            {
 | 
						|
                if(strtolower($hay)===strtolower($needle))
 | 
						|
                {
 | 
						|
                    return true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return false;
 | 
						|
        } 
 | 
						|
 | 
						|
        static function getWords($sentence,$trim=true)
 | 
						|
        {
 | 
						|
            $words  = array();
 | 
						|
            $ws     = explode(" ", $sentence);
 | 
						|
            
 | 
						|
            foreach($ws as $wds)
 | 
						|
            {
 | 
						|
                if($trim && trim($wds)=='')
 | 
						|
                {
 | 
						|
                    continue;
 | 
						|
                }
 | 
						|
 | 
						|
                $words[] = trim($wds);
 | 
						|
            }
 | 
						|
 | 
						|
            return $words;
 | 
						|
        }
 | 
						|
 | 
						|
        static function in_array_i($haystack, $needle)
 | 
						|
        {
 | 
						|
            return in_array(strtolower($needle), array_map("strtolower", $haystack));
 | 
						|
        }
 | 
						|
 | 
						|
        static function array_key_exists_i($haystack, $needle)
 | 
						|
        {
 | 
						|
            foreach(array_keys($haystack) as $key)
 | 
						|
            {
 | 
						|
                if(strtolower($key)===strtolower($needle))
 | 
						|
                {
 | 
						|
                    return true;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return false;
 | 
						|
        }
 | 
						|
 | 
						|
        static function get_start_end_pos($haystack, $needle)
 | 
						|
        {
 | 
						|
            $lastPos    = 0;
 | 
						|
            $positions  = array();
 | 
						|
            $return     = array();
 | 
						|
 | 
						|
            while (($lastPos = strpos($haystack, $needle, $lastPos))!== false) {
 | 
						|
                $positions[] = $lastPos;
 | 
						|
                $lastPos = $lastPos + strlen($needle);
 | 
						|
            }
 | 
						|
 | 
						|
            $ind=0;
 | 
						|
            foreach ($positions as $value) {
 | 
						|
                $return[$ind]['START-POSITION']   = $value;
 | 
						|
                $return[$ind]['END-POSITION']     = ($return[$ind]['START-POSITION'] + strlen($needle))-1;
 | 
						|
                $return[$ind]['LENGTH']           = strlen($needle);
 | 
						|
                $ind++;
 | 
						|
            }            
 | 
						|
            return $return;
 | 
						|
        }
 | 
						|
 | 
						|
        static function get_array_value_i($array, $key)
 | 
						|
        {
 | 
						|
            foreach($array as $k=>$val)
 | 
						|
            {
 | 
						|
                if(strtolower(trim($k))===strtolower(trim($key)))
 | 
						|
                {
 | 
						|
                    return $val;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            return '';
 | 
						|
        }
 | 
						|
 | 
						|
        static function parse_host($url)
 | 
						|
        {
 | 
						|
            return parse_url($url,PHP_URL_HOST);
 | 
						|
        }
 | 
						|
 | 
						|
        static function removeAlphabetsOnly($string)
 | 
						|
        {
 | 
						|
            return preg_replace("/[^0-9.:\-]/", "", $string);
 | 
						|
        }
 | 
						|
 | 
						|
        static function numerizeTime($string)
 | 
						|
        {
 | 
						|
            $calcData = $string;
 | 
						|
            $expld = explode(":",$string);
 | 
						|
            if(sizeof($expld)==3)
 | 
						|
            {
 | 
						|
                $calcData = (floatval($expld[0])*60*60)+(floatval($expld[1])*60*60)+floatval($expld[2]);
 | 
						|
            }
 | 
						|
            else if(sizeof($expld)==2)
 | 
						|
            {
 | 
						|
                $calcData = (floatval($expld[0])*60)+floatval($expld[1]);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                $calcData = floatval($expld[0]);
 | 
						|
            }
 | 
						|
            return $calcData;
 | 
						|
        }
 | 
						|
 | 
						|
        static function numerizeLength($string)
 | 
						|
        {
 | 
						|
            $calcData = $string;
 | 
						|
            $expld = explode("-",$string);
 | 
						|
            if(sizeof($expld)==2)
 | 
						|
            {
 | 
						|
                $calcData = (floatval($expld[0])*12)+floatval($expld[1]);
 | 
						|
            }
 | 
						|
            else
 | 
						|
            {
 | 
						|
                $calcData = floatval($expld[0]);
 | 
						|
            }
 | 
						|
            return $calcData;
 | 
						|
        }
 | 
						|
    }
 | 
						|
?>
 |