function plugin_init_themes() { global $PLUGIN_HOOKS; $PLUGIN_HOOKS['csrf_compliant']['themes'] = true; $PLUGIN_HOOKS['change_profile']['themes'] = array('PluginThemesProfile', 'changeProfile'); $plugin = new Plugin(); if ($plugin->isInstalled("themes") && $plugin->isActivated("themes")) { Plugin::registerClass('PluginThemesProfile', array('addtabon' => 'Profile')); Plugin::registerClass('PluginThemesTheme', array('addtabon' => 'Preference')); // Default new css and js file. if (plugin_themes_haveRight('themes', 'w')) { $PLUGIN_HOOKS['menu_entry']["themes"] = "front/themes.php"; $PLUGIN_HOOKS['submenu_entry']['themes']['search'] = 'front/themes.php'; $PLUGIN_HOOKS['submenu_entry']['themes']['add'] = 'front/themes.form.php'; } /*** Search for a default theme to display***/ $activeTheme = new PluginThemesTheme(); $activeTheme->getFromDB(PluginThemesTheme::getUserTheme()); if ($activeTheme->fields['name'] != "GLPI") { $PLUGIN_HOOKS['add_css']['themes'] = 'front/getfile.php?theme_id=' . $activeTheme->fields['id'] . '&type=css&file=' . $activeTheme->fields['name'] . '.css'; $PLUGIN_HOOKS['add_javascript']['themes'] = 'front/getfile.php?theme_id=' . $activeTheme->fields['id'] . '&type=js&file=' . $activeTheme->fields['name'] . '.js'; } } }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. themes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with themes. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ // Original Author of file: Jérôme Ansel <*****@*****.**> // ---------------------------------------------------------------------- include "../../../inc/includes.php"; if (!isset($_GET['theme_id'])) { die; } $t = new PluginThemesTheme(); $t->getFromDB($_GET['theme_id']); if (!isset($_GET['type'])) { $_GET['type'] = 'css'; } if (!isset($_GET['file'])) { die; } if (PluginThemesTheme::canView()) { $t->getFileContent($_GET['type'], $_GET['file']); } else { die; }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. themes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with themes. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ // Original Author of file: Jérôme Ansel <*****@*****.**> // ---------------------------------------------------------------------- include "../../../inc/includes.php"; if (!Session::getLoginUserID()) { die('You need to be logged to use this file.'); } else { if (!isset($_POST['theme_user_selection']) || $_POST['plugin_themes_themes_id'] == 0) { Session::addMessageAfterRedirect(__('You need to choose a theme.', 'themes'), false, ERROR); } else { $choosenTheme = new PluginThemesTheme(); $choosenTheme->getFromDB($_POST['plugin_themes_themes_id']); if ($choosenTheme->setAsUserTheme()) { Session::addMessageAfterRedirect(__('New theme set. You should see it now. Please empty your browser cache.', 'themes'), false, INFO); } else { Session::addMessageAfterRedirect(__('You need to choose a theme.', 'themes'), false, ERROR); } } Html::back(); }
static function showAllThemes() { global $DB, $CFG_GLPI; $t = new PluginThemesTheme(); $allThemes = $t->find(); echo '<table class="tab_glpi" style="margin-bottom:20px;"> <tr> <td> <img src="../../../pics/warning.png"> </td> <td class="icon_consol"> <span class="b">' . __('Setting a theme as default will make this theme visible by all users. If you want to use a theme for your own user, please use your preferences settings.', 'themes') . '</span> </td> </tr> </tbody></table>'; echo "<table class='tab_cadrehov' style='margin-bottom:20px;'>"; echo "<tr>\n <th colspan='6'>" . __('All themes available', 'themes') . "</th>\n </tr>"; echo "<tr>\n <th>" . __('Name', 'themes') . "</th>\n <th>" . __('Version', 'themes') . "</th>\n <th>" . __('Author', 'themes') . "</th>\n <th>" . __('Need javascript', 'themes') . "</th>\n <th>" . __('Screenshot', 'themes') . "</th>"; if (PluginThemesTheme::canCreate()) { echo "<th>Action</th>"; } echo "</tr>"; foreach ($allThemes as $themeDetails) { echo "<tr class='tab_bg_1'>"; /*** Name and Url ***/ echo "<td class='center'>"; if (empty($themeDetails['url'])) { echo $themeDetails['name']; } else { echo "<a title='" . __('Go to the theme website', 'themes') . "' href='" . $themeDetails['url']; echo "'>" . $themeDetails['name'] . "</a>"; } echo "</td>"; /*** version ***/ echo "<td class='center'>" . $themeDetails['version'] . "</td>"; /*** author and mail ***/ echo "<td class='center'>"; if (empty($themeDetails['mail'])) { echo $themeDetails['author']; } else { echo "<a title='" . __('Contact the author', 'themes') . "' href='mailto:" . $themeDetails['mail']; echo "'>" . $themeDetails['author'] . "</a>"; } echo "</td>"; /*** javascript ***/ echo "<td class='center'>"; if ($themeDetails['js']) { echo __('Yes', 'themes'); } else { echo __('No', 'themes'); } echo "</td>"; /*** preview ***/ echo "<td class='center'>"; if ($themeDetails['name'] == "GLPI") { $screenshotPath = $CFG_GLPI['root_doc'] . '/plugins/themes/img/defaultscreenshot.jpg'; $screenshotFile = GLPI_ROOT . '/plugins/themes/img/defaultscreenshot.jpg'; } else { $screenshotFile = PLUGIN_THEMES_UPLOAD_DIR . '/' . $themeDetails['name'] . '/screenshot.jpg'; $screenshotPath = $CFG_GLPI['root_doc'] . "/plugins/themes/front/getfile.php?theme_id=" . $themeDetails['id'] . "&type=img&file=screenshot.jpg"; } if (is_file($screenshotFile)) { echo "<a target='_blank' href='" . $screenshotPath . "'>\n <img src='" . $screenshotPath . "' height='100' /></a>"; } else { echo __('No screenshot available', 'themes'); } echo "</td>"; if (PluginThemesTheme::canCreate()) { /*** Make this theme the default one ***/ echo "<td class='center'>"; if ($themeDetails['active_theme'] == 0) { echo "<a href='?activate=" . $themeDetails['id'] . "'>" . __('Set as default theme', 'themes') . "</a><br /><br />"; } if ($themeDetails['name'] != "GLPI") { echo "<a href='?delete=" . $themeDetails['id'] . "'>" . __('Delete this theme', 'themes') . "</a>"; } echo "</td>"; } echo "</tr>"; } echo "</table>"; echo "<form method='post' action='' enctype=\"multipart/form-data\">"; echo "<table class='tab_cadrehov'><tr><th>"; echo __('Add a new theme', 'themes'); echo "</th></tr><tr><td class='center'>"; echo "<input type='file' name='themeFile' /> "; echo "<input type='submit' class='submit' name='add_theme' value='" . __('Choose', 'themes') . "' />"; echo "</td></tr></table>"; Html::closeForm(); }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. themes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with themes. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ // Original Author of file: Jérôme Ansel <*****@*****.**> // ---------------------------------------------------------------------- include "../../../inc/includes.php"; $t = new PluginThemesTheme(); if (isset($_POST['add_theme'])) { if (!isset($_FILES['themeFile'])) { Session::addMessageAfterRedirect(__('No file provided', 'themes'), false, ERROR); header('location:' . $CFG_GLPI['root_doc'] . '/plugins/themes/front/themes.php'); die; } $zip = zip_open($_FILES["themeFile"]["tmp_name"]); if (is_resource($zip)) { zip_close($zip); $isZipFile = true; } else { $isZipFile = false; } if (!$isZipFile) { Session::addMessageAfterRedirect(__('File need to be in Zip format', 'themes'), false, ERROR);