Dotclear

source: admin/blog_theme.php @ 2377:e2c358189e6c

Revision 2377:e2c358189e6c, 6.1 KB checked in by Denis Jean-Chirstian <contact@…>, 12 years ago (diff)

Better split of modules terms, aka plugin vs theme, fixed #1772

RevLine 
[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
13require dirname(__FILE__).'/../inc/admin/prepend.php';
14
15dcPage::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(
[2171]23     $core->themes, 
[2215]24     $core->blog->themes_path,
[2216]25     $core->blog->settings->system->store_theme_url
[2171]26);
[2286]27adminThemesList::$distributed_modules = explode(',', DC_DISTRIB_THEMES);
[2171]28
29# -- Theme screenshot --
[2215]30if (!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]51if ($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
78     dcPage::close();
79
80     # Stop reading code here
81     return;
[0]82}
83
[2171]84# -- Execute actions --
[2215]85try {
[2377]86     $list->doActions();
[2215]87}
88catch (Exception $e) {
89     $core->error->add($e->getMessage());
[0]90}
91
[2171]92# -- Page header --
93dcPage::open(__('Themes management'),
[2192]94     dcPage::jsLoad('js/_blog_theme.js').
[2171]95     dcPage::jsPageTabs().
[2227]96     dcPage::jsColorPicker().
[2171]97
98     # --BEHAVIOR-- themesToolsHeaders
99     $core->callBehavior('themesToolsHeaders', $core, false),
100
101     dcPage::breadcrumb(
102          array(
103               html::escapeHTML($core->blog->name) => '',
104               '<span class="page-title">'.__('Blog appearance').'</span>' => ''
105          ))
106);
107
108# -- Display modules lists --
[2227]109if ($core->auth->isSuperAdmin() && $list->isWritablePath()) {
[2171]110
111     # Updated modules from repo
[2216]112     $modules = $list->store->get(true);
[2171]113     if (!empty($modules)) {
114          echo 
115          '<div class="multi-part" id="update" title="'.html::escapeHTML(__('Update themes')).'">'.
116          '<h3>'.html::escapeHTML(__('Update themes')).'</h3>'.
117          '<p>'.sprintf(
[2227]118               __('There is one theme to update available from repository.', 'There are %s themes to update available from repository.', count($modules)),
119               count($modules)
[2171]120          ).'</p>';
121
122          $list
[2241]123               ->setList('theme-update')
[2227]124               ->setTab('themes')
[2171]125               ->setModules($modules)
[2227]126               ->displayModules(
[2171]127                    /*cols */      array('sshot', 'name', 'desc', 'author', 'version', 'current_version', 'parent'),
[2222]128                    /* actions */  array('update', 'delete')
[2171]129               );
130
131          echo
[2227]132          '<p class="info vertical-separator">'.sprintf(
133               __("Visit %s repository, the resources center for Dotclear."),
[2362]134               '<a href="http://themes.dotaddict.org/dc2/">Dotaddict</a>'
[2227]135               ).
136          '</p>'.
137
[2171]138          '</div>';
[0]139     }
140}
141
[2227]142# Activated modules
[2215]143$modules = $list->modules->getModules();
[2171]144if (!empty($modules)) {
145
146     echo
[2227]147     '<div class="multi-part" id="themes" title="'.__('Installed themes').'">'.
148     '<h3>'.__('Installed themes').'</h3>'.
149     '<p>'.__('You can configure and manage installed themes from this list.').'</p>';
[2171]150
151     $list
[2241]152          ->setList('theme-activate')
[2227]153          ->setTab('themes')
[2171]154          ->setModules($modules)
[2227]155          ->displayModules(
[2215]156               /* cols */          array('sshot', 'distrib', 'name', 'config', 'desc', 'author', 'version', 'parent'),
[2241]157               /* actions */  array('select', 'behavior', 'deactivate', 'delete')
[2192]158          );
[2227]159
160     echo 
161     '</div>';
[0]162}
163
[2227]164# Deactivated modules
[2215]165$modules = $list->modules->getDisabledModules();
[2192]166if (!empty($modules)) {
167
168     echo
[2227]169     '<div class="multi-part" id="deactivate" title="'.__('Deactivated themes').'">'.
[2192]170     '<h3>'.__('Deactivated themes').'</h3>'.
171     '<p>'.__('Deactivated themes are installed but not usable. You can activate them from here.').'</p>';
172
173     $list
[2241]174          ->setList('theme-deactivate')
[2227]175          ->setTab('themes')
[2192]176          ->setModules($modules)
[2227]177          ->displayModules(
[2192]178               /* cols */          array('name', 'distrib'),
179               /* actions */  array('activate', 'delete')
[2171]180          );
[2227]181
182     echo 
183     '</div>';
[0]184}
185
[2227]186if ($core->auth->isSuperAdmin() && $list->isWritablePath()) {
[0]187
[2171]188     # New modules from repo
[2227]189     $search = $list->getSearch();
[2216]190     $modules = $search ? $list->store->search($search) : $list->store->get();
[1332]191
[2215]192     if (!empty($search) || !empty($modules)) {
193          echo
[2227]194          '<div class="multi-part" id="new" title="'.__('Add themes').'">'.
[2291]195          '<h3>'.__('Add themes from repository').'</h3>';
196//        '<p>'.__('Search and install themes directly from repository.').'</p>';
[2171]197
[2215]198          $list
[2241]199               ->setList('theme-new')
[2227]200               ->setTab('new')
[2215]201               ->setModules($modules)
[2227]202               ->displaySearch()
203               ->displayIndex()
204               ->displayModules(
[2222]205                    /* cols */          array('expander', 'sshot', 'name', 'score', 'config', 'desc', 'author', 'version', 'parent', 'details', 'support'),
[2215]206                    /* actions */  array('install'),
207                    /* nav limit */     true
208               );
[2171]209
[2215]210          echo
211          '<p class="info vertical-separator">'.sprintf(
212               __("Visit %s repository, the resources center for Dotclear."),
[2337]213               '<a href="http://themes.dotaddict.org/dc2/">Dotaddict</a>'
[2215]214               ).
215          '</p>'.
[2171]216
[2215]217          '</div>';
218     }
[2171]219
220     # Add a new plugin
221     echo
[2215]222     '<div class="multi-part" id="addtheme" title="'.__('Install or upgrade manually').'">'.
[2227]223     '<h3>'.__('Add themes from a package').'</h3>'.
[2215]224     '<p>'.__('You can install themes by uploading or downloading zip files.').'</p>';
[2171]225
226     $list->displayManualForm();
[684]227
[2171]228     echo
229     '</div>';
[0]230}
231
[2282]232# --BEHAVIOR-- themesToolsTabs
233$core->callBehavior('themesToolsTabs', $core);
[2314]234dcPage::helpBlock('core_blog_theme');
[0]235dcPage::close();
Note: See TracBrowser for help on using the repository browser.

Sites map