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