Browse Source

Support for <link> elements with multiple entries in their 'rel' attributes

tags/0.6
Chris Smith 14 years ago
parent
commit
b9a637c9fb
1 changed files with 9 additions and 3 deletions
  1. 9
    3
      discoverer.inc.php

+ 9
- 3
discoverer.inc.php View File

@@ -299,14 +299,14 @@ class Discoverer {
299 299
  }
300 300
 
301 301
  protected static function getLinks($data) {
302
-  return self::getTags($data, 'link', 'rel', 'href');
302
+  return self::getTags($data, 'link', 'rel', 'href', true);
303 303
  }
304 304
 
305 305
  protected static function getMetaTags($data) {
306 306
   return self::getTags($data, 'meta', 'http-equiv', 'content');
307 307
  }
308 308
 
309
- protected static function getTags($data, $tag, $att1, $att2) {
309
+ protected static function getTags($data, $tag, $att1, $att2, $split = false) {
310 310
   preg_match_all('#<' . $tag . '\s*(.*?)\s*/?' . '>#is', $data, $matches);
311 311
 
312 312
   $links = array();
@@ -324,7 +324,13 @@ class Discoverer {
324 324
     $href = implode('', $m);
325 325
    }
326 326
 
327
-   $links[strtolower($rel)] = html_entity_decode($href);
327
+   if ($split) {
328
+    foreach (explode(' ', strtolower($rel)) as $part) {
329
+     $links[$part] = html_entity_decode($href);
330
+    }
331
+   } else {
332
+    $links[strtolower($rel)] = html_entity_decode($href);
333
+   }
328 334
   }
329 335
 
330 336
   return $links;

Loading…
Cancel
Save