Skip to content

Commit

Permalink
feature 2103 added: week may start on sunday/monday in the monthly ca…
Browse files Browse the repository at this point in the history
…lendar

git-svn-id: http://piwigo.org/svn/trunk@8626 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Jan 12, 2011
1 parent 6645898 commit 0ef332f
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 4 deletions.
5 changes: 5 additions & 0 deletions admin/configuration.php
Expand Up @@ -246,6 +246,11 @@
'CONF_GALLERY_TITLE' => htmlspecialchars($conf['gallery_title']),
'CONF_PAGE_BANNER' => htmlspecialchars($conf['page_banner']),
'CONF_GALLERY_URL' => $conf['gallery_url'],
'week_starts_on_options' => array(
'sunday' => $lang['day'][0],
'monday' => $lang['day'][1],
),
'week_starts_on_options_selected' => $conf['week_starts_on'],
));

foreach ($main_checkboxes as $checkbox)
Expand Down
9 changes: 9 additions & 0 deletions admin/themes/default/template/configuration.tpl
Expand Up @@ -87,6 +87,15 @@
<input type="checkbox" name="email_admin_on_new_user" {if ($main.email_admin_on_new_user)}checked="checked"{/if}>
</label>
</li>

<li>
<label>
<span class="property">
{'Week starts on'|@translate}
{html_options name="week_starts_on" options=$main.week_starts_on_options selected=$main.week_starts_on_options_selected}
</span>
</label>
</li>
</ul>
</fieldset>
{/if}
Expand Down
15 changes: 11 additions & 4 deletions include/calendar_monthly.class.php
Expand Up @@ -330,7 +330,7 @@ function build_year_calendar(&$tpl_var)

function build_month_calendar(&$tpl_var)
{
global $page;
global $page, $lang, $conf;

$query='SELECT '.pwg_db_get_dayofmonth($this->date_field).' as period,
COUNT(DISTINCT id) as count';
Expand Down Expand Up @@ -368,9 +368,12 @@ function build_month_calendar(&$tpl_var)
$items[$day]['width'] = $row['width'];
$items[$day]['height'] = $row['height'];
$items[$day]['dow'] = $row['dow'];
}

global $lang, $conf;
if ('sunday' == $conf['week_starts_on'])
{
$items[$day]['dow']++;
}
}

if ( !empty($items)
and $conf['calendar_month_cell_width']>0
Expand All @@ -395,7 +398,11 @@ function build_month_calendar(&$tpl_var)
{
$first_day_dow -= 1;
}
array_push( $wday_labels, array_shift($wday_labels) );

if ('monday' == $conf['week_starts_on'])
{
array_push( $wday_labels, array_shift($wday_labels) );
}
// END - pass now in week starting Monday

$cell_width = $conf['calendar_month_cell_width'];
Expand Down
1 change: 1 addition & 0 deletions install/config.sql
Expand Up @@ -51,3 +51,4 @@ INSERT INTO piwigo_config (param,value,comment)
'a:11:{s:6:"author";b:1;s:10:"created_on";b:1;s:9:"posted_on";b:1;s:10:"dimensions";b:1;s:4:"file";b:1;s:8:"filesize";b:1;s:4:"tags";b:1;s:10:"categories";b:1;s:6:"visits";b:1;s:12:"average_rate";b:1;s:13:"privacy_level";b:1;}',
'Information displayed on picture page'
);
INSERT INTO piwigo_config (param,value,comment) VALUES ('week_starts_on','monday','Monday may not be the first day of the week');
42 changes: 42 additions & 0 deletions install/db/93-database.php
@@ -0,0 +1,42 @@
<?php
// +-----------------------------------------------------------------------+
// | Piwigo - a PHP based picture gallery |
// +-----------------------------------------------------------------------+
// | Copyright(C) 2008-2010 Piwigo Team http://piwigo.org |
// | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net |
// | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick |
// +-----------------------------------------------------------------------+
// | This program is free software; you can redistribute it and/or modify |
// | it under the terms of the GNU General Public License as published by |
// | the Free Software Foundation |
// | |
// | This program is distributed in the hope that it will be useful, but |
// | WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public License |
// | along with this program; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
// | USA. |
// +-----------------------------------------------------------------------+

if (!defined('PHPWG_ROOT_PATH'))
{
die('Hacking attempt!');
}

$upgrade_description = 'Monday may not be the first day of the week';

$query = '
INSERT INTO '.PREFIX_TABLE.'config (param,value,comment)
VALUES (\'week_starts_on\',\'monday\', \''.$upgrade_description.'\')
;';
pwg_query($query);

echo
"\n"
. $upgrade_description
."\n"
;
?>
1 change: 1 addition & 0 deletions language/en_UK/admin.lang.php
Expand Up @@ -799,4 +799,5 @@
$lang['remove creation date'] = 'remove creation date';
$lang['with no album'] = 'with no album';
$lang['with no tag'] = 'with no tag';
$lang['Week starts on'] = 'Week starts on';
?>
1 change: 1 addition & 0 deletions language/fr_FR/admin.lang.php
Expand Up @@ -803,4 +803,5 @@
$lang['remove creation date'] = 'supprimer la date de création';
$lang['with no album'] = 'sans album';
$lang['with no tag'] = 'sans tag';
$lang['Week starts on'] = 'La semaine commence le';
?>

0 comments on commit 0ef332f

Please sign in to comment.