blog->settings->system->themes_url.'/'.$core->blog->settings->system->theme.'/img/'; $img_url = http::concatURL($core->blog->url,$img_url); $img_path = dirname(__FILE__).'/img/'; $standalone_config = (boolean) $core->themes->moduleInfo($core->blog->settings->system->theme,'standalone_config'); $list_types = array( __('Title') => 'title', __('Short') => 'short', __('Full') => 'full' ); $contexts = array( 'default' => __('Home (first page)'), 'default-page' => __('Home (other pages)'), 'category' => __('Entries for a category'), 'tag' => __('Entries for a tag'), 'search' => __('Search result entries'), 'archive' => __('Month archive entries') ); $fonts = array( __('default') => '', __('Ductile primary') => 'Ductile body', __('Ductile secondary') => 'Ductile alternate', __('Times New Roman') => 'Times New Roman', __('Georgia') => 'Georgia', __('Garamond') => 'Garamond', __('Helvetica/Arial') => 'Helvetica/Arial', __('Verdana') => 'Verdana', __('Trebuchet MS') => 'Trebuchet MS', __('Impact') => 'Impact', __('Monospace') => 'Monospace' ); function adjustFontSize($s) { if (preg_match('/^([0-9.]+)\s*(%|pt|px|em|ex)?$/',$s,$m)) { if (empty($m[2])) { $m[2] = 'em'; } return $m[1].$m[2]; } return null; } function adjustColor($c) { if ($c === '') { return ''; } $c = strtoupper($c); if (preg_match('/^[A-F0-9]{3,6}$/',$c)) { $c = '#'.$c; } if (preg_match('/^#[A-F0-9]{6}$/',$c)) { return $c; } if (preg_match('/^#[A-F0-9]{3,}$/',$c)) { return '#'.substr($c,1,1).substr($c,1,1).substr($c,2,1).substr($c,2,1).substr($c,3,1).substr($c,3,1); } return ''; } function computeContrastRatio($color,$background) { // Compute contrast ratio between two colors $color = adjustColor($color); if (($color == '') || (strlen($color) != 7)) return 0; $background = adjustColor($background); if (($background == '') || (strlen($background) != 7)) return 0; $l1 = (0.2126 * pow(hexdec(substr($color,1,2))/255,2.2)) + (0.7152 * pow(hexdec(substr($color,3,2))/255,2.2)) + (0.0722 * pow(hexdec(substr($color,5,2))/255,2.2)); $l2 = (0.2126 * pow(hexdec(substr($background,1,2))/255,2.2)) + (0.7152 * pow(hexdec(substr($background,3,2))/255,2.2)) + (0.0722 * pow(hexdec(substr($background,5,2))/255,2.2)); if ($l1 > $l2) { $ratio = ($l1 + 0.05) / ($l2 + 0.05); } else { $ratio = ($l2 + 0.05) / ($l1 + 0.05); } return $ratio; } function contrastRatioLevel($ratio,$size,$bold) { if ($size == '') { return ''; } // Eval font size in em (assume base font size in pixels equal to 16) if (preg_match('/^([0-9.]+)\s*(%|pt|px|em|ex)?$/',$size,$m)) { if (empty($m[2])) { $m[2] = 'em'; } } else { return ''; } switch ($m[2]) { case '%': $s = (float) $m[1] / 100; break; case 'pt': $s = (float) $m[1] / 12; break; case 'px': $s = (float) $m[1] / 16; break; case 'em': $s = (float) $m[1]; break; case 'ex': $s = (float) $m[1] / 2; break; default: return ''; } $large = ((($s > 1.5) && ($bold == false)) || (($s > 1.2) && ($bold == true))); // Check ratio if ($ratio > 7) { return 'AAA'; } elseif (($ratio > 4.5) && $large) { return 'AAA'; } elseif ($ratio > 4.5) { return 'AA'; } elseif (($ratio > 3) && $large) { return 'AA'; } return ''; } function contrastRatio($color,$background,$size='',$bold=false) { if (($color != '') && ($background != '')) { $ratio = computeContrastRatio($color,$background); $level = contrastRatioLevel($ratio,$size,$bold); return '('. sprintf(__('ratio = %.1f:1'),$ratio). ($level != '' ? ' / '.sprintf(__('WCAG %s'),$level) : ''). ')'; } return ''; } $ductile_base = array( // HTML 'subtitle_hidden' => null, // CSS 'body_font' => null, 'alternate_font' => null, 'blog_title_w' => null, 'blog_title_s' => null, 'blog_title_c' => null, 'post_title_w' => null, 'post_title_s' => null, 'post_title_c' => null, 'post_link_w' => null, 'post_link_v_c' => null, 'post_link_f_c' => null, 'blog_title_w_m' => null, 'blog_title_s_m' => null, 'blog_title_c_m' => null, 'post_title_w_m' => null, 'post_title_s_m' => null, 'post_title_c_m' => null, 'post_simple_title_c' => null ); $ductile_lists_base = array( 'default' => 'short', 'default-page' => 'short', 'category' => 'short', 'tag' => 'short', 'search' => 'short', 'archive' => 'title' ); $ductile_counts_base = array( 'default' => null, 'category' => null, 'tag' => null, 'search' => null ); $ductile_user = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_style'); $ductile_user = @unserialize($ductile_user); if (!is_array($ductile_user)) { $ductile_user = array(); } $ductile_user = array_merge($ductile_base,$ductile_user); $ductile_lists = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_lists'); $ductile_lists = @unserialize($ductile_lists); if (!is_array($ductile_lists)) { $ductile_lists = $ductile_lists_base; } $ductile_counts = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_counts'); $ductile_counts = @unserialize($ductile_counts); if (!is_array($ductile_counts)) { $ductile_counts = $ductile_counts_base; } $ductile_stickers = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_stickers'); $ductile_stickers = @unserialize($ductile_stickers); // If no stickers defined, add feed Atom one if (!is_array($ductile_stickers)) { $ductile_stickers = array(array( 'label' => __('Subscribe'), 'url' => $core->blog->url.$core->url->getBase('feed').'/atom', 'image' => 'sticker-feed.png' )); } $ductile_stickers_full = array(); // Get all sticker images already used if (is_array($ductile_stickers)) { foreach ($ductile_stickers as $v) { $ductile_stickers_full[] = $v['image']; } } // Get all sticker-*.png in img folder of theme $ductile_stickers_images = files::scandir($img_path); if (is_array($ductile_stickers_images)) { foreach ($ductile_stickers_images as $v) { if (preg_match('/^sticker\-(.*)\.png$/',$v)) { if (!in_array($v,$ductile_stickers_full)) { // image not already used $ductile_stickers[] = array( 'label' => null, 'url' => null, 'image' => $v); } } } } $conf_tab = isset($_POST['conf_tab']) ? $_POST['conf_tab'] : 'html'; if (!empty($_POST)) { try { # HTML if ($conf_tab == 'html') { $ductile_user['subtitle_hidden'] = (integer) !empty($_POST['subtitle_hidden']); $ductile_stickers = array(); for ($i = 0; $i < count($_POST['sticker_image']); $i++) { $ductile_stickers[] = array( 'label' => $_POST['sticker_label'][$i], 'url' => $_POST['sticker_url'][$i], 'image' => $_POST['sticker_image'][$i] ); } $order = array(); if (empty($_POST['ds_order']) && !empty($_POST['order'])) { $order = $_POST['order']; asort($order); $order = array_keys($order); } if (!empty($order)) { $new_ductile_stickers = array(); foreach ($order as $i => $k) { $new_ductile_stickers[] = array( 'label' => $ductile_stickers[$k]['label'], 'url' => $ductile_stickers[$k]['url'], 'image' => $ductile_stickers[$k]['image'] ); } $ductile_stickers = $new_ductile_stickers; } for ($i = 0; $i < count($_POST['list_type']); $i++) { $ductile_lists[$_POST['list_ctx'][$i]] = $_POST['list_type'][$i]; } for ($i = 0; $i < count($_POST['count_nb']); $i++) { $ductile_counts[$_POST['count_ctx'][$i]] = $_POST['count_nb'][$i]; } } # CSS if ($conf_tab == 'css') { $ductile_user['body_font'] = $_POST['body_font']; $ductile_user['alternate_font'] = $_POST['alternate_font']; $ductile_user['blog_title_w'] = (integer) !empty($_POST['blog_title_w']); $ductile_user['blog_title_s'] = adjustFontSize($_POST['blog_title_s']); $ductile_user['blog_title_c'] = adjustColor($_POST['blog_title_c']); $ductile_user['post_title_w'] = (integer) !empty($_POST['post_title_w']); $ductile_user['post_title_s'] = adjustFontSize($_POST['post_title_s']); $ductile_user['post_title_c'] = adjustColor($_POST['post_title_c']); $ductile_user['post_link_w'] = (integer) !empty($_POST['post_link_w']); $ductile_user['post_link_v_c'] = adjustColor($_POST['post_link_v_c']); $ductile_user['post_link_f_c'] = adjustColor($_POST['post_link_f_c']); $ductile_user['post_simple_title_c'] = adjustColor($_POST['post_simple_title_c']); $ductile_user['blog_title_w_m'] = (integer) !empty($_POST['blog_title_w_m']); $ductile_user['blog_title_s_m'] = adjustFontSize($_POST['blog_title_s_m']); $ductile_user['blog_title_c_m'] = adjustColor($_POST['blog_title_c_m']); $ductile_user['post_title_w_m'] = (integer) !empty($_POST['post_title_w_m']); $ductile_user['post_title_s_m'] = adjustFontSize($_POST['post_title_s_m']); $ductile_user['post_title_c_m'] = adjustColor($_POST['post_title_c_m']); } $core->blog->settings->addNamespace('themes'); $core->blog->settings->themes->put($core->blog->settings->system->theme.'_style',serialize($ductile_user)); $core->blog->settings->themes->put($core->blog->settings->system->theme.'_stickers',serialize($ductile_stickers)); $core->blog->settings->themes->put($core->blog->settings->system->theme.'_entries_lists',serialize($ductile_lists)); $core->blog->settings->themes->put($core->blog->settings->system->theme.'_entries_counts',serialize($ductile_counts)); // Blog refresh $core->blog->triggerBlog(); // Template cache reset $core->emptyTemplatesCache(); echo '

'. __('Theme configuration upgraded.'). '

'; } catch (Exception $e) { $core->error->add($e->getMessage()); } } // Legacy mode if (!$standalone_config) echo ''; # HTML Tab echo '
'; echo '
'; echo '
'.__('Header').''. '

'.'

'; if ($core->plugins->moduleExists('simpleMenu')) { echo '

'.sprintf(__('To configure the top menu go to the Simple Menu administration page.'),'plugin.php?p=simpleMenu').'

'; } echo '
'; echo '
'.__('Stickers').''; echo ''.''. ''. ''. ''. ''. ''. ''. ''. ''. ''; $count = 0; foreach ($ductile_stickers as $i => $v) { $count++; echo ''. ''. ''. ''. ''. ''; } echo ''. '
'.__('Stickers (footer)').'
'.''.__('Image').''.__('Label').''.__('URL').'
'.form::field(array('order['.$i.']'),2,3,$count,'position','',false). form::hidden(array('dynorder[]','dynorder-'.$i),$i).''.form::hidden(array('sticker_image[]'),$v['image']).' '.''.form::field(array('sticker_label[]','dsl-'.$i),20,255,$v['label']).''.form::field(array('sticker_url[]','dsu-'.$i),40,255,$v['url']).'
'; echo '
'; echo '
'.__('Entries list types and limits').''; echo ''.''. ''. ''. ''. ''. ''. ''. ''. ''; foreach ($ductile_lists as $k => $v) { echo ''. ''. ''; if (array_key_exists($k,$ductile_counts)) { echo ''; } else { echo ''; } echo ''; } echo ''. '
'.__('Entries lists').'
'.__('Context').''.__('Entries list type').''.__('Number of entries').'
'.$contexts[$k].''.form::hidden(array('list_ctx[]'),$k).form::combo(array('list_type[]'),$list_types,$v).''.form::hidden(array('count_ctx[]'),$k).form::field(array('count_nb[]'),2,3,$ductile_counts[$k]).'
'; echo '
'; echo ''; echo '

'.form::hidden('ds_order','').''.$core->formNonce().'

'; echo '
'; echo '
'; // Close tab # CSS tab echo '
'; echo '
'; echo '

'.__('General settings').'

'; echo '
'.__('Fonts').''. '

'. '

'. '
'; echo '
'; echo '
'; echo '
'.__('Blog title').''. '

'.'

'. '

'. form::field('blog_title_s',7,7,$ductile_user['blog_title_s']).'

'. '

'. form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker'). contrastRatio($ductile_user['blog_title_c'],'#ffffff', (!empty($ductile_user['blog_title_s']) ? $ductile_user['blog_title_s'] : '2em'), $ductile_user['blog_title_w']). '

'. '
'; echo '
'; echo '
'; echo '
'.__('Post title').''. '

'.'

'. '

'. form::field('post_title_s',7,7,$ductile_user['post_title_s']).'

'. '

'. form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker'). contrastRatio($ductile_user['post_title_c'],'#ffffff', (!empty($ductile_user['post_title_s']) ? $ductile_user['post_title_s'] : '2.5em'), $ductile_user['post_title_w']). '

'. '
'; echo '
'; echo '
'; echo '
'.__('Titles without link').''. '

'. form::field('post_simple_title_c',7,7,$ductile_user['post_simple_title_c'],'colorpicker'). contrastRatio($ductile_user['post_simple_title_c'],'#ffffff', '1.1em', // H5 minimum size false). '

'. '
'; echo '
'.__('Inside posts links').''. '

'.'

'. '

'. form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker'). contrastRatio($ductile_user['post_link_v_c'],'#ffffff', '1em', $ductile_user['post_link_w']). '

'. '

'. form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker'). contrastRatio($ductile_user['post_link_f_c'],'#ebebee', '1em', $ductile_user['post_link_w']). '

'. '
'; echo '

'.__('Mobile specific settings').'

'; echo '
'; echo '
'; echo '
'.__('Blog title').''. '

'.'

'. '

'. form::field('blog_title_s_m',7,7,$ductile_user['blog_title_s_m']).'

'. '

'. form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker'). contrastRatio($ductile_user['blog_title_c_m'],'#d7d7dc', (!empty($ductile_user['blog_title_s_m']) ? $ductile_user['blog_title_s_m'] : '1.8em'), $ductile_user['blog_title_w_m']). '

'. '
'; echo '
'; echo '
'; echo '
'.__('Post title').''. '

'.'

'. '

'. form::field('post_title_s_m',7,7,$ductile_user['post_title_s_m']).'

'. '

'. form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker'). contrastRatio($ductile_user['post_title_c_m'],'#ffffff', (!empty($ductile_user['post_title_s_m']) ? $ductile_user['post_title_s_m'] : '1.5em'), $ductile_user['post_title_w_m']). '

'. '
'; echo '
'; echo '
'; echo ''; echo '

'.$core->formNonce().'

'; echo '
'; echo '
'; // Close tab dcPage::helpBlock('ductile'); // Legacy mode if (!$standalone_config) echo '
'; ?>