Changeset 1061


Ignore:
Timestamp:
Mar 1, 2006, 5:33:52 AM (18 years ago)
Author:
rvelices
Message:

calendar improvement: month calendar view a la flickr

fix: html 4.01 compliant in rating.tpl

fix: issue with IE from version 1052 (redirect on access denied)

Location:
trunk
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/identification.php

    r1056 r1061  
    3636if ( !empty($_GET['redirect']) )
    3737{
    38   $redirect_to = $_GET['redirect'];
     38  $redirect_to = urldecode($_GET['redirect']);
    3939  if ( $user['is_the_guest'] )
    4040  {
     
    9999    'U_HOME' => PHPWG_ROOT_PATH.'category.php',
    100100    'U_REDIRECT' => $redirect_to,
    101    
     101
    102102    'F_LOGIN_ACTION' => PHPWG_ROOT_PATH.'identification.php'
    103103    ));
  • trunk/include/calendar_monthly.class.php

    r1059 r1061  
    114114      $this->build_nav_bar(
    115115          CDAY,
    116           $this->get_all_days_in_month(
    117               $this->date_components[CYEAR] ,$this->date_components[CMONTH]
    118             )
     116          range( 1, $this->get_all_days_in_month(
     117              $this->date_components[CYEAR] ,$this->date_components[CMONTH] )
     118              )
    119119        ); // days
    120120    }
     
    212212    $nb_days = 31;
    213213  }
    214   return range(1, $nb_days);
     214  return $nb_days;
    215215}
    216216
     
    325325function build_month_calendar()
    326326{
    327   $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%d")) as period,
    328             COUNT(id) as count';
     327  $query='SELECT DISTINCT(DAYOFMONTH('.$this->date_field.')) as period,
     328            COUNT( DISTINCT(id) ) as count';
    329329  $query.= $this->inner_sql;
    330330  $query.= $this->get_date_where($this->date_components);
     
    335335  while ($row = mysql_fetch_array($result))
    336336  {
    337     $d = $row['period'];
     337    $d = (int)$row['period'];
    338338    $items[$d] = array('nb_images'=>$row['count']);
    339339  }
     
    343343    $this->date_components[CDAY]=$day;
    344344    $query = '
    345 SELECT file,tn_ext,path, DAYOFWEEK('.$this->date_field.')-1 as dw';
     345SELECT file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as dow';
    346346    $query.= $this->inner_sql;
    347347    $query.= $this->get_date_where();
     
    354354    $items[$day]['tn_path'] = get_thumbnail_src($row['path'], @$row['tn_ext']);
    355355    $items[$day]['tn_file'] = $row['file'];
    356     $items[$day]['tn_dw'] = $row['dw'];
    357   }
    358 
    359   global $lang, $template;
    360   $template->assign_block_vars('thumbnails', array());
    361   $template->assign_block_vars('thumbnails.line', array());
    362   foreach ( $items as $day=>$data)
    363   {
    364     $url_base = $this->url_base.
    365           $this->date_components[CYEAR].'-'.
    366           $this->date_components[CMONTH].'-'.$day;
    367 
    368     $thumbnail_title = $lang['day'][$data['tn_dw']] . ' ' . $day;
    369     $name = $thumbnail_title .' ('.$data['nb_images'].')';
    370 
    371     $template->assign_block_vars(
    372         'thumbnails.line.thumbnail',
     356    $items[$day]['width'] = $row['width'];
     357    $items[$day]['height'] = $row['height'];
     358    $items[$day]['dow'] = $row['dow'];
     359  }
     360
     361  global $lang, $template, $conf;
     362
     363  if ( !empty($items)
     364      and $conf['calendar_month_cell_width']>0
     365      and $conf['calendar_month_cell_height']>0)
     366  {
     367    list($known_day) = array_keys($items);
     368    $known_dow = $items[$known_day]['dow'];
     369    $first_day_dow = ($known_dow-($known_day-1))%7;
     370    if ($first_day_dow<0)
     371    {
     372      $first_day_dow += 7;
     373    }
     374    //first_day_dow = week day corresponding to the first day of this month
     375    $wday_labels = $lang['day'];
     376
     377    // BEGIN - pass now in week starting Monday
     378    if ($first_day_dow==0)
     379    {
     380      $first_day_dow = 6;
     381    }
     382    else
     383    {
     384      $first_day_dow -= 1;
     385    }
     386    array_push( $wday_labels, array_shift($wday_labels) );
     387    // END - pass now in week starting Monday
     388
     389    $cell_width = $conf['calendar_month_cell_width'];
     390    $cell_height = $conf['calendar_month_cell_height'];
     391
     392    $template->set_filenames(
     393      array(
     394        'month_calendar'=>'month_calendar.tpl',
     395        )
     396      );
     397
     398    $template->assign_block_vars('calendar.thumbnails',
    373399        array(
    374           'IMAGE'=>$data['tn_path'],
    375           'IMAGE_ALT'=>$data['tn_file'],
    376           'IMAGE_TITLE'=>$thumbnail_title,
    377           'U_IMG_LINK'=>$url_base
    378          )
    379         );
    380     $template->assign_block_vars(
    381         'thumbnails.line.thumbnail.category_name',
    382         array(
    383           'NAME' => $name
     400           'WIDTH'=>$cell_width,
     401           'HEIGHT'=>$cell_height,
    384402          )
    385         );
     403      );
     404
     405    //fill the heading with day names
     406    $template->assign_block_vars('calendar.thumbnails.head', array());
     407    foreach( $wday_labels as $d => $label)
     408    {
     409      $template->assign_block_vars('calendar.thumbnails.head.col',
     410                    array('LABEL'=>$label)
     411                  );
     412    }
     413
     414    $template->assign_block_vars('calendar.thumbnails.row', array());
     415
     416    //fill the empty days in the week before first day of this month
     417    for ($i=0; $i<$first_day_dow; $i++)
     418    {
     419      $template->assign_block_vars('calendar.thumbnails.row.col', array());
     420      $template->assign_block_vars('calendar.thumbnails.row.col.blank', array());
     421    }
     422    for ($day=1; $day<=$this->get_all_days_in_month(
     423              $this->date_components[CYEAR] ,$this->date_components[CMONTH]); $day++)
     424    {
     425      $dow = ($first_day_dow + $day-1)%7;
     426      if ($dow==0)
     427      {
     428        $template->assign_block_vars('calendar.thumbnails.row', array());
     429      }
     430      $template->assign_block_vars('calendar.thumbnails.row.col', array());
     431      if ( !isset($items[$day]) )
     432      {
     433        $template->assign_block_vars('calendar.thumbnails.row.col.empty',
     434              array('LABEL'=>$day));
     435      }
     436      else
     437      {
     438        // first try to guess thumbnail size
     439        if ( !empty($items[$day]['width']) )
     440        {
     441          $tn_size = get_picture_size(
     442                 $items[$day]['width'], $items[$day]['height'],
     443                 $conf['tn_width'], $conf['tn_height'] );
     444        }
     445        else
     446        {// item not an image (tn is either mime type or an image)
     447          $tn_size = @getimagesize($items[$day]['tn_path']);
     448        }
     449        $tn_width = $tn_size[0];
     450        $tn_height = $tn_size[1];
     451
     452        // now need to fit the thumbnail of size tn_size within
     453        // a cell of size cell_size by playing with CSS position (left/top)
     454        // and the width and height of <img>.
     455        $ratio_w = $tn_width/$cell_width;
     456        $ratio_h = $tn_height/$cell_height;
     457
     458        $pos_top=$pos_left=0;
     459        $img_width=$img_height='';
     460        if ( $ratio_w>1 and $ratio_h>1)
     461        {// cell completely smaller than the thumbnail so we will let the browser
     462         // resize the thumbnail
     463          if ($ratio_w > $ratio_h )
     464          {// thumbnail ratio compared to cell -> wide format
     465            $img_height = 'height="'.$cell_height.'"';
     466            $browser_img_width = $cell_height*$tn_width/$tn_height;
     467            $pos_left = ($tn_width-$browser_img_width)/2;
     468          }
     469          else
     470          {
     471            $img_width = 'width="'.$cell_width.'"';
     472            $browser_img_height = $cell_width*$tn_height/$tn_width;
     473            $pos_top = ($tn_height-$browser_img_height)/2;
     474          }
     475        }
     476        else
     477        {
     478          $pos_left = ($tn_width-$cell_width)/2;
     479          $pos_top = ($tn_height-$cell_height)/2;
     480        }
     481
     482        $css_style = '';
     483        if ( round($pos_left)!=0)
     484        {
     485          $css_style.='left:'.round(-$pos_left).'px;';
     486        }
     487        if ( round($pos_top)!=0)
     488        {
     489          $css_style.='top:'.round(-$pos_top).'px;';
     490        }
     491        $url = $this->url_base.
     492              $this->date_components[CYEAR].'-'.
     493              $this->date_components[CMONTH].'-'.$day;
     494        $alt = $wday_labels[$dow] . ' ' . $day.
     495               ' ('.$items[$day]['nb_images'].')';
     496        $template->assign_block_vars('calendar.thumbnails.row.col.full',
     497              array(
     498                'LABEL'     => $day,
     499                'IMAGE'     => $items[$day]['tn_path'],
     500                'U_IMG_LINK'=> $url,
     501                'STYLE'     => $css_style,
     502                'IMG_WIDTH' => $img_width,
     503                'IMG_HEIGHT'=> $img_height,
     504                'IMAGE_ALT' => $alt,
     505              )
     506            );
     507      }
     508    }
     509    //fill the empty days in the week after the last day of this month
     510    while ( $dow<6 )
     511    {
     512      $template->assign_block_vars('calendar.thumbnails.row.col', array());
     513      $template->assign_block_vars('calendar.thumbnails.row.col.blank', array());
     514      $dow++;
     515    }
     516    $template->assign_var_from_handle('MONTH_CALENDAR', 'month_calendar');
     517  }
     518  else
     519  {
     520    $template->assign_block_vars('thumbnails', array());
     521    $template->assign_block_vars('thumbnails.line', array());
     522    foreach ( $items as $day=>$data)
     523    {
     524      $url = $this->url_base.
     525            $this->date_components[CYEAR].'-'.
     526            $this->date_components[CMONTH].'-'.$day;
     527
     528      $thumbnail_title = $lang['day'][$data['dow']] . ' ' . $day;
     529      $name = $thumbnail_title .' ('.$data['nb_images'].')';
     530
     531      $template->assign_block_vars(
     532          'thumbnails.line.thumbnail',
     533          array(
     534            'IMAGE'=>$data['tn_path'],
     535            'IMAGE_ALT'=>$data['tn_file'],
     536            'IMAGE_TITLE'=>$thumbnail_title,
     537            'U_IMG_LINK'=>$url
     538           )
     539          );
     540      $template->assign_block_vars(
     541          'thumbnails.line.thumbnail.category_name',
     542          array(
     543            'NAME' => $name
     544            )
     545          );
     546    }
    386547  }
    387548
  • trunk/include/config_default.inc.php

    r1059 r1061  
    103103$conf['calendar_show_empty'] = true;
    104104
     105// calendar_month_cell_width, calendar_month_cell_height : define the
     106// width and the height of a cell in the monthly calendar when viewing a
     107// given month. a value of 0 means that the pretty view is not shown.
     108// a good suggestion would be to have the width and the height equal
     109// and smaller than tn_width and tn_height. NOTE THAT tn_width AND tn_height
     110// MUST CORRESPOND APPROXIMATIVELY TO YOUR REAL THUMBNAIL SIZE, OTHERWISE
     111// THE IMAGES WILL NOT SHOW CORRECTLY
     112$conf['calendar_month_cell_width'] =80;
     113$conf['calendar_month_cell_height']=80;
     114
    105115// newcat_default_commentable : at creation, must a category be commentable
    106116// or not ?
  • trunk/include/functions_category.inc.php

    r1059 r1061  
    4848  {
    4949    $login_url = './identification.php?redirect='.
    50                   htmlentities(htmlentities($_SERVER['REQUEST_URI']));
     50                  urlencode(urlencode($_SERVER['REQUEST_URI']));
    5151    if ( ! $user['is_the_guest'] )
    5252    {
  • trunk/template/yoga/admin/rating.tpl

    • Property svn:eol-style set to native
    r1042 r1061  
    22
    33<form action="" method="GET" id="update">
     4<fieldset>
     5<legend></legend>
    46<input type="hidden" name="page" value="rating" />
    5 <fieldset>
    6 
    77<ul>
    88
     
    4040</p>
    4141</form>
    42 
    4342<div class="navigationBar">{NAVBAR}</div>
    44 
    4543<table width="100%">
    4644<tr class="throw">
  • trunk/template/yoga/category.tpl

    r1059 r1061  
    168168<!-- END calbar -->
    169169<!-- END calendar -->
     170
     171{MONTH_CALENDAR}
    170172
    171173<!-- BEGIN thumbnails -->
  • trunk/template/yoga/content.css

    r1059 r1061  
    180180
    181181
     182/* begin chronology/calendar elements*/
    182183#content DIV.calendarViews {
    183184  display: block;
     
    200201  margin: 0 2px;
    201202  border: 1px solid gray;
    202   color: dark-gray;
    203203}
    204204
     
    207207  margin: 0 2px;
    208208  border: 1px solid gray;
    209   color: lightgray;
    210209}
    211210
     
    225224}
    226225
     226/* nice looking month calendar*/
     227.calMonth { border: none; border-collapse: collapse; }
     228
     229TD.calDayCellFull, TD.calDayCellEmpty, TD.calDayCellBlank
     230{
     231  text-align:left;
     232  vertical-align: top;
     233  font: bold 18px Arial, Helvetica, sans-serif;
     234}
     235
     236TD.calDayHead { font: bold 12px Arial, Helvetica, sans-serif; }
     237
     238DIV.calImg
     239{
     240  overflow: hidden;
     241  vertical-align: bottom;
     242  z-index: 1;
     243  position: relative; /*<- this required by IE*/
     244}
     245
     246.calImg img
     247{
     248  position: relative;
     249  border: 0;
     250}
     251
     252.calBackDate {
     253  padding-left: 4px;
     254  padding-top: 0px;
     255  z-index: 2;
     256  position: absolute;
     257  text-align: left;
     258  vertical-align: top;
     259}
     260
     261.calForeDate {
     262  padding-left: 5px;
     263  padding-top: 1px;
     264  z-index: 3;
     265  position: absolute;
     266  text-align: left;
     267  vertical-align: top;
     268}
  • trunk/template/yoga/theme/clear/theme.css

    • Property svn:eol-style set to native
    r978 r1061  
    7878}
    7979
     80/*calendar elements*/
     81SPAN.calItemSel { color: dark-gray; }
     82
     83SPAN.calItemEmpty { color: lightgray; }
     84
     85
     86/* nice looking month calendar*/
     87TD.calDayCellEmpty, TD.calDayCellFull { border: 1px solid #7E7262;}
     88
     89TD.calDayCellEmpty { color: lightgray; }
     90
     91.calBackDate { color: #000; }
     92.calForeDate { color: #fff; }
  • trunk/template/yoga/theme/dark/theme.css

    r1059 r1061  
    115115}
    116116
    117 SPAN.calItemSel {
    118   color: #fff48e;
    119 }
     117/*calendar elements*/
     118SPAN.calItemSel { color: #fff48e; }
    120119
    121 SPAN.calItemEmpty {
    122   color: darkgray;
    123 }
     120SPAN.calItemEmpty { color: darkgray; }
     121
     122/* nice looking month calendar*/
     123TD.calDayCellEmpty, TD.calDayCellFull { border: 1px solid gray;}
     124
     125TD.calDayCellEmpty { color: lightgray; }
     126
     127.calBackDate { color: #000; }
     128.calForeDate { color: #fff; }
Note: See TracChangeset for help on using the changeset viewer.