Changeset 1051


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

new calendar completely integrated

Location:
trunk
Files:
1 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/category.php

    r1050 r1051  
    301301  'special_cat',
    302302  array(
    303     'URL' => PHPWG_ROOT_PATH.'category.php?cat=calendar',
     303    'URL' => PHPWG_ROOT_PATH.'category.php?calendar=m-c',
    304304    'TITLE' => $lang['calendar_hint'],
    305305    'NAME' => $lang['calendar']
     
    401401    );
    402402}
     403
     404if ($page['cat_nb_images']>0 and
     405    ( !isset($page['cat'])
     406      or ($page['cat'] != 'most_visited' and $page['cat'] != 'best_rated') )
     407   )
     408{
     409  // image order
     410  $template->assign_block_vars( 'preferred_image_order', array() );
     411
     412  $order_idx = isset($_COOKIE['pwg_image_order']) ?
     413                   $_COOKIE['pwg_image_order'] : 0;
     414
     415  $orders = get_category_preferred_image_orders();
     416  for ( $i = 0; $i < count($orders); $i++)
     417  {
     418    if ($orders[$i][2])
     419    {
     420      $url = PHPWG_ROOT_PATH.'category.php'
     421               .get_query_string_diff(array('image_order'));
     422      $url .= '&amp;image_order='.$i;
     423      $template->assign_block_vars( 'preferred_image_order.order', array(
     424        'DISPLAY' => $orders[$i][0],
     425        'URL' => $url,
     426        'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : '' ),
     427        ) );
     428    }
     429  }
     430}
     431
    403432if ( isset ( $page['cat'] ) )
    404433{
     
    423452      );
    424453  }
    425   if ($page['cat_nb_images']>0 and
    426        $page['cat'] != 'most_visited' and $page['cat'] != 'best_rated')
    427   {
    428     // image order
    429     $template->assign_block_vars( 'preferred_image_order', array() );
    430  
    431     $order_idx = isset($_COOKIE['pwg_image_order']) ?
    432                      $_COOKIE['pwg_image_order'] : 0;
    433 
    434     $orders = get_category_preferred_image_orders();
    435     for ( $i = 0; $i < count($orders); $i++)
    436     {
    437       if ($orders[$i][2])
    438       {
    439         $url = PHPWG_ROOT_PATH.'category.php'
    440                  .get_query_string_diff(array('image_order'));
    441         $url .= '&amp;image_order='.$i;
    442         $template->assign_block_vars( 'preferred_image_order.order', array(
    443           'DISPLAY' => $orders[$i][0],
    444           'URL' => $url,
    445           'SELECTED_OPTION' => ($order_idx==$i ? 'SELECTED' : '' ),
    446           ) );
    447       }
    448     }
    449   }
    450454}
    451455//------------------------------------------------------------ log informations
  • trunk/include/calendar_monthly.class.php

    r1050 r1051  
    127127      }
    128128    }
    129     $res = " AND $this->date_field BETWEEN '$b' AND '$e'" . $res;
     129    $res = " AND $this->date_field BETWEEN '$b' AND '$e 23:59:59'" . $res;
    130130  }
    131131  else
     
    236236    $url_base = $this->url_base.'c-'.$requested[0].'-'.$month;
    237237
    238     $nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">'.$lang['month'][$month].'</a>';
     238    $nav_bar = '<span class="calCalHead"><a href="'.$url_base.'">';
     239    $nav_bar .= $lang['month'][$month].'</a>';
    239240    $nav_bar .= ' ('.$month_data['nb_images'].')';
    240241    $nav_bar .= '</span><br>';
    241242
    242243    $url_base .= '-';
    243     $nav_bar .= $this->get_nav_bar_from_items( $url_base, $month_data['children'], $requested[1], 'calCal', false );
     244    $nav_bar .= $this->get_nav_bar_from_items( $url_base,
     245                     $month_data['children'], $requested[1], 'calCal', false );
    244246
    245247    $template->assign_block_vars( 'calendar.calbar',
     
    279281    $query.= $this->inner_sql;
    280282    $query.= $this->get_date_where($requested);
     283    $query.= '
     284  ORDER BY RAND()
     285  LIMIT 0,1';
    281286
    282287    $row = mysql_fetch_array(pwg_query($query));
     
    306311
    307312}
    308 
    309313?>
  • trunk/include/calendar_weekly.class.php

    r1050 r1051  
    7373  {
    7474    $y = $requested[0];
    75     $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31'";
     75    $res = " AND $this->date_field BETWEEN '$y-01-01' AND '$y-12-31 23:59:59'";
    7676  }
    7777
  • trunk/include/functions_calendar.inc.php

    r1050 r1051  
    232232    $query .= $calendar->inner_sql;
    233233    $query .= $calendar->get_date_where($requested);
     234    if ( isset($page['super_order_by']) )
     235    {
     236      $query .= '
     237  '.$conf['order_by'];
     238    }
     239    else
     240    {
     241      $order_by = str_replace(
     242                'ORDER BY ',
     243                'ORDER BY '.$calendar->date_field.',', $conf['order_by']
     244               );
     245      $query .= $order_by;
     246    }
    234247
    235248    $page['items'] = array_from_query($query, 'id');
  • 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;';
  • trunk/picture.php

    r1046 r1051  
    363363}
    364364
    365 $url_up = PHPWG_ROOT_PATH.'category.php?cat='.$page['cat'];
     365$url_up = PHPWG_ROOT_PATH.'category.php?';
     366if ( isset($page['cat']) )
     367{
     368  $url_up .= 'cat='.$page['cat'];
     369}
     370elseif ( isset($_GET['calendar']) )
     371{
     372  $url_up .= 'calendar='.$_GET['calendar'];
     373}
    366374
    367375$url_up_start = floor( $page['current_rank'] / $user['nb_image_page'] );
     
    374382if ( $page['cat'] == 'search' )
    375383{
    376   $url_up.= "&amp;search=".$_GET['search'];
     384  $url_up.= '&amp;search='.$_GET['search'];
    377385}
    378386if ( $page['cat'] == 'list' )
    379387{
    380   $url_up.= "&amp;list=".$_GET['list'];
     388  $url_up.= '&amp;list='.$_GET['list'];
    381389}
    382390
     
    778786if (!empty($picture['current']['date_creation']))
    779787{
    780   $infos['INFO_CREATION_DATE'] =
    781     // FIXME because of search engine partial rewrite, giving the author
    782     // name threw GET is not supported anymore. This feature should come
    783     // back later, with a better design (calendar view).
    784 //     '<a href="'.
    785 //       PHPWG_ROOT_PATH.'category.php?cat=search'.
    786 //       '&amp;search=date_creation:'.$picture['current']['date_creation']
    787 //       .'">'.format_date($picture['current']['date_creation']).'</a>';
    788     format_date($picture['current']['date_creation']);
     788  $val = format_date($picture['current']['date_creation']);
     789  if ( $conf['calendar_datefield'] == 'date_creation' )
     790  {
     791    $infos['INFO_CREATION_DATE'] = '<a href="'.
     792       PHPWG_ROOT_PATH.'category.php?calendar=c-'.
     793       $picture['current']['date_creation'].'">'.$val.'</a>';
     794  }
     795  else
     796  {
     797     $infos['INFO_CREATION_DATE'] = $val;
     798  }
    789799}
    790800else
     
    794804
    795805// date of availability
    796 $infos['INFO_AVAILABILITY_DATE'] =
    797 // FIXME because of search engine partial rewrite, giving the author
    798 // name threw GET is not supported anymore. This feature should come
    799 // back later, with a better design (calendar view).
    800 //
    801 //   '<a href="'.
    802 //     PHPWG_ROOT_PATH.'category.php?cat=search'.
    803 //     '&amp;search=date_available:'.
    804 //     substr($picture['current']['date_available'], 0, 10)
    805 //     .'">'.
    806 //   format_date($picture['current']['date_available'], 'mysql_datetime').
    807 //   '</a>';
    808 format_date($picture['current']['date_available'], 'mysql_datetime');
     806$val = format_date($picture['current']['date_available'], 'mysql_datetime');
     807if ( $conf['calendar_datefield'] == 'date_available' )
     808{
     809  $infos['INFO_AVAILABILITY_DATE'] = '<a href="'.
     810     PHPWG_ROOT_PATH.'category.php?calendar=c-'.
     811     substr($picture['current']['date_available'],0,10).'">'.$val.'</a>';
     812}
     813else
     814{
     815   $infos['INFO_AVAILABILITY_DATE'] = $val;
     816}
    809817
    810818// size in pixels
  • trunk/template/yoga/category.tpl

    r1050 r1051  
    132132     
    133133      <!-- BEGIN calendar_view -->
    134       <li><a href="{calendar_view.URL}" title="{lang:calendar}"><img src="{themeconf:icon_dir}/calendar.png" class="button" alt="{lang:calendar}"></a></li>
     134      <li><a href="{calendar_view.URL}" title="{lang:calendar_hint}"><img src="{themeconf:icon_dir}/calendar.png" class="button" alt="{lang:calendar}"></a></li>
    135135      <!-- END calendar_view -->
    136136      <!-- BEGIN normal_view -->
     
    144144   
    145145<!-- BEGIN calendar -->
    146 <div class="navigationBar">{calendar.YEARS_NAV_BAR}</div>
    147 <div class="navigationBar">{calendar.MONTHS_NAV_BAR}</div>
    148 <!-- END calendar -->
    149 
    150 <!-- BEGIN calendar -->
    151 
    152146<!-- BEGIN styles -->
    153147<div class="calendarStyles">Style: {calendar.styles.BAR}</div>
Note: See TracChangeset for help on using the changeset viewer.