[EC-CUBE 2.11.4] メーカー一覧ブロックを新規作成する

新年明けましておめでとうございます!
今年はプログラミングの技術を磨いて、もっとEC-CUBE本体にコミットをしていけたらいいなーと思っています。
よろしくお願いします。

さて先日、メーカー登録機能について書いてから、EC-CUBEのメーカー仕様について、うつらうつらと考えていました。
今回はその中で、「メーカー一覧ブロックがあれば便利でね?」とのことでやってみました。

メーカー一覧ブロック

PC版のみです。バグあったらご指摘を。

1.html/frontparts/bloc/maker.php を新規作成

<?php
/*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

// {{{ requires
require_once realpath(dirname(__FILE__)) . '/../../require.php';
require_once CLASS_EX_REALDIR . 'page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_Maker_Ex.php';

// }}}
// {{{ generate page

$objPage = new LC_Page_FrontParts_BLoc_Maker_Ex();
$objPage->blocItems = $params['items'];
register_shutdown_function(array($objPage, "destroy"));
$objPage->init();
$objPage->process();
?>

2.data/class_extends/page_extends/frontparts/bloc/LC_Page_FrontParts_Bloc_Maker_Ex.php を作成

<?php
/*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

// {{{ requires
require_once CLASS_REALDIR . 'pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Maker.php';

/**
 * メーカー のページクラス(拡張).
 *
 * LC_Page_FrontParts_Bloc_Maker をカスタマイズする場合はこのクラスを編集する.
 *
 * @package Page
 * @author LOCKON CO.,LTD.
 * @version $Id: LC_Page_FrontParts_Bloc_Maker_Ex.php 2012-01-01 08:55:00 fukap $
 */
class LC_Page_FrontParts_Bloc_Maker_Ex extends LC_Page_FrontParts_Bloc_Maker {

    // }}}
    // {{{ functions

    /**
     * Page を初期化する.
     *
     * @return void
     */
    function init() {
        parent::init();
    }

    /**
     * Page のプロセス.
     *
     * @return void
     */
    function process() {
        parent::process();
    }

    /**
     * デストラクタ.
     *
     * @return void
     */
    function destroy() {
        parent::destroy();
    }
}
?>

3.data/class/pages/frontparts/bloc/LC_Page_FrontParts_Bloc_Maker.php を新規作成

<?php
/*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

// {{{ requires
require_once CLASS_REALDIR . 'pages/frontparts/bloc/LC_Page_FrontParts_Bloc.php';

/**
 * メーカー のページクラス.
 *
 * @package Page
 * @author LOCKON CO.,LTD.
 * @version $Id: LC_Page_FrontParts_Bloc_Maker.php 2012-01-01 08:55:00 fukap $
 */
class LC_Page_FrontParts_Bloc_Maker extends LC_Page_FrontParts_Bloc {

    // }}}
    // {{{ functions

    /**
     * Page を初期化する.
     *
     * @return void
     */
    function init() {
        parent::init();
    }

    /**
     * Page のプロセス.
     *
     * @return void
     */
    function process() {
        $this->action();
        $this->sendResponse();
    }

    /**
     * Page のアクション.
     *
     * @return void
     */
    function action() {
        // メーカーを取得
        $this->arrMakers = $this->lfGetMakers();
    }

    /**
     * デストラクタ.
     *
     * @return void
     */
    function destroy() {
        parent::destroy();
    }

    /**
     * メーカー一覧を取得する
     *
     * @param
     * @return array メーカー一覧の二次元配列
     */
    function lfGetMakers(){
        $objQuery =& SC_Query_Ex::getSingletonInstance();
        $col = 'maker_id, name';
        $where = 'del_flg = 0';
        $from = 'dtb_maker';
        $objQuery->setOrder('rank desc');
        return $objQuery->select($col, $from, $where);
    }
}
?>

4.data/Smarty/templates/default/frontparts/bloc/maker.tpl を新規作成

<!--{*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *}-->
<style type="text/css">
div#maker_area h2 {
    background-color:#de5e17;
    text-align:center;
    color:#fff;
    padding:7px 0 7px 0;
}
</style>

<!--{if count($arrMakers) > 0}-->
    <div class="bloc_outer clearfix">
        <div id="maker_area">
            <h2>メーカー一覧</h2>
            <div class="bloc_body clearfix">
                <ul>
                <!--{foreach from=$arrMakers item=arrMaker}-->
                    <li>
                        <a href="<!--{$smarty.const.ROOT_URLPATH}-->products/list.php?transactionid=<!--{$transactionid}-->&mode=search&maker_id=<!--{$arrMaker.maker_id|u}-->">
                            <!--{$arrMaker.name|h}-->
                        </a>
                    </li>
                <!--{/foreach}-->
                </ul>
            </div>
        </div>
    </div>
<!--{/if}-->

5.データベースの dtb_bloc に新規ブロックの情報を登録する

insert into dtb_bloc values(10,10,'メーカー','maker.tpl','maker','now()','now()','frontparts/bloc/maker.php',0);

6.管理画面>デザイン管理>PC>レイアウト設定で、未使用ブロックに「メーカー」ができているのを確認し、
  トップページの適当な場所に配置する。

前にも書きましたが、メーカー登録機能はEC-CUBE2.11ではとても中途半端な仕様でもったいないです。
今後、本体標準機能として提供し続けるのか、プラグイン提供に切り分けるのかは議論すべきだろうと思いますが、
メーカー登録を実装するなら、メーカー登録可能項目を拡充し、メーカー一覧ブロックやメーカー一覧ページは備えていた方がいいと思います。
個人的には、プラグイン機能がうまく働くなら、プラグイン提供が良いと思います。