MACC

MACC Information

1, 'neic' => 1, 'mscc' => 1, 'sacc' => 1, 'mwgl' => 1, 'sccc' => 1, 'gpic' => 1, 'swic' => 1 ); $conference; $justLegend; if ($_GET['type'] && (strtolower($_GET['type']) == 'hs' || strtolower($_GET['type']) == 'college') ){ $type=strtolower($_GET['type']); } if ($_GET['conference'] && $conferences[strtolower($_GET['conference'])]){ $conference=strtolower($_GET['conference']); } if ($_GET['justLegend'] == '1'){ $justLegend=1; } class APPAEvent { var $curEvent; function setEvent($event){ $curEvent=$event; } function aGet($prop){ if (!is_array($this->curEvent)){return '';} if (array_key_exists($prop,$this->curEvent)){ return $this->curEvent[$prop]; }else{ return ''; } } function getPluginUrl () { return 'http://www.ncpapaintball.com/wp-content/plugins/appa_events/'; } function setCurEvent($event){ if (!is_array($event)){ return false; }else{ $this->curEvent=$event; return true; } } } $div=null; if ($LID){ $URI.='LID='.$LID; // if we're getting NCPA events, only display events that are for the current page's division if ($LID==2 && is_page()){ $page=$GLOBALS['post']; $parent=$page->post_parent; if ($page->ID==17){ $div='a,aa'; $parent=0; }elseif($page->ID==48){ $div='hs'; $parent=0; }elseif($page->ID==22){ $div='a'; $parent=0; } while ($parent){ if($parent == 22){ $div='a'; $parent=0; }elseif ($parent == 17){ $div='a,aa'; $parent=0; }elseif($parent == 48){ $div='hs'; $parent=0; }else{ $new_post=get_post($parent); $parent=$new_post->post_parent; } } }elseif (is_category()){ if (get_query_var('cat') == 10){ $div='hs'; }elseif (get_query_var('cat') == 9){ $div='a,aa'; } } }elseif($startDate){ if (preg_match('/CURRENT/i',$startDate)){ $URI.='startDate=%20&1=1'; }else{ $URI='startDate='.$startDate; } }else{ return; } if($type && ($type == 'college' || $type == 'hs')){ $div=$type; if ($_GET['div'] == 'a' || $_GET['div'] == 'aa' || $_GET['div'] == 'hs'){ $div=$_GET['div']; } print "

Full NCPA Event List

\n"; } if ($div != null){ $URI.="&div=$div"; } // process API request, and convert the response to an array based on the XML formatting $xmlStr=file_get_contents($URI); $arrXml=xml2array($xmlStr); $appa = new APPAEvent(); if (!$justLegend){ print "
\n"; } // loop through our array of events, and for each event, call the template function to display it myDisplayAPPAEventHeader(); myDisplayAPPAEventFooter(); if (!$justLegend){ print "\n"; print "\n"; if ($arrXml['Events']){ if (count($arrXml['Events']['event'])==1){ if (!$conference || ($conference && strtolower($arrXml['Events']['event']['conference']) == $conference) ){ if ($appa->setCurEvent($arrXml['Events']['event']) && function_exists('myDisplayAPPAEventRow') ){ myDisplayAPPAEventRow(&$appa); } } }elseif(count($arrXml['Events']['event'])==0){ print "\n"; }else{ foreach ($arrXml['Events'] as $Events => $EventsVal){ foreach ($arrXml['Events'][$Events] as $event){ if (!$conference || ($conference && strtolower($event['conference']) == $conference) ){ if ($appa->setCurEvent($event) && function_exists('myDisplayAPPAEventRow') ){ myDisplayAPPAEventRow(&$appa); } } } } } } echo "
Events listed By Date
We're in the off-season! New events will be announced by September!
\n"; print "Host an Event!
\n"; } $states=array(); if ($arrXml['Events']){ if (count($arrXml['Events']['event']) == 1 ){ if (is_array($arrXml['Events']['event']['venueinfo']) && is_string($arrXml['Events']['event']['venueinfo']['state']) ){ if (!$conference || ($conference && strtolower($arrXml['Events']['event']['conference']) == $conference) ){ $states[$arrXml['Events']['event']['venueinfo']['state']] = $arrXml['Events']['event']; } } }elseif(count($arrXml['Events']['event']) == 0){ }else{ foreach ($arrXml['Events'] as $Events => $EventsVal){ foreach ($arrXml['Events'][$Events] as $event){ if (!$conference || ($conference && strtolower($event['conference']) == $conference) ){ if (is_array($event['venueinfo']) && is_string($event['venueinfo']['state']) ){ if (!is_array($states[$event['venueinfo']['state']])){ $states[$event['venueinfo']['state']]=array(); } array_push($states[$event['venueinfo']['state']],$event); } } } } } } ksort($states,SORT_STRING); if (count($states) > 0){ print "\n"; print "\n"; if (!$justLegend){ foreach ($states as $state => $stateval){ print "\n"; foreach ($stateval as $event){ myDisplayEventRowMini($appa, $event); } } }else{ if ($arrXml['Events_attr']['count'] == 0){ }elseif($arrXml['Events_attr']['count']==1){ myDisplayEventRowMini($appa, $arrXml['Events']['event']); }else{ foreach ($arrXml['Events'] as $Events => $EventsVal){ foreach ($arrXml['Events'][$Events] as $event){ myDisplayEventRowMini($appa, $event); } } } } print "
Events listed By State
$state

\n"; } function myDisplayAPPAEventHeader(){ echo "
"; } function myDisplayAPPAEventFooter(){ $url = 'http://www.ncpapaintball.com/wp-content/plugins/appa_events/'; echo "
- College Class A
"; echo "- College Class AA
"; echo "- High School
"; echo "- Confirmed Event
"; echo "- Proposed Event
"; echo "
"; } function myDisplayEventRowMini($appa, $event){ print "\n"; echo "\n"; echo ''; if ($event['startdate'] == $event['enddate']){ echo date('F d, Y',strtotime($event['startdate'])); }else{ echo date('F d, Y',strtotime($event['startdate'])) . "
to
" . date('F d, Y', strtotime($event['enddate'])); } echo "
\n"; // End Event Date Column print "\n"; $prefix=""; if ($_GET['targetLink']){ $prefix=$_GET['targetLink']; } print "".$event['name']."
\n"; print "\n"; print "\n"; if ( 1 ) { $divisions=array(); while ( list($key,$val) = each($event['divisions']['division']) ) { if ( !is_array($val) ) { if ( $key != 'group' ) { next; } if ( preg_match('/High School/i',$val) || preg_match('/HS/i',$val) ) { $divisions['hs'] = 1; }elseif ( preg_match('/College/i',$val) && preg_match('/RaceTo-2/i',$val) ) { $divisions['aa'] = 1; }elseif ( preg_match('/Class A/i',$val) || preg_match('/X-?Ball/i',$val) ) { $divisions['a'] = 1; } } else { if ( preg_match('/High School/i',$val['group']) || preg_match('/HS/i',$val['group']) ) { $divisions['hs'] = 1; }elseif ( preg_match('/College/i',$val['group']) && preg_match('/RaceTo-2/i',$val['group']) ) { $divisions['aa'] = 1; }elseif ( preg_match('/Class A/i',$val['group']) || preg_match('/X-?Ball/i',$val['group']) ) { $divisions['a'] = 1; } } } if ( array_key_exists('a',$divisions) && !array_key_exists('aa',$divisions) && !array_key_exists('hs',$divisions) ) { echo ""; }elseif ( !array_key_exists('a',$divisions) && array_key_exists('aa',$divisions) && !array_key_exists('hs',$divisions) ) { echo ""; }elseif ( !array_key_exists('a',$divisions) && !array_key_exists('aa',$divisions) && array_key_exists('hs',$divisions) ) { echo ""; }elseif ( array_key_exists('a',$divisions) && array_key_exists('aa',$divisions) && array_key_exists('hs',$divisions) ) { echo ""; echo ""; echo ""; }elseif ( !array_key_exists('a',$divisions) && array_key_exists('aa',$divisions) && array_key_exists('hs',$divisions) ) { echo ""; echo ""; }else{ echo '-'.$event['format']; } } else { if ($event['format'] == 'A'){ echo ""; }elseif ($event['format'] == 'AA'){ echo ""; }elseif ($event['format'] == 'HS'){ echo ""; }elseif ($event['format'] == 'A/AA/HS'){ echo ""; echo ""; echo ""; }elseif ($event['format'] == 'AA/HS'){ echo ""; echo ""; }else{ echo '-'.$event['format']; } } print "\n"; echo '
'; if ($event['active'] == 'Yes'){ echo ""; }else{ echo ""; } echo "
\n"; print "\n"; } function myDisplayAPPAEventRow($appa){ echo "\n"; $startDate = strtotime($appa->aGet('startdate')); $endDate = strtotime($appa->aGet('enddate')); echo ''; // Row 1 - Name Column echo "\n"; $eventname; if(is_string($appa->aGet('name')) && $appa->aGet('name') != ''){ $eventname=$appa->aGet('name'); }elseif(is_string($appa->aGet('shortname')) && $appa->aGet('shortnamename') != ''){ $eventname=$appa->aGet('shortname'); } echo "$eventname"; echo "\n"; // End Name Column // Row 1 - Event Date Column echo "\n"; echo ''; //.$appa->aGet('eventshort'); if ($startDate == $endDate){ echo date('F d, Y',$startDate); }else{ echo date('F d, Y',$startDate) . "
to
" . date('F d, Y', $endDate); } echo "
\n"; // End Event Date Column // Row 1 - Format Column echo "\n"; if (is_string($appa->aGet('format')) && $appa->aGet('format') != ''){ if ($appa->aGet('lid') == 2){ $divisions=array(); $eventDivs = $appa->aGet('divisions'); while ( list($key,$val) = each($eventDivs['division'] ) ) { if ( !is_array($val) ) { if ( $key != 'group' ) { next; } if ( preg_match('/High School/i',$val) || preg_match('/HS/i',$val) ) { $divisions['hs'] = 1; }elseif ( preg_match('/College/i',$val) && preg_match('/RaceTo-2/i',$val) ) { $divisions['aa'] = 1; }elseif ( preg_match('/Class A/i',$val) || preg_match('/X-?Ball/i',$val) ) { $divisions['a'] = 1; } } else { if ( preg_match('/High School/i',$val['group']) || preg_match('/HS/i',$val['group']) ) { $divisions['hs'] = 1; }elseif ( preg_match('/College/i',$val['group']) && preg_match('/RaceTo-2/i',$val['group']) ) { $divisions['aa'] = 1; }elseif ( preg_match('/Class A/i',$val['group']) || preg_match('/X-?Ball/i',$val['group']) ) { $divisions['a'] = 1; } } } if ( array_key_exists('a',$divisions) && !array_key_exists('aa',$divisions) && !array_key_exists('hs',$divisions) ) { echo ""; }elseif ( !array_key_exists('a',$divisions) && array_key_exists('aa',$divisions) && !array_key_exists('hs',$divisions) ) { echo ""; }elseif ( !array_key_exists('a',$divisions) && !array_key_exists('aa',$divisions) && array_key_exists('hs',$divisions) ) { echo ""; }elseif ( array_key_exists('a',$divisions) && array_key_exists('aa',$divisions) && array_key_exists('hs',$divisions) ) { echo ""; echo ""; echo ""; }elseif ( !array_key_exists('a',$divisions) && array_key_exists('aa',$divisions) && array_key_exists('hs',$divisions) ) { echo ""; echo ""; }else{ echo '-'.$event['format']; } if ( 0 ) { if ($appa->aGet('format') == 'A'){ echo ""; }elseif ($appa->aGet('format') == 'AA'){ echo ""; }elseif ($appa->aGet('format') == 'HS'){ echo ""; }elseif ($appa->aGet('format') == 'A/AA/HS'){ echo ""; echo ""; echo ""; }elseif ($appa->aGet('format') == 'AA/HS'){ echo ""; echo ""; }else{ echo '-'.$appa->aGet('format'); } } }else{ echo '-'.$appa->aGet('format'); } } echo "\n"; // End Format Column // Row 1 - Active/Proposed Column echo '
'; if ($appa->aGet('active') == 'Yes'){ //echo '
  • '; echo ""; }else{ //echo '
  • '; echo ""; } echo "
    \n"; // End Active/Proposed Column echo "\n"; if (0){ echo ""; echo ""; if (is_string($appa->aGet('venueurl')) && $appa->aGet('venueurl') != ''){ echo ''.$appa->aGet('venue').''; }else{ echo ''.$appa->aGet('venue'); } echo "\n"; } echo "\n"; // Row 2 - Division and Paint Pricing Column echo "\n"; $divisions = $appa->aGet('divisions'); if (is_array($divisions)){ foreach ($divisions AS $division){ if (array_key_exists('group',$division) ){ if ($division['group'] == 'XBall - College'){$division['group']='College Class A';} if ($division['group'] == 'RaceTo-2 (5-man) - College'){$division['group'] = 'College Class AA';} if ($division['group'] == 'RaceTo-2 (3-man) - High School'){$division['group'] = 'High School';} echo "".$division['group'].": \$".$division['priceearly']."
    \n"; }else{ foreach ($divisions['division'] AS $division){ if ($division['group'] == 'XBall - College'){$division['group']='College Class A';} if ($division['group'] == 'RaceTo-2 (5-man) - College'){$division['group'] = 'College Class AA';} if ($division['group'] == 'RaceTo-2 (3-man) - High School'){$division['group'] = 'High School';} echo "".$division['group'].": \$".$division['priceearly']."
    \n"; } } } } if (is_string($appa->aGet('paint')) && $appa->aGet('paint') != ''){ echo "

    Paint Pricing: ".$appa->aGet('paint')."

    \n"; } echo "\n"; // Row 2 - Venue Information Column echo ""; $venue = $appa->aGet('venueinfo'); echo $venue['name']."
    ". $venue['address1']. ($venue['address2'] != '' && !is_array($venue['address2']) ? "
    ".$venue['address2']."
    " : "
    "). $venue['city'].", ".$venue['state']." ".$venue['zip']."
    \n". ""; if (is_string($venue['url']) && $venue['url'] != ''){ echo "
    Field Website\n"; } if (is_string($venue['direct']) && $venue['direct'] != ''){ echo "
    Map / Directions\n"; } echo "\n"; // End Venue Information Column echo "\n"; echo "\n"; // Row 3 - Signup Column echo "\n"; if ($appa->aGet('active') == 'Yes'){ print "APPA Paintball Registration SystemSign Up!\n"; }else{ print "APPA Paintball Registration System\n"; echo "Registration coming soon!\n"; } echo "\n"; // Row 3 - Team List Column echo ""; echo "\n"; print "APPA Paintball Registration System\n"; print "Team List
    \n"; echo "\n"; // Row 4 - Extra Information Row echo ""; if (is_string($appa->aGet('extrainfo')) && $appa->aGet('extrainfo') != ''){ echo "Notes: ".$appa->aGet('extrainfo')."
    \n"; } echo "\n"; echo "\n"; } function formatPhone($number) { $number = preg_replace('/\D/', '', $number); //Remove anything that is not a number if(strlen($number) < 10) { return ''; } return '('.substr($number, 0, 3) . ') ' . substr($number, 3, 3) . '-' . substr($number, 6); } function x2a(){ /** * xml2array() will convert the given XML text to an array in the XML structure. * Link: http://www.bin-co.com/php/scripts/xml2array/ * Arguments : $contents - The XML text * $get_attributes - 1 or 0. If this is 1 the function will get the attributes as well as the tag values - this results in a different array structure in the return value. * $priority - Can be 'tag' or 'attribute'. This will change the way the resulting array sturcture. For 'tag', the tags are given more importance. * Return: The parsed XML in an array form. Use print_r() to see the resulting array structure. * Examples: $array = xml2array(file_get_contents('feed.xml')); * $array = xml2array(file_get_contents('feed.xml', 1, 'attribute')); */ function xml2array($contents, $get_attributes=1, $priority = 'tag') { if(!$contents) return array(); if(!function_exists('xml_parser_create')) { //print "'xml_parser_create()' function not found!"; return array(); } //Get the XML parser of PHP - PHP must have this module for the parser to work $parser = xml_parser_create(''); xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); # http://minutillo.com/steve/weblog/2004/6/17/php-xml-and-character-encodings-a-tale-of-sadness-rage-and-data-loss xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, trim($contents), $xml_values); xml_parser_free($parser); if(!$xml_values) return;//Hmm... //Initializations $xml_array = array(); $parents = array(); $opened_tags = array(); $arr = array(); $current = &$xml_array; //Refference //Go through the tags. $repeated_tag_index = array();//Multiple tags with same name will be turned into an array foreach($xml_values as $data) { unset($attributes,$value);//Remove existing values, or there will be trouble //This command will extract these variables into the foreach scope // tag(string), type(string), level(int), attributes(array). extract($data);//We could use the array by itself, but this cooler. $result = array(); $attributes_data = array(); if(isset($value)) { if($priority == 'tag') $result = $value; else $result['value'] = $value; //Put the value in a assoc array if we are in the 'Attribute' mode } //Set the attributes too. if(isset($attributes) and $get_attributes) { foreach($attributes as $attr => $val) { if($priority == 'tag') $attributes_data[$attr] = $val; else $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr' } } //See tag status and do the needed. if($type == "open") {//The starting of the tag '' $parent[$level-1] = &$current; if(!is_array($current) or (!in_array($tag, array_keys($current)))) { //Insert New tag $current[$tag] = $result; if($attributes_data) $current[$tag. '_attr'] = $attributes_data; $repeated_tag_index[$tag.'_'.$level] = 1; $current = &$current[$tag]; } else { //There was another element with the same tag name if(isset($current[$tag][0])) {//If there is a 0th element it is already an array $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result; $repeated_tag_index[$tag.'_'.$level]++; } else {//This section will make the value an array if multiple tags with the same name appear together $current[$tag] = array($current[$tag],$result);//This will combine the existing item and the new item together to make an array $repeated_tag_index[$tag.'_'.$level] = 2; if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well $current[$tag]['0_attr'] = $current[$tag.'_attr']; unset($current[$tag.'_attr']); } } $last_item_index = $repeated_tag_index[$tag.'_'.$level]-1; $current = &$current[$tag][$last_item_index]; } } elseif($type == "complete") { //Tags that ends in 1 line '' //See if the key is already taken. if(!isset($current[$tag])) { //New Key $current[$tag] = $result; $repeated_tag_index[$tag.'_'.$level] = 1; if($priority == 'tag' and $attributes_data) $current[$tag. '_attr'] = $attributes_data; } else { //If taken, put all things inside a list(array) if(isset($current[$tag][0]) and is_array($current[$tag])) {//If it is already an array... // ...push the new element into that array. $current[$tag][$repeated_tag_index[$tag.'_'.$level]] = $result; if($priority == 'tag' and $get_attributes and $attributes_data) { $current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data; } $repeated_tag_index[$tag.'_'.$level]++; } else { //If it is not an array... $current[$tag] = array($current[$tag],$result); //...Make it an array using using the existing value and the new value $repeated_tag_index[$tag.'_'.$level] = 1; if($priority == 'tag' and $get_attributes) { if(isset($current[$tag.'_attr'])) { //The attribute of the last(0th) tag must be moved as well $current[$tag]['0_attr'] = $current[$tag.'_attr']; unset($current[$tag.'_attr']); } if($attributes_data) { $current[$tag][$repeated_tag_index[$tag.'_'.$level] . '_attr'] = $attributes_data; } } $repeated_tag_index[$tag.'_'.$level]++; //0 and 1 index is already taken } } } elseif($type == 'close') { //End of tag '' $current = &$parent[$level-1]; } } return($xml_array); } }
    Google+