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