Example #1
0
 protected function setGlobalFields()
 {
     // Get date string from session
     $sessionDate = $this->session->getDate('m/d/Y');
     $startTime = get_sub_field('start_time');
     $endTime = get_sub_field('end_time');
     if ($sessionDate != 'TBA' && !empty($startTime)) {
         try {
             $this->start = new \DateTime($sessionDate . ' ' . $startTime);
             $this->end = new \DateTime($sessionDate . ' ' . $endTime);
         } catch (\Exception $e) {
         }
     }
     return $this;
 }
 /**
  * Sort a list of sessions.
  *
  * @param   SessionModel  $a
  * @param   SessionModel  $b
  * @return  int
  */
 protected function sortSessions(SessionModel $a, SessionModel $b)
 {
     // Start time (asc)
     if (($start = $a->getStartTime('U') - $b->getStartTime('U')) !== 0) {
         return $start;
     }
     // End time (desc)
     if (($end = $b->getEndTime('U') - $a->getEndTime('U')) !== 0) {
         return $end;
     }
     // Society (asc)
     $societyMap = [1 => [], 2 => ['ASMBS'], 3 => ['TOS'], 4 => ['ASMBS', 'TOS']];
     $aSocieties = $a->getSocieties('name');
     $bSocieties = $b->getSocieties('name');
     sort($aSocieties);
     sort($bSocieties);
     $aValue = (int) array_search($aSocieties, $societyMap);
     $bValue = (int) array_search($bSocieties, $societyMap);
     if (($societyCmp = $aValue - $bValue) !== 0) {
         return $societyCmp;
     }
     // Title (asc)
     return strcasecmp($a->getTitle(), $b->getTitle());
 }