* @param string $redirector link redirector set in user settings.
* @param boolean $redirectorEncode Enable urlencode on redirected urls (default: true).
*/
- function __construct(
+ public function __construct(
$datastore,
$isLoggedIn,
$hidePublicLinks,
$this->hidePublicLinks = $hidePublicLinks;
$this->redirector = $redirector;
$this->redirectorEncode = $redirectorEncode === true;
- $this->checkDB();
- $this->readDB();
+ $this->check();
+ $this->read();
}
/**
/**
* Iterator - Returns the current element
*/
- function current()
+ public function current()
{
return $this->links[$this->keys[$this->position]];
}
/**
* Iterator - Returns the key of the current element
*/
- function key()
+ public function key()
{
return $this->keys[$this->position];
}
/**
* Iterator - Moves forward to next element
*/
- function next()
+ public function next()
{
++$this->position;
}
*
* Entries are sorted by date (latest first)
*/
- function rewind()
+ public function rewind()
{
$this->keys = array_keys($this->links);
rsort($this->keys);
/**
* Iterator - Checks if current position is valid
*/
- function valid()
+ public function valid()
{
return isset($this->keys[$this->position]);
}
*
* If no DB file is found, creates a dummy DB.
*/
- private function checkDB()
+ private function check()
{
if (file_exists($this->datastore)) {
return;
$this->links[$link['linkdate']] = $link;
// Write database to disk
- $this->writeDB();
+ $this->write();
}
/**
* Reads database from disk to memory
*/
- private function readDB()
+ private function read()
{
// Public links are hidden and user not logged in => nothing to show
*
* @throws IOException the datastore is not writable
*/
- private function writeDB()
+ private function write()
{
if (is_file($this->datastore) && !is_writeable($this->datastore)) {
// The datastore exists but is not writeable
*
* @param string $pageCacheDir page cache directory
*/
- public function savedb($pageCacheDir)
+ public function save($pageCacheDir)
{
if (!$this->loggedIn) {
// TODO: raise an Exception instead
die('You are not authorized to change the database.');
}
- $this->writeDB();
+ $this->write();
invalidateCaches($pageCacheDir);
}