Commit daa7d1cc authored by Adrien Dorsaz's avatar Adrien Dorsaz

Merge branch 'themeswitcher'

parents 303a41c4 cb940330
"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_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 <>
@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>';
......@@ -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>
<select name="themeSelected" id="themeSelected">';
foreach($themes as $theme){
echo '<option value="'.$theme.'">'.$theme.'</option>';
echo '
<button class="buttonThemeSwitcher" type="submit">Enregistrer</button>
<button class="buttonThemeSwitcher" type="submit">'._t('P_THEMESWITCHER_SAVE').'</button>
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);
echo "Vous ne devez pas avoir les droits d'écriture sur le fichier constant.php. Effectuez un <code>chmod 664 constant.php</code>";
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