<?php
/**
 * themes/[theme]/ckeditor4/preload.class.php
 * 
 * preload.class.php のクラス名は "ckeditor4_PreloadForTheme" 固定
 * setParams, preSetConfig, postSetConfig の3つの method を持つことができる
 * それぞれの method は必要な物だけでよい
 * 
 * @ param array $params Smarty プラグインから与えられたパラメタ
 * @ param array $config CKEditor に与える config 配列
 *                       key(string): config 名 
 *                       val(mixed) : 値  [] で括った文字列は、JavaScript のオブジェクトとして扱われる 
 *                                      その他の値は json_encode で処理され、 CKEditor に渡される
 * 
 * class ckeditor4_PreloadForTheme
 * {
 *     var $themeName; // 現在のテーマ名がセットされる
 *     
 *     // Smarty プラグインがから渡されたパラメタをカスタムする用
 *     function setParams(& $params) {}
 *     
 *     // ckeditor.config をカスタムする用
 *     // (Params 解釈前: Smarty プラグインで指定した toolbar や管理画面:一般設定の config は上書きできない)
 *     function preSetConfig(& $config, $params) {}
 *     
 *     // ckeditor.config をカスタムする用
 *     // (最終段階: すべての config を上書きできる)
 *     function postSetConfig(& $config, $params) {}
 * }
 * 
 * @author nao-pon
 */

if (!defined('XOOPS_ROOT_PATH')) exit();

class ckeditor4_PreloadForTheme
{
	var $themeName;
	
	function preSetConfig(& $config, $params) {
		
		// CKEditor.config: http://docs.ckeditor.com/#!/api/CKEDITOR.config
		
		if ($params['editor'] !== 'bbcode') {
			
			// bootstrap.min.css を編集エリアに追加読み込み
			$config['contentsCss'][] = XOOPS_THEME_URL . '/' . $this->themeName . '/css/bootstrap.min.css';
			
			// stylesSet を指定 (http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-stylesSet)
			$config['stylesSet'] =<<< EOD
[
	{ name: 'label',           element: 'span', attributes: { class: 'label'} },
	{ name: 'label-important', element: 'span', attributes: { class: 'label label-important'} },
	{ name: 'label-warning',   element: 'span', attributes: { class: 'label label-warning'} },
	{ name: 'label-success',   element: 'span', attributes: { class: 'label label-success'} },
	{ name: 'label-info',      element: 'span', attributes: { class: 'label label-info'} },
	{ name: 'label-inverse',   element: 'span', attributes: { class: 'label label-inverse'} },
	{ name: 'badge',           element: 'span', attributes: { class: 'badge'} },
	{ name: 'badge-important', element: 'span', attributes: { class: 'badge badge-important'} },
	{ name: 'badge-warning',   element: 'span', attributes: { class: 'badge badge-warning'} },
	{ name: 'badge-success',   element: 'span', attributes: { class: 'badge badge-success'} },
	{ name: 'badge-info',      element: 'span', attributes: { class: 'badge badge-info'} },
	{ name: 'badge-inverse',   element: 'span', attributes: { class: 'badge badge-inverse'} },
]
EOD;
		}

	}
}