| 1 | <?php |
|---|
| 2 | # -- BEGIN LICENSE BLOCK --------------------------------------- |
|---|
| 3 | # |
|---|
| 4 | # This file is part of Dotclear 2. |
|---|
| 5 | # |
|---|
| 6 | # Copyright (c) 2003-2013 Olivier Meunier & Association Dotclear |
|---|
| 7 | # Licensed under the GPL version 2.0 license. |
|---|
| 8 | # See LICENSE file or |
|---|
| 9 | # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html |
|---|
| 10 | # |
|---|
| 11 | # -- END LICENSE BLOCK ----------------------------------------- |
|---|
| 12 | |
|---|
| 13 | require dirname(__FILE__).'/../inc/admin/prepend.php'; |
|---|
| 14 | |
|---|
| 15 | dcPage::check('admin'); |
|---|
| 16 | |
|---|
| 17 | # -------------------------------------------------- |
|---|
| 18 | # @todo Add settings to Dotclear update features |
|---|
| 19 | if ($core->blog->settings->system->repository_theme_url === null) { |
|---|
| 20 | $core->blog->settings->system->put( |
|---|
| 21 | 'repository_theme_url', 'http://update.dotaddict.org/dc2/themes.xml', 'string', 'Themes XML feed location', true, true |
|---|
| 22 | ); |
|---|
| 23 | } |
|---|
| 24 | # -------------------------------------------------- |
|---|
| 25 | |
|---|
| 26 | # -- Loading themes -- |
|---|
| 27 | $core->themes = new dcThemes($core); |
|---|
| 28 | $core->themes->loadModules($core->blog->themes_path, null); |
|---|
| 29 | |
|---|
| 30 | # -- Repository helper -- |
|---|
| 31 | $repository = new dcRepository( |
|---|
| 32 | $core->themes, |
|---|
| 33 | $core->blog->settings->system->repository_theme_url |
|---|
| 34 | ); |
|---|
| 35 | $repository->check(); |
|---|
| 36 | |
|---|
| 37 | # -- Page helper -- |
|---|
| 38 | $list = new adminThemesList( |
|---|
| 39 | $core, |
|---|
| 40 | $core->blog->themes_path, |
|---|
| 41 | false |
|---|
| 42 | ); |
|---|
| 43 | |
|---|
| 44 | # -- Theme screenshot -- |
|---|
| 45 | if (!empty($_GET['shot']) && $core->themes->moduleExists($_GET['shot'])) |
|---|
| 46 | { |
|---|
| 47 | if (empty($_GET['src'])) { |
|---|
| 48 | $f = $core->blog->themes_path.'/'.$_GET['shot'].'/screenshot.jpg'; |
|---|
| 49 | } else { |
|---|
| 50 | $f = $core->blog->themes_path.'/'.$_GET['shot'].'/'.path::clean($_GET['src']); |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | $f = path::real($f); |
|---|
| 54 | |
|---|
| 55 | if (!file_exists($f)) { |
|---|
| 56 | $f = dirname(__FILE__).'/images/noscreenshot.png'; |
|---|
| 57 | } |
|---|
| 58 | |
|---|
| 59 | http::cache(array_merge(array($f),get_included_files())); |
|---|
| 60 | |
|---|
| 61 | header('Content-Type: '.files::getMimeType($f)); |
|---|
| 62 | header('Content-Length: '.filesize($f)); |
|---|
| 63 | readfile($f); |
|---|
| 64 | |
|---|
| 65 | exit; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | # -- Display module configuration page -- |
|---|
| 69 | if ($list->setConfigurationFile($core->themes, $core->blog->settings->system->theme)) { |
|---|
| 70 | |
|---|
| 71 | # Get content before page headers |
|---|
| 72 | include $list->getConfigurationFile(); |
|---|
| 73 | |
|---|
| 74 | # Gather content |
|---|
| 75 | $list->setConfigurationContent(); |
|---|
| 76 | |
|---|
| 77 | # Display page |
|---|
| 78 | dcPage::open(__('Blog appearance'), |
|---|
| 79 | dcPage::jsPageTabs(). |
|---|
| 80 | dcPage::jsColorPicker(). |
|---|
| 81 | |
|---|
| 82 | # --BEHAVIOR-- themesToolsHeaders |
|---|
| 83 | $core->callBehavior('themesToolsHeaders', $core, true), |
|---|
| 84 | |
|---|
| 85 | dcPage::breadcrumb( |
|---|
| 86 | array( |
|---|
| 87 | html::escapeHTML($core->blog->name) => '', |
|---|
| 88 | __('Blog appearance') => 'blog_theme.php', |
|---|
| 89 | '<span class="page-title">'.__('Theme configuration').'</span>' => '' |
|---|
| 90 | )) |
|---|
| 91 | ); |
|---|
| 92 | |
|---|
| 93 | if (!empty($_GET['done'])){ |
|---|
| 94 | dcPage::success(__('Theme successfully configured.')); |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | # Display previously gathered content |
|---|
| 98 | $list->getConfigurationContent(); |
|---|
| 99 | |
|---|
| 100 | dcPage::close(); |
|---|
| 101 | |
|---|
| 102 | # Stop reading code here |
|---|
| 103 | return; |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | # -- Execute actions -- |
|---|
| 107 | if (!empty($_POST) && empty($_REQUEST['conf']) && $core->auth->isSuperAdmin() && $list->isPathWritable()) { |
|---|
| 108 | try { |
|---|
| 109 | $list->executeAction('themes', $core->themes, $repository); |
|---|
| 110 | } |
|---|
| 111 | catch (Exception $e) { |
|---|
| 112 | $core->error->add($e->getMessage()); |
|---|
| 113 | } |
|---|
| 114 | } |
|---|
| 115 | |
|---|
| 116 | # -- Page header -- |
|---|
| 117 | dcPage::open(__('Themes management'), |
|---|
| 118 | // (!$conf_file ? dcPage::jsLoad('js/_blog_theme.js') : ''). |
|---|
| 119 | dcPage::jsPageTabs(). |
|---|
| 120 | dcPage::jsColorPicker(), |
|---|
| 121 | |
|---|
| 122 | # --BEHAVIOR-- themesToolsHeaders |
|---|
| 123 | $core->callBehavior('themesToolsHeaders', $core, false), |
|---|
| 124 | |
|---|
| 125 | dcPage::breadcrumb( |
|---|
| 126 | array( |
|---|
| 127 | html::escapeHTML($core->blog->name) => '', |
|---|
| 128 | '<span class="page-title">'.__('Blog appearance').'</span>' => '' |
|---|
| 129 | )) |
|---|
| 130 | ); |
|---|
| 131 | |
|---|
| 132 | # -- Succes messages -- |
|---|
| 133 | if (!empty($_GET['msg'])) { |
|---|
| 134 | $list->displayMessage($_GET['msg']); |
|---|
| 135 | } |
|---|
| 136 | |
|---|
| 137 | # -- Display modules lists -- |
|---|
| 138 | if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { |
|---|
| 139 | |
|---|
| 140 | # Updated modules from repo |
|---|
| 141 | $modules = $repository->get(true); |
|---|
| 142 | if (!empty($modules)) { |
|---|
| 143 | echo |
|---|
| 144 | '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update themes')).'">'. |
|---|
| 145 | '<h3>'.html::escapeHTML(__('Update themes')).'</h3>'. |
|---|
| 146 | '<p>'.sprintf( |
|---|
| 147 | __('There is one theme to update available from %2$s.', 'There are %s themes to update available from %s.', count($modules)), |
|---|
| 148 | count($modules), |
|---|
| 149 | '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>' |
|---|
| 150 | ).'</p>'; |
|---|
| 151 | |
|---|
| 152 | $list |
|---|
| 153 | ->newList('theme-update') |
|---|
| 154 | ->setModules($modules) |
|---|
| 155 | ->setPageTab('update') |
|---|
| 156 | ->displayModulesList( |
|---|
| 157 | /*cols */ array('sshot', 'name', 'desc', 'author', 'version', 'current_version', 'parent'), |
|---|
| 158 | /* actions */ array('update') |
|---|
| 159 | ); |
|---|
| 160 | |
|---|
| 161 | echo |
|---|
| 162 | '</div>'; |
|---|
| 163 | } |
|---|
| 164 | } |
|---|
| 165 | |
|---|
| 166 | # List all active plugins |
|---|
| 167 | echo |
|---|
| 168 | '<div class="multi-part" id="themes" title="'.__('Installed themes').'">'; |
|---|
| 169 | |
|---|
| 170 | $modules = $core->themes->getModules(); |
|---|
| 171 | if (!empty($modules)) { |
|---|
| 172 | |
|---|
| 173 | echo |
|---|
| 174 | '<h3>'.__('Activated themes').'</h3>'. |
|---|
| 175 | '<p>'.__('Manage installed themes from this list.').'</p>'; |
|---|
| 176 | |
|---|
| 177 | $list |
|---|
| 178 | ->newList('theme-activate') |
|---|
| 179 | ->setModules($modules) |
|---|
| 180 | ->setPageTab('themes') |
|---|
| 181 | ->displayModulesList( |
|---|
| 182 | /* cols */ array('sshot', 'name', 'config', 'desc', 'author', 'version', 'parent'), |
|---|
| 183 | /* actions */ array('deactivate', 'delete') |
|---|
| 184 | ); |
|---|
| 185 | } |
|---|
| 186 | |
|---|
| 187 | echo |
|---|
| 188 | '</div>'; |
|---|
| 189 | |
|---|
| 190 | if ($core->auth->isSuperAdmin() && $list->isPathWritable()) { |
|---|
| 191 | |
|---|
| 192 | # New modules from repo |
|---|
| 193 | $search = $list->getSearchQuery(); |
|---|
| 194 | $modules = $search ? $repository->search($search) : $repository->get(); |
|---|
| 195 | |
|---|
| 196 | echo |
|---|
| 197 | '<div class="multi-part" id="new" title="'.__('Add themes from Dotaddict').'">'. |
|---|
| 198 | '<h3>'.__('Add themes from Dotaddict repository').'</h3>'; |
|---|
| 199 | |
|---|
| 200 | $list |
|---|
| 201 | ->newList('theme-new') |
|---|
| 202 | ->setModules($modules) |
|---|
| 203 | ->setPageTab('new') |
|---|
| 204 | ->displaySearchForm() |
|---|
| 205 | ->displayNavMenu() |
|---|
| 206 | ->displayModulesList( |
|---|
| 207 | /* cols */ array('expander', 'sshot', 'name', 'config', 'desc', 'author', 'version', 'parent'), |
|---|
| 208 | /* actions */ array('install'), |
|---|
| 209 | /* nav limit */ true |
|---|
| 210 | ); |
|---|
| 211 | |
|---|
| 212 | echo |
|---|
| 213 | '<p class="info vertical-separator">'.sprintf( |
|---|
| 214 | __("Visit %s repository, the resources center for Dotclear."), |
|---|
| 215 | '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>' |
|---|
| 216 | ). |
|---|
| 217 | '</p>'. |
|---|
| 218 | |
|---|
| 219 | '</div>'; |
|---|
| 220 | |
|---|
| 221 | # Add a new plugin |
|---|
| 222 | echo |
|---|
| 223 | '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'; |
|---|
| 224 | |
|---|
| 225 | echo '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>'; |
|---|
| 226 | |
|---|
| 227 | $list->displayManualForm(); |
|---|
| 228 | |
|---|
| 229 | echo |
|---|
| 230 | '</div>'; |
|---|
| 231 | } |
|---|
| 232 | |
|---|
| 233 | dcPage::close(); |
|---|
| 234 | ?> |
|---|