mirror of
https://github.com/wallabag/wallabag.git
synced 2024-12-25 00:50:29 +00:00
Merge branch 'dev' into emded-dependencies
This commit is contained in:
commit
20f00edd15
4 changed files with 101 additions and 2 deletions
|
@ -108,8 +108,8 @@ class Database {
|
||||||
public function updatePassword($userId, $password)
|
public function updatePassword($userId, $password)
|
||||||
{
|
{
|
||||||
$sql_update = "UPDATE users SET password=? WHERE id=?";
|
$sql_update = "UPDATE users SET password=? WHERE id=?";
|
||||||
$params_update = array($password, $id);
|
$params_update = array($password, $userId);
|
||||||
$this->updateUserConfig($userId, 'password', $password);
|
$query = $this->executeQuery($sql_update, $params_update);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateUserConfig($userId, $key, $value) {
|
public function updateUserConfig($userId, $key, $value) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ class Poche
|
||||||
public $pagination;
|
public $pagination;
|
||||||
|
|
||||||
private $currentTheme = '';
|
private $currentTheme = '';
|
||||||
|
private $currentLanguage = '';
|
||||||
private $notInstalledMessage = array();
|
private $notInstalledMessage = array();
|
||||||
|
|
||||||
# @todo make this dynamic (actually install themes and save them in the database including author information et cetera)
|
# @todo make this dynamic (actually install themes and save them in the database including author information et cetera)
|
||||||
|
@ -83,6 +84,15 @@ class Poche
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->currentTheme = $themeDirectory;
|
$this->currentTheme = $themeDirectory;
|
||||||
|
|
||||||
|
# Set up language
|
||||||
|
$languageDirectory = $this->user->getConfigValue('language');
|
||||||
|
|
||||||
|
if ($languageDirectory === false) {
|
||||||
|
$languageDirectory = DEFAULT_THEME;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->currentLanguage = $languageDirectory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function configFileIsAvailable() {
|
public function configFileIsAvailable() {
|
||||||
|
@ -253,6 +263,10 @@ class Poche
|
||||||
public function getTheme() {
|
public function getTheme() {
|
||||||
return $this->currentTheme;
|
return $this->currentTheme;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getLanguage() {
|
||||||
|
return $this->currentLanguage;
|
||||||
|
}
|
||||||
|
|
||||||
public function getInstalledThemes() {
|
public function getInstalledThemes() {
|
||||||
$handle = opendir(THEME);
|
$handle = opendir(THEME);
|
||||||
|
@ -277,6 +291,29 @@ class Poche
|
||||||
return $themes;
|
return $themes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getInstalledLanguages() {
|
||||||
|
$handle = opendir(LOCALE);
|
||||||
|
$languages = array();
|
||||||
|
|
||||||
|
while (($language = readdir($handle)) !== false) {
|
||||||
|
# Languages are stored in a directory, so all directory names are languages
|
||||||
|
# @todo move language installation data to database
|
||||||
|
if (! is_dir(LOCALE . '/' . $language) || in_array($language, array('..', '.'))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$current = false;
|
||||||
|
|
||||||
|
if ($language === $this->getLanguage()) {
|
||||||
|
$current = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
$languages[] = array('name' => $language, 'current' => $current);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $languages;
|
||||||
|
}
|
||||||
|
|
||||||
public function getDefaultConfig()
|
public function getDefaultConfig()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
|
@ -369,8 +406,10 @@ class Poche
|
||||||
$compare_dev = version_compare(POCHE, $dev);
|
$compare_dev = version_compare(POCHE, $dev);
|
||||||
$compare_prod = version_compare(POCHE, $prod);
|
$compare_prod = version_compare(POCHE, $prod);
|
||||||
$themes = $this->getInstalledThemes();
|
$themes = $this->getInstalledThemes();
|
||||||
|
$languages = $this->getInstalledLanguages();
|
||||||
$tpl_vars = array(
|
$tpl_vars = array(
|
||||||
'themes' => $themes,
|
'themes' => $themes,
|
||||||
|
'languages' => $languages,
|
||||||
'dev' => $dev,
|
'dev' => $dev,
|
||||||
'prod' => $prod,
|
'prod' => $prod,
|
||||||
'compare_dev' => $compare_dev,
|
'compare_dev' => $compare_dev,
|
||||||
|
@ -495,6 +534,44 @@ class Poche
|
||||||
Tools::redirect('?view=config');
|
Tools::redirect('?view=config');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateLanguage()
|
||||||
|
{
|
||||||
|
# no data
|
||||||
|
if (empty($_POST['language'])) {
|
||||||
|
}
|
||||||
|
|
||||||
|
# we are not going to change it to the current language...
|
||||||
|
if ($_POST['language'] == $this->getLanguage()) {
|
||||||
|
$this->messages->add('w', _('still using the "' . $this->getLanguage() . '" language!'));
|
||||||
|
Tools::redirect('?view=config');
|
||||||
|
}
|
||||||
|
|
||||||
|
$languages = $this->getInstalledLanguages();
|
||||||
|
$actualLanguage = false;
|
||||||
|
|
||||||
|
foreach ($languages as $language) {
|
||||||
|
if ($language['name'] == $_POST['language']) {
|
||||||
|
$actualLanguage = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $actualLanguage) {
|
||||||
|
$this->messages->add('e', _('that language does not seem to be installed'));
|
||||||
|
Tools::redirect('?view=config');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->store->updateUserConfig($this->user->getId(), 'language', $_POST['language']);
|
||||||
|
$this->messages->add('s', _('you have changed your language preferences'));
|
||||||
|
|
||||||
|
$currentConfig = $_SESSION['poche_user']->config;
|
||||||
|
$currentConfig['language'] = $_POST['language'];
|
||||||
|
|
||||||
|
$_SESSION['poche_user']->setConfig($currentConfig);
|
||||||
|
|
||||||
|
Tools::redirect('?view=config');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* checks if login & password are correct and save the user in session.
|
* checks if login & password are correct and save the user in session.
|
||||||
* it redirects the user to the $referer link
|
* it redirects the user to the $referer link
|
||||||
|
|
|
@ -67,7 +67,10 @@ if (isset($_GET['login'])) {
|
||||||
$poche->export();
|
$poche->export();
|
||||||
} elseif (isset($_GET['updatetheme'])) {
|
} elseif (isset($_GET['updatetheme'])) {
|
||||||
$poche->updateTheme();
|
$poche->updateTheme();
|
||||||
|
} elseif (isset($_GET['updatelanguage'])) {
|
||||||
|
$poche->updateLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) {
|
elseif (isset($_GET['plainurl']) && !empty($_GET['plainurl'])) {
|
||||||
$plain_url = new Url(base64_encode($_GET['plainurl']));
|
$plain_url = new Url(base64_encode($_GET['plainurl']));
|
||||||
$poche->action('add', $plain_url);
|
$poche->action('add', $plain_url);
|
||||||
|
|
|
@ -47,6 +47,25 @@
|
||||||
<input type="hidden" name="token" value="{{ token }}">
|
<input type="hidden" name="token" value="{{ token }}">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<h2>{% trans "Change your language" %}</h2>
|
||||||
|
<form method="post" action="?updatelanguage" name="changelanguageform">
|
||||||
|
<fieldset class="w500p">
|
||||||
|
<div class="row">
|
||||||
|
<label class="col w150p" for="language">{% trans "Language:" %}</label>
|
||||||
|
<select class="col" id="language" name="language">
|
||||||
|
{% for language in languages %}
|
||||||
|
<option value="{{ language.name }}" {{ language.current ? 'selected' : '' }}>{{ language.name }}</option>
|
||||||
|
{% endfor %}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="row mts txtcenter">
|
||||||
|
<button class="bouton" type="submit" tabindex="4">{% trans "Update" %}</button>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
<input type="hidden" name="returnurl" value="{{ referer }}">
|
||||||
|
<input type="hidden" name="token" value="{{ token }}">
|
||||||
|
</form>
|
||||||
|
|
||||||
<h2>{% trans "Change your password" %}</h2>
|
<h2>{% trans "Change your password" %}</h2>
|
||||||
<form method="post" action="?config" name="loginform">
|
<form method="post" action="?config" name="loginform">
|
||||||
<fieldset class="w500p">
|
<fieldset class="w500p">
|
||||||
|
|
Loading…
Reference in a new issue