diff options
Diffstat (limited to '')
-rw-r--r-- | identification.php | 4 | ||||
-rw-r--r-- | include/calendar_monthly.class.php | 223 | ||||
-rw-r--r-- | include/config_default.inc.php | 10 | ||||
-rw-r--r-- | include/functions_category.inc.php | 2 | ||||
-rw-r--r-- | template/yoga/admin/rating.tpl | 150 | ||||
-rw-r--r-- | template/yoga/category.tpl | 2 | ||||
-rw-r--r-- | template/yoga/content.css | 46 | ||||
-rw-r--r-- | template/yoga/month_calendar.tpl | 47 | ||||
-rw-r--r-- | template/yoga/theme/clear/theme.css | 13 | ||||
-rw-r--r-- | template/yoga/theme/dark/theme.css | 17 |
10 files changed, 396 insertions, 118 deletions
diff --git a/identification.php b/identification.php index b53e76a2d..ad270bc83 100644 --- a/identification.php +++ b/identification.php @@ -35,7 +35,7 @@ $errors = array(); $redirect_to = ''; if ( !empty($_GET['redirect']) ) { - $redirect_to = $_GET['redirect']; + $redirect_to = urldecode($_GET['redirect']); if ( $user['is_the_guest'] ) { array_push($errors, $lang['access_forbiden']); @@ -98,7 +98,7 @@ $template->assign_vars( 'U_LOST_PASSWORD' => PHPWG_ROOT_PATH.'password.php', 'U_HOME' => PHPWG_ROOT_PATH.'category.php', 'U_REDIRECT' => $redirect_to, - + 'F_LOGIN_ACTION' => PHPWG_ROOT_PATH.'identification.php' )); diff --git a/include/calendar_monthly.class.php b/include/calendar_monthly.class.php index 3a4207076..107c98634 100644 --- a/include/calendar_monthly.class.php +++ b/include/calendar_monthly.class.php @@ -113,9 +113,9 @@ function generate_category_content($url_base, $view_type) { $this->build_nav_bar( CDAY, - $this->get_all_days_in_month( - $this->date_components[CYEAR] ,$this->date_components[CMONTH] - ) + range( 1, $this->get_all_days_in_month( + $this->date_components[CYEAR] ,$this->date_components[CMONTH] ) + ) ); // days } } @@ -211,7 +211,7 @@ function get_all_days_in_month($year, $month) { $nb_days = 31; } - return range(1, $nb_days); + return $nb_days; } function build_global_calendar() @@ -324,8 +324,8 @@ function build_year_calendar() function build_month_calendar() { - $query='SELECT DISTINCT(DATE_FORMAT('.$this->date_field.',"%d")) as period, - COUNT(id) as count'; + $query='SELECT DISTINCT(DAYOFMONTH('.$this->date_field.')) as period, + COUNT( DISTINCT(id) ) as count'; $query.= $this->inner_sql; $query.= $this->get_date_where($this->date_components); $query.= ' @@ -334,7 +334,7 @@ function build_month_calendar() $result = pwg_query($query); while ($row = mysql_fetch_array($result)) { - $d = $row['period']; + $d = (int)$row['period']; $items[$d] = array('nb_images'=>$row['count']); } @@ -342,7 +342,7 @@ function build_month_calendar() { $this->date_components[CDAY]=$day; $query = ' -SELECT file,tn_ext,path, DAYOFWEEK('.$this->date_field.')-1 as dw'; +SELECT file,tn_ext,path, width, height, DAYOFWEEK('.$this->date_field.')-1 as dow'; $query.= $this->inner_sql; $query.= $this->get_date_where(); $query.= ' @@ -353,36 +353,197 @@ SELECT file,tn_ext,path, DAYOFWEEK('.$this->date_field.')-1 as dw'; $row = mysql_fetch_array(pwg_query($query)); $items[$day]['tn_path'] = get_thumbnail_src($row['path'], @$row['tn_ext']); $items[$day]['tn_file'] = $row['file']; - $items[$day]['tn_dw'] = $row['dw']; + $items[$day]['width'] = $row['width']; + $items[$day]['height'] = $row['height']; + $items[$day]['dow'] = $row['dow']; } - global $lang, $template; - $template->assign_block_vars('thumbnails', array()); - $template->assign_block_vars('thumbnails.line', array()); - foreach ( $items as $day=>$data) + global $lang, $template, $conf; + + if ( !empty($items) + and $conf['calendar_month_cell_width']>0 + and $conf['calendar_month_cell_height']>0) { - $url_base = $this->url_base. - $this->date_components[CYEAR].'-'. - $this->date_components[CMONTH].'-'.$day; + list($known_day) = array_keys($items); + $known_dow = $items[$known_day]['dow']; + $first_day_dow = ($known_dow-($known_day-1))%7; + if ($first_day_dow<0) + { + $first_day_dow += 7; + } + //first_day_dow = week day corresponding to the first day of this month + $wday_labels = $lang['day']; + + // BEGIN - pass now in week starting Monday + if ($first_day_dow==0) + { + $first_day_dow = 6; + } + else + { + $first_day_dow -= 1; + } + array_push( $wday_labels, array_shift($wday_labels) ); + // END - pass now in week starting Monday - $thumbnail_title = $lang['day'][$data['tn_dw']] . ' ' . $day; - $name = $thumbnail_title .' ('.$data['nb_images'].')'; + $cell_width = $conf['calendar_month_cell_width']; + $cell_height = $conf['calendar_month_cell_height']; - $template->assign_block_vars( - 'thumbnails.line.thumbnail', - array( - 'IMAGE'=>$data['tn_path'], - 'IMAGE_ALT'=>$data['tn_file'], - 'IMAGE_TITLE'=>$thumbnail_title, - 'U_IMG_LINK'=>$url_base - ) - ); - $template->assign_block_vars( - 'thumbnails.line.thumbnail.category_name', + $template->set_filenames( + array( + 'month_calendar'=>'month_calendar.tpl', + ) + ); + + $template->assign_block_vars('calendar.thumbnails', array( - 'NAME' => $name + 'WIDTH'=>$cell_width, + 'HEIGHT'=>$cell_height, ) - ); + ); + + //fill the heading with day names + $template->assign_block_vars('calendar.thumbnails.head', array()); + foreach( $wday_labels as $d => $label) + { + $template->assign_block_vars('calendar.thumbnails.head.col', + array('LABEL'=>$label) + ); + } + + $template->assign_block_vars('calendar.thumbnails.row', array()); + + //fill the empty days in the week before first day of this month + for ($i=0; $i<$first_day_dow; $i++) + { + $template->assign_block_vars('calendar.thumbnails.row.col', array()); + $template->assign_block_vars('calendar.thumbnails.row.col.blank', array()); + } + for ($day=1; $day<=$this->get_all_days_in_month( + $this->date_components[CYEAR] ,$this->date_components[CMONTH]); $day++) + { + $dow = ($first_day_dow + $day-1)%7; + if ($dow==0) + { + $template->assign_block_vars('calendar.thumbnails.row', array()); + } + $template->assign_block_vars('calendar.thumbnails.row.col', array()); + if ( !isset($items[$day]) ) + { + $template->assign_block_vars('calendar.thumbnails.row.col.empty', + array('LABEL'=>$day)); + } + else + { + // first try to guess thumbnail size + if ( !empty($items[$day]['width']) ) + { + $tn_size = get_picture_size( + $items[$day]['width'], $items[$day]['height'], + $conf['tn_width'], $conf['tn_height'] ); + } + else + {// item not an image (tn is either mime type or an image) + $tn_size = @getimagesize($items[$day]['tn_path']); + } + $tn_width = $tn_size[0]; + $tn_height = $tn_size[1]; + + // now need to fit the thumbnail of size tn_size within + // a cell of size cell_size by playing with CSS position (left/top) + // and the width and height of <img>. + $ratio_w = $tn_width/$cell_width; + $ratio_h = $tn_height/$cell_height; + + $pos_top=$pos_left=0; + $img_width=$img_height=''; + if ( $ratio_w>1 and $ratio_h>1) + {// cell completely smaller than the thumbnail so we will let the browser + // resize the thumbnail + if ($ratio_w > $ratio_h ) + {// thumbnail ratio compared to cell -> wide format + $img_height = 'height="'.$cell_height.'"'; + $browser_img_width = $cell_height*$tn_width/$tn_height; + $pos_left = ($tn_width-$browser_img_width)/2; + } + else + { + $img_width = 'width="'.$cell_width.'"'; + $browser_img_height = $cell_width*$tn_height/$tn_width; + $pos_top = ($tn_height-$browser_img_height)/2; + } + } + else + { + $pos_left = ($tn_width-$cell_width)/2; + $pos_top = ($tn_height-$cell_height)/2; + } + + $css_style = ''; + if ( round($pos_left)!=0) + { + $css_style.='left:'.round(-$pos_left).'px;'; + } + if ( round($pos_top)!=0) + { + $css_style.='top:'.round(-$pos_top).'px;'; + } + $url = $this->url_base. + $this->date_components[CYEAR].'-'. + $this->date_components[CMONTH].'-'.$day; + $alt = $wday_labels[$dow] . ' ' . $day. + ' ('.$items[$day]['nb_images'].')'; + $template->assign_block_vars('calendar.thumbnails.row.col.full', + array( + 'LABEL' => $day, + 'IMAGE' => $items[$day]['tn_path'], + 'U_IMG_LINK'=> $url, + 'STYLE' => $css_style, + 'IMG_WIDTH' => $img_width, + 'IMG_HEIGHT'=> $img_height, + 'IMAGE_ALT' => $alt, + ) + ); + } + } + //fill the empty days in the week after the last day of this month + while ( $dow<6 ) + { + $template->assign_block_vars('calendar.thumbnails.row.col', array()); + $template->assign_block_vars('calendar.thumbnails.row.col.blank', array()); + $dow++; + } + $template->assign_var_from_handle('MONTH_CALENDAR', 'month_calendar'); + } + else + { + $template->assign_block_vars('thumbnails', array()); + $template->assign_block_vars('thumbnails.line', array()); + foreach ( $items as $day=>$data) + { + $url = $this->url_base. + $this->date_components[CYEAR].'-'. + $this->date_components[CMONTH].'-'.$day; + + $thumbnail_title = $lang['day'][$data['dow']] . ' ' . $day; + $name = $thumbnail_title .' ('.$data['nb_images'].')'; + + $template->assign_block_vars( + 'thumbnails.line.thumbnail', + array( + 'IMAGE'=>$data['tn_path'], + 'IMAGE_ALT'=>$data['tn_file'], + 'IMAGE_TITLE'=>$thumbnail_title, + 'U_IMG_LINK'=>$url + ) + ); + $template->assign_block_vars( + 'thumbnails.line.thumbnail.category_name', + array( + 'NAME' => $name + ) + ); + } } return true; diff --git a/include/config_default.inc.php b/include/config_default.inc.php index 224e906b4..5a61c12e3 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -102,6 +102,16 @@ $conf['calendar_show_any'] = true; //no elements for these $conf['calendar_show_empty'] = true; +// calendar_month_cell_width, calendar_month_cell_height : define the +// width and the height of a cell in the monthly calendar when viewing a +// given month. a value of 0 means that the pretty view is not shown. +// a good suggestion would be to have the width and the height equal +// and smaller than tn_width and tn_height. NOTE THAT tn_width AND tn_height +// MUST CORRESPOND APPROXIMATIVELY TO YOUR REAL THUMBNAIL SIZE, OTHERWISE +// THE IMAGES WILL NOT SHOW CORRECTLY +$conf['calendar_month_cell_width'] =80; +$conf['calendar_month_cell_height']=80; + // newcat_default_commentable : at creation, must a category be commentable // or not ? $conf['newcat_default_commentable'] = 'true'; diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 23a50b354..0214656bc 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -47,7 +47,7 @@ function check_restrictions($category_id) if (in_array($category_id, explode(',', $user['forbidden_categories']))) { $login_url = './identification.php?redirect='. - htmlentities(htmlentities($_SERVER['REQUEST_URI'])); + urlencode(urlencode($_SERVER['REQUEST_URI'])); if ( ! $user['is_the_guest'] ) { echo '<div style="text-align:center;">'; diff --git a/template/yoga/admin/rating.tpl b/template/yoga/admin/rating.tpl index 7bc688deb..37cf6e1c4 100644 --- a/template/yoga/admin/rating.tpl +++ b/template/yoga/admin/rating.tpl @@ -1,76 +1,74 @@ -<h2>{lang:Rating} [{NB_ELEMENTS} {lang:elements}]</h2>
-
-<form action="" method="GET" id="update">
-<input type="hidden" name="page" value="rating" />
-<fieldset>
-
-<ul>
-
-<li><label>{lang:elements per page}: <input type="text" name="display" size="2" value="{DISPLAY}"></label></li>
-
-<li>
-<label>{lang:Sort by}:
-<select name="order_by">
-<!-- BEGIN order_by -->
-<option value="{order_by.VALUE}" {order_by.SELECTED}>{order_by.CONTENT}</option>
-<!-- END order_by -->
-</select>
-</label></li>
-
-<li>{lang:Filter}:
-<label>
- <input type="radio" class="radio" name="display_filter" {DISPLAY_FILTER_ALL_CHECKED} value="all"/>
- {lang:users} & {lang:guest}
-</label>
-<label>
- <input type="radio" class="radio" name="display_filter" {DISPLAY_FILTER_USER_CHECKED} value="user"/>
- {lang:users}
-</label>
-<label>
- <input type="radio" class="radio" name="display_filter" {DISPLAY_FILTER_GUEST_CHECKED} value="guest"/>
- {lang:guest}
-</label>
-</li>
-
-</ul>
-
-</fieldset>
-<p class="bottomButtons">
-<input type="submit" value="{lang:Submit}" />
-</p>
-</form>
-
-<div class="navigationBar">{NAVBAR}</div>
-
-<table width="100%">
-<tr class="throw">
- <td>{lang:File}</td>
- <td>{lang:Number of rates}</td>
- <td>{lang:Average rate}</td>
- <td>{lang:Controversy}</td>
- <td>{lang:Sum of rates}</td>
- <td>{lang:Rate}</td>
- <td>{lang:Username}</td>
- <td>{lang:Rate date}</td>
- <td></td>
-</tr>
-<!-- BEGIN image -->
-<tr valign="bottom">
- <td rowspan="{image.NB_RATES_PLUS1}"><a href="{image.U_URL}"><img src="{image.U_THUMB}" alt="{image.FILE}" title="{image.FILE}"></a></td>
- <td rowspan="{image.NB_RATES_PLUS1}"><strong>{image.NB_RATES}/{image.NB_RATES_TOTAL}</strong></td>
- <td rowspan="{image.NB_RATES_PLUS1}"><strong>{image.AVG_RATE}</strong></td>
- <td rowspan="{image.NB_RATES_PLUS1}"><strong>{image.STD_RATE}</strong></td>
- <td rowspan="{image.NB_RATES_PLUS1}" style="border-right: 1px solid;" ><strong>{image.SUM_RATE}</strong></td>
-</tr>
-<!-- BEGIN rate -->
-<tr>
- <td>{image.rate.RATE}</td>
- <td><b>{image.rate.USER}</b></td>
- <td><span class="date">{image.rate.DATE}</span></td>
- <td><a href="{image.rate.U_DELETE}"><img src="{themeconf:icon_dir}/delete.png" class="button" style="border:none;vertical-align:middle; margin-left:5px;" alt="[{lang:delete}]"/></a></td>
-</tr>
-<!-- END rate -->
-<!-- END image -->
-</table>
-
-<div class="navigationBar">{NAVBAR}</div>
+<h2>{lang:Rating} [{NB_ELEMENTS} {lang:elements}]</h2> + +<form action="" method="GET" id="update"> +<fieldset> +<legend></legend> +<input type="hidden" name="page" value="rating" /> +<ul> + +<li><label>{lang:elements per page}: <input type="text" name="display" size="2" value="{DISPLAY}"></label></li> + +<li> +<label>{lang:Sort by}: +<select name="order_by"> +<!-- BEGIN order_by --> +<option value="{order_by.VALUE}" {order_by.SELECTED}>{order_by.CONTENT}</option> +<!-- END order_by --> +</select> +</label></li> + +<li>{lang:Filter}: +<label> + <input type="radio" class="radio" name="display_filter" {DISPLAY_FILTER_ALL_CHECKED} value="all"/> + {lang:users} & {lang:guest} +</label> +<label> + <input type="radio" class="radio" name="display_filter" {DISPLAY_FILTER_USER_CHECKED} value="user"/> + {lang:users} +</label> +<label> + <input type="radio" class="radio" name="display_filter" {DISPLAY_FILTER_GUEST_CHECKED} value="guest"/> + {lang:guest} +</label> +</li> + +</ul> + +</fieldset> +<p class="bottomButtons"> +<input type="submit" value="{lang:Submit}" /> +</p> +</form> +<div class="navigationBar">{NAVBAR}</div> +<table width="100%"> +<tr class="throw"> + <td>{lang:File}</td> + <td>{lang:Number of rates}</td> + <td>{lang:Average rate}</td> + <td>{lang:Controversy}</td> + <td>{lang:Sum of rates}</td> + <td>{lang:Rate}</td> + <td>{lang:Username}</td> + <td>{lang:Rate date}</td> + <td></td> +</tr> +<!-- BEGIN image --> +<tr valign="bottom"> + <td rowspan="{image.NB_RATES_PLUS1}"><a href="{image.U_URL}"><img src="{image.U_THUMB}" alt="{image.FILE}" title="{image.FILE}"></a></td> + <td rowspan="{image.NB_RATES_PLUS1}"><strong>{image.NB_RATES}/{image.NB_RATES_TOTAL}</strong></td> + <td rowspan="{image.NB_RATES_PLUS1}"><strong>{image.AVG_RATE}</strong></td> + <td rowspan="{image.NB_RATES_PLUS1}"><strong>{image.STD_RATE}</strong></td> + <td rowspan="{image.NB_RATES_PLUS1}" style="border-right: 1px solid;" ><strong>{image.SUM_RATE}</strong></td> +</tr> +<!-- BEGIN rate --> +<tr> + <td>{image.rate.RATE}</td> + <td><b>{image.rate.USER}</b></td> + <td><span class="date">{image.rate.DATE}</span></td> + <td><a href="{image.rate.U_DELETE}"><img src="{themeconf:icon_dir}/delete.png" class="button" style="border:none;vertical-align:middle; margin-left:5px;" alt="[{lang:delete}]"/></a></td> +</tr> +<!-- END rate --> +<!-- END image --> +</table> + +<div class="navigationBar">{NAVBAR}</div> diff --git a/template/yoga/category.tpl b/template/yoga/category.tpl index 12b2e56f9..379004e73 100644 --- a/template/yoga/category.tpl +++ b/template/yoga/category.tpl @@ -168,6 +168,8 @@ <!-- END calbar --> <!-- END calendar --> +{MONTH_CALENDAR} + <!-- BEGIN thumbnails --> <ul class="thumbnails"> <!-- BEGIN line --> diff --git a/template/yoga/content.css b/template/yoga/content.css index a426b64e1..6f3c440c4 100644 --- a/template/yoga/content.css +++ b/template/yoga/content.css @@ -179,6 +179,7 @@ SPAN.filename:after { } +/* begin chronology/calendar elements*/ #content DIV.calendarViews { display: block; text-align: left; @@ -199,14 +200,12 @@ SPAN.calItemSel { font-weight: bold; margin: 0 2px; border: 1px solid gray; - color: dark-gray; } SPAN.calItemEmpty { font-weight: bold; margin: 0 2px; border: 1px solid gray; - color: lightgray; } #content DIV.calendarCalBar { @@ -224,3 +223,46 @@ SPAN.calCal { margin: 0 2px; } +/* nice looking month calendar*/ +.calMonth { border: none; border-collapse: collapse; } + +TD.calDayCellFull, TD.calDayCellEmpty, TD.calDayCellBlank +{ + text-align:left; + vertical-align: top; + font: bold 18px Arial, Helvetica, sans-serif; +} + +TD.calDayHead { font: bold 12px Arial, Helvetica, sans-serif; } + +DIV.calImg +{ + overflow: hidden; + vertical-align: bottom; + z-index: 1; + position: relative; /*<- this required by IE*/ +} + +.calImg img +{ + position: relative; + border: 0; +} + +.calBackDate { + padding-left: 4px; + padding-top: 0px; + z-index: 2; + position: absolute; + text-align: left; + vertical-align: top; +} + +.calForeDate { + padding-left: 5px; + padding-top: 1px; + z-index: 3; + position: absolute; + text-align: left; + vertical-align: top; +} diff --git a/template/yoga/month_calendar.tpl b/template/yoga/month_calendar.tpl new file mode 100644 index 000000000..cd3586a23 --- /dev/null +++ b/template/yoga/month_calendar.tpl @@ -0,0 +1,47 @@ +<!-- BEGIN calendar --> +<!-- BEGIN thumbnails --> +<style type="text/css"> +<!-- +TD.calDayCellFull, TD.calDayCellEmpty, TD.calDayCellBlank +{ + width: {calendar.thumbnails.WIDTH}px; + height: {calendar.thumbnails.HEIGHT}px; +} +DIV.calImg +{ + width: {calendar.thumbnails.WIDTH}px; + height: {calendar.thumbnails.HEIGHT}px; +} +//--></style> +<table class="calMonth" align="center" cellpadding="1"> +<!-- BEGIN head --> + <thead> + <!-- BEGIN col --> + <td class="calDayHead">{calendar.thumbnails.head.col.LABEL}</td> + <!-- END col --> + </thead> +<!-- END head --> +<!-- BEGIN row --> + <tr> + <!-- BEGIN col --> + <!-- BEGIN blank --> + <td class="calDayCellBlank"> + <!-- END blank --> + <!-- BEGIN empty --> + <td class="calDayCellEmpty">{calendar.thumbnails.row.col.empty.LABEL} + <!-- END empty --> + <!-- BEGIN full --> + <td class="calDayCellFull"><div class="calBackDate">{calendar.thumbnails.row.col.full.LABEL}</div><div class="calForeDate">{calendar.thumbnails.row.col.full.LABEL}</div> + <div class="calImg"><a href="{calendar.thumbnails.row.col.full.U_IMG_LINK}"> + <img style="{calendar.thumbnails.row.col.full.STYLE}" {calendar.thumbnails.row.col.full.IMG_WIDTH} {calendar.thumbnails.row.col.full.IMG_HEIGHT} + src="{calendar.thumbnails.row.col.full.IMAGE}" alt="{calendar.thumbnails.row.col.full.IMAGE_ALT}" + title="{calendar.thumbnails.row.col.full.IMAGE_ALT}"> + </a></div> + <!-- END full --> + </td> + <!-- END col --> + </tr> +<!-- END row --> +</table> +<!-- END thumbnails --> +<!-- END calendar --> diff --git a/template/yoga/theme/clear/theme.css b/template/yoga/theme/clear/theme.css index c4a7a5522..92216df92 100644 --- a/template/yoga/theme/clear/theme.css +++ b/template/yoga/theme/clear/theme.css @@ -77,3 +77,16 @@ A.navThumb, A.navThumb:hover { font-weight: bold; } +/*calendar elements*/ +SPAN.calItemSel { color: dark-gray; } + +SPAN.calItemEmpty { color: lightgray; } + + +/* nice looking month calendar*/ +TD.calDayCellEmpty, TD.calDayCellFull { border: 1px solid #7E7262;} + +TD.calDayCellEmpty { color: lightgray; } + +.calBackDate { color: #000; } +.calForeDate { color: #fff; } diff --git a/template/yoga/theme/dark/theme.css b/template/yoga/theme/dark/theme.css index 6b28e3ce3..746e57bc3 100644 --- a/template/yoga/theme/dark/theme.css +++ b/template/yoga/theme/dark/theme.css @@ -114,10 +114,15 @@ A.navThumb, A.navThumb:hover { background:#3f3f3f; } -SPAN.calItemSel { - color: #fff48e; -} +/*calendar elements*/ +SPAN.calItemSel { color: #fff48e; } -SPAN.calItemEmpty { - color: darkgray; -} +SPAN.calItemEmpty { color: darkgray; } + +/* nice looking month calendar*/ +TD.calDayCellEmpty, TD.calDayCellFull { border: 1px solid gray;} + +TD.calDayCellEmpty { color: lightgray; } + +.calBackDate { color: #000; } +.calForeDate { color: #fff; } |