private static function getLinksList($links, $block = '<ul>%s</ul>', $item = '<li%2$s>%1$s</li>') { $list = ''; # Find current link item if any $current = -1; $current_size = 0; $self_uri = http::getSelfURI(); foreach ($links as $k => $v) { if (!preg_match('$^([a-z][a-z0-9.+-]+://)$', $v['link_href'])) { $url = http::concatURL($self_uri, $v['link_href']); if (strlen($url) > $current_size && preg_match('/^' . preg_quote($url, '/') . '/', $self_uri)) { $current = $k; $current_size = strlen($url); } } } foreach ($links as $k => $v) { $title = $v['link_title']; $href = $v['link_href']; $desc = $v['link_desc']; $lang = $v['link_lang']; $xfn = $v['link_xfn']; $link = '<a href="' . html::escapeHTML($href) . '"' . (!$lang ? '' : ' hreflang="' . html::escapeHTML($lang) . '"') . (!$desc ? '' : ' title="' . html::escapeHTML($desc) . '"') . (!$xfn ? '' : ' rel="' . html::escapeHTML($xfn) . '"') . '>' . html::escapeHTML($title) . '</a>'; $current_class = $current == $k ? ' class="active"' : ''; $list .= sprintf($item, $link, $current_class) . "\n"; } return sprintf($block, $list) . "\n"; }
# This file is part of Ductile, a theme for Dotclear # # Copyright (c) 2011 - Association Dotclear # Licensed under the GPL version 2.0 license. # See LICENSE file or # http://www.gnu.org/licenses/old-licenses/gpl-2.0.html # # -- END LICENSE BLOCK ----------------------------------------- if (!defined('DC_CONTEXT_ADMIN')) { return; } l10n::set(dirname(__FILE__) . '/locales/' . $_lang . '/admin'); if (preg_match('#^http(s)?://#', $core->blog->settings->system->themes_url)) { $img_url = http::concatURL($core->blog->settings->system->themes_url, '/' . $core->blog->settings->system->theme . '/img/'); } else { $img_url = http::concatURL($core->blog->url, $core->blog->settings->system->themes_url . '/' . $core->blog->settings->system->theme . '/img/'); } $img_path = dirname(__FILE__) . '/img/'; $tpl_path = dirname(__FILE__) . '/tpl/'; $standalone_config = (bool) $core->themes->moduleInfo($core->blog->settings->system->theme, 'standalone_config'); // Load contextual help if (file_exists(dirname(__FILE__) . '/locales/' . $_lang . '/resources.php')) { require dirname(__FILE__) . '/locales/' . $_lang . '/resources.php'; } $list_types = array(__('Title') => 'title', __('Short') => 'short', __('Full') => 'full'); // Get all _entry-*.html in tpl folder of theme $list_types_templates = files::scandir($tpl_path); if (is_array($list_types_templates)) { foreach ($list_types_templates as $v) { if (preg_match('/^_entry\\-(.*)\\.html$/', $v, $m)) { if (isset($m[1])) {
if (!$can_write_images) { dcPage::message(__('For the following reasons, images cannot be created. You won\'t be able to change some background properties.') . $notices, false, true); } echo '<form id="theme_config" action="' . $p_url . '" method="post" enctype="multipart/form-data">'; echo '<div class="fieldset"><h3>' . __('Customization') . '</h3>' . '<h4>' . __('General') . '</h4>'; if ($can_write_images) { echo '<p class="field"><label for="body_bg_c">' . __('Background color:') . '</label> ' . form::field('body_bg_c', 7, 7, $blowup_user['body_bg_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="body_bg_g">' . __('Background color fill:') . '</label> ' . form::combo('body_bg_g', $gradient_types, $blowup_user['body_bg_g']) . '</p>'; } echo '<p class="field"><label for="body_txt_f">' . __('Main text font:') . '</label> ' . form::combo('body_txt_f', blowupConfig::fontsList(), $blowup_user['body_txt_f']) . '</p>' . '<p class="field"><label for="body_txt_s">' . __('Main text font size:') . '</label> ' . form::field('body_txt_s', 7, 7, $blowup_user['body_txt_s']) . '</p>' . '<p class="field"><label for="body_txt_c">' . __('Main text color:') . '</label> ' . form::field('body_txt_c', 7, 7, $blowup_user['body_txt_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="body_line_height">' . __('Text line height:') . '</label> ' . form::field('body_line_height', 7, 7, $blowup_user['body_line_height']) . '</p>' . '<h4 class="border-top">' . __('Links') . '</h4>' . '<p class="field"><label for="body_link_c">' . __('Links color:') . '</label> ' . form::field('body_link_c', 7, 7, $blowup_user['body_link_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="body_link_v_c">' . __('Visited links color:') . '</label> ' . form::field('body_link_v_c', 7, 7, $blowup_user['body_link_v_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="body_link_f_c">' . __('Focus links color:') . '</label> ' . form::field('body_link_f_c', 7, 7, $blowup_user['body_link_f_c'], 'colorpicker') . '</p>' . '<h4 class="border-top">' . __('Page top') . '</h4>'; if ($can_write_images) { echo '<p class="field"><label for="prelude_c">' . __('Prelude color:') . '</label> ' . form::field('prelude_c', 7, 7, $blowup_user['prelude_c'], 'colorpicker') . '</p>'; } echo '<p class="field"><label for="blog_title_hide">' . __('Hide main title') . '</label> ' . form::checkbox('blog_title_hide', 1, $blowup_user['blog_title_hide']) . '</p>' . '<p class="field"><label for="blog_title_f">' . __('Main title font:') . '</label> ' . form::combo('blog_title_f', blowupConfig::fontsList(), $blowup_user['blog_title_f']) . '</p>' . '<p class="field"><label for="blog_title_s">' . __('Main title font size:') . '</label> ' . form::field('blog_title_s', 7, 7, $blowup_user['blog_title_s']) . '</p>' . '<p class="field"><label for="blog_title_c">' . __('Main title color:') . '</label> ' . form::field('blog_title_c', 7, 7, $blowup_user['blog_title_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="blog_title_a">' . __('Main title alignment:') . '</label> ' . form::combo('blog_title_a', array(__('center') => 'center', __('left') => 'left', __('right') => 'right'), $blowup_user['blog_title_a']) . '</p>' . '<p class="field"><label for="blog_title_p">' . __('Main title position (x:y)') . '</label> ' . form::field('blog_title_p', 7, 7, $blowup_user['blog_title_p']) . '</p>'; if ($can_write_images) { if ($blowup_user['top_image'] == 'custom' && $blowup_user['uploaded']) { $preview_image = http::concatURL($core->blog->url, blowupConfig::imagesURL() . '/page-t.png'); } else { $preview_image = dcPage::getPF('blowupConfig/alpha-img/page-t/' . $blowup_user['top_image'] . '.png'); } echo '<h5 class="pretty-title">' . __('Top image') . '</h5>' . '<p class="field"><label for="top_image">' . __('Top image') . '</label> ' . form::combo('top_image', $top_images, $blowup_user['top_image'] ? $blowup_user['top_image'] : 'default') . '</p>' . '<p>' . __('Choose "Custom..." to upload your own image.') . '</p>' . '<p id="uploader"><label for="upfile">' . __('Add your image:') . '</label> ' . ' (' . sprintf(__('JPEG or PNG file, 800 pixels wide, maximum size %s'), files::size(DC_MAX_UPLOAD_SIZE)) . ')' . '<input type="file" name="upfile" id="upfile" size="35" />' . '</p>' . '<h5>' . __('Preview') . '</h5>' . '<div class="grid" style="width:800px;border:1px solid #ccc;">' . '<img style="display:block;" src="' . $preview_image . '" alt="" id="image-preview" />' . '</div>'; } echo '<h4 class="border-top">' . __('Sidebar') . '</h4>' . '<p class="field"><label for="sidebar_position">' . __('Sidebar position:') . '</label> ' . form::combo('sidebar_position', array(__('right') => 'right', __('left') => 'left'), $blowup_user['sidebar_position']) . '</p>' . '<p class="field"><label for="sidebar_text_f">' . __('Sidebar text font:') . '</label> ' . form::combo('sidebar_text_f', blowupConfig::fontsList(), $blowup_user['sidebar_text_f']) . '</p>' . '<p class="field"><label for="sidebar_text_s">' . __('Sidebar text font size:') . '</label> ' . form::field('sidebar_text_s', 7, 7, $blowup_user['sidebar_text_s']) . '</p>' . '<p class="field"><label for="sidebar_text_c">' . __('Sidebar text color:') . '</label> ' . form::field('sidebar_text_c', 7, 7, $blowup_user['sidebar_text_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="sidebar_title_f">' . __('Sidebar titles font:') . '</label> ' . form::combo('sidebar_title_f', blowupConfig::fontsList(), $blowup_user['sidebar_title_f']) . '</p>' . '<p class="field"><label for="sidebar_title_s">' . __('Sidebar titles font size:') . '</label> ' . form::field('sidebar_title_s', 7, 7, $blowup_user['sidebar_title_s']) . '</p>' . '<p class="field"><label for="sidebar_title_c">' . __('Sidebar titles color:') . '</label> ' . form::field('sidebar_title_c', 7, 7, $blowup_user['sidebar_title_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="sidebar_title2_f">' . __('Sidebar 2nd level titles font:') . '</label> ' . form::combo('sidebar_title2_f', blowupConfig::fontsList(), $blowup_user['sidebar_title2_f']) . '</p>' . '<p class="field"><label for="sidebar_title2_s">' . __('Sidebar 2nd level titles font size:') . '</label> ' . form::field('sidebar_title2_s', 7, 7, $blowup_user['sidebar_title2_s']) . '</p>' . '<p class="field"><label for="sidebar_title2_c">' . __('Sidebar 2nd level titles color:') . '</label> ' . form::field('sidebar_title2_c', 7, 7, $blowup_user['sidebar_title2_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="sidebar_line_c">' . __('Sidebar lines color:') . '</label> ' . form::field('sidebar_line_c', 7, 7, $blowup_user['sidebar_line_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="sidebar_link_c">' . __('Sidebar links color:') . '</label> ' . form::field('sidebar_link_c', 7, 7, $blowup_user['sidebar_link_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="sidebar_link_v_c">' . __('Sidebar visited links color:') . '</label> ' . form::field('sidebar_link_v_c', 7, 7, $blowup_user['sidebar_link_v_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="sidebar_link_f_c">' . __('Sidebar focus links color:') . '</label> ' . form::field('sidebar_link_f_c', 7, 7, $blowup_user['sidebar_link_f_c'], 'colorpicker') . '</p>' . '<h4 class="border-top">' . __('Entries') . '</h4>' . '<p class="field"><label for="date_title_f">' . __('Date title font:') . '</label> ' . form::combo('date_title_f', blowupConfig::fontsList(), $blowup_user['date_title_f']) . '</p>' . '<p class="field"><label for="date_title_s">' . __('Date title font size:') . '</label> ' . form::field('date_title_s', 7, 7, $blowup_user['date_title_s']) . '</p>' . '<p class="field"><label for="date_title_c">' . __('Date title color:') . '</label> ' . form::field('date_title_c', 7, 7, $blowup_user['date_title_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="post_title_f">' . __('Entry title font:') . '</label> ' . form::combo('post_title_f', blowupConfig::fontsList(), $blowup_user['post_title_f']) . '</p>' . '<p class="field"><label for="post_title_s">' . __('Entry title font size:') . '</label> ' . form::field('post_title_s', 7, 7, $blowup_user['post_title_s']) . '</p>' . '<p class="field"><label for="post_title_c">' . __('Entry title color:') . '</label> ' . form::field('post_title_c', 7, 7, $blowup_user['post_title_c'], 'colorpicker') . '</p>'; if ($can_write_images) { echo '<p class="field"><label for="post_comment_bg_c">' . __('Comment background color:') . '</label> ' . form::field('post_comment_bg_c', 7, 7, $blowup_user['post_comment_bg_c'], 'colorpicker') . '</p>'; } echo '<p class="field"><label for="post_comment_c">' . __('Comment text color:') . '</label> ' . form::field('post_comment_c', 7, 7, $blowup_user['post_comment_c'], 'colorpicker') . '</p>'; if ($can_write_images) { echo '<p class="field"><label for="post_commentmy_bg_c">' . __('My comment background color:') . '</label> ' . form::field('post_commentmy_bg_c', 7, 7, $blowup_user['post_commentmy_bg_c'], 'colorpicker') . '</p>'; } echo '<p class="field"><label for="post_commentmy_c">' . __('My comment text color:') . '</label> ' . form::field('post_commentmy_c', 7, 7, $blowup_user['post_commentmy_c'], 'colorpicker') . '</p>' . '<h4 class="border-top">' . __('Footer') . '</h4>' . '<p class="field"><label for="footer_f">' . __('Footer font:') . '</label> ' . form::combo('footer_f', blowupConfig::fontsList(), $blowup_user['footer_f']) . '</p>' . '<p class="field"><label for="footer_s">' . __('Footer font size:') . '</label> ' . form::field('footer_s', 7, 7, $blowup_user['footer_s']) . '</p>' . '<p class="field"><label for="footer_c">' . __('Footer color:') . '</label> ' . form::field('footer_c', 7, 7, $blowup_user['footer_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="footer_l_c">' . __('Footer links color:') . '</label> ' . form::field('footer_l_c', 7, 7, $blowup_user['footer_l_c'], 'colorpicker') . '</p>' . '<p class="field"><label for="footer_bg_c">' . __('Footer background color:') . '</label> ' . form::field('footer_bg_c', 7, 7, $blowup_user['footer_bg_c'], 'colorpicker') . '</p>'; echo '<h4 class="border-top">' . __('Additional CSS') . '</h4>' . '<p><label for="extra_css">' . __('Any additional CSS styles (must be written using the CSS syntax):') . '</label> ' . form::textarea('extra_css', 72, 5, html::escapeHTML($blowup_user['extra_css']), 'maximal', '', false, 'title="' . __('Additional CSS') . '"') . '</p>' . '</div>';
public function displayModules($cols = array('name', 'config', 'version', 'desc'), $actions = array(), $nav_limit = false) { echo '<form action="' . $this->getURL() . '" method="post" class="modules-form-actions">' . '<div id="' . html::escapeHTML($this->list_id) . '" class="modules' . (in_array('expander', $cols) ? ' expandable' : '') . ' one-box">'; $sort_field = $this->getSort(); # Sort modules by id $modules = $this->getSearch() === null ? self::sortModules($this->data, $sort_field, $this->sort_asc) : $this->data; $res = ''; $count = 0; foreach ($modules as $id => $module) { # Show only requested modules if ($nav_limit && $this->getSearch() === null) { $char = substr($module[$sort_field], 0, 1); if (!in_array($char, $this->nav_list)) { $char = $this->nav_special; } if ($this->getIndex() != $char) { continue; } } $current = $this->core->blog->settings->system->theme == $id && $this->modules->moduleExists($id); $distrib = self::isDistributedModule($id) ? ' dc-box' : ''; $line = '<div class="box ' . ($current ? 'medium current-theme' : 'theme') . $distrib . '">'; if (in_array('name', $cols) && !$current) { $line .= '<h4 class="module-name">'; if (in_array('checkbox', $cols)) { $line .= '<label for="' . html::escapeHTML($this->list_id) . '_modules_' . html::escapeHTML($id) . '">' . form::checkbox(array('modules[' . $count . ']', html::escapeHTML($this->list_id) . '_modules_' . html::escapeHTML($id)), html::escapeHTML($id)) . html::escapeHTML($module['name']) . '</label>'; } else { $line .= form::hidden(array('modules[' . $count . ']'), html::escapeHTML($id)) . html::escapeHTML($module['name']); } $line .= $this->core->formNonce() . '</h4>'; } # Display score only for debug purpose if (in_array('score', $cols) && $this->getSearch() !== null && defined('DC_DEBUG') && DC_DEBUG) { $line .= '<p class="module-score debug">' . sprintf(__('Score: %s'), $module['score']) . '</p>'; } if (in_array('sshot', $cols)) { # Screenshot from url if (preg_match('#^http(s)?://#', $module['sshot'])) { $sshot = $module['sshot']; } elseif (file_exists($this->core->blog->themes_path . '/' . $id . '/screenshot.jpg')) { $sshot = $this->getURL('shot=' . rawurlencode($id)); } else { $sshot = 'images/noscreenshot.png'; } $line .= '<div class="module-sshot"><img src="' . $sshot . '" alt="' . sprintf(__('%s screenshot.'), html::escapeHTML($module['name'])) . '" /></div>'; } $line .= '<div class="module-infos toggle-bloc">'; if (in_array('name', $cols) && $current) { $line .= '<h4 class="module-name">'; if (in_array('checkbox', $cols)) { $line .= '<label for="' . html::escapeHTML($this->list_id) . '_modules_' . html::escapeHTML($id) . '">' . form::checkbox(array('modules[' . $count . ']', html::escapeHTML($this->list_id) . '_modules_' . html::escapeHTML($id)), html::escapeHTML($id)) . html::escapeHTML($module['name']) . '</label>'; } else { $line .= form::hidden(array('modules[' . $count . ']'), html::escapeHTML($id)) . html::escapeHTML($module['name']); } $line .= '</h4>'; } $line .= '<p>'; if (in_array('desc', $cols)) { $line .= '<span class="module-desc">' . html::escapeHTML(__($module['desc'])) . '</span> '; } if (in_array('author', $cols)) { $line .= '<span class="module-author">' . sprintf(__('by %s'), html::escapeHTML($module['author'])) . '</span> '; } if (in_array('version', $cols)) { $line .= '<span class="module-version">' . sprintf(__('version %s'), html::escapeHTML($module['version'])) . '</span> '; } if (in_array('current_version', $cols)) { $line .= '<span class="module-current-version">' . sprintf(__('(current version %s)'), html::escapeHTML($module['current_version'])) . '</span> '; } if (in_array('parent', $cols) && !empty($module['parent'])) { if ($this->modules->moduleExists($module['parent'])) { $line .= '<span class="module-parent-ok">' . sprintf(__('(built on "%s")'), html::escapeHTML($module['parent'])) . '</span> '; } else { $line .= '<span class="module-parent-missing">' . sprintf(__('(requires "%s")'), html::escapeHTML($module['parent'])) . '</span> '; } } $has_details = in_array('details', $cols) && !empty($module['details']); $has_support = in_array('support', $cols) && !empty($module['support']); if ($has_details || $has_support) { $line .= '<span class="mod-more">'; if ($has_details) { $line .= '<a class="module-details" href="' . $module['details'] . '">' . __('Details') . '</a>'; } if ($has_support) { $line .= ' - <a class="module-support" href="' . $module['support'] . '">' . __('Support') . '</a>'; } $line .= '</span>'; } $line .= '</p>' . '</div>'; $line .= '<div class="module-actions toggle-bloc">'; # Plugins actions if ($current) { # _GET actions if (file_exists(path::real($this->core->blog->themes_path . '/' . $id) . '/style.css')) { $theme_url = preg_match('#^http(s)?://#', $this->core->blog->settings->system->themes_url) ? http::concatURL($this->core->blog->settings->system->themes_url, '/' . $id) : http::concatURL($this->core->blog->url, $this->core->blog->settings->system->themes_url . '/' . $id); $line .= '<p><a href="' . $theme_url . '/style.css">' . __('View stylesheet') . '</a></p>'; } $line .= '<div class="current-actions">'; if (file_exists(path::real($this->core->blog->themes_path . '/' . $id) . '/_config.php')) { $line .= '<p><a href="' . $this->getURL('module=' . $id . '&conf=1', false) . '" class="button submit">' . __('Configure theme') . '</a></p>'; } # --BEHAVIOR-- adminCurrentThemeDetails $line .= $this->core->callBehavior('adminCurrentThemeDetails', $this->core, $id, $module); $line .= '</div>'; } # _POST actions if (!empty($actions)) { $line .= '<p>' . implode(' ', $this->getActions($id, $module, $actions)) . '</p>'; } $line .= '</div>'; $line .= '</div>'; $count++; $res = $current ? $line . $res : $res . $line; } echo $res . '</div>'; if (!$count && $this->getSearch() === null) { echo '<p class="message">' . __('No themes matched your search.') . '</p>'; } elseif ((in_array('checkbox', $cols) || $count > 1) && !empty($actions) && $this->core->auth->isSuperAdmin()) { $buttons = $this->getGlobalActions($actions, in_array('checkbox', $cols)); if (!empty($buttons)) { if (in_array('checkbox', $cols)) { echo '<p class="checkboxes-helpers"></p>'; } echo '<div>' . implode(' ', $buttons) . '</div>'; } } echo '</form>'; return $this; }
function display_theme_details($id, $details, $current) { global $core; $screenshot = 'images/noscreenshot.png'; if (file_exists($core->blog->themes_path . '/' . $id . '/screenshot.jpg')) { $screenshot = 'blog_theme.php?shot=' . rawurlencode($id); } $radio_id = 'theme_' . html::escapeHTML($id); $theme_url = http::concatURL($core->blog->url, $core->blog->settings->themes_url . '/' . $id); $has_conf = file_exists(path::real($core->blog->themes_path . '/' . $id) . '/_config.php'); $has_css = file_exists(path::real($core->blog->themes_path . '/' . $id) . '/style.css'); $parent = $core->themes->moduleInfo($id, 'parent'); $has_parent = (bool) $parent; if ($has_parent) { $is_parent_present = $core->themes->moduleExists($parent); } $res = '<div class="theme-details' . ($current ? ' current-theme' : '') . '">' . '<div class="theme-shot"><img src="' . $screenshot . '" alt="" /></div>' . '<div class="theme-info">' . '<h3>' . form::radio(array('theme', $radio_id), html::escapeHTML($id), $current, '', '', $has_parent && !$is_parent_present) . ' ' . '<label class="classic" for="' . $radio_id . '">' . html::escapeHTML($details['name']) . '</label></h3>' . '<p><span class="theme-desc">' . html::escapeHTML($details['desc']) . '</span> ' . '<span class="theme-author">' . sprintf(__('by %s'), html::escapeHTML($details['author'])) . '</span> ' . '<span class="theme-version">' . sprintf(__('version %s'), html::escapeHTML($details['version'])) . '</span> '; if ($has_parent) { if ($is_parent_present) { $res .= '<span class="theme-parent-ok">' . sprintf(__('(built on "%s")'), html::escapeHTML($parent)) . '</span> '; } else { $res .= '<span class="theme-parent-missing">' . sprintf(__('(requires "%s")'), html::escapeHTML($parent)) . '</span> '; } } if ($has_css) { $res .= '<a class="theme-css" href="' . $theme_url . '/style.css">' . __('Stylesheet') . '</a>'; } $res .= '</p>'; $res .= '</div>' . '<div class="theme-actions">'; if ($current && $has_conf) { $res .= '<p><a href="blog_theme.php?conf=1" class="button">' . __('Theme configuration') . '</a></p>'; } if ($current) { # --BEHAVIOR-- adminCurrentThemeDetails $res .= $core->callBehavior('adminCurrentThemeDetails', $core, $id, $details); } $res .= '</div>' . '</div>'; return $res; }