Changed the Fetch-method on the Parser so it supports local files

master
Morten Fangel 2010-02-10 13:00:50 +01:00
rodzic d5f52a297a
commit e0d25803d2
12 zmienionych plików z 31 dodań i 17 usunięć

0
SG_iCal.php 100644 → 100755
Wyświetl plik

0
blocks/SG_iCal_VCalendar.php 100644 → 100755
Wyświetl plik

0
blocks/SG_iCal_VEvent.php 100644 → 100755
Wyświetl plik

0
blocks/SG_iCal_VTimeZone.php 100644 → 100755
Wyświetl plik

0
helpers/SG_iCal_Duration.php 100644 → 100755
Wyświetl plik

0
helpers/SG_iCal_Factory.php 100644 → 100755
Wyświetl plik

0
helpers/SG_iCal_Freq.php 100644 → 100755
Wyświetl plik

0
helpers/SG_iCal_Line.php 100644 → 100755
Wyświetl plik

22
helpers/SG_iCal_Parser.php 100644 → 100755
Wyświetl plik

@ -23,13 +23,26 @@ class SG_iCal_Parser {
}
/**
* Fetches url and stores it in the content member
* Fetches a resource and tries to make sure it's UTF8
* encoded
* @return string
*/
protected static function Fetch( $url ) {
$c = curl_init();
protected static function Fetch( $resource ) {
$is_utf8 = true;
curl_setopt($c, CURLOPT_URL, $url);
if( is_file( $resource ) ) {
// The resource is a local file
$content = file_get_contents($resource);
if( ! self::_ValidUtf8( $content ) ) {
// The file doesn't appear to be UTF8
$is_utf8 = false;
}
} else {
// The resource isn't local, so it's assumed to
// be a URL
$c = curl_init();
curl_setopt($c, CURLOPT_URL, $resource);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
if( !ini_get('safe_mode') ){
curl_setopt($c, CURLOPT_FOLLOWLOCATION, true);
@ -45,6 +58,7 @@ class SG_iCal_Parser {
// The data isn't utf-8
$is_utf8 = false;
}
}
if( !$is_utf8 ) {
$content = utf8_encode($content);

0
helpers/SG_iCal_Query.php 100644 → 100755
Wyświetl plik

0
tests/common.php 100644 → 100755
Wyświetl plik

0
tests/helpers/FreqTest.php 100644 → 100755
Wyświetl plik