예제 #1
0
 public function selectLiveAlbumsForPeriodQuery($period)
 {
     //echo $period;
     $dh = new DateHelper();
     $month_array = $dh->month_array();
     if (array_key_exists($period, $month_array)) {
         //period is a month e.g. 'january' | 'february' etc
         $month = $month_array[$period];
         $year = $month > date('n') ? date('Y') - 1 : date('Y');
         $start = mktime(0, 0, 0, $month, 1, $year);
         $end = mktime(0, 0, 0, $month + 1, 0, $year);
     } else {
         //period is a year e.g. '2009' | '1964'
         $start = mktime(0, 0, 0, 1, 1, $period);
         $end = mktime(0, 0, 0, 1, 0, $period + 1);
     }
     return "SELECT * FROM albums WHERE status=" . Content::STATUS_LIVE . " AND datedisplayed BETWEEN {$start} AND {$end}" . " ORDER BY datedisplayed DESC";
 }
예제 #2
0
 private function periodToStartEndValues($period, $mode = 'news')
 {
     $boundary['start'] = 0;
     $boundary['end'] = 0;
     $period = strtolower($period);
     //in case some genius sends us a capitalized month
     $date_helper = new DateHelper();
     $month_array = $date_helper->month_array();
     if (array_key_exists($period, $month_array)) {
         //$period contains a month
         $month = $month_array[$period];
         switch ($mode) {
             case 'news':
                 $year = $month > date('n') ? date('Y') - 1 : date('Y');
                 break;
             case 'events':
                 $year = $month < date('n') ? date('Y') + 1 : date('Y');
                 break;
         }
         $start = mktime(0, 0, 0, $month, 0, $year);
         $end = mktime(0, 0, 0, $month + 1, 0, $year);
     } elseif (preg_match('/[0-9]{4}/', $period) !== 0) {
         //$period contains a 4-digit year
         $year = $period;
         $start = mktime(0, 0, 0, 1, 1, $year);
         $end = mktime(0, 0, 0, 0, 0, $year + 1);
     } else {
         //bad $period value
         throw new Exception('Bad $period Value passed: ' . $period);
     }
     $boundary['start'] = $start;
     $boundary['end'] = $end;
     return $boundary;
 }