Index: branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Bloc_Ex.php
===================================================================
--- branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Bloc_Ex.php	(revision 22610)
+++ branches/version-2_12-dev/data/class_extends/helper_extends/SC_Helper_Bloc_Ex.php	(revision 22610)
@@ -0,0 +1,39 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 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 . 'helper/SC_Helper_Bloc.php';
+
+/**
+ * ブロックを管理するヘルパークラス(拡張).
+ *
+ * LC_Helper_Bloc をカスタマイズする場合はこのクラスを編集する.
+ *
+ * @package Helper
+ * @author pineray
+ * @version $Id:$
+ */
+class SC_Helper_Bloc_Ex extends SC_Helper_Bloc
+{
+    //put your code here
+}
Index: branches/version-2_12-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php
===================================================================
--- branches/version-2_12-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php	(revision 22567)
+++ branches/version-2_12-dev/data/class/pages/admin/design/LC_Page_Admin_Design_Bloc.php	(revision 22610)
@@ -86,4 +86,5 @@
         $this->device_type_id = $objFormParam->getValue('device_type_id', DEVICE_TYPE_PC);
 
+        $objBloc = new SC_Helper_Bloc_Ex($this->device_type_id);
         $objLayout = new SC_Helper_PageLayout_Ex();
 
@@ -92,7 +93,7 @@
             case 'confirm':
                 if (!$is_error) {
-                    $this->arrErr = $this->lfCheckError($objFormParam, $this->arrErr, $objLayout);
+                    $this->arrErr = $this->lfCheckError($objFormParam, $this->arrErr, $objBloc);
                     if (SC_Utils_Ex::isBlank($this->arrErr)) {
-                        $result = $this->doRegister($objFormParam, $objLayout);
+                        $result = $this->doRegister($objFormParam, $objBloc);
                         if ($result !== false) {
                             $arrPram = array(
@@ -112,5 +113,5 @@
             case 'delete':
                 if (!$is_error) {
-                    if ($this->doDelete($objFormParam, $objLayout)) {
+                    if ($this->doDelete($objFormParam, $objBloc)) {
                         $arrPram = array(
                             'device_type_id' => $this->device_type_id,
@@ -134,8 +135,8 @@
         if (!$is_error) {
             // ブロック一覧を取得
-            $this->arrBlocList = $objLayout->getBlocs($this->device_type_id);
+            $this->arrBlocList = $objBloc->getList();
             // bloc_id が指定されている場合にはブロックデータの取得
             if (!SC_Utils_Ex::isBlank($this->bloc_id)) {
-                $arrBloc = $this->getBlocTemplate($this->device_type_id, $this->bloc_id, $objLayout);
+                $arrBloc = $this->getBlocTemplate($this->bloc_id, $objBloc);
                 $objFormParam->setParam($arrBloc);
             }
@@ -177,21 +178,12 @@
      * ブロックのテンプレートを取得する.
      *
-     * @param integer $device_type_id 端末種別ID
      * @param integer $bloc_id ブロックID
-     * @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス
+     * @param SC_Helper_Bloc_Ex $objBloc SC_Helper_Bloc_Ex インスタンス
      * @return array ブロック情報の配列
      */
-    function getBlocTemplate($device_type_id, $bloc_id, &$objLayout)
-    {
-        $arrBloc = $objLayout->getBlocs($device_type_id, 'bloc_id = ?', array($bloc_id));
-        if (SC_Utils_Ex::isAbsoluteRealPath($arrBloc[0]['tpl_path'])) {
-            $tpl_path = $arrBloc[0]['tpl_path'];
-        } else {
-            $tpl_path = SC_Helper_PageLayout_Ex::getTemplatePath($device_type_id) . BLOC_DIR . $arrBloc[0]['tpl_path'];
-        }
-        if (file_exists($tpl_path)) {
-            $arrBloc[0]['bloc_html'] = file_get_contents($tpl_path);
-        }
-        return $arrBloc[0];
+    function getBlocTemplate($bloc_id, SC_Helper_Bloc_Ex &$objBloc)
+    {
+        $arrBloc = $objBloc->get($bloc_id);
+        return $arrBloc;
     }
 
@@ -203,57 +195,18 @@
      *
      * @param SC_FormParam $objFormParam SC_FormParam インスタンス
-     * @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス
+     * @param SC_Helper_Bloc $objBloc SC_Helper_Bloc インスタンス
      * @return integer|boolean 登録が成功した場合, 登録したブロックID;
      *                         失敗した場合 false
      */
-    function doRegister(&$objFormParam, &$objLayout)
+    function doRegister(&$objFormParam, SC_Helper_Bloc_Ex &$objBloc)
     {
         $arrParams = $objFormParam->getHashArray();
-
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        $objQuery->begin();
-
-        // blod_id が空の場合は新規登録
-        $is_new = SC_Utils_Ex::isBlank($arrParams['bloc_id']);
-        $bloc_dir = $objLayout->getTemplatePath($arrParams['device_type_id']) . BLOC_DIR;
-        // 既存データの重複チェック
-        if (!$is_new) {
-            $arrExists = $objLayout->getBlocs($arrParams['device_type_id'], 'bloc_id = ?', array($arrParams['bloc_id']));
-
-            // 既存のファイルが存在する場合は削除しておく
-            $exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl';
-            if (file_exists($exists_file)) {
-                unlink($exists_file);
-            }
-        }
-
-        $table = 'dtb_bloc';
-        $arrValues = $objQuery->extractOnlyColsOf($table, $arrParams);
-        $arrValues['tpl_path'] = $arrParams['filename'] . '.tpl';
-        $arrValues['update_date'] = 'CURRENT_TIMESTAMP';
-
-        // 新規登録
-        if ($is_new || SC_Utils_Ex::isBlank($arrExists)) {
-            $objQuery->setOrder('');
-            $arrValues['bloc_id'] = 1 + $objQuery->max('bloc_id', $table, 'device_type_id = ?',
-                                                       array($arrValues['device_type_id']));
-            $arrValues['create_date'] = 'CURRENT_TIMESTAMP';
-            $objQuery->insert($table, $arrValues);
-        }
-        // 更新
-        else {
-            $objQuery->update($table, $arrValues, 'bloc_id = ? AND device_type_id = ?',
-                              array($arrValues['bloc_id'], $arrValues['device_type_id']));
-        }
-
-        $bloc_path = $bloc_dir . $arrValues['tpl_path'];
-        if (!SC_Helper_FileManager_Ex::sfWriteFile($bloc_path, $arrParams['bloc_html'])) {
+        $result = $objBloc->save($arrParams);
+
+        if (!$result) {
             $this->arrErr['err'] = '※ ブロックの書き込みに失敗しました<br />';
-            $objQuery->rollback();
-            return false;
-        }
-
-        $objQuery->commit();
-        return $arrValues['bloc_id'];
+        }
+
+        return $result;
     }
 
@@ -262,42 +215,17 @@
      *
      * @param SC_FormParam $objFormParam SC_FormParam インスタンス
-     * @param SC_Helper_PageLayout $objLayout SC_Helper_PageLayout インスタンス
+     * @param SC_Helper_Bloc $objBloc SC_Helper_Bloc インスタンス
      * @return boolean 登録が成功した場合 true; 失敗した場合 false
      */
-    function doDelete(&$objFormParam, &$objLayout)
+    function doDelete(&$objFormParam, SC_Helper_Bloc_Ex &$objBloc)
     {
         $arrParams = $objFormParam->getHashArray();
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        $objQuery->begin();
-
-        $arrExists = $objLayout->getBlocs($arrParams['device_type_id'], 'bloc_id = ? AND deletable_flg = 1',
-                                          array($arrParams['bloc_id']));
-        $is_error = false;
-        if (!SC_Utils_Ex::isBlank($arrExists)) {
-            $objQuery->delete('dtb_bloc', 'bloc_id = ? AND device_type_id = ?',
-                              array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id']));
-            $objQuery->delete('dtb_blocposition', 'bloc_id = ? AND device_type_id = ?',
-                              array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id']));
-
-            $bloc_dir = $objLayout->getTemplatePath($arrParams['device_type_id']) . BLOC_DIR;
-            $exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl';
-
-            // ファイルの削除
-            if (file_exists($exists_file)) {
-                if (!unlink($exists_file)) {
-                    $is_error = true;
-                }
-            }
-        } else {
-            $is_error = true;
-        }
-
-        if ($is_error) {
+        $result = $objBloc->delete($arrParams['bloc_id']);
+
+        if (!$result) {
             $this->arrErr['err'] = '※ ブロックの削除に失敗しました<br />';
-            $objQuery->rollback();
-            return false;
-        }
-        $objQuery->commit();
-        return true;
+        }
+
+        return $result;
     }
 
@@ -308,5 +236,5 @@
      * @return array エラーメッセージの配列
      */
-    function lfCheckError(&$objFormParam, &$arrErr, &$objLayout)
+    function lfCheckError(&$objFormParam, &$arrErr, SC_Helper_Bloc_Ex &$objBloc)
     {
         $arrParams = $objFormParam->getHashArray();
@@ -324,5 +252,5 @@
             $arrValues[] = $arrParams['bloc_id'];
         }
-        $arrBloc = $objLayout->getBlocs($arrParams['device_type_id'], $where, $arrValues);
+        $arrBloc = $objBloc->getWhere($where, $arrValues);
         if (!SC_Utils_Ex::isBlank($arrBloc)) {
             $objErr->arrErr['filename'] = '※ 同じファイル名のデータが存在しています。別のファイル名を入力してください。<br />';
Index: branches/version-2_12-dev/data/class/helper/SC_Helper_PageLayout.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_PageLayout.php	(revision 22567)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_PageLayout.php	(revision 22610)
@@ -138,9 +138,6 @@
     function getBlocs($device_type_id = DEVICE_TYPE_PC, $where = '', $arrParams = array(), $has_realpath = true)
     {
-        $objQuery =& SC_Query_Ex::getSingletonInstance();
-        $where = 'device_type_id = ? ' . (SC_Utils_Ex::isBlank($where) ? $where : 'AND ' . $where);
-        $arrParams = array_merge(array($device_type_id), $arrParams);
-        $objQuery->setOrder('bloc_id');
-        $arrBlocs = $objQuery->select('*', 'dtb_bloc', $where, $arrParams);
+        $objBloc = new SC_Helper_Bloc_Ex($device_type_id);
+        $arrBlocs = $objBloc->getWhere($where, $arrParams);
         if ($has_realpath) {
             $this->setBlocPathTo($device_type_id, $arrBlocs);
Index: branches/version-2_12-dev/data/class/helper/SC_Helper_Bloc.php
===================================================================
--- branches/version-2_12-dev/data/class/helper/SC_Helper_Bloc.php	(revision 22610)
+++ branches/version-2_12-dev/data/class/helper/SC_Helper_Bloc.php	(revision 22610)
@@ -0,0 +1,198 @@
+<?php
+/*
+ * This file is part of EC-CUBE
+ *
+ * Copyright(c) 2000-2013 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.
+ */
+
+/**
+ * ブロックを管理するヘルパークラス.
+ *
+ * @package Helper
+ * @author pineray
+ * @version $Id:$
+ */
+class SC_Helper_Bloc
+{
+    private $device_type_id = NULL;
+
+    function __construct($devide_type_id = DEVICE_TYPE_PC)
+    {
+        $this->device_type_id = $devide_type_id;
+    }
+
+    /**
+     * ブロックの情報を取得.
+     * 
+     * @param integer $bloc_id ブロックID
+     * @return array
+     */
+    public function get($bloc_id)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $col = '*';
+        $where = 'bloc_id = ? AND device_type_id = ?';
+        $arrRet = $objQuery->getRow($col, 'dtb_bloc', $where, array($bloc_id, $this->device_type_id));
+        if (SC_Utils_Ex::isAbsoluteRealPath($arrRet['tpl_path'])) {
+            $tpl_path = $arrRet['tpl_path'];
+        } else {
+            $tpl_path = SC_Helper_PageLayout_Ex::getTemplatePath($this->device_type_id) . BLOC_DIR . $arrRet['tpl_path'];
+        }
+        if (file_exists($tpl_path)) {
+            $arrRet['bloc_html'] = file_get_contents($tpl_path);
+        }
+        return $arrRet;
+    }
+
+    /**
+     * ブロック一覧の取得.
+     *
+     * @return array
+     */
+    public function getList()
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $col = '*';
+        $where = 'device_type_id = ?';
+        $table = 'dtb_bloc';
+        $arrRet = $objQuery->select($col, $table, $where, array($this->device_type_id));
+        return $arrRet;
+    }
+
+    /**
+     * where句で条件を指定してブロック一覧を取得.
+     * 
+     * @param string $where
+     * @param array $sqlval
+     */
+    public function getWhere($where = '', $sqlval = array())
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $col = '*';
+        $where = 'device_type_id = ? ' . (SC_Utils_Ex::isBlank($where) ? $where : 'AND ' . $where);
+        array_unshift($sqlval, $this->device_type_id);
+        $table = 'dtb_bloc';
+        $arrRet = $objQuery->select($col, $table, $where, $sqlval);
+        return $arrRet;
+    }
+
+    /**
+     * ブロックの登録.
+     * 
+     * @param array $sqlval
+     * @return multiple 登録成功:ブロックID, 失敗:FALSE
+     */
+    public function save($sqlval)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $objQuery->begin();
+
+        // blod_id が空の場合は新規登録
+        $is_new = SC_Utils_Ex::isBlank($sqlval['bloc_id']);
+        $bloc_dir = SC_Helper_PageLayout_Ex::getTemplatePath($sqlval['device_type_id']) . BLOC_DIR;
+        // 既存データの重複チェック
+        if (!$is_new) {
+            $arrExists = $this->get($sqlval['bloc_id']);
+
+            // 既存のファイルが存在する場合は削除しておく
+            $exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl';
+            if (file_exists($exists_file)) {
+                unlink($exists_file);
+            }
+        }
+
+        $table = 'dtb_bloc';
+        $arrValues = $objQuery->extractOnlyColsOf($table, $sqlval);
+        $arrValues['tpl_path'] = $sqlval['filename'] . '.tpl';
+        $arrValues['update_date'] = 'CURRENT_TIMESTAMP';
+
+        // 新規登録
+        if ($is_new || SC_Utils_Ex::isBlank($arrExists)) {
+            $objQuery->setOrder('');
+            $arrValues['bloc_id'] = 1 + $objQuery->max('bloc_id', $table, 'device_type_id = ?',
+                                                       array($arrValues['device_type_id']));
+            $arrValues['create_date'] = 'CURRENT_TIMESTAMP';
+            $objQuery->insert($table, $arrValues);
+        }
+        // 更新
+        else {
+            $objQuery->update($table, $arrValues, 'bloc_id = ? AND device_type_id = ?',
+                              array($arrValues['bloc_id'], $arrValues['device_type_id']));
+        }
+
+        $bloc_path = $bloc_dir . $arrValues['tpl_path'];
+        if (!SC_Helper_FileManager_Ex::sfWriteFile($bloc_path, $sqlval['bloc_html'])) {
+            $objQuery->rollback();
+            return false;
+        }
+
+        $objQuery->commit();
+        return $arrValues['bloc_id'];
+    }
+
+    /**
+     * ブロックの削除.
+     * 
+     * @param integer $bloc_id
+     * @return boolean
+     */
+    public function delete($bloc_id)
+    {
+        $objQuery =& SC_Query_Ex::getSingletonInstance();
+        $objQuery->begin();
+
+        $arrExists = $this->getWhere('bloc_id = ? AND deletable_flg = 1', array($bloc_id));
+        $is_error = false;
+        if (!SC_Utils_Ex::isBlank($arrExists)) {
+            $objQuery->delete('dtb_bloc', 'bloc_id = ? AND device_type_id = ?',
+                              array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id']));
+            $objQuery->delete('dtb_blocposition', 'bloc_id = ? AND device_type_id = ?',
+                              array($arrExists[0]['bloc_id'], $arrExists[0]['device_type_id']));
+
+            $bloc_dir = SC_Helper_PageLayout_Ex::getTemplatePath($this->device_type_id) . BLOC_DIR;
+            $exists_file = $bloc_dir . $arrExists[0]['filename'] . '.tpl';
+
+            // ファイルの削除
+            if (file_exists($exists_file)) {
+                if (!unlink($exists_file)) {
+                    $is_error = true;
+                }
+            }
+        } else {
+            $is_error = true;
+        }
+
+        if ($is_error) {
+            $objQuery->rollback();
+            return false;
+        }
+        $objQuery->commit();
+        return true;
+    }
+
+    /**
+     * 端末種別IDのメンバー変数を取得.
+     * 
+     * @return integer 端末種別ID
+     */
+    public function getDeviceTypeID()
+    {
+        return $this->device_type_id; 
+    }
+}
