Add week days and use theme('table')

nicholas.alipaz - July 15, 2009 - 18:49
Project:Availability Calendars
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

I am attaching a patch that does the following:

  1. Rewrites the theme_availability_calendars_month to use the theme_table function and be more drupal-proof
  2. Add the days of the week as a header for each availability_calendar table, this coincides with the users' specified first day of week in the node edit form
  3. Add a 'key' as the first table in the availability calendar node view, this comes with a preference to turn the key on/off under the Availability calendar settings section of the node edit form.
  4. Moved the 'Month name/edit link' into a div above the table to make room for the new header row with the days of the week.

this is patched against todays version of the 6.x-dev. I hope you guys find that these features are useful and make it into the module. I can help troubleshoot code and make changes if needed, let me know.

#1

nicholas.alipaz - July 15, 2009 - 18:51

attaching patch.

Additionally see a running version of this patch here:
http://sorkbeachrentals.regencyweb.info/lower-unit-availability.html

AttachmentSize
availability_calendars_headerrows.patch 10.03 KB

#2

nicholas.alipaz - July 20, 2009 - 03:50
Title:Add Days of Week and use theme_table() Function» Add Days of Week and use theme_table() Function [patch attached]

Any testers for this? I did a lot of work on it and was hoping for any input on the changes.

#3

kiamlaluno - July 24, 2009 - 20:27
Title:Add Days of Week and use theme_table() Function [patch attached]» Add week days and use theme('table')

#4

geodaniel - July 26, 2009 - 22:41

Thanks for the patch. I've tried it out a little, and generally I'd say it looks good, though I have two comments about it. First, great that there is a key generated by the module now, but I'm not sure I'd always want it grouped in with the calendars, so could this perhaps be made into a block? Second, I don't think we can just wrap the single letter representations for days in the t() function, as they won't be properly translatable like that (e.g. T could be Tuesday or Thursday).

#5

kiamlaluno - July 26, 2009 - 23:44

I don't think we can just wrap the single letter representations for days in the t() function.

Also, the letter T is always the letter T in all the languages that use the Latin alphabet; it's more probable you are interested in translating the week days.

#6

nicholas.alipaz - July 27, 2009 - 16:00

That sounds reasonable. what about doing something like

<?php
  $days
= array(
       
13 => t('Monday'),
       
12 => t('Tuesday'),
       
11 => t('Wednesday'),
       
10 => t('Thursday'),
       
9 => t('Friday'),
       
8 => t('Saturday'),
       
7 => t('Sunday'),
       
6 => t('Monday'),
       
5 => t('Tuesday'),
       
4 => t('Wednesday'),
       
3 => t('Thursday'),
       
2 => t('Friday'),
       
1 => t('Saturday'),
       
0 => t('Sunday'),
  );
?>

Then just doing something like:

<?php
$day
= substr(0, 1, $days[$i]);
array_push($headers, array('data' => $day, 'class' => 'dayofweek'));
?>

That would get us the first letter and allow for better translation. If you like it then I can repatch later this week.

For the key, that is a nice idea for adding it to a block, but I still think the option to include it within the page is nice too. Perhaps we could leave it there with the flag for turning it off/on of course. Then we could add an option for a block in a future change?

Let me know what you guys think.

#7

kiamlaluno - July 27, 2009 - 16:30

That would not actually work for languages like Hebrew, Chinese; doing like you suggest, you will get the last character of the word, not the first (the last character because they write from right to left).

A better way is to use the short name of the week day ("Mon", "Tue", "Wed"); in this way, who translates the module understand what the words to translate are, and he will translate them correctly (in example, in Italian they become "Lun", "Mar", "Mer").

#8

nicholas.alipaz - July 27, 2009 - 16:36

hhmm, I kind of wondered about that when I wrote it... I will think some more.

#9

nicholas.alipaz - July 27, 2009 - 16:45

Another option would be to use the first three letters as the archive module does:
http://drupal.org/files/issues/archieve.JPG

#10

kiamlaluno - July 27, 2009 - 16:59

It still preferable to let the translator people decide the short name of the week days; in reference to languages like Hebrew, it's not possible to programmatically get a valid abbreviation for the week days.

What the module does is to use a function call like t('Mon').

#11

nicholas.alipaz - July 27, 2009 - 17:07

Actually, what you said is exactly what I am suggesting. Just use t('Mon') as the header then let translators do what they like. no substr() parsing or anything.

#12

kiamlaluno - July 27, 2009 - 17:14

I didn't correctly understand what you mean by "to use the first three letters".
What you suggested is the only way to proceed, I think.

#13

nicholas.alipaz - July 27, 2009 - 17:19

Ok, glad we agree, I will repatch that part. Do you or anyone have any input on the suggestion regarding the key as Dan mentioned?

#14

kiamlaluno - July 27, 2009 - 17:22

I actually didn't understand that reference to a key; I would be glad to give a suggestion, if somebody would tell me what it is exactly. :-)

#15

nicholas.alipaz - July 27, 2009 - 17:28

Take a look at http://sorkbeachrentals.regencyweb.info/lower-unit-availability.html

Notice the "Key" (also known as a "Legend" to some folks), Dan is suggesting it not be listed within the area for the calendars. Put it in a block instead.

My opinion differs in that I think the option to show it among the calendars should remain, but the addition of a block should be an added feature. Of course the node edit form contains a flag to turn this key on/off on a per node basis.

Thanks.

#16

kiamlaluno - July 27, 2009 - 17:40

In cases like this one, it is better to let the users decide what they like better.
I would add a setting so the user can decide if the key must appear or not, and I would also add a block for the key.

#17

nicholas.alipaz - July 27, 2009 - 17:48

OK, I agree and that is precisely what I had suggested. I am going to open another issue for adding that feature. I will not be adding it in this patch, it is too large as is.

#18

kiamlaluno - July 27, 2009 - 17:50

It is also better to keep feature requests separated.

#19

nicholas.alipaz - August 1, 2009 - 05:13

Issue fixed. The changes have been commited (guess I didn't need the brackets in the commit :blush:):
http://drupal.org/cvs?commit=245738

I promise future changes will be better separated.

#20

nicholas.alipaz - August 1, 2009 - 05:17
Status:needs review» fixed

marking fixed

#21

System Message - August 15, 2009 - 05:20
Status:fixed» closed

Automatically closed -- issue fixed for 2 weeks with no activity.

 
 

Drupal is a registered trademark of Dries Buytaert.