- Release archives now have the same structure as GitHub-generated archives:
- archives contain a `Shaarli` directory, itself containing sources + dependencies
- the tarball is now gzipped
+- Minor code cleanup: PHPDoc, spelling, unused variables, etc.
### Fixed
- Fix the server `<self>` value in Atom/RSS feeds
*
* The code is read from the raw content of the version file on the Git server.
*
+ * @param string $url URL to reach to get the latest version.
+ * @param int $timeout Timeout to check the URL (in seconds).
+ *
* @return mixed the version code from the repository if available, else 'false'
*/
public static function getLatestGitVersionCode($url, $timeout=2)
* @param int $checkInterval the minimum interval between update checks (in seconds
* @param bool $enableCheck whether to check for new versions
* @param bool $isLoggedIn whether the user is logged in
+ * @param string $branch check update for the given branch
*
* @throws Exception an invalid branch has been set for update checks
*
}
}
- // Check cache and data directories are readable and writeable
+ // Check cache and data directories are readable and writable
foreach (array(
$conf->get('resource.thumbnails_cache'),
$conf->get('resource.data_dir'),
}
}
- // Check configuration files are readable and writeable
+ // Check configuration files are readable and writable
foreach (array(
$conf->getConfigFileExt(),
$conf->get('resource.datastore'),
/**
* Returns the cached version of a page, if it exists and should be cached
*
- * @return a cached version of the page if it exists, null otherwise
+ * @return string a cached version of the page if it exists, null otherwise
*/
public function cachedVersion()
{
/**
* Count private links in given linklist.
*
- * @param array $links Linklist.
+ * @param array|Countable $links Linklist.
*
* @return int Number of private links.
*/
*
* @param string $description shaare's description.
* @param string $redirector if a redirector is set, use it to gerenate links.
+ * @param string $indexUrl URL to Shaarli's index.
*
* @return string formatted description.
*/
* Imports Web bookmarks from an uploaded Netscape bookmark dump
*
* @param array $post Server $_POST parameters
- * @param array $file Server $_FILES parameters
+ * @param array $files Server $_FILES parameters
* @param LinkDB $linkDb Loaded LinkDB instance
* @param string $pagecache Page cache
*
* Example: preselect Europe/Paris
* list($htmlform, $js) = generateTimeZoneForm('Europe/Paris');
*
- * @param string $preselected_timezone preselected timezone (optional)
+ * @param string $preselectedTimezone preselected timezone (optional)
*
- * @return an array containing the generated HTML form and Javascript code
+ * @return array containing the generated HTML form and Javascript code
**/
function generateTimeZoneForm($preselectedTimezone='')
{
$pcity = substr($preselectedTimezone, $spos+1);
}
- // Display config form:
- $timezoneForm = '';
- $timezoneJs = '';
-
// The list is in the form 'Europe/Paris', 'America/Argentina/Buenos_Aires'
// We split the list in continents/cities.
$continents = array();
* @param string $continent the timezone continent
* @param string $city the timezone city
*
- * @return whether continent/city is a valid timezone
+ * @return bool whether continent/city is a valid timezone
*/
function isTimeZoneValid($continent, $city)
{
*
* @param array $doneUpdates Updates which are already done.
* @param LinkDB $linkDB LinkDB instance.
- * @oaram ConfigManager $conf Configuration Manager instance.
+ * @param ConfigManager $conf Configuration Manager instance.
* @param boolean $isLoggedIn True if the user is logged in.
*/
public function __construct($doneUpdates, $linkDB, $conf, $isLoggedIn)
{
return $url . (!endsWith($url, '/') ? '/' : '');
}
-/**
- * Converts an URL with an IDN host to a ASCII one.
- *
- * @param string $url Input URL.
- *
- * @return string converted URL.
- */
-function url_with_idn_to_ascii($url)
-{
- $parts = parse_url($url);
- $parts['host'] = idn_to_ascii($parts['host']);
- $httpUrl = new \http\Url($parts);
- return $httpUrl->toString();
-}
/**
* URL representation and cleanup utilities
*
*
* In Shaarli, they are used as a tinyurl-like link to individual entries,
* e.g. smallHash('20111006_131924') --> yZH23w
+ *
+ * @param string $text Create a hash from this text.
+ *
+ * @return string generated small hash.
*/
function smallHash($text)
{
}
/**
- * Link sanitization before templating
+ * Sanitize link before rendering.
+ *
+ * @param array $link Link to escape.
*/
function sanitizeLink(&$link)
{
$data = json_decode($data, true);
if ($data === null) {
$error = json_last_error();
- throw new Exception('An error occured while parsing JSON file: error code #'. $error);
+ throw new Exception('An error occurred while parsing JSON file: error code #'. $error);
}
return $data;
}
/**
* Constructor.
+ *
+ * @param string $configFile Configuration file path without extension.
*/
public function __construct($configFile = 'data/config')
{
$absurl = escape(index_url($_SERVER).'?do=daily&day='.$day); // Absolute URL of the corresponding "Daily" page.
// Build the HTML body of this RSS entry.
- $html = '';
- $href = '';
$links = array();
// We pre-format some fields for proper output.
// Get only links which have a thumbnail.
foreach($links as $link)
{
- $permalink='?'.escape(smallhash($link['linkdate']));
+ $permalink='?'.escape(smallHash($link['linkdate']));
$thumb=lazyThumbnail($conf, $link['url'],$permalink);
if ($thumb!='') // Only output links which have a thumbnail.
{
$maxcount = max($maxcount, $value);
}
- // Sort tags alphabetically: case insensitive, support locale if avalaible.
+ // Sort tags alphabetically: case insensitive, support locale if available.
uksort($tags, function($a, $b) {
// Collator is part of PHP intl.
if (class_exists('Collator')) {
$next_page_url = '?page=' . ($page-1) . $searchtermUrl . $searchtagsUrl;
}
- $token = isLoggedIn() ? getToken($conf) : '';
-
// Fill all template fields.
$data = array(
'previous_page_url' => $previous_page_url,
* Read a non existent config file -> empty array.
*
* @expectedException Exception
- * @expectedExceptionMessage An error occured while parsing JSON file: error code #4
+ * @expectedExceptionMessage An error occurred while parsing JSON file: error code #4
*/
public function testReadInvalidJson()
{