diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/common.inc.php | 2 | ||||
-rw-r--r-- | include/dblayer/functions_mysql.inc.php | 73 | ||||
-rw-r--r-- | include/functions_calendar.inc.php | 5 | ||||
-rw-r--r-- | include/functions_user.inc.php | 2 | ||||
-rw-r--r-- | include/section_init.inc.php | 4 |
5 files changed, 78 insertions, 8 deletions
diff --git a/include/common.inc.php b/include/common.inc.php index 9fdc014d5..1ec1d38c7 100644 --- a/include/common.inc.php +++ b/include/common.inc.php @@ -92,7 +92,7 @@ foreach( array( include(PHPWG_ROOT_PATH . 'include/config_default.inc.php'); @include(PHPWG_ROOT_PATH. 'include/config_local.inc.php'); -include(PHPWG_ROOT_PATH .'include/dblayer/functions_mysql.inc.php'); +include(PHPWG_ROOT_PATH .'include/dblayer/functions_'.$conf['dblayer'].'.inc.php'); if(isset($conf['show_php_errors']) && !empty($conf['show_php_errors'])) { diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php index f21ace0f3..e47119535 100644 --- a/include/dblayer/functions_mysql.inc.php +++ b/include/dblayer/functions_mysql.inc.php @@ -538,6 +538,79 @@ function boolean_to_string($var) } } +/** + * + * interval and date functions + * + */ + + +function pwg_db_get_recent_period_expression($period, $date='CURRENT_DATE') +{ + if ($date!='CURRENT_DATE') + { + $date = '\''.$date.'\''; + } + + return 'SUBDATE('.$date.',INTERVAL '.$period.' DAY)'; +} + +function pwg_db_get_recent_period($period, $date='CURRENT_DATE') +{ + $query = ' +SELECT '.pwg_db_get_recent_period_expression($period); + list($d) = pwg_db_fetch_row(pwg_query($query)); + + return $d; +} + +function pwg_db_get_date_YYYYMM($date) +{ + return 'DATE_FORMAT('.$date.', \'%Y%m\')'; +} + +function pwg_db_get_date_MMDD($date) +{ + return 'DATE_FORMAT('.$date.', \'%m%d\')'; +} + +function pwg_db_get_year($date) +{ + return 'YEAR('.$date.')'; +} + +function pwg_db_get_month($date) +{ + return 'MONTH('.$date.')'; +} + +function pwg_db_get_week($date, $mode=null) +{ + if ($mode) + { + return 'WEEK('.$date.', '.$mode.')'; + } + else + { + return 'WEEK('.$date.')'; + } +} + +function pwg_db_get_dayofmonth($date) +{ + return 'DAYOFMONTH('.$date.')'; +} + +function pwg_db_get_dayofweek($date) +{ + return 'DAYOFWEEK('.$date.')'; +} + +function pwg_db_get_weekday($date) +{ + return 'WEEKDAY('.$date.')'; +} + // my_error returns (or send to standard output) the message concerning the // error occured for the last mysql query. function my_error($header, $die) diff --git a/include/functions_calendar.inc.php b/include/functions_calendar.inc.php index 74c366f8c..362c4cf14 100644 --- a/include/functions_calendar.inc.php +++ b/include/functions_calendar.inc.php @@ -258,7 +258,7 @@ WHERE id IN (' . implode(',',$page['items']) .')'; if ($must_show_list) { - $query = 'SELECT DISTINCT(id)'; + $query = 'SELECT id'; $query .= $calendar->inner_sql.' '.$calendar->get_date_where(); if ( isset($page['super_order_by']) ) @@ -284,9 +284,8 @@ WHERE id IN (' . implode(',',$page['items']) .')'; $query .= ' '.$order_by; } - $page['items'] = array_from_query($query, 'id'); + $page['items'] = array_from_query($query, 'id'); } pwg_debug('end initialize_calendar'); } - ?>
\ No newline at end of file diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 2a2ed79e9..850fad110 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -642,7 +642,7 @@ FROM '.CATEGORIES_TABLE.' as c } $query.= ' - GROUP BY c.id'; + GROUP BY c.id, c.global_rank'; $result = pwg_query($query); diff --git a/include/section_init.inc.php b/include/section_init.inc.php index 5cc0fbb35..c6576f1ea 100644 --- a/include/section_init.inc.php +++ b/include/section_init.inc.php @@ -122,6 +122,7 @@ if (script_basename() == 'picture') // basename without file extention } $page = array_merge( $page, parse_section_url( $tokens, $next_token) ); + if ( !isset($page['section']) ) { $page['section'] = 'categories'; @@ -156,10 +157,7 @@ if ( !isset($page['section']) ) } } - $page = array_merge( $page, parse_well_known_params_url( $tokens, $next_token) ); - - if ( script_basename()=='picture' and 'categories'==$page['section'] and !isset($page['category']) and !isset($page['chronology_field']) ) { //access a picture only by id, file or id-file without given section |