$this->hidePublicLinks = $hidePublicLinks;
$this->redirector = $redirector;
$this->redirectorEncode = $redirectorEncode === true;
- $this->checkDB();
- $this->readDB();
+ $this->check();
+ $this->read();
}
/**
*
* 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);
}
$importCount++;
}
- $linkDb->savedb($pagecache);
+ $linkDb->save($pagecache);
return self::importStatus(
$filename,
$filesize,
$link['tags'] = implode(' ', array_unique(LinkFilter::tagsStrToArray($link['tags'], true)));
$this->linkDB[$link['linkdate']] = $link;
}
- $this->linkDB->savedb($this->conf->get('resource.page_cache'));
+ $this->linkDB->save($this->conf->get('resource.page_cache'));
return true;
}
$value['tags']=trim(implode(' ',$tags));
$LINKSDB[$key]=$value;
}
- $LINKSDB->savedb($conf->get('resource.page_cache'));
+ $LINKSDB->save($conf->get('resource.page_cache'));
echo '<script>alert("Tag was removed from '.count($linksToAlter).' links.");document.location=\'?\';</script>';
exit;
}
$value['tags']=trim(implode(' ',$tags));
$LINKSDB[$key]=$value;
}
- $LINKSDB->savedb($conf->get('resource.page_cache')); // Save to disk.
+ $LINKSDB->save($conf->get('resource.page_cache')); // Save to disk.
echo '<script>alert("Tag was renamed in '.count($linksToAlter).' links.");document.location=\'?searchtags='.urlencode($_POST['totag']).'\';</script>';
exit;
}
$pluginManager->executeHooks('save_link', $link);
$LINKSDB[$linkdate] = $link;
- $LINKSDB->savedb($conf->get('resource.page_cache'));
+ $LINKSDB->save($conf->get('resource.page_cache'));
pubsubhub($conf);
// If we are called from the bookmarklet, we must close the popup:
$pluginManager->executeHooks('delete_link', $LINKSDB[$linkdate]);
unset($LINKSDB[$linkdate]);
- $LINKSDB->savedb('resource.page_cache'); // save to disk
+ $LINKSDB->save('resource.page_cache'); // save to disk
// If we are called from the bookmarklet, we must close the popup:
if (isset($_GET['source']) && ($_GET['source']=='bookmarklet' || $_GET['source']=='firefoxsocialapi')) { echo '<script>self.close();</script>'; exit; }
unlink(self::$testDatastore);
$this->assertFileNotExists(self::$testDatastore);
- $checkDB = self::getMethod('checkDB');
+ $checkDB = self::getMethod('check');
$checkDB->invokeArgs($linkDB, array());
$this->assertFileExists(self::$testDatastore);
$datastoreSize = filesize(self::$testDatastore);
$this->assertGreaterThan(0, $datastoreSize);
- $checkDB = self::getMethod('checkDB');
+ $checkDB = self::getMethod('check');
$checkDB->invokeArgs($linkDB, array());
// ensure the datastore is left unmodified
/**
* Save the links to the DB
*/
- public function testSaveDB()
+ public function testSave()
{
$testDB = new LinkDB(self::$testDatastore, true, false);
$dbSize = sizeof($testDB);
'tags'=>'unit test'
);
$testDB[$link['linkdate']] = $link;
- $testDB->savedb('tests');
+ $testDB->save('tests');
$testDB = new LinkDB(self::$testDatastore, true, false);
$this->assertEquals($dbSize + 1, sizeof($testDB));