summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAlessandro Cosentino <cosenal@gmail.com>2012-08-11 12:19:37 -0400
committerAlessandro Cosentino <cosenal@gmail.com>2012-08-11 12:19:37 -0400
commit3443468538567c2cd23dc43b101b284c6af1a2e8 (patch)
tree0404288fcea3d0db05880bb75492311f68e487a0 /lib
parent48513e8e42c72409109f21804964b7c54527f6c0 (diff)
fix namespace issues from previous commit
Diffstat (limited to 'lib')
-rw-r--r--lib/utils.php22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/utils.php b/lib/utils.php
index 6418620b7..618cfc5d0 100644
--- a/lib/utils.php
+++ b/lib/utils.php
@@ -10,12 +10,12 @@
*
*/
+namespace OCA\News;
+
// load SimplePie library
//TODO: is this file a suitable place for the following require?
require_once('news/3rdparty/SimplePie/autoloader.php');
-namespace OCA\News;
-
class Utils {
/**
@@ -24,7 +24,7 @@ class Utils {
* @returns an instance of OC_News_Feed
*/
public static function fetch($url){
- $spfeed = new SimplePie_Core();
+ $spfeed = new \SimplePie_Core();
$spfeed->set_feed_url( $url );
$spfeed->enable_cache( false );
@@ -57,7 +57,7 @@ class Utils {
$feed->setFavicon($favicon);
}
else { // try really hard to find a favicon
- if( null !== ($webFavicon = discoverFavicon($url)) )
+ if( null !== ($webFavicon = self::discoverFavicon($url)) )
$feed->setFavicon($webFavicon);
}
return $feed;
@@ -68,12 +68,12 @@ class Utils {
}
public static function checkFavicon($favicon) {
- $file = new SimplePie_File($favicon);
+ $file = new \SimplePie_File($favicon);
// size in bytes
$filesize = strlen($file->body);
if($file->success && $filesize > 0 && $filesize < 50000) {
- $sniffer = new SimplePie_Content_Type_Sniffer($file);
+ $sniffer = new \SimplePie_Content_Type_Sniffer($file);
if(substr($sniffer->get_type(), 0, 6) === 'image/') {
return true;
}
@@ -83,13 +83,13 @@ class Utils {
public static function discoverFavicon($url) {
//try webroot favicon
- $favicon = SimplePie_Misc::absolutize_url('/favicon.ico', $url);
+ $favicon = \SimplePie_Misc::absolutize_url('/favicon.ico', $url);
- if(checkFavicon($favicon))
+ if(self::checkFavicon($favicon))
return $favicon;
//try to extract favicon from web page
- $absoluteUrl = SimplePie_Misc::absolutize_url('/', $url);
+ $absoluteUrl = \SimplePie_Misc::absolutize_url('/', $url);
$handle = curl_init ( );
curl_setopt ( $handle, CURLOPT_URL, $absoluteUrl );
@@ -112,14 +112,14 @@ class Utils {
elseif ( 0===strpos(parse_url($favicon,PHP_URL_PATH),'/') ) {
$url_token = parse_url($meta['final']);
sprintf( '%s://%s/%s', $url_token['scheme'], $url_token['host'], $favicon );
- if(checkFavicon($favicon))
+ if(self::checkFavicon($favicon))
return $favicon;
}
// so it appears to be a relative path
else {
$url_token = parse_url($meta['final']);
sprintf( '%s://%s%s%s', $url_token['scheme'], $url_token['host'], dirname($url_token['path']), $favicon );
- if(checkFavicon($favicon))
+ if(self::checkFavicon($favicon))
return $favicon;
}
}