* @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
*
}
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) {
'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'
*
* @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']) : '';
$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]
);
}
$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();
// 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;
}
}
$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;
}
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;
}
// 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) {
&& $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);
$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.
);
// 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);
// 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>'.
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;
}
* ],
* ]
* This example renders as:
- * <form form-attribute-1="form attribute 1 value" form-attribute-2="form attribute 2 value">
- * <input input-1-attribute-1="input 1 attribute 1 value" input-1-attribute-2="input 1 attribute 2 value">
- * <input input-2-attribute-1="input 2 attribute 1 value">
- * </form>
+ * <form form-attribute-1="form attribute 1 value" form-attribute-2="form attribute 2 value">
+ * <input input-1-attribute-1="input 1 attribute 1 value" input-1-attribute-2="input 1 attribute 2 value">
+ * <input input-2-attribute-1="input 2 attribute 1 value">
+ * </form>
*/
$form = array(
'attr' => array(
$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(
2,
count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'ars.userfriendly.org'))
);
-
+
$this->assertEquals(
2,
count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'ars org'))
1,
count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'publishing media'))
);
-
+
$this->assertEquals(
1,
count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, 'mercurial w3c'))
);
-
+
$this->assertEquals(
3,
count(self::$linkFilter->filter(LinkFilter::$FILTER_TEXT, '"free software"'))
'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) {
$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) {
$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) {
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()
{
$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']
+ );
}
/**
$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];
$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']);
}
\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']);
\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'])
+ );
}
/**