[Bridge] Use space indentation everywhere
This commit is contained in:
parent
7961f8081e
commit
d80efed1f4
1 changed files with 41 additions and 41 deletions
|
@ -17,12 +17,12 @@ abstract class BridgeAbstract implements BridgeInterface{
|
||||||
protected $cache;
|
protected $cache;
|
||||||
protected $items = array();
|
protected $items = array();
|
||||||
|
|
||||||
public $name = "Unnamed bridge";
|
public $name = "Unnamed bridge";
|
||||||
public $uri = "";
|
public $uri = "";
|
||||||
public $description = 'No description provided';
|
public $description = 'No description provided';
|
||||||
public $maintainer = 'No maintainer';
|
public $maintainer = 'No maintainer';
|
||||||
public $useProxy = true;
|
public $useProxy = true;
|
||||||
public $parameters = array();
|
public $parameters = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch probative exception
|
* Launch probative exception
|
||||||
|
@ -175,22 +175,22 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract {
|
||||||
*/
|
*/
|
||||||
public function get_cached($url) {
|
public function get_cached($url) {
|
||||||
$simplified_url = str_replace(["http://", "https://", "?", "&", "="], ["", "", "/", "/", "/"], $url);
|
$simplified_url = str_replace(["http://", "https://", "?", "&", "="], ["", "", "/", "/", "/"], $url);
|
||||||
// TODO build this from the variable given to Cache
|
// TODO build this from the variable given to Cache
|
||||||
$pageCacheDir = __DIR__ . '/../cache/'."pages/";
|
$pageCacheDir = __DIR__ . '/../cache/'."pages/";
|
||||||
$filename = $pageCacheDir.$simplified_url;
|
$filename = $pageCacheDir.$simplified_url;
|
||||||
if (substr($filename, -1) == '/') {
|
if (substr($filename, -1) == '/') {
|
||||||
$filename = $filename."index.html";
|
$filename = $filename."index.html";
|
||||||
}
|
}
|
||||||
if(file_exists($filename)) {
|
if(file_exists($filename)) {
|
||||||
// $this->message("loading cached file from ".$filename." for page at url ".$url);
|
// $this->message("loading cached file from ".$filename." for page at url ".$url);
|
||||||
// TODO touch file and its parent, and try to do neighbour deletion
|
// TODO touch file and its parent, and try to do neighbour deletion
|
||||||
$this->refresh_in_cache($pageCacheDir, $filename);
|
$this->refresh_in_cache($pageCacheDir, $filename);
|
||||||
$content=file_get_contents($filename);
|
$content=file_get_contents($filename);
|
||||||
} else {
|
} else {
|
||||||
// $this->message("we have no local copy of ".$url." Downloading to ".$filename);
|
// $this->message("we have no local copy of ".$url." Downloading to ".$filename);
|
||||||
$dir = substr($filename, 0, strrpos($filename, '/'));
|
$dir = substr($filename, 0, strrpos($filename, '/'));
|
||||||
if(!is_dir($dir)) {
|
if(!is_dir($dir)) {
|
||||||
// $this->message("creating directories for ".$dir);
|
// $this->message("creating directories for ".$dir);
|
||||||
mkdir($dir, 0777, true);
|
mkdir($dir, 0777, true);
|
||||||
}
|
}
|
||||||
$content=$this->getContents($url);
|
$content=$this->getContents($url);
|
||||||
|
@ -216,17 +216,17 @@ abstract class HttpCachingBridgeAbstract extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
|
|
||||||
private function refresh_in_cache($pageCacheDir, $filename) {
|
private function refresh_in_cache($pageCacheDir, $filename) {
|
||||||
$currentPath = $filename;
|
$currentPath = $filename;
|
||||||
while(!$pageCacheDir==$currentPath) {
|
while(!$pageCacheDir==$currentPath) {
|
||||||
touch($currentPath);
|
touch($currentPath);
|
||||||
$currentPath = dirname($currentPath);
|
$currentPath = dirname($currentPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remove_from_cache($url) {
|
public function remove_from_cache($url) {
|
||||||
$simplified_url = str_replace(["http://", "https://", "?", "&", "="], ["", "", "/", "/", "/"], $url);
|
$simplified_url = str_replace(["http://", "https://", "?", "&", "="], ["", "", "/", "/", "/"], $url);
|
||||||
// TODO build this from the variable given to Cache
|
// TODO build this from the variable given to Cache
|
||||||
$pageCacheDir = __DIR__ . '/../cache/'."pages/";
|
$pageCacheDir = __DIR__ . '/../cache/'."pages/";
|
||||||
$filename = realpath($pageCacheDir.$simplified_url);
|
$filename = realpath($pageCacheDir.$simplified_url);
|
||||||
$this->message("removing from cache \"".$filename."\" WELL, NOT REALLY");
|
$this->message("removing from cache \"".$filename."\" WELL, NOT REALLY");
|
||||||
// filename is NO GOOD
|
// filename is NO GOOD
|
||||||
|
@ -243,17 +243,17 @@ class Bridge{
|
||||||
throw new \LogicException('Please use ' . __CLASS__ . '::create for new object.');
|
throw new \LogicException('Please use ' . __CLASS__ . '::create for new object.');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a bridge is an instantiable bridge.
|
* Checks if a bridge is an instantiable bridge.
|
||||||
* @param string $nameBridge name of the bridge that you want to use
|
* @param string $nameBridge name of the bridge that you want to use
|
||||||
* @return true if it is an instantiable bridge, false otherwise.
|
* @return true if it is an instantiable bridge, false otherwise.
|
||||||
*/
|
*/
|
||||||
static public function isInstantiable($nameBridge) {
|
static public function isInstantiable($nameBridge) {
|
||||||
|
|
||||||
$re = new ReflectionClass($nameBridge);
|
$re = new ReflectionClass($nameBridge);
|
||||||
return $re->IsInstantiable();
|
return $re->IsInstantiable();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -275,10 +275,10 @@ class Bridge{
|
||||||
|
|
||||||
require_once $pathBridge;
|
require_once $pathBridge;
|
||||||
|
|
||||||
if(Bridge::isInstantiable($nameBridge)) {
|
if(Bridge::isInstantiable($nameBridge)) {
|
||||||
return new $nameBridge();
|
return new $nameBridge();
|
||||||
} else {
|
} else {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,11 +308,11 @@ class Bridge{
|
||||||
* Lists the available bridges.
|
* Lists the available bridges.
|
||||||
* @return array List of the bridges
|
* @return array List of the bridges
|
||||||
*/
|
*/
|
||||||
static public function listBridges() {
|
static public function listBridges() {
|
||||||
|
|
||||||
$pathDirBridge = self::getDir();
|
$pathDirBridge = self::getDir();
|
||||||
$listBridge = array();
|
$listBridge = array();
|
||||||
$dirFiles = scandir($pathDirBridge);
|
$dirFiles = scandir($pathDirBridge);
|
||||||
|
|
||||||
if( $dirFiles !== false ){
|
if( $dirFiles !== false ){
|
||||||
foreach( $dirFiles as $fileName ) {
|
foreach( $dirFiles as $fileName ) {
|
||||||
|
@ -322,17 +322,17 @@ class Bridge{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $listBridge;
|
return $listBridge;
|
||||||
}
|
}
|
||||||
static function isWhitelisted( $whitelist, $name ) {
|
static function isWhitelisted( $whitelist, $name ) {
|
||||||
if(in_array($name, $whitelist) or in_array($name.'.php', $whitelist) or
|
if(in_array($name, $whitelist) or in_array($name.'.php', $whitelist) or
|
||||||
// DEPRECATED: the nameBridge notation will be removed in future releases
|
// DEPRECATED: the nameBridge notation will be removed in future releases
|
||||||
in_array($name.'Bridge', $whitelist) or in_array($name.'Bridge.php', $whitelist) or
|
in_array($name.'Bridge', $whitelist) or in_array($name.'Bridge.php', $whitelist) or
|
||||||
count($whitelist) === 1 and trim($whitelist[0]) === '*')
|
count($whitelist) === 1 and trim($whitelist[0]) === '*')
|
||||||
return TRUE;
|
return TRUE;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue