コード例 #1
0
ファイル: index.php プロジェクト: nikrou/dotclear
        if ($can_write_images) {
            $uploaded = null;
            if ($blowup_user['uploaded'] && is_file(blowupConfig::imagesPath() . '/' . $blowup_user['uploaded'])) {
                $uploaded = blowupConfig::imagesPath() . '/' . $blowup_user['uploaded'];
            }
            if (!empty($_FILES['upfile']) && !empty($_FILES['upfile']['name'])) {
                files::uploadStatus($_FILES['upfile']);
                $uploaded = blowupConfig::uploadImage($_FILES['upfile']);
                $blowup_user['uploaded'] = basename($uploaded);
            }
            $blowup_user['top_image'] = in_array($_POST['top_image'], $top_images) ? $_POST['top_image'] : 'default';
            $blowup_user['body_bg_c'] = dcThemeConfig::adjustColor($_POST['body_bg_c']);
            $blowup_user['body_bg_g'] = in_array($_POST['body_bg_g'], $gradient_types) ? $_POST['body_bg_g'] : '';
            $blowup_user['post_comment_bg_c'] = dcThemeConfig::adjustColor($_POST['post_comment_bg_c']);
            $blowup_user['post_commentmy_bg_c'] = dcThemeConfig::adjustColor($_POST['post_commentmy_bg_c']);
            $blowup_user['prelude_c'] = dcThemeConfig::adjustColor($_POST['prelude_c']);
            blowupConfig::createImages($blowup_user, $uploaded);
        }
        if ($can_write_css) {
            blowupConfig::createCss($blowup_user);
        }
        $core->blog->settings->addNamespace('themes');
        $core->blog->settings->themes->put('blowup_style', serialize($blowup_user));
        $core->blog->triggerBlog();
        dcPage::addSuccessNotice(__('Theme configuration has been successfully updated.'));
        http::redirect($p_url);
    } catch (Exception $e) {
        $core->error->add($e->getMessage());
    }
}
?>
コード例 #2
0
ファイル: _config.php プロジェクト: nikrou/dotclear
            $ductile_user['blog_title_w'] = (int) (!empty($_POST['blog_title_w']));
            $ductile_user['blog_title_s'] = dcThemeConfig::adjustFontSize($_POST['blog_title_s']);
            $ductile_user['blog_title_c'] = dcThemeConfig::adjustColor($_POST['blog_title_c']);
            $ductile_user['post_title_w'] = (int) (!empty($_POST['post_title_w']));
            $ductile_user['post_title_s'] = dcThemeConfig::adjustFontSize($_POST['post_title_s']);
            $ductile_user['post_title_c'] = dcThemeConfig::adjustColor($_POST['post_title_c']);
            $ductile_user['post_link_w'] = (int) (!empty($_POST['post_link_w']));
            $ductile_user['post_link_v_c'] = dcThemeConfig::adjustColor($_POST['post_link_v_c']);
            $ductile_user['post_link_f_c'] = dcThemeConfig::adjustColor($_POST['post_link_f_c']);
            $ductile_user['post_simple_title_c'] = dcThemeConfig::adjustColor($_POST['post_simple_title_c']);
            $ductile_user['blog_title_w_m'] = (int) (!empty($_POST['blog_title_w_m']));
            $ductile_user['blog_title_s_m'] = dcThemeConfig::adjustFontSize($_POST['blog_title_s_m']);
            $ductile_user['blog_title_c_m'] = dcThemeConfig::adjustColor($_POST['blog_title_c_m']);
            $ductile_user['post_title_w_m'] = (int) (!empty($_POST['post_title_w_m']));
            $ductile_user['post_title_s_m'] = dcThemeConfig::adjustFontSize($_POST['post_title_s_m']);
            $ductile_user['post_title_c_m'] = dcThemeConfig::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();
        dcPage::message(__('Theme configuration upgraded.'), true, true);
    } catch (Exception $e) {
        $core->error->add($e->getMessage());
    }
}
コード例 #3
0
 public static function createImages(&$config, $uploaded)
 {
     $body_color = $config['body_bg_c'];
     $prelude_color = $config['prelude_c'];
     $gradient = $config['body_bg_g'];
     $comment_color = $config['post_comment_bg_c'];
     $comment_color_my = $config['post_commentmy_bg_c'];
     $top_image = $config['top_image'];
     $config['top_height'] = null;
     if ($top_image != 'custom' && !isset(self::$top_images[$top_image])) {
         $top_image = 'default';
     }
     if ($uploaded && !is_file($uploaded)) {
         $uploaded = null;
     }
     if (!self::canWriteImages(true)) {
         throw new Exception(__('Unable to create images.'));
     }
     $body_fill = array('light' => dirname(__FILE__) . '/../alpha-img/gradient-l.png', 'medium' => dirname(__FILE__) . '/../alpha-img/gradient-m.png', 'dark' => dirname(__FILE__) . '/../alpha-img/gradient-d.png');
     $body_g = isset($body_fill[$gradient]) ? $body_fill[$gradient] : false;
     if ($top_image == 'custom' && $uploaded) {
         $page_t = $uploaded;
     } else {
         $page_t = dirname(__FILE__) . '/../alpha-img/page-t/' . $top_image . '.png';
     }
     $body_bg = dirname(__FILE__) . '/../alpha-img/body-bg.png';
     $page_t_mask = dirname(__FILE__) . '/../alpha-img/page-t/image-mask.png';
     $page_b = dirname(__FILE__) . '/../alpha-img/page-b.png';
     $comment_t = dirname(__FILE__) . '/../alpha-img/comment-t.png';
     $comment_b = dirname(__FILE__) . '/../alpha-img/comment-b.png';
     $default_bg = '#e0e0e0';
     $default_prelude = '#ededed';
     self::dropImage(basename($body_bg));
     self::dropImage('page-t.png');
     self::dropImage(basename($page_b));
     self::dropImage(basename($comment_t));
     self::dropImage(basename($comment_b));
     $body_color = dcThemeConfig::adjustColor($body_color);
     $prelude_color = dcThemeConfig::adjustColor($prelude_color);
     $comment_color = dcThemeConfig::adjustColor($comment_color);
     if ($top_image || $body_color || $gradient != 'light' || $prelude_color || $uploaded) {
         if (!$body_color) {
             $body_color = $default_bg;
         }
         $body_color = sscanf($body_color, '#%2X%2X%2X');
         # Create body gradient with color
         $d_body_bg = imagecreatetruecolor(50, 180);
         $fill = imagecolorallocate($d_body_bg, $body_color[0], $body_color[1], $body_color[2]);
         imagefill($d_body_bg, 0, 0, $fill);
         # User choosed a gradient
         if ($body_g) {
             $s_body_bg = imagecreatefrompng($body_g);
             imagealphablending($s_body_bg, true);
             imagecopy($d_body_bg, $s_body_bg, 0, 0, 0, 0, 50, 180);
             imagedestroy($s_body_bg);
         }
         if (!$prelude_color) {
             $prelude_color = $default_prelude;
         }
         $prelude_color = sscanf($prelude_color, '#%2X%2X%2X');
         $s_prelude = imagecreatetruecolor(50, 30);
         $fill = imagecolorallocate($s_prelude, $prelude_color[0], $prelude_color[1], $prelude_color[2]);
         imagefill($s_prelude, 0, 0, $fill);
         imagecopy($d_body_bg, $s_prelude, 0, 0, 0, 0, 50, 30);
         imagepng($d_body_bg, self::imagesPath() . '/' . basename($body_bg));
     }
     if ($top_image || $body_color || $gradient != 'light') {
         # Create top image from uploaded image
         $size = getimagesize($page_t);
         $size = $size[1];
         $type = files::getMimeType($page_t);
         $d_page_t = imagecreatetruecolor(800, $size);
         if ($type == 'image/png') {
             $s_page_t = @imagecreatefrompng($page_t);
         } else {
             $s_page_t = @imagecreatefromjpeg($page_t);
         }
         if (!$s_page_t) {
             throw new exception(__('Unable to open image.'));
         }
         $fill = imagecolorallocate($d_page_t, $body_color[0], $body_color[1], $body_color[2]);
         imagefill($d_page_t, 0, 0, $fill);
         if ($type == 'image/png') {
             # PNG, we only add body gradient and image
             imagealphablending($s_page_t, true);
             imagecopyresized($d_page_t, $d_body_bg, 0, 0, 0, 50, 800, 130, 50, 130);
             imagecopy($d_page_t, $s_page_t, 0, 0, 0, 0, 800, $size);
         } else {
             # JPEG, we add image and a frame with rounded corners
             imagecopy($d_page_t, $s_page_t, 0, 0, 0, 0, 800, $size);
             imagecopy($d_page_t, $d_body_bg, 0, 0, 0, 50, 8, 4);
             imagecopy($d_page_t, $d_body_bg, 0, 4, 0, 54, 4, 4);
             imagecopy($d_page_t, $d_body_bg, 792, 0, 0, 50, 8, 4);
             imagecopy($d_page_t, $d_body_bg, 796, 4, 0, 54, 4, 4);
             $mask = imagecreatefrompng($page_t_mask);
             imagealphablending($mask, true);
             imagecopy($d_page_t, $mask, 0, 0, 0, 0, 800, 11);
             imagedestroy($mask);
             $fill = imagecolorallocate($d_page_t, 255, 255, 255);
             imagefilledrectangle($d_page_t, 0, 11, 3, $size - 1, $fill);
             imagefilledrectangle($d_page_t, 796, 11, 799, $size - 1, $fill);
             imagefilledrectangle($d_page_t, 0, $size - 9, 799, $size - 1, $fill);
         }
         $config['top_height'] = $size . 'px';
         imagepng($d_page_t, self::imagesPath() . '/page-t.png');
         imagedestroy($d_body_bg);
         imagedestroy($d_page_t);
         imagedestroy($s_page_t);
         # Create bottom image with color
         $d_page_b = imagecreatetruecolor(800, 8);
         $fill = imagecolorallocate($d_page_b, $body_color[0], $body_color[1], $body_color[2]);
         imagefill($d_page_b, 0, 0, $fill);
         $s_page_b = imagecreatefrompng($page_b);
         imagealphablending($s_page_b, true);
         imagecopy($d_page_b, $s_page_b, 0, 0, 0, 0, 800, 160);
         imagepng($d_page_b, self::imagesPath() . '/' . basename($page_b));
         imagedestroy($d_page_b);
         imagedestroy($s_page_b);
     }
     if ($comment_color) {
         self::commentImages($comment_color, $comment_t, $comment_b, basename($comment_t), basename($comment_b));
     }
     if ($comment_color_my) {
         self::commentImages($comment_color_my, $comment_t, $comment_b, 'commentmy-t.png', 'commentmy-b.png');
     }
 }