[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 | ); |
---|
[2286] | 34 | adminThemesList::$distributed_modules = explode(',', DC_DISTRIB_THEMES); |
---|
[2171] | 35 | |
---|
| 36 | # -- Theme screenshot -- |
---|
[2215] | 37 | if (!empty($_GET['shot']) && $list->modules->moduleExists($_GET['shot'])) { |
---|
| 38 | |
---|
| 39 | $f= path::real(empty($_GET['src']) ? |
---|
| 40 | $core->blog->themes_path.'/'.$_GET['shot'].'/screenshot.jpg' : |
---|
| 41 | $core->blog->themes_path.'/'.$_GET['shot'].'/'.path::clean($_GET['src']) |
---|
| 42 | ); |
---|
| 43 | |
---|
[0] | 44 | if (!file_exists($f)) { |
---|
| 45 | $f = dirname(__FILE__).'/images/noscreenshot.png'; |
---|
| 46 | } |
---|
[2215] | 47 | |
---|
| 48 | http::cache(array_merge(array($f), get_included_files())); |
---|
| 49 | |
---|
[0] | 50 | header('Content-Type: '.files::getMimeType($f)); |
---|
| 51 | header('Content-Length: '.filesize($f)); |
---|
| 52 | readfile($f); |
---|
[2215] | 53 | |
---|
[0] | 54 | exit; |
---|
| 55 | } |
---|
| 56 | |
---|
[2182] | 57 | # -- Display module configuration page -- |
---|
[2227] | 58 | if ($list->setConfiguration($core->blog->settings->system->theme)) { |
---|
[0] | 59 | |
---|
[2182] | 60 | # Get content before page headers |
---|
[2227] | 61 | include $list->includeConfiguration(); |
---|
[2166] | 62 | |
---|
[2182] | 63 | # Gather content |
---|
[2227] | 64 | $list->getConfiguration(); |
---|
[2182] | 65 | |
---|
| 66 | # Display page |
---|
[2171] | 67 | dcPage::open(__('Blog appearance'), |
---|
[2182] | 68 | dcPage::jsPageTabs(). |
---|
| 69 | dcPage::jsColorPicker(). |
---|
[2171] | 70 | |
---|
| 71 | # --BEHAVIOR-- themesToolsHeaders |
---|
[2182] | 72 | $core->callBehavior('themesToolsHeaders', $core, true), |
---|
[2171] | 73 | |
---|
| 74 | dcPage::breadcrumb( |
---|
| 75 | array( |
---|
| 76 | html::escapeHTML($core->blog->name) => '', |
---|
[2227] | 77 | __('Blog appearance') => $list->getURL('',false), |
---|
[2171] | 78 | '<span class="page-title">'.__('Theme configuration').'</span>' => '' |
---|
| 79 | )) |
---|
[2189] | 80 | ); |
---|
| 81 | |
---|
[2182] | 82 | # Display previously gathered content |
---|
[2227] | 83 | $list->displayConfiguration(); |
---|
[2171] | 84 | |
---|
| 85 | dcPage::close(); |
---|
| 86 | |
---|
| 87 | # Stop reading code here |
---|
| 88 | return; |
---|
[0] | 89 | } |
---|
| 90 | |
---|
[2171] | 91 | # -- Execute actions -- |
---|
[2215] | 92 | try { |
---|
| 93 | $list->doActions('themes'); |
---|
| 94 | } |
---|
| 95 | catch (Exception $e) { |
---|
| 96 | $core->error->add($e->getMessage()); |
---|
[0] | 97 | } |
---|
| 98 | |
---|
[2171] | 99 | # -- Page header -- |
---|
| 100 | dcPage::open(__('Themes management'), |
---|
[2192] | 101 | dcPage::jsLoad('js/_blog_theme.js'). |
---|
[2171] | 102 | dcPage::jsPageTabs(). |
---|
[2227] | 103 | dcPage::jsColorPicker(). |
---|
[2171] | 104 | |
---|
| 105 | # --BEHAVIOR-- themesToolsHeaders |
---|
| 106 | $core->callBehavior('themesToolsHeaders', $core, false), |
---|
| 107 | |
---|
| 108 | dcPage::breadcrumb( |
---|
| 109 | array( |
---|
| 110 | html::escapeHTML($core->blog->name) => '', |
---|
| 111 | '<span class="page-title">'.__('Blog appearance').'</span>' => '' |
---|
| 112 | )) |
---|
| 113 | ); |
---|
| 114 | |
---|
| 115 | # -- Display modules lists -- |
---|
[2227] | 116 | if ($core->auth->isSuperAdmin() && $list->isWritablePath()) { |
---|
[2171] | 117 | |
---|
| 118 | # Updated modules from repo |
---|
[2216] | 119 | $modules = $list->store->get(true); |
---|
[2171] | 120 | if (!empty($modules)) { |
---|
| 121 | echo |
---|
| 122 | '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update themes')).'">'. |
---|
| 123 | '<h3>'.html::escapeHTML(__('Update themes')).'</h3>'. |
---|
| 124 | '<p>'.sprintf( |
---|
[2227] | 125 | __('There is one theme to update available from repository.', 'There are %s themes to update available from repository.', count($modules)), |
---|
| 126 | count($modules) |
---|
[2171] | 127 | ).'</p>'; |
---|
| 128 | |
---|
| 129 | $list |
---|
[2241] | 130 | ->setList('theme-update') |
---|
[2227] | 131 | ->setTab('themes') |
---|
[2171] | 132 | ->setModules($modules) |
---|
[2227] | 133 | ->displayModules( |
---|
[2171] | 134 | /*cols */ array('sshot', 'name', 'desc', 'author', 'version', 'current_version', 'parent'), |
---|
[2222] | 135 | /* actions */ array('update', 'delete') |
---|
[2171] | 136 | ); |
---|
| 137 | |
---|
| 138 | echo |
---|
[2227] | 139 | '<p class="info vertical-separator">'.sprintf( |
---|
| 140 | __("Visit %s repository, the resources center for Dotclear."), |
---|
| 141 | '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>' |
---|
| 142 | ). |
---|
| 143 | '</p>'. |
---|
| 144 | |
---|
[2171] | 145 | '</div>'; |
---|
[0] | 146 | } |
---|
| 147 | } |
---|
| 148 | |
---|
[2227] | 149 | # Activated modules |
---|
[2215] | 150 | $modules = $list->modules->getModules(); |
---|
[2171] | 151 | if (!empty($modules)) { |
---|
| 152 | |
---|
| 153 | echo |
---|
[2227] | 154 | '<div class="multi-part" id="themes" title="'.__('Installed themes').'">'. |
---|
| 155 | '<h3>'.__('Installed themes').'</h3>'. |
---|
| 156 | '<p>'.__('You can configure and manage installed themes from this list.').'</p>'; |
---|
[2171] | 157 | |
---|
| 158 | $list |
---|
[2241] | 159 | ->setList('theme-activate') |
---|
[2227] | 160 | ->setTab('themes') |
---|
[2171] | 161 | ->setModules($modules) |
---|
[2227] | 162 | ->displayModules( |
---|
[2215] | 163 | /* cols */ array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'), |
---|
[2241] | 164 | /* actions */ array('select', 'behavior', 'deactivate', 'delete') |
---|
[2192] | 165 | ); |
---|
[2227] | 166 | |
---|
| 167 | echo |
---|
| 168 | '</div>'; |
---|
[0] | 169 | } |
---|
| 170 | |
---|
[2227] | 171 | # Deactivated modules |
---|
[2215] | 172 | $modules = $list->modules->getDisabledModules(); |
---|
[2192] | 173 | if (!empty($modules)) { |
---|
| 174 | |
---|
| 175 | echo |
---|
[2227] | 176 | '<div class="multi-part" id="deactivate" title="'.__('Deactivated themes').'">'. |
---|
[2192] | 177 | '<h3>'.__('Deactivated themes').'</h3>'. |
---|
| 178 | '<p>'.__('Deactivated themes are installed but not usable. You can activate them from here.').'</p>'; |
---|
| 179 | |
---|
| 180 | $list |
---|
[2241] | 181 | ->setList('theme-deactivate') |
---|
[2227] | 182 | ->setTab('themes') |
---|
[2192] | 183 | ->setModules($modules) |
---|
[2227] | 184 | ->displayModules( |
---|
[2192] | 185 | /* cols */ array('name', 'distrib'), |
---|
| 186 | /* actions */ array('activate', 'delete') |
---|
[2171] | 187 | ); |
---|
[2227] | 188 | |
---|
| 189 | echo |
---|
| 190 | '</div>'; |
---|
[0] | 191 | } |
---|
| 192 | |
---|
[2227] | 193 | if ($core->auth->isSuperAdmin() && $list->isWritablePath()) { |
---|
[0] | 194 | |
---|
[2171] | 195 | # New modules from repo |
---|
[2227] | 196 | $search = $list->getSearch(); |
---|
[2216] | 197 | $modules = $search ? $list->store->search($search) : $list->store->get(); |
---|
[1332] | 198 | |
---|
[2215] | 199 | if (!empty($search) || !empty($modules)) { |
---|
| 200 | echo |
---|
[2227] | 201 | '<div class="multi-part" id="new" title="'.__('Add themes').'">'. |
---|
[2291] | 202 | '<h3>'.__('Add themes from repository').'</h3>'; |
---|
| 203 | // '<p>'.__('Search and install themes directly from repository.').'</p>'; |
---|
[2171] | 204 | |
---|
[2215] | 205 | $list |
---|
[2241] | 206 | ->setList('theme-new') |
---|
[2227] | 207 | ->setTab('new') |
---|
[2215] | 208 | ->setModules($modules) |
---|
[2227] | 209 | ->displaySearch() |
---|
| 210 | ->displayIndex() |
---|
| 211 | ->displayModules( |
---|
[2222] | 212 | /* cols */ array('expander', 'sshot', 'name', 'score', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'), |
---|
[2215] | 213 | /* actions */ array('install'), |
---|
| 214 | /* nav limit */ true |
---|
| 215 | ); |
---|
[2171] | 216 | |
---|
[2215] | 217 | echo |
---|
| 218 | '<p class="info vertical-separator">'.sprintf( |
---|
| 219 | __("Visit %s repository, the resources center for Dotclear."), |
---|
| 220 | '<a href="http://dotaddict.org/dc2/themes">Dotaddict</a>' |
---|
| 221 | ). |
---|
| 222 | '</p>'. |
---|
[2171] | 223 | |
---|
[2215] | 224 | '</div>'; |
---|
| 225 | } |
---|
[2171] | 226 | |
---|
| 227 | # Add a new plugin |
---|
| 228 | echo |
---|
[2215] | 229 | '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'. |
---|
[2227] | 230 | '<h3>'.__('Add themes from a package').'</h3>'. |
---|
[2215] | 231 | '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>'; |
---|
[2171] | 232 | |
---|
| 233 | $list->displayManualForm(); |
---|
[684] | 234 | |
---|
[2171] | 235 | echo |
---|
| 236 | '</div>'; |
---|
[0] | 237 | } |
---|
| 238 | |
---|
[2282] | 239 | # --BEHAVIOR-- themesToolsTabs |
---|
| 240 | $core->callBehavior('themesToolsTabs', $core); |
---|
| 241 | |
---|
[0] | 242 | dcPage::close(); |
---|