mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2026-01-28 10:47:09 +00:00
diskcache: unify naming
This commit is contained in:
@@ -194,20 +194,20 @@ class DiskCache {
|
||||
$this->dir = CACHE_DIR . "/" . basename(clean($dir));
|
||||
}
|
||||
|
||||
public function getDir() {
|
||||
public function get_dir() {
|
||||
return $this->dir;
|
||||
}
|
||||
|
||||
public function makeDir() {
|
||||
public function make_dir() {
|
||||
if (!is_dir($this->dir)) {
|
||||
return mkdir($this->dir);
|
||||
}
|
||||
}
|
||||
|
||||
public function isWritable($filename = "") {
|
||||
public function is_writable($filename = "") {
|
||||
if ($filename) {
|
||||
if (file_exists($this->getFullPath($filename)))
|
||||
return is_writable($this->getFullPath($filename));
|
||||
if (file_exists($this->get_full_path($filename)))
|
||||
return is_writable($this->get_full_path($filename));
|
||||
else
|
||||
return is_writable($this->dir);
|
||||
} else {
|
||||
@@ -216,44 +216,44 @@ class DiskCache {
|
||||
}
|
||||
|
||||
public function exists($filename) {
|
||||
return file_exists($this->getFullPath($filename));
|
||||
return file_exists($this->get_full_path($filename));
|
||||
}
|
||||
|
||||
public function getSize($filename) {
|
||||
public function get_size($filename) {
|
||||
if ($this->exists($filename))
|
||||
return filesize($this->getFullPath($filename));
|
||||
return filesize($this->get_full_path($filename));
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
public function getFullPath($filename) {
|
||||
public function get_full_path($filename) {
|
||||
return $this->dir . "/" . basename(clean($filename));
|
||||
}
|
||||
|
||||
public function put($filename, $data) {
|
||||
return file_put_contents($this->getFullPath($filename), $data);
|
||||
return file_put_contents($this->get_full_path($filename), $data);
|
||||
}
|
||||
|
||||
public function touch($filename) {
|
||||
return touch($this->getFullPath($filename));
|
||||
return touch($this->get_full_path($filename));
|
||||
}
|
||||
|
||||
public function get($filename) {
|
||||
if ($this->exists($filename))
|
||||
return file_get_contents($this->getFullPath($filename));
|
||||
return file_get_contents($this->get_full_path($filename));
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getMimeType($filename) {
|
||||
public function get_mime_type($filename) {
|
||||
if ($this->exists($filename))
|
||||
return mime_content_type($this->getFullPath($filename));
|
||||
return mime_content_type($this->get_full_path($filename));
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getFakeExtension($filename) {
|
||||
$mimetype = $this->getMimeType($filename);
|
||||
public function get_fake_extension($filename) {
|
||||
$mimetype = $this->get_mime_type($filename);
|
||||
|
||||
if ($mimetype)
|
||||
return isset($this->mimeMap[$mimetype]) ? $this->mimeMap[$mimetype] : "";
|
||||
@@ -262,17 +262,17 @@ class DiskCache {
|
||||
}
|
||||
|
||||
public function send($filename) {
|
||||
$fake_extension = $this->getFakeExtension($filename);
|
||||
$fake_extension = $this->get_fake_extension($filename);
|
||||
|
||||
if ($fake_extension)
|
||||
$fake_extension = ".$fake_extension";
|
||||
|
||||
header("Content-Disposition: inline; filename=\"${filename}${fake_extension}\"");
|
||||
|
||||
return $this->send_local_file($this->getFullPath($filename));
|
||||
return $this->send_local_file($this->get_full_path($filename));
|
||||
}
|
||||
|
||||
public function getUrl($filename) {
|
||||
public function get_url($filename) {
|
||||
return get_self_url_prefix() . "/public.php?op=cached_url&file=" . basename($this->dir) . "/" . basename($filename);
|
||||
}
|
||||
|
||||
@@ -280,7 +280,7 @@ class DiskCache {
|
||||
// this is called separately after sanitize() and plugin render article hooks to allow
|
||||
// plugins work on original source URLs used before caching
|
||||
// NOTE: URLs should be already absolutized because this is called after sanitize()
|
||||
static public function rewriteUrls($str)
|
||||
static public function rewrite_urls($str)
|
||||
{
|
||||
$res = trim($str);
|
||||
if (!$res) return '';
|
||||
@@ -301,7 +301,7 @@ class DiskCache {
|
||||
$cached_filename = sha1($url);
|
||||
|
||||
if ($cache->exists($cached_filename)) {
|
||||
$url = $cache->getUrl($cached_filename);
|
||||
$url = $cache->get_url($cached_filename);
|
||||
|
||||
$entry->setAttribute($attr, $url);
|
||||
$entry->removeAttribute("srcset");
|
||||
@@ -318,7 +318,7 @@ class DiskCache {
|
||||
$cached_filename = sha1($matches[$i]["url"]);
|
||||
|
||||
if ($cache->exists($cached_filename)) {
|
||||
$matches[$i]["url"] = $cache->getUrl($cached_filename);
|
||||
$matches[$i]["url"] = $cache->get_url($cached_filename);
|
||||
|
||||
$need_saving = true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user