<commit_before><?php

require_once LIBDIR .'/harvard_calendar.php';


$data = array();

switch ($_REQUEST['command']) {
  case 'day':
   $type = $_REQUEST['type'];
   $time = isset($_REQUEST['time']) ? $_REQUEST['time'] : time();

   $date1 = date('Ym', $time);
   $month = "?startdate=" .$date1 ."01&months=1";

   $date = date('Ymd', $time);
   $events = array();

  // $url = HARVARD_EVENTS_ICS_BASE_URL ."?startdate=" .$date;
   // extracting data for one month at a time
    $url = HARVARD_EVENTS_ICS_BASE_URL .$month; 
   if ($type == 'Events') {
       $events = makeIcalDayEvents($url, $date, NULL);
   }


   foreach ($events as $event) {
     $data[] = clean_up_ical_event($event);
   }
   break;


   case 'search':
     $searchString = isset($_REQUEST['q']) ? $_REQUEST['q'] : '';

       // retrieve data for the week
       //$url = HARVARD_EVENTS_ICS_BASE_URL ."?days=7" ."&search=" .$id ."&filterfield1=15202";
       $url = HARVARD_EVENTS_ICS_BASE_URL ."?days=7" ."&search=" .$searchString;
       $events = makeIcalSearchEvents($url, $searchString);

       foreach ($events as $event) {
            $event_data[] = clean_up_ical_event($event);
        }

         $data['events'] = $event_data;
   break;

   case 'category':
    if ($id = $_REQUEST['id']) {
     $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : time();
     $end = isset($_REQUEST['end']) ? $_REQUEST['end'] : $start + 86400;

     $date1 = date('Ym', $start);
     $start = date('Ymd', $start);
     $end = date('Ymd', $end);
     //retrieve data for the whole month at a time
     $month = "?startdate=" .$date1 ."01&months=1";
     $url = HARVARD_EVENTS_ICS_BASE_URL .$month ."&filter1=" .$id ."&filterfield1=15202";

    $events = makeIcalDayEvents($url, $start, $id);

    foreach ($events as $event) {
        $data[] = clean_up_ical_event($event);
        }
    }
   break;

   case 'categories':
    $categories = Harvard_Calendar::get_categories(PATH_TO_EVENTS_CAT);

       foreach ($categories as $categoryObject) {
     
           $name = ucwords($categoryObject->get_name());
           $catid = $categoryObject->get_cat_id();
           $url = $categoryObject->get_url();

           $catData = array('name' => $name,
		      'catid' => $catid,
                      'url' => $url);

           $data[] = $catData;
           }
   break;

   case 'academic':
		$data = get_academic_events($_REQUEST['year']);
       	break;

   default:
       break;

 
}

echo json_encode($data);

?><commit_msg>Academic Calendar does not have a datePicker now.<commit_after><?php

require_once LIBDIR .'/harvard_calendar.php';


$data = array();

switch ($_REQUEST['command']) {
  case 'day':
   $type = $_REQUEST['type'];
   $time = isset($_REQUEST['time']) ? $_REQUEST['time'] : time();

   $date1 = date('Ym', $time);
   $month = "?startdate=" .$date1 ."01&months=1";

   $date = date('Ymd', $time);
   $events = array();

  // $url = HARVARD_EVENTS_ICS_BASE_URL ."?startdate=" .$date;
   // extracting data for one month at a time
    $url = HARVARD_EVENTS_ICS_BASE_URL .$month; 
   if ($type == 'Events') {
       $events = makeIcalDayEvents($url, $date, NULL);
   }


   foreach ($events as $event) {
     $data[] = clean_up_ical_event($event);
   }
   break;


   case 'search':
     $searchString = isset($_REQUEST['q']) ? $_REQUEST['q'] : '';

       // retrieve data for the week
       //$url = HARVARD_EVENTS_ICS_BASE_URL ."?days=7" ."&search=" .$id ."&filterfield1=15202";
       $url = HARVARD_EVENTS_ICS_BASE_URL ."?days=7" ."&search=" .$searchString;
       $events = makeIcalSearchEvents($url, $searchString);

       foreach ($events as $event) {
            $event_data[] = clean_up_ical_event($event);
        }

         $data['events'] = $event_data;
   break;

   case 'category':
    if ($id = $_REQUEST['id']) {
     $start = isset($_REQUEST['start']) ? $_REQUEST['start'] : time();
     $end = isset($_REQUEST['end']) ? $_REQUEST['end'] : $start + 86400;

     $date1 = date('Ym', $start);
     $start = date('Ymd', $start);
     $end = date('Ymd', $end);
     //retrieve data for the whole month at a time
     $month = "?startdate=" .$date1 ."01&months=1";
     $url = HARVARD_EVENTS_ICS_BASE_URL .$month ."&filter1=" .$id ."&filterfield1=15202";

    $events = makeIcalDayEvents($url, $start, $id);

    foreach ($events as $event) {
        $data[] = clean_up_ical_event($event);
        }
    }
   break;

   case 'categories':
    $categories = Harvard_Calendar::get_categories(PATH_TO_EVENTS_CAT);

       foreach ($categories as $categoryObject) {
     
           $name = ucwords($categoryObject->get_name());
           $catid = $categoryObject->get_cat_id();
           $url = $categoryObject->get_url();

           $catData = array('name' => $name,
		      'catid' => $catid,
                      'url' => $url);

           $data[] = $catData;
           }
   break;

   case 'academic':
		$data = get_academic_events($_REQUEST['year']);

                if ($data == null)
                    $data = array();
       	break;

   default:
       break;

 
}

echo json_encode($data);

?>
{'fraction_non_alphanumeric': 0.184, 'fraction_numerical': 0.011707317073170732, 'mean_word_length': 2.7553113553113553, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '224339', 'n_tokens_mistral': 1822, 'n_tokens_neox': 1724, 'n_words': 364}