Ignore:
Timestamp:
Feb 23, 2006, 3:30:19 AM (18 years ago)
Author:
rvelices
Message:

new calendar completely integrated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/section_init.inc.php

    r1047 r1051  
    5353           or $_GET['cat'] == 'best_rated'
    5454           or $_GET['cat'] == 'recent_pics'
    55            or $_GET['cat'] == 'recent_cats'
    56            or $_GET['cat'] == 'calendar')
     55           or $_GET['cat'] == 'recent_cats')
    5756  {
    5857    $page['cat'] = $_GET['cat'];
     
    9897$page['nb_image_page'] = $user['nb_image_page'];
    9998
     99if (isset($_COOKIE['pwg_image_order'])
     100    and is_numeric($_COOKIE['pwg_image_order'])
     101    and $_COOKIE['pwg_image_order'] > 0)
     102{
     103  $orders = get_category_preferred_image_orders();
     104
     105  $conf['order_by'] = str_replace(
     106    'ORDER BY ',
     107    'ORDER BY '.$orders[ $_COOKIE['pwg_image_order'] ][1].',',
     108    $conf['order_by']
     109    );
     110  $page['super_order_by'] = true;
     111}
     112
    100113if (isset($page['cat']))
    101114{
    102   if ($page['cat'] != 'most_visited' and $page['cat'] != 'best_rated')
    103   {
    104     if (isset($_COOKIE['pwg_image_order'])
    105         and is_numeric($_COOKIE['pwg_image_order'])
    106         and $_COOKIE['pwg_image_order'] > 0)
    107     {
    108       $orders = get_category_preferred_image_orders();
    109 
    110       $conf['order_by'] = str_replace(
    111         'ORDER BY ',
    112         'ORDER BY '.$orders[ $_COOKIE['pwg_image_order'] ][1].',',
    113         $conf['order_by']
    114         );
    115     }
    116   }
    117  
     115 
    118116// +-----------------------------------------------------------------------+
    119117// |                              category                                 |
     
    121119  if (is_numeric($page['cat']))
    122120  {
    123     $query = '
    124 SELECT image_id
    125   FROM '.IMAGE_CATEGORY_TABLE.'
    126     INNER JOIN '.IMAGES_TABLE.' ON id = image_id
    127   WHERE category_id = '.$page['cat'].'
    128   '.$conf['order_by'].'
    129 ;';
    130 
    131121    $result = get_cat_info($page['cat']);
    132    
     122
    133123    $page = array_merge(
    134124      $page,
     
    143133        'cat_id_uppercat'  => $result['id_uppercat'],
    144134        'uppercats'        => $result['uppercats'],
    145                
     135
    146136        'title' => get_cat_display_name($result['name'], '', false),
    147         'items' => array_from_query($query, 'image_id'),
    148         'thumbnails_include' =>
     137        )
     138      );
     139    if ( !isset($_GET['calendar']) )
     140    {
     141      $query = '
     142SELECT image_id
     143  FROM '.IMAGE_CATEGORY_TABLE.'
     144    INNER JOIN '.IMAGES_TABLE.' ON id = image_id
     145  WHERE category_id = '.$page['cat'].'
     146  '.$conf['order_by'].'
     147;';
     148      $page['items'] = array_from_query($query, 'image_id');
     149      $page['thumbnails_include'] =
    149150          $result['nb_images'] > 0
    150151          ? 'include/category_default.inc.php'
    151           : 'include/category_subcats.inc.php',
    152         )
    153       );
     152          : 'include/category_subcats.inc.php';
     153    }//otherwise the calendar will requery all subitems
    154154  }
    155155  // special section
     
    256256    else if ($page['cat'] == 'most_visited')
    257257    {
     258      $page['super_order_by'] = true;
     259      $conf['order_by'] = ' ORDER BY hit DESC, file ASC';
    258260      $query = '
    259261SELECT DISTINCT(id)
     
    261263    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
    262264  WHERE hit > 0
    263     AND '.$forbidden.'
    264   ORDER BY hit DESC, file ASC
     265    AND '.$forbidden.
     266  $conf['order_by'].'
    265267  LIMIT 0, '.$conf['top_number'].'
    266268;';
     
    276278    }
    277279// +-----------------------------------------------------------------------+
    278 // |                           calendar section                            |
    279 // +-----------------------------------------------------------------------+
    280     else if ($page['cat'] == 'calendar')
    281     {
    282       $page['cat_nb_images'] = 0;
    283       $page['title'] = $lang['calendar'];
    284       if (isset($_GET['year'])
    285           and preg_match('/^\d+$/', $_GET['year']))
    286       {
    287         $page['calendar_year'] = (int)$_GET['year'];
    288       }
    289       if (isset($_GET['month'])
    290           and preg_match('/^(\d+)\.(\d{2})$/', $_GET['month'], $matches))
    291       {
    292         $page['calendar_year'] = (int)$matches[1];
    293         $page['calendar_month'] = (int)$matches[2];
    294       }
    295       if (isset($_GET['day'])
    296           and preg_match('/^(\d+)\.(\d{2})\.(\d{2})$/',
    297                          $_GET['day'],
    298                          $matches))
    299       {
    300         $page['calendar_year'] = (int)$matches[1];
    301         $page['calendar_month'] = (int)$matches[2];
    302         $page['calendar_day'] = (int)$matches[3];
    303       }
    304       if (isset($page['calendar_year']))
    305       {
    306         $page['title'] .= ' (';
    307         if (isset($page['calendar_day']))
    308         {
    309           if ($page['calendar_year'] >= 1970)
    310           {
    311             $unixdate = mktime(
    312               0,
    313               0,
    314               0,
    315               $page['calendar_month'],
    316               $page['calendar_day'],
    317               $page['calendar_year']
    318               );
    319             $page['title'].= $lang['day'][date("w", $unixdate)];
    320           }
    321           $page['title'].= ' '.$page['calendar_day'].', ';
    322         }
    323         if (isset($page['calendar_month']))
    324         {
    325           $page['title'] .= $lang['month'][$page['calendar_month']].' ';
    326         }
    327         $page['title'] .= $page['calendar_year'];
    328         $page['title'] .= ')';
    329       }
    330        
    331       $page['where'] = 'WHERE '.$conf['calendar_datefield'].' IS NOT NULL';
    332       if (isset($forbidden))
    333       {
    334         $page['where'].= ' AND '.$forbidden;
    335       }
    336 
    337       $page['thumbnails_include'] = 'include/category_calendar.inc.php';
    338     }
    339 // +-----------------------------------------------------------------------+
    340280// |                          best rated section                           |
    341281// +-----------------------------------------------------------------------+
    342282    else if ($page['cat'] == 'best_rated')
    343283    {
     284      $page['super_order_by'] = true;
     285      $conf['order_by'] = ' ORDER BY average_rate DESC, id ASC';
     286
    344287      $query ='
    345288SELECT DISTINCT(id)
     
    347290    INNER JOIN '.IMAGE_CATEGORY_TABLE.' AS ic ON id = ic.image_id
    348291  WHERE average_rate IS NOT NULL
    349     AND '.$forbidden.'
    350   ORDER BY average_rate DESC, id ASC
     292    AND '.$forbidden.
     293  $conf['order_by'].'
    351294  LIMIT 0, '.$conf['top_number'].'
    352295;';
Note: See TracChangeset for help on using the changeset viewer.