diff -u b/flickr.inc b/flickr.inc
--- b/flickr.inc
+++ b/flickr.inc
@@ -579,14 +579,41 @@
// As variables might change during processing, we set a fixed version of it
// to use for the key to set the block cache after processing at the end.
$idfix = $id;
- // Standarize the date format, independent from the input.
+ // Standardize the date format, independent from the input.
$datefromfix = $datefrom;
$datetofix = $dateto;
if (!isset($dateto)) {
$dateto = $datefrom;
}
- $datefrom = empty($datefrom) ? '' : date("Y-m-d", strtotime($datefrom));
- $dateto = empty($dateto) ? '' : date("Y-m-d", strtotime($dateto));
+ $datestart = strtotime($datefrom);
+ $dateend = strtotime($dateto);
+ // Try again but turning DD/MM/YYYY to DD-MM-YYYY.
+ // See http://www.hashbangcode.com/node/702 (first part only).
+ if (!empty($datefrom) && ($datestart === FALSE || $dateend === FALSE || $datestart > $dateend)) {
+ $datestart = strtotime(str_replace('/', '-', $datefrom));
+ $dateend = strtotime(str_replace('/', '-', $dateto));
+ $ambiguous = l(t('ambiguous'), 'http://php.net/manual/en/function.strtotime.php#100144', array(
+ 'attributes' => array(
+ 'title' => t('PHP: strtotime - Manual'),
+ 'target' => '_blank',
+ ),
+ ));
+ $dateformat = l(t('accepted date format'), 'http://php.net/manual/en/datetime.formats.date.php/', array(
+ 'attributes' => array(
+ 'title' => t('PHP: Date Formats - Manual'),
+ 'target' => '_blank',
+ ),
+ ));
+ drupal_set_message(t("You used the date format DD/MM/YYYY (starting with the day). As some dates are !ambiguous (e.g. is 04/05/2013 5 April or 4 May?) it is recommended to use dashes when you start with the day (DD-MM-YYYY), slashes when you start with the month (MM/DD/YYYY) or use any other !dateformat (e.g. 11 Jan 2015).", array(
+ '!ambiguous' => $ambiguous,
+ '!dateformat' => $dateformat,
+ )), 'warning', FALSE);
+ }
+ if (!empty($datefrom) && ($datestart === FALSE || $dateend === FALSE)) {
+ drupal_set_message(t("Invalid date provided."), 'error', FALSE);
+ }
+ $datefrom = empty($datefrom) ? '' : date("Y-m-d", $datestart);
+ $dateto = empty($dateto) ? '' : date("Y-m-d", $dateend);
$datefrom = isset($datefrom) ? $datefrom . ' 00:00:00' : '';
$dateto = isset($dateto) ? $dateto . ' 23:59:59' : '';
// Remove spaces from tags but save the original for matches in text instead
only in patch2:
unchanged:
--- a/filter/flickr_filter.module
+++ b/filter/flickr_filter.module
@@ -53,6 +53,18 @@ function flickr_filter_tips($filter, $format, $long = FALSE) {
'title' => t('Go to Flickr configuration page'),
),
));
+ $dateformats = l(t('Accepted date formats'), 'http://php.net/manual/en/datetime.formats.date.php/', array(
+ 'attributes' => array(
+ 'title' => t('PHP: Date Formats - Manual'),
+ 'target' => '_blank',
+ ),
+ ));
+ $relativeformats = l(t('relative formats'), 'http://php.net/manual/en/datetime.formats.relative.php/', array(
+ 'attributes' => array(
+ 'title' => t('PHP: Relative Formats - Manual'),
+ 'target' => '_blank',
+ ),
+ ));
$count = variable_get('flickr_counter', 1) ? 'true' : 'false';
$extend = variable_get('flickr_extend', 1) ? 'true' : 'false';
$default_userid = variable_get('flickr_default_userid', '');
@@ -93,20 +105,20 @@ function flickr_filter_tips($filter, $format, $long = FALSE) {
n (320px) and c (800px) sizes are missing on \"older\" Flickr images. Photos with non existing sizes will be skipped in albums.
- PARAMETER EXAMPLES (omit a parameter to use the default value):
+ PARAMETER EXAMPLES. Omitting a parameter will result in the default value to be used.
id=lolandese1 : A photo, set, user or group ID. id=public grabs CC licensed public photos (only for [flickr-user:...]). Default: id=@default_userid (!config).
!find_id Valid ID values: numeric ID (the one that contains a '@'), path alias, Flickr username or the user's email.
- class=\"floatleft foo bar\" : Syntax as in HTML. Wrap the value in quotes (or not) and put spaces between multiple classes. Applies to the outer HTML element of a photo or album.
- style=\"float:left; border:solid 2px;\" : Syntax as in HTML. Wrap the value in quotes (or not) and put semicolons between different style declarations. Applies to the outer HTML element of a photo or album.
- size=q : Big square (150px). The sizes x and y display a slideshow and ignore number, media, tags, location and sort settings. Default single photo: size=@default_size, album photo: size=@default_size_album (both !config).
- num=4 : Display 4 photos. Default: num=@default_number (!config). For albums only.
If set to 1, the single image will behave as such. Heading and counter will be omitted, and float might apply. Used to display a single changing random or recent image.
+ class=\"floatleft foo bar\" : Syntax as in HTML. Wrap the value in quotes (or not) and put spaces between multiple classes.
Applies to the outer HTML element of a photo or album.
+ style=\"float:left; border:solid 2px;\" : Syntax as in HTML. Wrap the value in quotes (or not) and put semicolons between different style declarations.
Applies to the outer HTML element of a photo or album.
+ size=q : Big square (150px). The sizes x and y display a slideshow and ignore number, media, tags, location and sort settings.
Default single photo: size=@default_size, album photo: size=@default_size_album (both !config).
+ num=4 : Display 4 photos. Default: num=@default_number (!config). For albums only.
If set to 1, the single image will behave as such. Heading and counter will be omitted, and float might apply.
Used to display a single changing random or recent image.
media=all : Display both photos and videos. Default: media=photos. For albums only.
- tags=kids/men : Separate multiple tags with a slash (/). Display all set, group or user photos that contain the indicated tags. Case insensitive, matches any tag, for photosets and galleries even partial.
You can exclude results that match a term by prepending it with a - character.
Public albums will only display photos that match all tags. Like on Flickr spaces are removed from tags (e.g. 'Victoria park' becomes 'victoriapark'). For albums only.
- extend=true : Extend the tag filter to search for matching terms also in the Flickr photo title and description besides Flickr tags. Default: extend=@default_extend (!config). For albums only.
+ tags=kids/men : Separate multiple tags with a slash (/). Display all set, group or user photos that contain the indicated tags.
Case insensitive, matches any tag, for photosets and galleries even partial. You can exclude results that match a term by prepending it with a - character.
Public albums will only display photos that match all tags. Like on Flickr spaces are removed from tags (e.g. 'Victoria park' becomes 'victoriapark').
For albums only.
+ extend=true : Extend the tag filter to search for matching terms also in the Flickr photo title and description besides Flickr tags.
Default: extend=@default_extend (!config). For albums only.
tag_mode=all : Matches 'all' defined tags (AND). The other possible value is 'any' (OR).
If this parameter is omitted, 'all' is used if no Flickr user ID is known (public search), otherwise 'any' is used. For albums only.
- location=48.85837/2.294481/0.2 : Display photos within 200 mt from the Eiffel Tower. Lat/lon/radius (in km). Separate values with a slash (/).
To get the coordinates for a location, right-click on a Google map and choose 'What's here?' or copy/paste it from the URL. Substitute the comma (,) with a slash (/).
Optionally add a radius to force a major number of results to filter on (max. 32 km). If omitted it defaults to 14 meter and gradually expands to 32 km until a sufficient number of results are returned.
For user and group albums only, also public.
- date=2015-01-11 : Display photos taken on 11 January 2015. Format: YYYY-MM-DD. Separate two date values with a slash (/) to cover a timespan of multiple days. For user and group albums only, also public.
Use it in combination with a location to grab public photos of events.
+ location=48.85837/2.294481/0.2 : Display photos within 200 mt from the Eiffel Tower. Lat/lon/radius (in km). Separate values with a slash (/).
To get the coordinates for a location, right-click on a Google map and choose 'What's here?' or copy/paste it from the URL.
Substitute the comma (,) with a slash (/). Optionally add a radius to force a major number of results to filter on (max. 32 km).
If omitted it defaults to 14 meter and gradually expands to 32 km until a sufficient number of results are returned.
For user and group albums only, also public.
+ date=2015-01-11 : Display photos taken on 11 January 2015. !dateformats, also !relativeformats (e.g. 'first day of last month | last day of last month').
Separate two date values with a vertical bar (|) to cover a timespan of multiple days. For user and group albums only, also public.
Tip: Use it in combination with a location to grab public photos of an event.
heading=h3 : Wraps the album title in HTML tags. Use 'p' to apply no style or 'none' to suppress the title. Default heading=@default_heading (!config). For albums only.
- sort=views : Display the most viewed Flickr photos first (popularity, slower response after cache clear). Other values: unsorted = recent as delivered by the Flickr API (fastest response),
random (slower response after cache clear), taken (newest first), posted (newest first) , added (for groups only, newest first) and id (on photo ID, newest first). Default: sort=unsorted. For albums only.
+ sort=views : Display the most viewed Flickr photos first (popularity, slower response after cache clear).
Other values: unsorted = recent as delivered by the Flickr API (fastest response),
random (slower response after cache clear), taken (newest first), posted (newest first) , added (for groups only, newest first) and id (on photo ID, newest first). Default: sort=unsorted. For albums only.
filter=interesting : Display the most interesting photos. Other possible value: relevant. For user and group albums only, also public.
count=false : Suppress display of the counter under the album (e.g. 5 out of 124 on Flickr). Default: count=@default_count (!config). For albums only.
mintitle=999 : Suppress display of the title in the photo captions for images below a width of 999 px. Default: mintitle=@default_mintitle (!config).
@@ -124,6 +136,8 @@ function flickr_filter_tips($filter, $format, $long = FALSE) {
'@default_count' => $count,
'@default_extend' => $extend,
'!config' => $config,
+ '!dateformats' => $dateformats,
+ '!relativeformats' => $relativeformats,
));
if ($long) {
$output .= ' ' . t('The size parameter can be one of the following:');
@@ -171,7 +185,7 @@ function flickr_filter_split_config($string) {
// Put each setting on its own line.
$string = str_replace(',', "\n", $string);
// Break them up around commas.
- preg_match_all('/([a-zA-Z_.]+)=([-@\/0-9a-zA-Z :;_.\%"\'&]+)/', $string, $parts, PREG_SET_ORDER);
+ preg_match_all('/([a-zA-Z_.]+)=([-@\/0-9a-zA-Z :;_.\|\%"\'&]+)/', $string, $parts, PREG_SET_ORDER);
foreach ($parts as $part) {
// Normalize to lowercase and remove extra spaces.
$name = strtolower(trim($part[1]));
@@ -282,7 +296,7 @@ function flickr_filter_callback_album($matches) {
$config['date'][1] = NULL;
}
else {
- $config['date'] = explode("/", $config['date']);
+ $config['date'] = explode("|", $config['date']);
if (!isset($config['date'][1])) {
$config['date'][1] = NULL;
}
@@ -406,7 +420,7 @@ function flickr_filter_callback_group($matches) {
$config['date'][1] = NULL;
}
else {
- $config['date'] = explode("/", $config['date']);
+ $config['date'] = explode("|", $config['date']);
if (!isset($config['date'][1])) {
$config['date'][1] = NULL;
}
@@ -506,7 +520,7 @@ function flickr_filter_callback_gallery($matches) {
$config['date'][1] = NULL;
}
else {
- $config['date'] = explode("/", $config['date']);
+ $config['date'] = explode("|", $config['date']);
if (!isset($config['date'][1])) {
$config['date'][1] = NULL;
}
@@ -610,7 +624,7 @@ function flickr_filter_callback_favorites($matches) {
$config['date'][1] = NULL;
}
else {
- $config['date'] = explode("/", $config['date']);
+ $config['date'] = explode("|", $config['date']);
if (!isset($config['date'][1])) {
$config['date'][1] = NULL;
}