Plugin Directory

Changeset 1217917


Ignore:
Timestamp:
08/11/2015 06:49:40 AM (11 years ago)
Author:
s-hiroshi
Message:

Refactor custom field

Location:
min-calendar/trunk/admin
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • min-calendar/trunk/admin/class-admin-controller.php

    r1217818 r1217917  
    77 * @property MC_Post_Form $post_form
    88 * @property MC_Appearance $appearance
    9  * @property MC_Admin_Action $action
     9 * @property MC_Manage_Form_Action $action
    1010 */
    1111class MC_Admin_Controller
    1212{
    1313
    14     /** @var MC_Admin_Action */
     14    /** @var MC_Manage_Form_Action */
    1515    public $action;
    1616    /** @var MC_Post_Form */
     
    2525    {
    2626        $this->porst_form = new MC_Post_Form();
    27         $this->action     = new MC_Admin_Action();
     27        $this->action     = new MC_Manage_Form_Action();
    2828        $this->appearance = new MC_Appearance();
    2929    }
    3030
    3131    /**
    32      * 管理画面処理
     32     * 管理画面作成
    3333     */
    3434    public function setup() {
     
    3838
    3939    /**
    40      * 管理画面へMin Calendarページ追加
     40     * Min Calendar関連ページ作成
    4141     */
    4242    public function admin_menu()
    4343    {
    4444        if ( current_user_can( 'edit' ) ) {
     45            // メニュー追加
    4546            add_object_page(
    4647                'Min Calendar',
     
    5051                array( $this, 'admin_management_page' )
    5152            );
    52 
    53             // カスタム投稿タイプmincalendarの一覧
    54             $post_list = add_submenu_page(
     53            // 一覧ページ追加
     54            $list_page = add_submenu_page(
    5555                'mincalendar',
    5656                __( 'Edit Calendar', 'mincalendar' ),
     
    6060                array( $this, 'admin_management_page' )
    6161            );
    62 
    63             // MC_Admin_Action->manage_postをコールバックに設定
    64             add_action( 'load-' . $post_list, array( $this->action, 'manage_post' ) );
    65 
    66             // カレンダーオプション設定画面
     62            // MC_Manage_Form_Action->manage_postをコールバックに設定
     63            add_action( 'load-' . $list_page, array( $this->action, 'manage_post' ) );
     64            // 外観ページ(カレンダーオプション)
    6765            add_submenu_page(
    6866                'mincalendar',
     
    7371                array( $this->appearance, 'admin_appearance_page' )
    7472            );
    75 
    76         }
    77     }
    78 
    79 
    80     /**
    81      * Min Calendarページ呼び出し
     73        }
     74    }
     75
     76    /**
     77     * Min Calendarページ管理
    8278     *
    83      * 投稿の編集は編集画面表示しそれ他は投稿リストを表示する
     79     * 既存の投稿は編集画面表示しその他はリストを表示します
    8480     */
    8581    public function admin_management_page()
    8682    {
    8783        $post_wrapper = $this->action->get_post_wrapper();
    88 
    89         // 編集処理
    9084        if ( $post_wrapper ) {
    91             $post_form = new MC_Post_Form();
    92             $html      = $post_form->get_form( $post_wrapper );
    93             MC_Custom_Field::set_field( $post_wrapper, $html );
    94 //            $this->add_meta_boxes();
    95 //            do_meta_boxes( 'mincalendar', 'normal', array( $post_wrapper, $html ) );
    96             // get_htmlはエスケープ済みマークアップを返す
    97             echo $post_wrapper->get_html();
    98             return;
    99         }
    100 
    101         // リスト表示
     85            // 編集画面
     86            echo $this->get_edit_page($post_wrapper);
     87        } else {
     88            // 一覧画面
     89            echo $this->get_list_page();
     90        }
     91    }
     92   
     93    /**
     94     * 編集画面マークアップ取得
     95     *
     96     * @return string マークアップ
     97     */
     98    public function get_edit_page($post_wrapper) {
     99        $post_form = new MC_Post_Form();
     100        $html      = $post_form->get_form( $post_wrapper );
     101        MC_Custom_Field::set_field( $post_wrapper, $html );
     102        // get_htmlはエスケープ済みマークアップを返す
     103        return $post_wrapper->get_html();
     104    }
     105
     106    /**
     107     * 一覧画面マークアップ取得
     108     *
     109     * @return string マークアップ
     110     */
     111    public function get_list_page() {
    102112        $this->list_table = new MC_List_Table();
    103113        $this->list_table->prepare_items();
     
    126136        ob_clean();
    127137
    128         $html .= '</form>' . PHP_EOL
    129             . '</div>';
    130 
    131         echo $html;
    132     }
    133 
     138        $html .= '</form>' . PHP_EOL . '</div>';
     139       
     140        return $html;
     141    }
    134142
    135143    /**
     
    184192            true
    185193        );
    186 
    187194    }
    188195
     
    198205            'mincalendar_meta_box_id',
    199206            __( 'Min Calendar Meta Box', 'mincalendar' ),
    200             array( $this, 'set_field' ),
     207            array( $this, 'set_field' ), // カスタムフィールド追加
    201208            'mincalendar',
    202209            'normal'
  • min-calendar/trunk/admin/class-appearance.php

    r1217818 r1217917  
    306306        }
    307307
    308 
    309308        /*
    310309         * 設定値取得
    311310         */
    312311        $this->options = (array ) json_decode( get_option( 'mincalendar-options' ) );
    313 
    314312
    315313        /*
  • min-calendar/trunk/admin/class-manage-form-action.php

    r1217906 r1217917  
    11<?php
     2
    23/**
    34 * MC_Manage_Form_Action
     
    2829    /**
    2930     * 管理画面でMin Calendar Postページ表示処理
    30      * 
     31     *
    3132     * wp-admin/admin.php?page=mincalendar&postid=1745&action=edit
    3233     *
    3334     * Min Calendar Postページ表示処理順序
    34      * 
     35     *
    3536     * 1. 当メソッド(manage_post)
    3637     * 2. MC_Admin_Controller->admin_management_page
     
    4041    public function manage_post()
    4142    {
    42         $action = MC_Admin_Utility::get_current_action();
     43        $action = false;
     44        if ( isset( $_REQUEST['action'] ) && - 1 != $_REQUEST['action'] ) {
     45            $action = $_REQUEST['action'];
     46        }
    4347        // save
    4448        if ( 'save' === $action ) {
     
    5357            $this->delete();
    5458        }
    55         $post_id = isset( $_GET['postid'] ) ? (int) $_GET['postid'] : '';
     59        $post_id      = isset( $_GET['postid'] ) ? (int) $_GET['postid'] : '';
    5660        $post_wrapper = null;
    5761
     
    191195            $deleted += 1;
    192196        }
    193         $query = array();
     197        $query       = array();
    194198        $redirect_to = add_query_arg( $query, menu_page_url( 'mincalendar', false ) );
    195199        wp_safe_redirect( $redirect_to );
  • min-calendar/trunk/admin/class-post-form.php

    r1217818 r1217917  
    1616        return $this->form( $post_wrapper );
    1717    }
    18 
    1918
    2019    /**
  • min-calendar/trunk/admin/class-validation.php

    r1217818 r1217917  
    11<?php
    2 
    32class MC_Validation
    43{
    5 
    64    /**
    75     * カラー表記が16進数かをチェック
     
    2927    }
    3028
    31 
    3229    /**
    3330     * サイズ指定が数字または数字+(px|em|%)の形かチェック
     
    4340        return false;
    4441    }
    45 
    4642
    4743    /**
     
    5955    }
    6056
    61 
    6257    /**
    6358     * 配置指定チェック
     
    7368        return false;
    7469    }
    75 
    7670}
Note: See TracChangeset for help on using the changeset viewer.