Commit ae1329c6 authored by Martin Postma's avatar Martin Postma
Browse files

Issue #2486149: Accept location coordinates also in degrees, minutes and seconds

parent f50e8dbd
Loading
Loading
Loading
Loading
+7 −6
Changes for filter/flickr_filter.module: 7 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ 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(
  $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',
@@ -105,6 +105,7 @@ function flickr_filter_tips($filter, $format, $long = FALSE) {
    </tr>
  </table>
  The 'c' size (800px) is missing on Flickr images uploaded before March 1, 2012. Photos with non existing sizes will be skipped in albums.<br /><br />
  <strong>TIP</strong>: Not only the node body but also blocks make use of a text format. Build your own custom Flickr album block using the Flickr Filter syntax.<br /><br />
  <strong>PARAMETER EXAMPLES</strong>. Omitting a parameter will result in the default value to be used.<br />
  <strong>id=lolandese1</strong> : A photo, set, user or group ID. <strong>id=public</strong> grabs CC licensed public photos (only for <em>[flickr-user:...]</em>). <strong>Default: id=@default_userid</strong> (!config).<br />&nbsp;&nbsp;!find_id Valid ID values: numeric ID (the one that contains a '@'), path alias, Flickr username or the user's email.<br />
  <strong>class=\"floatleft foo bar\"</strong> : Syntax as in HTML. Wrap the value in quotes (or not) and put spaces between multiple classes.<br />&nbsp;&nbsp;Applies to the outer HTML element of a photo or album.<br />
@@ -115,10 +116,10 @@ function flickr_filter_tips($filter, $format, $long = FALSE) {
  <strong>tags=kids/men</strong> : <strong>Separate multiple tags with a slash (/).</strong> Display all set, group or user photos that contain the indicated tags.<br />&nbsp;&nbsp;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.<br />&nbsp;&nbsp;Public albums will only display photos that match all tags. Like on Flickr spaces are removed from tags (e.g. 'Victoria park' becomes 'victoriapark').<br />&nbsp;&nbsp;For albums only.<br />
  <strong>extend=true</strong> : Extend the tag filter to search for matching terms also in the Flickr photo title and description besides Flickr tags.<br />&nbsp;&nbsp;<strong>Default: extend=@default_extend</strong> (!config). For albums only.<br />
  <strong>tag_mode=all</strong> : Matches 'all' defined tags (AND). The other possible value is 'any' (OR).<br />&nbsp;&nbsp;If this parameter is omitted, 'all' is used if no Flickr user ID is known (public search), otherwise 'any' is used. For albums only.<br />
  <strong>location=48.85837/2.294481/0.2</strong> : Display photos within 200 mt from the Eiffel Tower. Lat/lon/radius (in km). Separate values with a slash (/).<br />&nbsp;&nbsp;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.<br />&nbsp;&nbsp;Substitute the comma (,) with a slash (/). Optionally add a radius to force a major number of results to filter on (max. 32 km).<br />&nbsp;&nbsp;If omitted it defaults to 14 meter and gradually expands to 32 km until a sufficient number of results are returned.<br />&nbsp;&nbsp;For user and group albums only, also public.<br />
  <strong>date=2015-01-11</strong> : Display photos taken on 11 January 2015. !dateformats, also !relativeformats (e.g. 'first day of last month | last day of last month').<br />&nbsp;&nbsp;Separate two date values with a vertical bar (|) to cover a timespan of multiple days. For user and group albums only, also public.<br />&nbsp;&nbsp;Tip: Use it in combination with a location to grab public photos of an event.<br />
  <strong>location=48.85837/2.294481/0.2</strong> : Display photos within 200 mt from the Eiffel Tower. Lat/lon/radius (in km). Separate values with a slash (/).<br />&nbsp;&nbsp;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.<br />&nbsp;&nbsp;Substitute the comma (,) with a slash (/). Optionally add a radius to force a major number of results to filter on (max. 32 km).<br />&nbsp;&nbsp;If the radius is omitted it defaults to 14 meter and gradually expands to 32 km until a sufficient number of results are returned.<br />&nbsp;&nbsp;Besides decimal coordinates also degrees are accepted, e.g. 2° 21' 50.72\". For user and group albums only, also public.<br />
  <strong>date=2015-01-11</strong> : Display photos taken on 11 January 2015.<br />&nbsp;&nbsp;Many !dateformats (e.g. '11 Jan 2015'), also !relativeformats (e.g. 'first day of last month | last day of last month').<br />&nbsp;&nbsp;Separate two date values with a vertical bar (|) to cover a timespan of multiple days. For user and group albums only, also public.<br />&nbsp;&nbsp;<strong>Tip</strong>: Use a date in combination with a location to grab public photos of an event.<br />
  <strong>heading=h3</strong> : Wraps the album title in HTML tags. Use 'p' to apply no style or 'none' to suppress the title. <strong>Default heading=@default_heading</strong> (!config). For albums only.<br />
  <strong>sort=views</strong> : Display the most viewed Flickr photos first (popularity, slower response after cache clear).<br />&nbsp;&nbsp;Other values: <em>unsorted</em> = recent as delivered by the Flickr API (fastest response),<br />&nbsp;&nbsp;<em>random</em> (slower response after cache clear), <em>taken</em> (newest first), <em>posted</em> (newest first) , <em>added</em> (for groups only, newest first) and <em>id</em> (on photo ID, newest first). <strong>Default: sort=unsorted</strong>. For albums only.<br />
  <strong>sort=views</strong> : Display the most viewed Flickr photos first (popularity, slower response after cache clear).<br />&nbsp;&nbsp;Other values: <em>unsorted</em> = recent as delivered by the Flickr API (fastest response),<br />&nbsp;&nbsp;<em>random</em> (slower response after cache clear), <em>taken</em> (newest first), <em>posted</em> (newest first) , <em>added</em> (for groups only, newest first) and <em>id</em> (on photo ID, newest first).<br />&nbsp;&nbsp;<strong>Default: sort=unsorted</strong>. For albums only.<br />
  <strong>filter=interesting</strong> : Display the most interesting photos. Other possible value: <em>relevant</em>. For user and group albums only, also public.<br />
  <strong>count=false</strong> : Suppress display of the counter under the album (e.g. <em>5 out of 124 on Flickr</em>). <strong>Default: count=@default_count</strong> (!config). For albums only.<br />
  <strong>mintitle=999</strong> : Suppress display of the title in the photo captions for images below a width of 999 px. <strong>Default: mintitle=@default_mintitle</strong> (!config).<br />
@@ -184,8 +185,8 @@ function flickr_filter_split_config($string) {
  $attribs = array();
  // 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);
  // Break them up around the equal sign (=).
  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]));
+24 −12
Changes for flickr.inc: 24 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -579,9 +579,32 @@ function flickr_album($type = 'user', $id = '39873962@N08', $show_n = NULL, $siz
  // 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;
  // Standardize the date format, independent from the input.
  $datefromfix = $datefrom;
  $datetofix = $dateto;
  // Also Flickr converts tags to lowercase, removes spaces and the ampersand.
  $tags = strtolower(str_replace(array(' ', '&'), '', $tags));
  // drupal_is_front_page() is added because it also can have arg(0) == 'node'.
  $cache = cache_get('flickr_block_' . $delta . '_' . $idfix . '_' . $tags . '_' . $lat . '_' . $datetofix . '_' . $datefromfix . '_' . arg(0) . '_' . drupal_is_front_page() . '_' . $page);
  // If $delta is a number it is a block that could be cached.
  if ($cache && is_numeric($delta)) {
    $output = $cache->data;
  }

  // In any other case we generate an album, including a heading and counter.
  else {
  // Turn GPS coordinates from degrees / minutes / seconds to decimal format.
    if (isset($lat)) {
      $dmslat = preg_match_all('/[(\.|,)0-9]+/', $lat, $matches);
      $deg = isset($matches[0][0]) ? $matches[0][0] : $lat;
      $min = isset($matches[0][1]) ? $matches[0][1] : 0;
      $sec = isset($matches[0][2]) ? $matches[0][2] : 0;
      $lat = $deg+((($min*60)+($sec))/3600);
      $dmslon = preg_match_all('/[(\.|,)0-9]+/', $lon, $matches);
      $deg = isset($matches[0][0]) ? $matches[0][0] : $lon;
      $min = isset($matches[0][1]) ? $matches[0][1] : 0;
      $sec = isset($matches[0][2]) ? $matches[0][2] : 0;
      $lon = $deg+((($min*60)+($sec))/3600);
    }
    if (!isset($dateto)) {
      $dateto = $datefrom;
    }
@@ -622,8 +645,6 @@ function flickr_album($type = 'user', $id = '39873962@N08', $show_n = NULL, $siz
    // Remove tags to exclude (preceded by a minus symbol) for album titles.
    $tagsfixnoexclude = preg_replace('/,(^|\s)*-(\w+)/', '', $tags);
    $pagefix = $page;
  // Also Flickr converts tags to lowercase, removes spaces and the ampersand.
  $tags = strtolower(str_replace(array(' ', '&'), '', $tags));
    // Set the default tag mode appropriate.
    if ($tag_mode == 'context') {
      $tag_mode = empty($id) || $id == 'public' || $id == '39873962@N08' ? 'all' : 'any';
@@ -632,15 +653,6 @@ function flickr_album($type = 'user', $id = '39873962@N08', $show_n = NULL, $siz
      $tag_mode = 'any';
      drupal_set_message(t("The tag mode has been forced to 'any' (OR) for extended text matching (tags, titles and description). To use 'all' (AND) put 'extend=false' in Flickr's text filter code."), 'warning', FALSE);
    }
  // drupal_is_front_page() is added because it also can have arg(0) == 'node'.
  $cache = cache_get('flickr_block_' . $delta . '_' . $idfix . '_' . $tags . '_' . $lat . '_' . $datetofix . '_' . $datefromfix . '_' . arg(0) . '_' . drupal_is_front_page() . '_' . $page);
  // If $delta is a number it is a block that could be cached.
  if ($cache && is_numeric($delta)) {
    $output = $cache->data;
  }

  // In any other case we generate an album, including a heading and counter.
  else {
    $sizes = flickr_photo_sizes();
    $show_n = is_null($show_n) ? variable_get('flickr_photos_per_page', 6) : $show_n;
    $size = is_null($size) ? variable_get('flickr_default_size_album', 's') : $size;