EC cube でfckeditoerを使う。

カテゴリー: EC cube — admin @ 2009 年 5 月 9 日1:02 AM

http://wiki.ec-orange2.jp/index.php?%E3%82%AB%E3%82%B9%E3%82%BF%E3%83%9E%E3%82%A4%E3%82%BA%EF%BC%9A%E5%BF%9C%E7%94%A8%2F%E3%82%A8%E3%83%87%E3%82%A3%E3%82%BF%E3%81%AE%E3%83%AA%E3%83%83%E3%83%81%E5%8C%96

を参照させて頂きました。(補足付き)

fckconfig.jsの編集

解凍して作成されたfckeditor/fckconfig.jsを編集します。

//FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ;	// PHP style server side code↓FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ;	// PHP style server side codevar _FileBrowserLanguage	= 'php' ;	←'php'を設定var _QuickUploadLanguage	= 'php' ;	←'php'を設定

fckeditor.jsの編集

FCKeditorのパスを設定します。
ショップのドキュメントルート+/user_data/fckeditor/
としておきます。

FCKeditor.BasePath = '/shop/user_data/fckeditor/' ;

アップローダー設定

config.phpの編集

ファイルアップロードのサーバーサイドのスクリプト設定を行います。

/html/user_data/fckeditor/editor/filemanager/connectors/php/config.php

を編集します。

$Config['Enabled'] = true ; ←trueにする↓アップロードしたファイルの保存先(ドキュメントルートからのパス)$Config['UserFilesPath'] = '(ここはURLにします。)/shop/upload/save_image/’ ;↓アップロードしたファイルの(絶対パス)$Config[’UserFilesAbsolutePath’] = ‘/var/www/eccubes/html/upload/save_image/’ ;

↓アップロード出来るファイルを画像ファイルのみに変更

$Config[’AllowedExtensions’][’File’]	= array(’gif’, ‘jpeg’, ‘jpg’, ‘png’) ;

※FCKeditorのファイルアップロード機能はユーザー認証を必要としません。第三者が勝手にファイルをアップロードする事が可能なので、利用する際は注意してください。

テンプレートの編集

htmlの<head>内で必要な時だけ呼び出すために

data/Smarty/templates/default/admin/main_frame.tpl

の<head>~</head>に以下を追加します。

<!--{$tpl_head_option|smarty:nodefaults}-->

pageクラスの編集

FCKeditorを使用するページのクラスを編集します

  • LC_Page_Admin_Design_Bloc.php 192行目付近
    以下のように変更してください。

     

    default:
    $this->tpl_javascript .=     function fckeditorCreate(){var oFCKeditor = new FCKeditor( ‘bloc_html’ ) ;oFCKeditor.Height=’420′;
    
    oFCKeditor.ReplaceTextarea() ;
    
    }
    
    ;
    $this->tpl_head_option =
    <script type=”text/javascript” src=”.URL_DIR.user_data/fckeditor/fckeditor.js”></script>;
    $this->tpl_onload .= fckeditorCreate();
    if(isset($_POST[mode])) {
    GC_Utils::gfPrintLog(MODEエラー:.$_POST[mode]);
    }
    break;
  • LC_Page_Admin_Design_MainEdit.php 227行目付近
    以下のように変更してください

     

    $this->tpl_javascript .=     function fckeditorCreate(){var oFCKeditor = new FCKeditor( ‘tpl_data’ ) ;oFCKeditor.Height=’620′;
    
    oFCKeditor.ReplaceTextarea() ;
    
    }
    
    ;
    $this->tpl_head_option = <script type=”text/javascript” src=”.URL_DIR.user_data/fckeditor/fckeditor.js”></script>;
    $this->tpl_onload .= fckeditorCreate();
    
    // 画面の表示
    $objView->assignobj($this);
  • LC_Page_Admin_Products_Product.php
    まず以下の関数を追加します

     

    function lfSetFCKeditor(){
    $this->tpl_javascript .=     function fckeditorCreate(){var oFCKeditor = new FCKeditor() ;oFCKeditor.BasePath    = ‘/shop/user_data/fckeditor/’ ;
    
    oFCKeditor.Height=’420′;
    
    oFCKeditor.InstanceName = ‘main_comment’;
    
    oFCKeditor.ReplaceTextarea() ;
    
    for (i = 1; i < 6; i++) {
    
    oFCKeditor.InstanceName = ’sub_comment’+i;
    
    oFCKeditor.ReplaceTextarea() ;
    
    }
    
    }
    
    ;
    $this->tpl_head_option .= <script type=”text/javascript” src=”.URL_DIR.user_data/fckeditor/fckeditor.js”></script>;
    $this->tpl_onload .= fckeditorCreate();;
    }

    lfProductPage()の中を以下のように修正します。

     

            if (isset($_POST[image_key]) && !empty($_POST[image_key])) {
    $anchor_hash = location.hash=’# . $_POST[image_key] . ;
    } elseif (isset($_POST[anchor_key]) && !empty($_POST[anchor_key])) {
    $anchor_hash = location.hash=’# . $_POST[anchor_key] . ;
    } else {
    $anchor_hash = ;
    }

     

            if (isset($_POST[image_key]) && !empty($_POST[image_key])) {
    $anchor_hash = location.hash=’# . $_POST[image_key] . ‘;;
    } elseif (isset($_POST[anchor_key]) && !empty($_POST[anchor_key])) {
    $anchor_hash = location.hash=’# . $_POST[anchor_key] . ‘;;
    } else {
    $anchor_hash = ;
    }

また、lfProductPage()の最後に以下の行を追加します。

 

$this->lfSetFCKeditor();
  • detail.tpl
    main_commentとsub_comment1~5のnl2brを削除してください。

許可するタグの追加

管理画面のシステム設定→マスタデータ管理でmtb_allowed_tagに入力許可するタグを追加します。

BBcodeのsiteurlのtarget=”_blank”解除

カテゴリー: xoops — admin @ 2008 年 5 月 29 日12:38 AM

BBcodeのsiteurlのtarget指定を変更する

xoopsを使用していると様々な用途でBBcodeを使用する機会が出てくることでしょう。
さて、最もよく使用するものと言えば、

  • [img]
  • [url]
  • [siteurl]

あたりではないでしょうか。xoopsでは昔から[url]も[siteurl]もtargetにblank指定が標準でされていて、何もしなければ別窓で開いてしまう訳です。
[url]はまだ良いのですが、[siteurl]は自分のサイト内なのでちょっと鬱陶しいですね。
あんまり別窓で開きまくると怪しげなサイトのような雰囲気を醸し出してしまいます。
今回、別窓で開かないようにする為の改造を施してみます。

具体的な変更方法

今回はxoopscube2.1Lagacyの変更方法。
2.0系とかだとgoogle等の検索エンジンで探すと引っ掛かるでしょう。

XOOPSルートディレクトリ/modules/legacy/kernel/Legacy_TextFilter.class.php

この部分で、

292行目   

    function makeXCodeConvertTable(&$patterns, &$replacements) {   

        $patterns[] = "/\[siteurl\=(['\"]?)([^\"'<>]*)\\1\](.*)\[\/siteurl\]/sU";   

        $replacements[0][] = $replacements[1][] = '<a href="'.XOOPS_URL.'/\\2" mce_href="'.XOOPS_URL.'/\\2" target="_blank">\\3</a>'; 

はい、ここをいじります。ここでBBcodeのパターンを置き換えています。
今回はsiteurlをとりあえず変更するので、別窓で開かないようにする為には、target=”_blank”を削除すれば良いのです。

292行目   

    function makeXCodeConvertTable(&$patterns, &$replacements) {   

        $patterns[] = "/\[siteurl\=(['\"]?)([^\"'<>]*)\\1\](.*)\[\/siteurl\]/sU";   

        $replacements[0][] = $replacements[1][] = '<a href="'.XOOPS_URL.'/\\2" mce_href="'.XOOPS_URL.'/\\2">\\3</a>';

簡単に出来ますね。

ちなみに、xhtmlのstrictとかでコーディングされている方は、urlなどもtarget指定しないようにここで設定したり出来ます。