/html/data/class/pages/admin/system/LC_Page_Admin_System_Masterdata.php
http://eccubeonazure.codeplex.com · PHP · 207 lines · 91 code · 25 blank · 91 comment · 14 complexity · 39b42099b3d3bcceb5d6a8c853100405 MD5 · raw file
- <?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_EX_REALDIR . 'page_extends/admin/LC_Page_Admin_Ex.php';
- /**
- * ????????? ???????.
- *
- * @package Page
- * @author LOCKON CO.,LTD.
- * @version $Id$
- */
- class LC_Page_Admin_System_Masterdata extends LC_Page_Admin_Ex {
- // }}}
- // {{{ functions
- /**
- * Page ??????.
- *
- * @return void
- */
- function init() {
- parent::init();
- $this->tpl_mainpage = 'system/masterdata.tpl';
- $this->tpl_subno = 'masterdata';
- $this->tpl_mainno = 'system';
- $this->tpl_maintitle = '??????';
- $this->tpl_subtitle = '?????????';
- }
- /**
- * Page ?????.
- *
- * @return void
- */
- function process() {
- $this->action();
- $this->sendResponse();
- }
- /**
- * Page ??????.
- *
- * @return void
- */
- function action() {
- $this->arrMasterDataName = $this->getMasterDataNames(array("mtb_pref",
- "mtb_zip",
- "mtb_constants"));
- $masterData = new SC_DB_MasterData_Ex();
- switch ($this->getMode()) {
- case 'edit':
- // POST ???????????
- $this->masterDataName = $this->checkMasterDataName($_POST, $this->arrMasterDataName);
- $this->errorMessage = $this->checkUniqueID($_POST);
- if (empty($this->errorMessage)) {
- // ???????????????????
- $this->registMasterData($_POST, $masterData, $this->masterDataName);
- $this->tpl_onload = "window.alert('??????????????????');";
- }
- case 'show':
- // POST ???????????
- $this->masterDataName = $this->checkMasterDataName($_POST, $this->arrMasterDataName);
- // DB ????????????
- $this->arrMasterData =
- $masterData->getDbMasterData($this->masterDataName);
- break;
- default:
- }
- }
- /**
- * ??????.
- *
- * @return void
- */
- function destroy() {
- parent::destroy();
- }
- /**
- * ???????????????
- *
- * @access private
- * @param array $_POST?
- * @param array $arrMasterDataName ????????????????
- * @return string $master_data_name ???????????????????
- */
- function checkMasterDataName(&$arrParams, &$arrMasterDataName) {
- if (in_array($arrParams['master_data_name'], $arrMasterDataName)) {
- $master_data_name = $arrParams['master_data_name'];
- return $master_data_name;
- } else {
- SC_Utils_Ex::sfDispError("");
- }
- }
- /**
- * ????????????????.
- *
- * @access private
- * @param array $ignores ????????????????
- * @return array ???????????
- */
- function getMasterDataNames($ignores = array()) {
- $dbFactory = SC_DB_DBFactory_Ex::getInstance();
- $arrMasterDataName = $dbFactory->findTableNames("mtb_");
- $i = 0;
- foreach ($arrMasterDataName as $val) {
- foreach ($ignores as $ignore) {
- if ($val == $ignore) {
- unset($arrMasterDataName[$i]);
- }
- }
- $i++;
- }
- return $arrMasterDataName;
- }
- /**
- * ID ??????????????.
- *
- * ??????????????????????????.
- *
- * @access private
- * @return void|string ??????????????????????.
- */
- function checkUniqueID(&$arrParams) {
- $arrId = $arrParams['id'];
- for ($i = 0; $i < count($arrId); $i++) {
- $id = $arrId[$i];
- // ??????
- if ($arrId[$i] != "") {
- for ($j = $i + 1; $j < count($arrId); $j++) {
- if ($id == $arrId[$j]) {
- return $id . " ????????????????.";
- }
- }
- }
- }
- }
- /**
- * ??????????.
- *
- * @access private{
- * @param array $arrParams $_POST?
- * @param object $masterData SC_DB_MasterData_Ex()
- * @param string $master_data_name ??????????????????
- * @return void
- */
- function registMasterData($arrParams, &$masterData, $master_data_name) {
- $arrTmp = array();
- foreach ($arrParams['id'] as $key => $val) {
- // ID ????????????
- if ($val != "") {
- $arrTmp[$val] = $arrParams['name'][$key];
- }
- }
- // ??????????
- $masterData->objQuery =& SC_Query_Ex::getSingletonInstance();
- $masterData->objQuery->begin();
- $masterData->deleteMasterData($master_data_name, false);
- // TODO ????????????????????
- $masterData->registMasterData($master_data_name,
- array('id', 'name', 'rank'),
- $arrTmp, false);
- $masterData->objQuery->commit();
- }
- }
- ?>