*/
public function __construct($url)
{
- $this->parts = parse_url(trim($url));
+ $url = self::cleanupUnparsedUrl(trim($url));
+ $this->parts = parse_url($url);
if (!empty($url) && empty($this->parts['scheme'])) {
$this->parts['scheme'] = 'http';
}
}
+ /**
+ * Clean up URL before it's parsed.
+ * ie. handle urlencode, url prefixes, etc.
+ *
+ * @param string $url URL to clean.
+ *
+ * @return string cleaned URL.
+ */
+ protected static function cleanupUnparsedUrl($url)
+ {
+ return self::removeFirefoxAboutReader($url);
+ }
+
+ /**
+ * Remove Firefox Reader prefix if it's present.
+ *
+ * @param string $input url
+ *
+ * @return string cleaned url
+ */
+ protected static function removeFirefoxAboutReader($input)
+ {
+ $firefoxPrefix = 'about://reader?url=';
+ if (startsWith($input, $firefoxPrefix)) {
+ return urldecode(ltrim($input, $firefoxPrefix));
+ }
+ return $input;
+ }
+
/**
* Returns a string representation of this URL
*/
return strcasecmp($a, $b);
});
- $tagList=array();
- foreach($tags as $key=>$value)
- // Tag font size scaling: default 15 and 30 logarithm bases affect scaling, 22 and 6 are arbitrary font sizes for max and min sizes.
- {
- $tagList[$key] = array('count'=>$value,'size'=>log($value, 15) / log($maxcount, 30) * (22-6) + 6);
+ $tagList = array();
+ foreach($tags as $key => $value) {
+ // Tag font size scaling:
+ // default 15 and 30 logarithm bases affect scaling,
+ // 22 and 6 are arbitrary font sizes for max and min sizes.
+ $size = log($value, 15) / log($maxcount, 30) * 2.2 + 0.8;
+ $tagList[$key] = array(
+ 'count' => $value,
+ 'size' => number_format($size, 2, '.', ''),
+ );
}
$data = array(
self::$baseUrl.'?my=stuff&is=kept#again',
$url->cleanup()
);
+
+ // test firefox reader url
+ $url = new Url(
+ 'about://reader?url=' . urlencode(self::$baseUrl .'?my=stuff&is=kept')
+ );
+ $this->assertEquals(self::$baseUrl.'?my=stuff&is=kept', $url->cleanup());
+
}
/**
<div id="cloudtag">
{loop="tags"}
- <span class="count">{$value.count}</span>
- <a href="?searchtags={$key|urlencode}" style="font-size:{$value.size}pt;">{$key}</a>
+ <span class="count">{$value.count}</span><a
+ href="?searchtags={$key|urlencode}" style="font-size:{$value.size}em;">{$key}</a>
{loop="$value.tag_plugin"}
{$value}
{/loop}