kazpgmの日記

『プログラム自動作成@自動生成』作成の日記

TOOL更新_ベースになるサンプルを作成中。の続き。

TOOL更新_ベースになるサンプルを作成中。の続き。
http://d.hatena.ne.jp/kazpgm/20100121/1264095498 (TOOL更新_ベースになるサンプルを作成中)を修正した。

<<修正前>>

<<修正後>>

<<修正前>>

<<修正後>>

■LogininfoAController.php 修正
 ・AppConstクラスを使うように修正
<<修正前>>

// 管理者用Controllerの基底クラス
require_once 'ControllerABaseExt.php';
・・・
// admin側Controller実装クラス
class Logininfo_LogininfoAController extends ControllerABaseExt {
・・・
        $conditions[ControllerBase::STM] = $condstm; // ステートメント
        $conditions[ControllerBase::VAL_ARY] = $condvalary; // 値の配列

<<修正後>>

// 管理者用Controllerの基底クラス
require_once 'ControllerAdminBase.php';
・・・
// admin側Controller実装クラス
class Logininfo_LogininfoAController extends ControllerAdminBase {
・・・
        $conditions[AppConst::STM] = $condstm; // ステートメント
        $conditions[AppConst::VAL_ARY] = $condvalary; // 値の配列

■LogininfoAUtil.php
 ・AppConstクラスを使うように修正

<<修正前>>
        $condstm = $conditions[ControllerBase::STM];    // ステートメント
        $valary = $conditions[ControllerBase::VAL_ARY]; // 値の配列
・・・
        $condstm = $conditions[ControllerBase::STM];        // ステートメント
        $valary = $conditions[ControllerBase::VAL_ARY]; // 値の配列

<<修正後>>

        $condstm = $conditions[AppConst::STM];    // ステートメント
        $valary = $conditions[AppConst::VAL_ARY]; // 値の配列
・・・
        $condstm = $conditions[AppConst::STM];        // ステートメント
        $valary = $conditions[AppConst::VAL_ARY]; // 値の配列

■ControllerABaseExt.php ー> ControllerAdminBase.php 名前変更および、修正
 ・アクションクラスは管理者側、ユーザ側、その他のプログラムで違うので
  ControllerABase.phpからここに移動した。

    // indexアクション(実装ロジック)
    public function indexAction() 
    {
        $this->_o['mode'] = ''; // モードを空にする。
        $this->_commAct();
    }

    // 一覧アクション
    public function listAction()
    {
        $this->_o['mode'] = 'list'; // モード設定する。
        $this->_commAct();
    }

    // 検索実行アクション
    public function listdoAction()
    {
        $this->_o['mode'] = 'list_do'; // モード設定する。
        $this->_commAct();
    }

    // 一覧昇順降順アクション
    public function listupdwnAction()
    {
        $this->_o['mode'] = 'list_up_dwn'; // モード設定する。
        $this->_commAct();
    }

    // 詳細、変更から戻ったときアクション
    public function listbackAction()
    {
        $this->_o['mode'] = 'list_back'; // モード設定する。
        $this->_commAct();
    }

    // 登録アクション
    public function insAction()
    {
        $this->_o['mode'] = 'ins'; // モード設定する。
        $this->_commAct();
    }

    // 登録の実行アクション
    public function insdoAction()
    {
        $this->_o['mode'] = 'ins_do'; // モード設定する。
        $this->_commAct();
    }

    // 変更アクション
    public function updAction()
    {
        $this->_o['mode'] = 'upd'; // モード設定する。
        $this->_commAct();
    }

    // 変更の実行アクション
    public function upddoAction()
    {
        $this->_o['mode'] = 'upd_do'; // モード設定する。
        $this->_commAct();
    }

    // 削除の実行アクション
    public function deldoAction()
    {
        $this->_o['mode'] = 'del_do'; // モード設定する。
        $this->_commAct();
    }

    // 詳細の実行アクション
    public function detailAction()
    {
        $this->_o['mode'] = 'detail'; // モード設定する。
        $this->_commAct();
    }

    // CSVダウンロードの実行アクション
    public function csvAction()
    {
        $this->_o['mode'] = 'csv'; // モード設定する。
        $this->_commAct();
    }

・ControllerBase.phpのindexActionメソッドを変更したための修正
 トークンチェックをControllerBase.phpからControllerAdminBase.phpに移動した。

    protected function _commActSub() { // 親クラスでabstractメソッドにしてある。親クラスの_commAct()から呼ばれる。
        $this->_o['c_elements_idx'] = '0';
        $this->_mode = strtolower($this->_o['mode']);
        $this->_modeBk = $this->_mode;
        // トークンチェックを行う。セッションは管理者側、ユーザ側別にしてあります。
        if (TokenHandle::isTokenValid($this->_getAdminKbn(), $this->_o, strtolower($this->_o['mode']), 
                             $this->_getAdminKbn() == AppConst::VAL_USER) == false) { // 管理者側トークンチェック
            // トークンチェックエラー場合
            throw new AppException('画面遷移(トークンチェック)エラーです。');
        }

・その他
 _getAdminKbnメソッド(管理者側かユーザ側かを戻す。(おもにトークンチェックで使用する))追加

■ControllerABase.php   ー> ControllerDbBase.php 名前変更および、修正
 このクラスはDBマネージャを使用するプログラムに使用する基底クラスという考え方にした。
 ・トークンチェックをこのクラスからControllerAdminBase.phpに移動した。
 ・アクションクラスをこのクラスからControllerAdminBase.phpに移動した。

■ControllerBase.php 修正
 このクラスはDBマネージャを使用しないプログラムに使用する基底クラスという考え方にした。
 ・indexアクションの作りを継承しやすいように変更した。
 ・AppConst::VAL_APPのようにAppConstクラスを使うようにした。
<<修正前>>

    // indexアクション(実装ロジック)
    public function indexAction() 
    {
        try {
            // ログ
            $this->_logger = new AppLogr($this->_getDebugDir(), $this->_getDebugFlg());
            $this->_preDo();  // 注意:DB beginは承継先のDB接続取得後に行います。
            // 入力データダンプ
            if ($this->_getStartDebugFlg() == true) {
                $this->_logger->outDbgLog('[START]: _sess', $this->_sess);    // セッションデータ(array)
                $this->_logger->outDbgLog('[START]: _o', $this->_o);    // 画面入力データ(array)
            }
            $this->_indexActionSub();
        // プログラム内のアプリケーション用例外
        } catch (AppException $e) {
・・・        }
    }

    // indexアクション
    abstract protected function _indexActionSub();
・・・
        $this->_sessObj = new Zend_Session_Namespace('app');    // app用セッション

<<修正後>>

    // indexアクション(実装ロジック)
    public function indexAction() 
    {
        $this->_commAct();
    }

    // 共通アクション(実装ロジック)
    public function _commAct() 
    {
        try {
            // ログ
            $this->_logger = new AppLogr($this->_getDebugDir(), $this->_getDebugFlg());
            $this->_preDo();  // 注意:DB beginは承継先のDB接続取得後に行います。
            // 入力データダンプ
            if ($this->_getStartDebugFlg() == true) {
                $this->_logger->outDbgLog('[START]: _sess', $this->_sess);    // セッションデータ(array)
                $this->_logger->outDbgLog('[START]: _o', $this->_o);    // 画面入力データ(array)
            }
            $this->_commActSub();
        // プログラム内のアプリケーション用例外
        } catch (AppException $e) {
・・・
        }
    }

    // 共通アクション
    abstract protected function _commActSub();
・・・
        $this->_sessObj = new Zend_Session_Namespace(AppConst::VAL_APP);    // app用セッション

7/3 08:00-18:00
7/7 06:00-08:00 せっかくの七夕なので、ここのところ修正した内容を反映した。ユーザ側の作りも視野においての修正です。
9/23 17:00-17:30

if (TokenHandle::isTokenValid($this->_getAdminKbn(), strtolower($this->_o['mode']), 
$this->_getAdminKbn() == AppConst::VAL_USER) == false) { // 管理者側トークンチェック
を
if (TokenHandle::isTokenValid($this->_getAdminKbn(), $this->_o, strtolower($this->_o['mode']), 
$this->_getAdminKbn() == AppConst::VAL_USER) == false) { // 管理者側トークンチェック
に変更した

2011/03/07 4:00-4:10 http://d.hatena.ne.jp/kazpgm/20110307/1299523681(TOOL更新_Ver0.1Zd(次期バージョン)の管理者側もすべてアクションで切り分けるように修正した。(modeパラメータを使わないようにした。)など。)の内容を反映した。