X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=application%2FLinkDB.php;h=c8b162b6b4931678fde97767cfc3775483e07efb;hb=1ef05d3601e942eba74bd66554d629be2fa05efe;hp=2d42c51420bd015941e3392b724807706c3f5d4c;hpb=628b97cbdf276785eb9ff4f7a124e81e67d2f76c;p=github%2Fshaarli%2FShaarli.git diff --git a/application/LinkDB.php b/application/LinkDB.php index 2d42c514..c8b162b6 100644 --- a/application/LinkDB.php +++ b/application/LinkDB.php @@ -87,7 +87,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess * @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, @@ -100,8 +100,8 @@ class LinkDB implements Iterator, Countable, ArrayAccess $this->hidePublicLinks = $hidePublicLinks; $this->redirector = $redirector; $this->redirectorEncode = $redirectorEncode === true; - $this->checkDB(); - $this->readDB(); + $this->check(); + $this->read(); } /** @@ -164,7 +164,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess /** * Iterator - Returns the current element */ - function current() + public function current() { return $this->links[$this->keys[$this->position]]; } @@ -172,7 +172,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess /** * Iterator - Returns the key of the current element */ - function key() + public function key() { return $this->keys[$this->position]; } @@ -180,7 +180,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess /** * Iterator - Moves forward to next element */ - function next() + public function next() { ++$this->position; } @@ -190,7 +190,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess * * Entries are sorted by date (latest first) */ - function rewind() + public function rewind() { $this->keys = array_keys($this->links); rsort($this->keys); @@ -200,7 +200,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess /** * Iterator - Checks if current position is valid */ - function valid() + public function valid() { return isset($this->keys[$this->position]); } @@ -210,7 +210,7 @@ class LinkDB implements Iterator, Countable, ArrayAccess * * If no DB file is found, creates a dummy DB. */ - private function checkDB() + private function check() { if (file_exists($this->datastore)) { return; @@ -243,13 +243,13 @@ You use the community supported version of the original Shaarli project, by Seba $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 @@ -315,7 +315,7 @@ You use the community supported version of the original Shaarli project, by Seba * * @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 @@ -337,14 +337,14 @@ You use the community supported version of the original Shaarli project, by Seba * * @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); }