[core] Remove HttpCachingBridgeAbstract

BridgeAbstract implements all functions to cover the implementation
This commit is contained in:
logmanoriginal 2016-09-10 19:13:01 +02:00
parent 2eec89ab27
commit 9be03f199b
2 changed files with 0 additions and 46 deletions

View file

@ -1,45 +0,0 @@
<?php
require_once(__DIR__ . '/BridgeInterface.php');
/**
* Extension of BridgeAbstract allowing caching of files downloaded over http.
*/
abstract class HttpCachingBridgeAbstract extends BridgeAbstract {
/**
* Maintain locally cached versions of pages to download, to avoid multiple downloads.
* @param url url to cache
* @param duration duration of the cache file in seconds (default: 24h/86400s)
* @return content of the file as string
*/
public function get_cached($url, $duration = 86400){
$this->debugMessage('Caching url ' . $url . ', duration ' . $duration);
$filepath = __DIR__ . '/../cache/pages/' . sha1($url) . '.cache';
$this->debugMessage('Cache file ' . $filepath);
if(file_exists($filepath) && filectime($filepath) < time() - $duration){
unlink ($filepath);
$this->debugMessage('Cached file deleted: ' . $filepath);
}
if(file_exists($filepath)){
$this->debugMessage('Loading cached file ' . $filepath);
touch($filepath);
$content = file_get_contents($filepath);
} else {
$this->debugMessage('Caching ' . $url . ' to ' . $filepath);
$dir = substr($filepath, 0, strrpos($filepath, '/'));
if(!is_dir($dir)){
$this->debugMessage('Creating directory ' . $dir);
mkdir($dir, 0777, true);
}
$content = $this->getContents($url);
if($content !== false){
file_put_contents($filepath, $content);
}
}
return str_get_html($content);
}
}

View file

@ -12,7 +12,6 @@ require __DIR__ . '/Format.php';
require __DIR__ . '/FormatAbstract.php';
require __DIR__ . '/Bridge.php';
require __DIR__ . '/BridgeAbstract.php';
require __DIR__ . '/HttpCachingBridgeAbstract.php';
require __DIR__ . '/FeedExpander.php';
require __DIR__ . '/Cache.php';
require __DIR__ . '/CacheAbstract.php';