Commit daa7d1cc authored by Adrien Dorsaz's avatar Adrien Dorsaz

Merge branch 'themeswitcher'

parents 303a41c4 cb940330
{
"P_THEMESWITCHER_SWITCH_THEME":"Switch theme",
"P_THEMESWITCHER_SAVE":"Save",
"P_THEMESWITCHER_NOWRITE_ERROR":"It seems you don't have permission to write the constant.php file. Please, run the command <code>chmod 664 constant.php</code>",
"P_THEMESWITCHER_CONNECTION_ERROR":"You have to be logged to do this action"
}
{
"P_THEMESWITCHER_SWITCH_THEME":"Changer de thème",
"P_THEMESWITCHER_SAVE":"Enregistrer",
"P_THEMESWITCHER_NOWRITE_ERROR":"Vous ne devez pas avoir les droits d'écriture sur le fichier constant.php. Effectuez un <code>chmod 664 constant.php</code>",
"P_THEMESWITCHER_CONNECTION_ERROR":"Vous devez être connecté pour cette action"
}
......@@ -4,12 +4,12 @@
@author Simounet <contact@simounet.net>
@link http://www.simounet.net
@licence CC BY-SA
@version 1.0.0
@version 1.0.1
@description Le plugin ThemeSwitcher permet de changer de thème via la page de gestion.
*/
function themeswitcher_plugin_AddLink_and_Save(){
echo '<li><a class="toggle" href="#themeSwitcher">Changer de thème</a></li>';
echo '<li><a class="toggle" href="#themeSwitcher">'._t('P_THEMESWITCHER_SWITCH_THEME').'</a></li>';
if(isset($_POST['themeSelected'])){
themeswitcher_plugin_change();
}
......@@ -20,27 +20,30 @@ function themeswitcher_plugin_AddForm(){
echo '
<section class="themeSwitcher" id="themeSwitcher" name="themeSwitcher">
<form action="settings.php" method="post">
<h2>Changer de thème :</h2>
<h2>'._t('P_THEMESWITCHER_SWITCH_THEME').'</h2>
<select name="themeSelected" id="themeSelected">';
foreach($themes as $theme){
echo '<option value="'.$theme.'">'.$theme.'</option>';
}
echo '
</select>
<button class="buttonThemeSwitcher" type="submit">Enregistrer</button>
<button class="buttonThemeSwitcher" type="submit">'._t('P_THEMESWITCHER_SAVE').'</button>
</form>
</section>
';
}
function themeswitcher_plugin_change(){
$myUser = (isset($_SESSION['currentUser'])?unserialize($_SESSION['currentUser']):false);
if($myUser===false) exit(_t('P_THEMESWITCHER_CONNECTION_ERROR'));
$fileName = 'constant.php';
$searchfor = 'marigolds';
$file = file_get_contents($fileName);
$result = preg_replace("/'DEFAULT_THEME',(.?)'(.*)'/", "'DEFAULT_THEME','".$_POST['themeSelected']."'", $file);
$put = file_put_contents($fileName, $result);
if(!$put){
echo "Vous ne devez pas avoir les droits d'écriture sur le fichier constant.php. Effectuez un <code>chmod 664 constant.php</code>";
echo _t('P_THEMESWITCHER_NOWRITE_ERROR');
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment