function theme_selector() { $id = 'select_theme'; $selecteur = ' <form class="' . $formclass . '" id="' . $id . '">' . "\n"; //on cherche tous les dossiers du repertoire themes et des sous dossier styles et squelettes, et on les range dans le tableau $wakkaConfig['templates'] $repertoire_initial = 'tools' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'themes'; $GLOBALS['wiki']->config['templates'] = search_template_files($repertoire_initial); //s'il y a un repertoire themes a la racine, on va aussi chercher les templates dedans if (is_dir('themes')) { $repertoire_racine = 'themes'; $GLOBALS['wiki']->config['templates'] = array_merge($GLOBALS['wiki']->config['templates'], search_template_files($repertoire_racine)); if (is_array($GLOBALS['wiki']->config['templates'])) { ksort($GLOBALS['wiki']->config['templates']); } } $selecteur .= ' <div class="control-group form-group">' . "\n" . ' <label class="control-label col-lg-4">' . _t('TEMPLATE_THEME') . '</label>' . "\n" . ' <div class="controls col-lg-7">' . "\n" . ' <select class="form-control" id="changetheme" name="theme_select">' . "\n"; foreach (array_keys($GLOBALS['wiki']->config['templates']) as $key => $value) { $selecteur .= ' <option value="' . $value . '">' . $value . '</option>' . "\n"; } $selecteur .= ' </select>' . "\n" . ' </div>' . "\n" . ' </div>' . "\n"; $selecteur .= ' <div class="control-group form-group">' . "\n" . ' <label class="control-label col-lg-4">' . _t('TEMPLATE_SQUELETTE') . '</label>' . "\n" . ' <div class="controls col-lg-7">' . "\n" . ' <select class="form-control" id="changesquelette" name="squelette_select">' . "\n"; ksort($GLOBALS['wiki']->config['templates'][$GLOBALS['wiki']->config['favorite_theme']]['squelette']); foreach ($GLOBALS['wiki']->config['templates'][$GLOBALS['wiki']->config['favorite_theme']]['squelette'] as $key => $value) { $selecteur .= ' <option value="' . $key . '">' . $value . '</option>' . "\n"; } $selecteur .= ' </select>' . "\n" . ' </div>' . "\n" . ' </div>' . "\n"; ksort($GLOBALS['wiki']->config['templates'][$GLOBALS['wiki']->config['favorite_theme']]['style']); $selecteur .= ' <div class="control-group form-group">' . "\n" . ' <label class="control-label col-lg-4">' . _t('TEMPLATE_STYLE') . '</label>' . "\n" . ' <div class="controls col-lg-7">' . "\n" . ' <select class="form-control" id="changestyle" name="style_select">' . "\n"; foreach ($GLOBALS['wiki']->config['templates'][$GLOBALS['wiki']->config['favorite_theme']]['style'] as $key => $value) { $selecteur .= ' <option value="' . $key . '">' . $value . '</option>' . "\n"; } $selecteur .= ' </select>' . "\n" . ' </div>' . "\n" . ' </div>' . "\n"; // $selecteur .= '</form>'."\n"; $GLOBALS['js'] = (isset($GLOBALS['js']) ? $GLOBALS['js'] : '') . add_templates_list_js() . "\n"; $GLOBALS['js'] = (isset($GLOBALS['js']) ? $GLOBALS['js'] : '') . add_change_theme_js() . "\n"; return $selecteur; }
function show_form_theme_selector($mode = 'selector', $formclass = 'form-horizontal') { // en mode edition on recupere aussi les images de fond if ($mode == 'edit') { $id = 'form_graphical_options'; // recuperation des images de fond $backgroundsdir = 'files/backgrounds'; $dir = is_dir($backgroundsdir) ? opendir($backgroundsdir) : false; while ($dir && ($file = readdir($dir)) !== false) { $imgextension = strtolower(substr($file, -4, 4)); // les jpg sont les fonds d'ecrans, ils doivent etre mis en miniature if ($imgextension == '.jpg') { if (!is_file($backgroundsdir . '/thumbs/' . $file)) { require_once 'tools/attach/libs/class.imagetransform.php'; $imgTrans = new imageTransform(); $imgTrans->sourceFile = $backgroundsdir . '/' . $file; $imgTrans->targetFile = $backgroundsdir . '/thumbs/' . $file; $imgTrans->resizeToWidth = 100; $imgTrans->resizeToHeight = 75; if ($imgTrans->resize()) { $backgrounds[] = $imgTrans->targetFile; } } else { $backgrounds[] = $backgroundsdir . '/thumbs/' . $file; } } elseif ($imgextension == '.png') { $backgrounds[] = $backgroundsdir . '/' . $file; } } if ($dir) { closedir($dir); } $bgselector = ''; if (isset($backgrounds) && is_array($backgrounds)) { $bgselector .= '<h3>' . _t('TEMPLATE_BG_IMAGE') . '</h3> <div id="bgCarousel" class="carousel" data-interval="5000" data-pause="true"> <!-- Carousel items --> <div class="carousel-inner">' . "\n"; $nb = 0; $thumbs_per_slide = 8; $firstitem = true; sort($backgrounds); foreach ($backgrounds as $background) { $nb++; if ($nb == 1) { $bgselectorlist = ''; $class = ''; } // dans le cas ou il n'y a pas d'image de fond selectionnee on bloque la premiere diapo if ($GLOBALS['wiki']->config['favorite_background_image'] == '' && $firstitem) { $class = ' active'; $firstitem = false; } $choosen = $background == 'files/backgrounds/' . $GLOBALS['wiki']->config['favorite_background_image']; if ($choosen) { $class = ' active'; } $imgextension = strtolower(substr($background, -4, 4)); if ($imgextension == '.jpg') { $bgselectorlist .= '<img class="bgimg' . ($choosen ? ' choosen' : '') . '" src="' . $background . '" width="100" height="75" />' . "\n"; } elseif ($imgextension == '.png') { $bgselectorlist .= '<div class="mozaicimg' . ($choosen ? ' choosen' : '') . '" style="background:url(' . $background . ') repeat top left;"></div>' . "\n"; } // on finit la diapositive if ($nb == $thumbs_per_slide) { $nb = 0; $bgselector .= '<div class="item' . $class . '">' . "\n" . $bgselectorlist . '</div>' . "\n"; } } // si la boucle se termine et qu'on ne vient pas de finir une diapositive if ($nb != 0) { $bgselector .= '<div class="item' . $class . '">' . "\n" . $bgselectorlist . '</div>' . "\n"; } $bgselector .= '</div> <!-- Carousel nav --> <a class="carousel-control left" href="#bgCarousel" data-slide="prev">‹</a> <a class="carousel-control right" href="#bgCarousel" data-slide="next">›</a> </div>' . "\n"; } } else { $id = 'form_theme_selector'; $bgselector = ''; } $selecteur = ' <form class="' . $formclass . '" id="' . $id . '">' . "\n"; //on cherche tous les dossiers du repertoire themes et des sous dossier styles et squelettes, et on les range dans le tableau $wakkaConfig['templates'] $repertoire_initial = 'tools' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'themes'; $GLOBALS['wiki']->config['templates'] = search_template_files($repertoire_initial); //s'il y a un repertoire themes a la racine, on va aussi chercher les templates dedans if (is_dir('themes')) { $repertoire_racine = 'themes'; $GLOBALS['wiki']->config['templates'] = array_merge($GLOBALS['wiki']->config['templates'], search_template_files($repertoire_racine)); if (is_array($GLOBALS['wiki']->config['templates'])) { ksort($GLOBALS['wiki']->config['templates']); } } $selecteur .= ' <div class="control-group form-group">' . "\n" . ' <label class="control-label col-lg-4">' . _t('TEMPLATE_THEME') . '</label>' . "\n" . ' <div class="controls col-lg-7">' . "\n" . ' <select class="form-control" id="changetheme" name="theme">' . "\n"; foreach (array_keys($GLOBALS['wiki']->config['templates']) as $key => $value) { if ($value !== $GLOBALS['wiki']->config['favorite_theme']) { $selecteur .= ' <option value="' . $value . '">' . $value . '</option>' . "\n"; } else { $selecteur .= ' <option value="' . $value . '" selected="selected">' . $value . '</option>' . "\n"; } } $selecteur .= ' </select>' . "\n" . ' </div>' . "\n" . ' </div>' . "\n"; $selecteur .= ' <div class="control-group form-group">' . "\n" . ' <label class="control-label col-lg-4">' . _t('TEMPLATE_SQUELETTE') . '</label>' . "\n" . ' <div class="controls col-lg-7">' . "\n" . ' <select class="form-control" id="changesquelette" name="squelette">' . "\n"; ksort($GLOBALS['wiki']->config['templates'][$GLOBALS['wiki']->config['favorite_theme']]['squelette']); foreach ($GLOBALS['wiki']->config['templates'][$GLOBALS['wiki']->config['favorite_theme']]['squelette'] as $key => $value) { if ($value !== $GLOBALS['wiki']->config['favorite_squelette']) { $selecteur .= ' <option value="' . $key . '">' . $value . '</option>' . "\n"; } else { $selecteur .= ' <option value="' . $GLOBALS['wiki']->config['favorite_squelette'] . '" selected="selected">' . $value . '</option>' . "\n"; } } $selecteur .= ' </select>' . "\n" . ' </div>' . "\n" . ' </div>' . "\n"; ksort($GLOBALS['wiki']->config['templates'][$GLOBALS['wiki']->config['favorite_theme']]['style']); $selecteur .= ' <div class="control-group form-group">' . "\n" . ' <label class="control-label col-lg-4">' . _t('TEMPLATE_STYLE') . '</label>' . "\n" . ' <div class="controls col-lg-7">' . "\n" . ' <select class="form-control" id="changestyle" name="style">' . "\n"; foreach ($GLOBALS['wiki']->config['templates'][$GLOBALS['wiki']->config['favorite_theme']]['style'] as $key => $value) { if ($value !== $GLOBALS['wiki']->config['favorite_style']) { $selecteur .= ' <option value="' . $key . '">' . $value . '</option>' . "\n"; } else { $selecteur .= ' <option value="' . $GLOBALS['wiki']->config['favorite_style'] . '" selected="selected">' . $value . '</option>' . "\n"; } } $selecteur .= ' </select>' . "\n" . ' </div>' . "\n" . ' </div>' . "\n" . $bgselector . "\n"; if ($mode == 'edit') { $selecteur .= ' <div class="panel-group accordion" id="accordion-avanced-page-settings"> <div class="panel panel-default accordion-group"> <div class="panel-heading accordion-heading"> <h4 class="panel-title accordion-trigger" data-parent="#accordion-avanced-page-settings" href="#avanced-page-settings" data-target="#avanced-page-settings" data-toggle="collapse" title="' . _t('SEE_THE_ADVANCED_PARAMETERS') . '">' . _t('ADVANCED_PARAMETERS') . '</h4> </div> <div id="avanced-page-settings" class="panel-collapse accordion-body collapse"> <div class="panel-body accordion-inner"> <div class="control-group form-group"> <label class="control-label col-lg-4">' . _t('PAGE_LANGUAGE') . '</label> <div class="controls col-lg-7"> <select class="form-control" name="lang">' . "\n"; // choice of language foreach ($GLOBALS['available_languages'] as $value) { $selecteur .= " <option value=\"" . $value . "\"" . ($value == $GLOBALS['prefered_language'] ? ' selected="selected"' : '') . ">" . ucfirst(htmlentities($GLOBALS['languages_list'][$value]['nativeName'], ENT_COMPAT | ENT_HTML401, 'UTF-8')) . "</option>\n"; } $selecteur .= ' </select> </div> </div>' . "\n"; $tablistWikinames = $GLOBALS['wiki']->LoadAll('SELECT DISTINCT tag FROM ' . $GLOBALS['wiki']->GetConfigValue('table_prefix') . 'pages WHERE latest="Y"'); foreach ($tablistWikinames as $tag) { $listWikinames[] = $tag['tag']; } $listWikinames = '["' . implode('","', $listWikinames) . '"]'; $selecteur .= ' <fieldset> <legend>' . _t('CHOOSE_PAGE_FOR') . ' : </legend> <div class="control-group form-group"> <label class="control-label col-lg-4">' . _t('HORIZONTAL_MENU_PAGE') . '</label> <div class="controls col-lg-7"> <input class="form-control" type="text" autocomplete="off" name="PageMenuHaut" data-provide="typeahead" data-items="5" data-source=\'' . $listWikinames . '\' value="' . (isset($GLOBALS['wiki']->page["metadatas"]['PageMenuHaut']) ? $GLOBALS['wiki']->page["metadatas"]['PageMenuHaut'] : 'PageMenuHaut') . '" /> </div> </div>' . "\n"; $selecteur .= ' <div class="control-group form-group"> <label class="control-label col-lg-4">' . _t('FAST_ACCESS_RIGHT_PAGE') . '</label> <div class="controls col-lg-7"> <input class="form-control" type="text" autocomplete="off" name="PageRapideHaut" data-provide="typeahead" data-items="5" data-source=\'' . $listWikinames . '\' value="' . (isset($GLOBALS['wiki']->page["metadatas"]['PageRapideHaut']) ? $GLOBALS['wiki']->page["metadatas"]['PageRapideHaut'] : 'PageRapideHaut') . '" /> </div> </div>' . "\n"; $selecteur .= ' <div class="control-group form-group"> <label class="control-label col-lg-4">' . _t('HEADER_PAGE') . '</label> <div class="controls col-lg-7"> <input class="form-control" type="text" autocomplete="off" name="PageHeader" data-provide="typeahead" data-items="5" data-source=\'' . $listWikinames . '\' value="' . (isset($GLOBALS['wiki']->page["metadatas"]['PageHeader']) ? $GLOBALS['wiki']->page["metadatas"]['PageHeader'] : 'PageHeader') . '" /> </div> </div>' . "\n"; $selecteur .= ' <div class="control-group form-group"> <label class="control-label col-lg-4">' . _t('FOOTER_PAGE') . '</label> <div class="controls col-lg-7"> <input class="form-control" type="text" autocomplete="off" name="PageFooter" data-provide="typeahead" data-items="5" data-source=\'' . $listWikinames . '\' value="' . (isset($GLOBALS['wiki']->page["metadatas"]['PageFooter']) ? $GLOBALS['wiki']->page["metadatas"]['PageFooter'] : 'PageFooter') . '" /> </div> </div>' . "\n"; $selecteur .= ' <div class="control-group form-group"> <label class="control-label col-lg-4">' . _t('VERTICAL_MENU_PAGE') . '</label> <div class="controls col-lg-7"> <input class="form-control" type="text" autocomplete="off" name="PageMenu" data-provide="typeahead" data-items="5" data-source=\'' . $listWikinames . '\' value="' . (isset($GLOBALS['wiki']->page["metadatas"]['PageMenu']) ? $GLOBALS['wiki']->page["metadatas"]['PageMenu'] : 'PageMenu') . '" /> </div> </div>' . "\n"; $selecteur .= ' <div class="control-group form-group"> <label class="control-label col-lg-4">' . _t('RIGHT_COLUMN_PAGE') . '</label> <div class="controls col-lg-7"> <input class="form-control" type="text" autocomplete="off" name="PageColonneDroite" data-provide="typeahead" data-items="5" data-source=\'' . $listWikinames . '\' value="' . (isset($GLOBALS['wiki']->page["metadatas"]['PageColonneDroite']) ? $GLOBALS['wiki']->page["metadatas"]['PageColonneDroite'] : 'PageColonneDroite') . '" /> </div> </div>' . "\n" . '</fieldset> </div> </div> </div> </div> <!-- /#avanced-page-settings -->'; } $selecteur .= '</form>' . "\n"; $GLOBALS['js'] = (isset($GLOBALS['js']) ? $GLOBALS['js'] : '') . add_templates_list_js() . "\n"; return $selecteur; }
//squelette par défaut define('SQUELETTE_PAR_DEFAUT', isset($wakkaConfig['favorite_squelette']) ? $wakkaConfig['favorite_squelette'] : 'yeswiki.tpl.html'); //pour que seul le propriétaire et l'admin puissent changer de theme define('SEUL_ADMIN_ET_PROPRIO_CHANGENT_THEME', true); // Desactivation de l'extension template si l'extension navigation est presente et active. if (isset($plugins_list['navigation'])) { unset($k); return; } //on cherche tous les dossiers du repertoire themes et des sous dossier styles et squelettes, et on les range dans le tableau $wakkaConfig['templates'] $repertoire_initial = 'tools' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'themes'; $wakkaConfig['templates'] = search_template_files($repertoire_initial); //s'il y a un repertoire themes a la racine, on va aussi chercher les templates dedans if (is_dir('themes')) { $repertoire_racine = 'themes'; $wakkaConfig['templates'] = array_merge($wakkaConfig['templates'], search_template_files($repertoire_racine)); if (is_array($wakkaConfig['templates'])) { ksort($wakkaConfig['templates']); } } //si le theme est passé en paramètre, on l'utilise //=======Changer de theme================================================================================================= if (isset($_REQUEST['theme']) && array_key_exists($_REQUEST['theme'], $wakkaConfig['templates'])) { $wakkaConfig['favorite_theme'] = $_REQUEST['theme']; } else { $wakkaConfig['favorite_theme'] = THEME_PAR_DEFAUT; } //=======Changer de style===================================================================================================== $styles['none'] = 'pas de style'; if (isset($_REQUEST['style']) && array_key_exists($_REQUEST['style'], $wakkaConfig['templates'][$wakkaConfig['favorite_theme']]['style'])) { $wakkaConfig['favorite_style'] = $_REQUEST['style'];