Ignore:
Timestamp:
Nov 30, 2009, 9:41:11 PM (14 years ago)
Author:
nikrou
Message:

Feature 1255 :
sql functions for calendar (interval, year, month, ...)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/calendar_base.class.php

    r4367 r4398  
    216216$this->inner_sql.
    217217$this->get_date_where($level).'
    218   GROUP BY period
     218  GROUP BY period
     219  ORDER BY period ASC
    219220;';
    220221
     
    266267  {
    267268    global $template, $page;
     269
    268270    $prev = $next =null;
    269271    if ( empty($page['chronology_date']) )
    270272      return;
    271     $query = 'SELECT CONCAT_WS(\'-\'';
    272     for ($i=0; $i<count($page['chronology_date']); $i++)
     273   
     274    $sub_query = '';
     275    $nb_elements = count($page['chronology_date']);
     276    for ($i=0; $i<$nb_elements; $i++)
    273277    {
    274278      if ( 'any' === $page['chronology_date'][$i] )
    275279      {
    276         $query .= ','.'"any"';
     280        $sub_query .= '\'any\'';
    277281      }
    278282      else
    279283      {
    280         $query .= ','.$this->calendar_levels[$i]['sql'];
    281       }
    282     }
    283     $current = implode('-', $page['chronology_date'] );
    284 
    285     $query.=') as period' . $this->inner_sql .'
     284        $sub_query .= pwg_db_cast_to_text($this->calendar_levels[$i]['sql']);
     285      }
     286      if ($i<($nb_elements-1))
     287      {
     288        $sub_query .= ',';
     289      }
     290    }
     291    $query = 'SELECT '.pwg_db_concat_ws($sub_query, '-').' AS period';
     292    $query .= $this->inner_sql .'
    286293AND ' . $this->date_field . ' IS NOT NULL
    287294GROUP BY period';
    288 
     295   
     296    $current = implode('-', $page['chronology_date'] );
    289297    $upper_items = array_from_query( $query, 'period');
    290298
Note: See TracChangeset for help on using the changeset viewer.