1
0
Fork 0
mirror of https://github.com/Yetangitu/ampache synced 2025-10-03 09:49:30 +02:00

Cosmetics: death to tabs

The refactoring I've been doing has reminded me of my strong preference
for spaces, and I feel inclined to impose my will on the tree.
This commit is contained in:
Paul Arthur 2013-01-26 03:00:32 -05:00
parent 8a750c3e87
commit ef4d366060
304 changed files with 30876 additions and 30875 deletions

View file

@ -1,5 +1,5 @@
<?php
/* vim:set tabstop=8 softtabstop=8 shiftwidth=8 noexpandtab: */
/* vim:set softtabstop=4 shiftwidth=4 expandtab: */
/**
*
* LICENSE: GNU General Public License, version 2 (GPLv2)
@ -30,113 +30,113 @@
*/
abstract class database_object {
private static $object_cache = array();
private static $object_cache = array();
// Statistics for debugging
public static $cache_hit = 0;
private static $_enabled = false;
// Statistics for debugging
public static $cache_hit = 0;
private static $_enabled = false;
/**
* get_info
* retrieves the info from the database and puts it in the cache
*/
public function get_info($id,$table_name='') {
/**
* get_info
* retrieves the info from the database and puts it in the cache
*/
public function get_info($id,$table_name='') {
$table_name = $table_name ? Dba::escape($table_name) : Dba::escape(strtolower(get_class($this)));
$table_name = $table_name ? Dba::escape($table_name) : Dba::escape(strtolower(get_class($this)));
// Make sure we've got a real id
if (!is_numeric($id)) { return array(); }
// Make sure we've got a real id
if (!is_numeric($id)) { return array(); }
if (self::is_cached($table_name,$id)) {
return self::get_from_cache($table_name,$id);
}
if (self::is_cached($table_name,$id)) {
return self::get_from_cache($table_name,$id);
}
$sql = "SELECT * FROM `$table_name` WHERE `id`='$id'";
$db_results = Dba::read($sql);
$sql = "SELECT * FROM `$table_name` WHERE `id`='$id'";
$db_results = Dba::read($sql);
if (!$db_results) { return array(); }
if (!$db_results) { return array(); }
$row = Dba::fetch_assoc($db_results);
$row = Dba::fetch_assoc($db_results);
self::add_to_cache($table_name,$id,$row);
self::add_to_cache($table_name,$id,$row);
return $row;
return $row;
} // get_info
} // get_info
/**
* clear_cache
*/
public static function clear_cache() {
self::$object_cache = array();
}
/**
* clear_cache
*/
public static function clear_cache() {
self::$object_cache = array();
}
/**
* is_cached
* this checks the cache to see if the specified object is there
*/
public static function is_cached($index,$id) {
/**
* is_cached
* this checks the cache to see if the specified object is there
*/
public static function is_cached($index,$id) {
// Make sure we've got some parents here before we dive below
if (!isset(self::$object_cache[$index])) { return false; }
// Make sure we've got some parents here before we dive below
if (!isset(self::$object_cache[$index])) { return false; }
return isset(self::$object_cache[$index][$id]);
return isset(self::$object_cache[$index][$id]);
} // is_cached
} // is_cached
/**
* get_from_cache
* This attempts to retrive the specified object from the cache we've got here
*/
public static function get_from_cache($index,$id) {
/**
* get_from_cache
* This attempts to retrive the specified object from the cache we've got here
*/
public static function get_from_cache($index,$id) {
// Check if the object is set
if (isset(self::$object_cache[$index])
&& isset(self::$object_cache[$index][$id])
) {
// Check if the object is set
if (isset(self::$object_cache[$index])
&& isset(self::$object_cache[$index][$id])
) {
self::$cache_hit++;
return self::$object_cache[$index][$id];
}
self::$cache_hit++;
return self::$object_cache[$index][$id];
}
return false;
return false;
} // get_from_cache
} // get_from_cache
/**
* add_to_cache
* This adds the specified object to the specified index in the cache
*/
public static function add_to_cache($index,$id,$data) {
/**
* add_to_cache
* This adds the specified object to the specified index in the cache
*/
public static function add_to_cache($index,$id,$data) {
if (!self::$_enabled) { return false; }
if (!self::$_enabled) { return false; }
$value = is_null($data) ? false : $data;
self::$object_cache[$index][$id] = $value;
$value = is_null($data) ? false : $data;
self::$object_cache[$index][$id] = $value;
} // add_to_cache
} // add_to_cache
/**
* remove_from_cache
* This function clears something from the cache, there are a few places we need to do this
* in order to have things display correctly
*/
public static function remove_from_cache($index,$id) {
/**
* remove_from_cache
* This function clears something from the cache, there are a few places we need to do this
* in order to have things display correctly
*/
public static function remove_from_cache($index,$id) {
if (isset(self::$object_cache[$index]) && isset(self::$object_cache[$index][$id])) {
unset(self::$object_cache[$index][$id]);
}
if (isset(self::$object_cache[$index]) && isset(self::$object_cache[$index][$id])) {
unset(self::$object_cache[$index][$id]);
}
} // remove_from_cache
} // remove_from_cache
/**
* _auto_init
* Load in the cache settings once so we can avoid function calls
*/
public static function _auto_init() {
/**
* _auto_init
* Load in the cache settings once so we can avoid function calls
*/
public static function _auto_init() {
self::$_enabled = Config::get('memory_cache');
self::$_enabled = Config::get('memory_cache');
} // _auto_init
} // _auto_init
} // end database_object