lint: fix line-length warnings
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
This commit is contained in:
parent
067c2dd8f5
commit
9d9f6d75b9
13 changed files with 132 additions and 44 deletions
|
@ -7,7 +7,8 @@
|
|||
* @param int $timeout network timeout (in seconds)
|
||||
* @param int $maxBytes maximum downloaded bytes (default: 4 MiB)
|
||||
* @param callable|string $curlWriteFunction Optional callback called during the download (cURL CURLOPT_WRITEFUNCTION).
|
||||
* Can be used to add download conditions on the headers (response code, content type, etc.).
|
||||
* Can be used to add download conditions on the
|
||||
* headers (response code, content type, etc.).
|
||||
*
|
||||
* @return array HTTP response headers, downloaded content
|
||||
*
|
||||
|
|
|
@ -149,7 +149,9 @@ protected function initPhpTranslator()
|
|||
}
|
||||
|
||||
try {
|
||||
$extension = Translations::fromPoFile($translationPath . $this->language .'/LC_MESSAGES/'. $domain .'.po');
|
||||
$extension = Translations::fromPoFile(
|
||||
$translationPath . $this->language .'/LC_MESSAGES/'. $domain .'.po'
|
||||
);
|
||||
$extension->setDomain($domain);
|
||||
$this->translator->loadTranslations($extension);
|
||||
} catch (\InvalidArgumentException $e) {
|
||||
|
|
|
@ -249,11 +249,14 @@ private function check()
|
|||
'id' => 1,
|
||||
'title'=> t('The personal, minimalist, super-fast, database free, bookmarking service'),
|
||||
'url'=>'https://shaarli.readthedocs.io',
|
||||
'description'=>t('Welcome to Shaarli! This is your first public bookmark. To edit or delete me, you must first login.
|
||||
'description'=>t(
|
||||
'Welcome to Shaarli! This is your first public bookmark. '
|
||||
.'To edit or delete me, you must first login.
|
||||
|
||||
To learn how to use Shaarli, consult the link "Documentation" at the bottom of this page.
|
||||
|
||||
You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'),
|
||||
You use the community supported version of the original Shaarli project, by Sebastien Sauvage.'
|
||||
),
|
||||
'private'=>0,
|
||||
'created'=> new DateTime(),
|
||||
'tags'=>'opensource software'
|
||||
|
@ -419,8 +422,12 @@ public function filterDay($request)
|
|||
*
|
||||
* @return array filtered links, all links if no suitable filter was provided.
|
||||
*/
|
||||
public function filterSearch($filterRequest = array(), $casesensitive = false, $visibility = 'all', $untaggedonly = false)
|
||||
{
|
||||
public function filterSearch(
|
||||
$filterRequest = array(),
|
||||
$casesensitive = false,
|
||||
$visibility = 'all',
|
||||
$untaggedonly = false
|
||||
) {
|
||||
// Filter link database according to parameters.
|
||||
$searchtags = isset($filterRequest['searchtags']) ? escape($filterRequest['searchtags']) : '';
|
||||
$searchterm = isset($filterRequest['searchterm']) ? escape($filterRequest['searchterm']) : '';
|
||||
|
|
|
@ -82,7 +82,10 @@ private static function importStatus(
|
|||
$status .= t('has an unknown file format. Nothing was imported.');
|
||||
} else {
|
||||
$status .= vsprintf(
|
||||
t('was successfully processed in %d seconds: %d links imported, %d links overwritten, %d links skipped.'),
|
||||
t(
|
||||
'was successfully processed in %d seconds: '
|
||||
.'%d links imported, %d links overwritten, %d links skipped.'
|
||||
),
|
||||
[$duration, $importCount, $overwriteCount, $skipCount]
|
||||
);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,10 @@ public function __construct($conf)
|
|||
$this->conf->set('thumbnails.enabled', false);
|
||||
$this->conf->write(true);
|
||||
// TODO: create a proper error handling system able to catch exceptions...
|
||||
die(t('php-gd extension must be loaded to use thumbnails. Thumbnails are now disabled. Please reload the page.'));
|
||||
die(t(
|
||||
'php-gd extension must be loaded to use thumbnails. '
|
||||
.'Thumbnails are now disabled. Please reload the page.'
|
||||
));
|
||||
}
|
||||
|
||||
$this->wt = new WebThumbnailer();
|
||||
|
|
|
@ -104,12 +104,20 @@ public function write($filepath, $conf)
|
|||
|
||||
// Store all $conf['config']
|
||||
foreach ($conf['config'] as $key => $value) {
|
||||
$configStr .= '$GLOBALS[\'config\'][\''. $key .'\'] = '.var_export($conf['config'][$key], true).';'. PHP_EOL;
|
||||
$configStr .= '$GLOBALS[\'config\'][\''
|
||||
. $key
|
||||
.'\'] = '
|
||||
.var_export($conf['config'][$key], true).';'
|
||||
. PHP_EOL;
|
||||
}
|
||||
|
||||
if (isset($conf['plugins'])) {
|
||||
foreach ($conf['plugins'] as $key => $value) {
|
||||
$configStr .= '$GLOBALS[\'plugins\'][\''. $key .'\'] = '.var_export($conf['plugins'][$key], true).';'. PHP_EOL;
|
||||
$configStr .= '$GLOBALS[\'plugins\'][\''
|
||||
. $key
|
||||
.'\'] = '
|
||||
.var_export($conf['plugins'][$key], true).';'
|
||||
. PHP_EOL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
49
index.php
49
index.php
|
@ -806,7 +806,10 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
|||
$params['searchtags'] = trim($params['searchtags']).' '.trim($_GET['addtag']);
|
||||
}
|
||||
|
||||
unset($params['page']); // We also remove page (keeping the same page has no sense, since the results are different)
|
||||
// We also remove page (keeping the same page has no sense, since the
|
||||
// results are different)
|
||||
unset($params['page']);
|
||||
|
||||
header('Location: ?'.http_build_query($params));
|
||||
exit;
|
||||
}
|
||||
|
@ -837,7 +840,9 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
|||
unset($params['searchtags']);
|
||||
}
|
||||
|
||||
unset($params['page']); // We also remove page (keeping the same page has no sense, since the results are different)
|
||||
// We also remove page (keeping the same page has no sense, since
|
||||
// the results are different)
|
||||
unset($params['page']);
|
||||
}
|
||||
header('Location: ?'.http_build_query($params));
|
||||
exit;
|
||||
|
@ -954,15 +959,26 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
|||
}
|
||||
|
||||
// Make sure old password is correct.
|
||||
$oldhash = sha1($_POST['oldpassword'].$conf->get('credentials.login').$conf->get('credentials.salt'));
|
||||
if ($oldhash!= $conf->get('credentials.hash')) {
|
||||
echo '<script>alert("'. t('The old password is not correct.') .'");document.location=\'?do=changepasswd\';</script>';
|
||||
$oldhash = sha1(
|
||||
$_POST['oldpassword'].$conf->get('credentials.login').$conf->get('credentials.salt')
|
||||
);
|
||||
if ($oldhash != $conf->get('credentials.hash')) {
|
||||
echo '<script>alert("'
|
||||
. t('The old password is not correct.')
|
||||
.'");document.location=\'?do=changepasswd\';</script>';
|
||||
exit;
|
||||
}
|
||||
// Save new password
|
||||
// Salt renders rainbow-tables attacks useless.
|
||||
$conf->set('credentials.salt', sha1(uniqid('', true) .'_'. mt_rand()));
|
||||
$conf->set('credentials.hash', sha1($_POST['setpassword'] . $conf->get('credentials.login') . $conf->get('credentials.salt')));
|
||||
$conf->set(
|
||||
'credentials.hash',
|
||||
sha1(
|
||||
$_POST['setpassword']
|
||||
. $conf->get('credentials.login')
|
||||
. $conf->get('credentials.salt')
|
||||
)
|
||||
);
|
||||
try {
|
||||
$conf->write($loginManager->isLoggedIn());
|
||||
} catch (Exception $e) {
|
||||
|
@ -1015,7 +1031,8 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
|||
&& $thumbnailsMode !== $conf->get('thumbnails.mode', Thumbnailer::MODE_NONE)
|
||||
) {
|
||||
$_SESSION['warnings'][] = t(
|
||||
'You have enabled or changed thumbnails mode. <a href="?do=thumbs_update">Please synchronize them</a>.'
|
||||
'You have enabled or changed thumbnails mode. '
|
||||
.'<a href="?do=thumbs_update">Please synchronize them</a>.'
|
||||
);
|
||||
}
|
||||
$conf->set('thumbnails.mode', $thumbnailsMode);
|
||||
|
@ -1296,7 +1313,9 @@ function renderPage($conf, $pluginManager, $LINKSDB, $history, $sessionManager,
|
|||
$description = empty($_GET['description']) ? '' : escape($_GET['description']);
|
||||
$tags = empty($_GET['tags']) ? '' : escape($_GET['tags']);
|
||||
$private = !empty($_GET['private']) && $_GET['private'] === "1" ? 1 : 0;
|
||||
// If this is an HTTP(S) link, we try go get the page to extract the title (otherwise we will to straight to the edit form.)
|
||||
|
||||
// If this is an HTTP(S) link, we try go get the page to extract
|
||||
// the title (otherwise we will to straight to the edit form.)
|
||||
if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) {
|
||||
// Short timeout to keep the application responsive
|
||||
// The callback will fill $charset and $title with data from the downloaded page.
|
||||
|
@ -1514,7 +1533,11 @@ function ($a, $b) {
|
|||
);
|
||||
|
||||
// TODO: do not handle exceptions/errors in JS.
|
||||
echo '<script>alert("'. $e->getMessage() .'");document.location=\'?do='. Router::$PAGE_PLUGINSADMIN .'\';</script>';
|
||||
echo '<script>alert("'
|
||||
. $e->getMessage()
|
||||
.'");document.location=\'?do='
|
||||
. Router::$PAGE_PLUGINSADMIN
|
||||
.'\';</script>';
|
||||
exit;
|
||||
}
|
||||
header('Location: ?do='. Router::$PAGE_PLUGINSADMIN);
|
||||
|
@ -1749,7 +1772,8 @@ function install($conf, $sessionManager, $loginManager)
|
|||
// This part makes sure sessions works correctly.
|
||||
// (Because on some hosts, session.save_path may not be set correctly,
|
||||
// or we may not have write access to it.)
|
||||
if (isset($_GET['test_session']) && ( !isset($_SESSION) || !isset($_SESSION['session_tested']) || $_SESSION['session_tested']!='Working')) {
|
||||
if (isset($_GET['test_session'])
|
||||
&& ( !isset($_SESSION) || !isset($_SESSION['session_tested']) || $_SESSION['session_tested']!='Working')) {
|
||||
// Step 2: Check if data in session is correct.
|
||||
$msg = t(
|
||||
'<pre>Sessions do not seem to work correctly on your server.<br>'.
|
||||
|
@ -1817,7 +1841,10 @@ function install($conf, $sessionManager, $loginManager)
|
|||
echo '<script>alert("'. $e->getMessage() .'");document.location=\'?\';</script>';
|
||||
exit;
|
||||
}
|
||||
echo '<script>alert("Shaarli is now configured. Please enter your login/password and start shaaring your links!");document.location=\'?do=login\';</script>';
|
||||
echo '<script>alert('
|
||||
.'"Shaarli is now configured. '
|
||||
.'Please enter your login/password and start shaaring your links!"'
|
||||
.');document.location=\'?do=login\';</script>';
|
||||
exit;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,15 @@ public function testFilter()
|
|||
|
||||
$this->assertEquals(
|
||||
self::$refDB->countUntaggedLinks(),
|
||||
count(self::$linkFilter->filter(LinkFilter::$FILTER_TAG, /*$request=*/'', /*$casesensitive=*/false, /*$visibility=*/'all', /*$untaggedonly=*/true))
|
||||
count(
|
||||
self::$linkFilter->filter(
|
||||
LinkFilter::$FILTER_TAG,
|
||||
/*$request=*/'',
|
||||
/*$casesensitive=*/false,
|
||||
/*$visibility=*/'all',
|
||||
/*$untaggedonly=*/true
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertEquals(
|
||||
|
|
|
@ -83,7 +83,9 @@ public function testCurlDownloadCallbackOk()
|
|||
'Date: Sat, 28 Oct 2017 12:01:33 GMT',
|
||||
'Content-Type: text/html; charset=utf-8',
|
||||
'Status: 200 OK',
|
||||
'end' => 'th=device-width"><title>Refactoring · GitHub</title><link rel="search" type="application/opensea',
|
||||
'end' => 'th=device-width">'
|
||||
.'<title>Refactoring · GitHub</title>'
|
||||
.'<link rel="search" type="application/opensea',
|
||||
'<title>ignored</title>',
|
||||
];
|
||||
foreach ($data as $key => $line) {
|
||||
|
@ -106,7 +108,9 @@ public function testCurlDownloadCallbackOkNoCharset()
|
|||
$callback = get_curl_download_callback($charset, $title, 'ut_curl_getinfo_no_charset');
|
||||
$data = [
|
||||
'HTTP/1.1 200 OK',
|
||||
'end' => 'th=device-width"><title>Refactoring · GitHub</title><link rel="search" type="application/opensea',
|
||||
'end' => 'th=device-width">'
|
||||
.'<title>Refactoring · GitHub</title>'
|
||||
.'<link rel="search" type="application/opensea',
|
||||
'<title>ignored</title>',
|
||||
];
|
||||
foreach ($data as $key => $line) {
|
||||
|
@ -126,7 +130,9 @@ public function testCurlDownloadCallbackOkHtmlCharset()
|
|||
$data = [
|
||||
'HTTP/1.1 200 OK',
|
||||
'<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />',
|
||||
'end' => 'th=device-width"><title>Refactoring · GitHub</title><link rel="search" type="application/opensea',
|
||||
'end' => 'th=device-width">'
|
||||
.'<title>Refactoring · GitHub</title>'
|
||||
.'<link rel="search" type="application/opensea',
|
||||
'<title>ignored</title>',
|
||||
];
|
||||
foreach ($data as $key => $line) {
|
||||
|
@ -211,23 +217,26 @@ public function testCountPrivateLinks()
|
|||
public function testText2clickableWithoutRedirector()
|
||||
{
|
||||
$text = 'stuff http://hello.there/is=someone#here otherstuff';
|
||||
$expectedText = 'stuff <a href="http://hello.there/is=someone#here">http://hello.there/is=someone#here</a> otherstuff';
|
||||
$expectedText = 'stuff <a href="http://hello.there/is=someone#here">'
|
||||
.'http://hello.there/is=someone#here</a> otherstuff';
|
||||
$processedText = text2clickable($text, '');
|
||||
$this->assertEquals($expectedText, $processedText);
|
||||
|
||||
$text = 'stuff http://hello.there/is=someone#here(please) otherstuff';
|
||||
$expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)">http://hello.there/is=someone#here(please)</a> otherstuff';
|
||||
$expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)">'
|
||||
.'http://hello.there/is=someone#here(please)</a> otherstuff';
|
||||
$processedText = text2clickable($text, '');
|
||||
$this->assertEquals($expectedText, $processedText);
|
||||
|
||||
$text = 'stuff http://hello.there/is=someone#here(please)&no otherstuff';
|
||||
$expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)&no">http://hello.there/is=someone#here(please)&no</a> otherstuff';
|
||||
$expectedText = 'stuff <a href="http://hello.there/is=someone#here(please)&no">'
|
||||
.'http://hello.there/is=someone#here(please)&no</a> otherstuff';
|
||||
$processedText = text2clickable($text, '');
|
||||
$this->assertEquals($expectedText, $processedText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test text2clickable a redirector set.
|
||||
* Test text2clickable with a redirector set.
|
||||
*/
|
||||
public function testText2clickableWithRedirector()
|
||||
{
|
||||
|
|
|
@ -393,20 +393,32 @@ public function testDatastoreIds()
|
|||
$this->assertEquals('Naming conventions... #private', $linkDB[0]['description']);
|
||||
$this->assertEquals('samba cartoon web', $linkDB[0]['tags']);
|
||||
$this->assertTrue($linkDB[0]['private']);
|
||||
$this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_142300'), $linkDB[0]['created']);
|
||||
$this->assertEquals(
|
||||
DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_142300'),
|
||||
$linkDB[0]['created']
|
||||
);
|
||||
|
||||
$this->assertTrue(isset($linkDB[1]));
|
||||
$this->assertFalse(isset($linkDB[1]['linkdate']));
|
||||
$this->assertEquals(1, $linkDB[1]['id']);
|
||||
$this->assertEquals('UserFriendly - Samba', $linkDB[1]['title']);
|
||||
$this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_172539'), $linkDB[1]['created']);
|
||||
$this->assertEquals(
|
||||
DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_172539'),
|
||||
$linkDB[1]['created']
|
||||
);
|
||||
|
||||
$this->assertTrue(isset($linkDB[2]));
|
||||
$this->assertFalse(isset($linkDB[2]['linkdate']));
|
||||
$this->assertEquals(2, $linkDB[2]['id']);
|
||||
$this->assertEquals('Geek and Poke', $linkDB[2]['title']);
|
||||
$this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_182539'), $linkDB[2]['created']);
|
||||
$this->assertEquals(DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_190301'), $linkDB[2]['updated']);
|
||||
$this->assertEquals(
|
||||
DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_182539'),
|
||||
$linkDB[2]['created']
|
||||
);
|
||||
$this->assertEquals(
|
||||
DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, '20121206_190301'),
|
||||
$linkDB[2]['updated']
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -127,7 +127,9 @@ public function testPostLinkMinimal()
|
|||
$this->assertEquals('', $data['description']);
|
||||
$this->assertEquals([], $data['tags']);
|
||||
$this->assertEquals(false, $data['private']);
|
||||
$this->assertTrue(new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created']));
|
||||
$this->assertTrue(
|
||||
new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
|
||||
);
|
||||
$this->assertEquals('', $data['updated']);
|
||||
|
||||
$historyEntry = $this->history->getHistory()[0];
|
||||
|
@ -170,7 +172,9 @@ public function testPostLinkFull()
|
|||
$this->assertEquals($link['description'], $data['description']);
|
||||
$this->assertEquals($link['tags'], $data['tags']);
|
||||
$this->assertEquals(true, $data['private']);
|
||||
$this->assertTrue(new \DateTime('2 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created']));
|
||||
$this->assertTrue(
|
||||
new \DateTime('2 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
|
||||
);
|
||||
$this->assertEquals('', $data['updated']);
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,9 @@ public function testPutLinkMinimal()
|
|||
\DateTime::createFromFormat('Ymd_His', '20150310_114651'),
|
||||
\DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
|
||||
);
|
||||
$this->assertTrue(new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated']));
|
||||
$this->assertTrue(
|
||||
new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated'])
|
||||
);
|
||||
|
||||
$historyEntry = $this->history->getHistory()[0];
|
||||
$this->assertEquals(\History::UPDATED, $historyEntry['event']);
|
||||
|
@ -159,7 +161,9 @@ public function testPutLinkWithValues()
|
|||
\DateTime::createFromFormat('Ymd_His', '20150310_114651'),
|
||||
\DateTime::createFromFormat(\DateTime::ATOM, $data['created'])
|
||||
);
|
||||
$this->assertTrue(new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated']));
|
||||
$this->assertTrue(
|
||||
new \DateTime('5 seconds ago') < \DateTime::createFromFormat(\DateTime::ATOM, $data['updated'])
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue