You are here

function flickr_filter_split_config in Flickr 5

Same name and namespace in other branches
  1. 6 filter/flickr_filter.module \flickr_filter_split_config()
  2. 7 filter/flickr_filter.module \flickr_filter_split_config()

Parse parameters to the fiter from a format like: id=26159919@N00, size=m,show = 9, class=something,style=float:left;border:1px into an associative array with two sub-arrays. The first sub-array is parameters for the request, the second are HTML attributes (class and style).

2 calls to flickr_filter_split_config()
flickr_filter_callback_photo in filter/flickr_filter.module
Filter callback for a photo.
flickr_filter_callback_photoset in filter/flickr_filter.module
Filter callback for a photoset.

File

filter/flickr_filter.module, line 56

Code

function flickr_filter_split_config($string) {
  $config = array();
  $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);
  foreach ($parts as $part) {

    // normalize to lower case and remove extra spaces
    $name = strtolower(trim($part[1]));
    $value = trim($part[2]);
    if ($name == 'style' || $name == 'class') {
      $attribs[$name] = $value;
    }
    else {
      $config[$name] = $value;
    }
  }
  return array(
    $config,
    $attribs,
  );
}