|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Admin Page Framework |
|
4
|
|
|
* |
|
5
|
|
|
* http://en.michaeluno.jp/admin-page-framework/ |
|
6
|
|
|
* Copyright (c) 2013-2016 Michael Uno; Licensed MIT |
|
7
|
|
|
* |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* Provides methods to format form in-page tabs definition arrays. |
|
12
|
|
|
* |
|
13
|
|
|
* @package AdminPageFramework |
|
14
|
|
|
* @subpackage Factory/AdminPage/Format |
|
15
|
|
|
* @since 3.6.0 |
|
16
|
|
|
* @internal |
|
17
|
|
|
*/ |
|
18
|
|
|
class AdminPageFramework_Format_InPageTab extends AdminPageFramework_Format_Base { |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Represents the structure of the sub-field definition array. |
|
22
|
|
|
* @since 2.0.0 |
|
23
|
|
|
* @since 3.3.1 Moved from `AdminPageFramework_Page`. |
|
24
|
|
|
* @since 3.6.0 Moved from `AdminPageFramework_Page_Model`. |
|
25
|
|
|
* @var array |
|
26
|
|
|
* @static |
|
27
|
|
|
* @access private |
|
28
|
|
|
* @internal |
|
29
|
|
|
*/ |
|
30
|
|
|
static public $aStructure = array( |
|
31
|
|
|
'page_slug' => null, |
|
32
|
|
|
'tab_slug' => null, |
|
33
|
|
|
'title' => null, |
|
34
|
|
|
'order' => 10, // (integer) |
|
35
|
|
|
'show_in_page_tab' => true, // 3.6.0+ (boolean) |
|
36
|
|
|
'parent_tab_slug' => null, // this needs to be set if the above show_in_page_tab is false so that the framework can mark the parent tab to be active when the hidden page is accessed. |
|
37
|
|
|
'url' => null, // 3.5.0+ This allows the user set custom link. |
|
38
|
|
|
'disabled' => null, // 3.5.10+ (boolean) If true, the link will be unlinked. |
|
39
|
|
|
'attributes' => null, // 3.5.10+ (array) Applies to the navigation tab bar element. |
|
40
|
|
|
'capability' => null, // 3.6.0+ (string) |
|
41
|
|
|
'if' => true, // 3.6.0+ (boolean) |
|
42
|
|
|
'show_debug_info' => null, // 3.8.8+ (boolean, optional) Whether to show debug information. If not set, the existent `bShowDebugInfo` property value will be used. The initial value here is `null` as the default value will be assigned in the formatting method. |
|
43
|
|
|
); |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Stores an in-page tab definition. |
|
47
|
|
|
*/ |
|
48
|
|
|
public $aInPageTab = array(); |
|
49
|
|
|
|
|
50
|
|
|
public $sPageSlug = ''; |
|
51
|
|
|
|
|
52
|
|
|
public $oFactory; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* Sets up properties |
|
56
|
|
|
*/ |
|
57
|
|
|
public function __construct( /* $aInPageTab, $sPageSlug, $oFactory */ ) { |
|
58
|
|
|
|
|
59
|
|
|
$_aParameters = func_get_args() + array( |
|
60
|
|
|
$this->aInPageTab, |
|
61
|
|
|
$this->sPageSlug, |
|
62
|
|
|
$this->oFactory, |
|
63
|
|
|
); |
|
64
|
|
|
$this->aInPageTab = $_aParameters[ 0 ]; |
|
|
|
|
|
|
65
|
|
|
$this->sPageSlug = $_aParameters[ 1 ]; |
|
66
|
|
|
$this->oFactory = $_aParameters[ 2 ]; |
|
67
|
|
|
|
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* |
|
72
|
|
|
* @return array A sub-fields definition array. |
|
73
|
|
|
*/ |
|
74
|
|
|
public function get() { |
|
75
|
|
|
|
|
76
|
|
|
return array( |
|
77
|
|
|
'page_slug' => $this->sPageSlug, |
|
78
|
|
|
) + $this->aInPageTab + array( |
|
79
|
|
|
'capability' => $this->_getPageCapability(), |
|
80
|
|
|
'show_debug_info' => $this->_getPageShowDebugInfo(), |
|
81
|
|
|
) + self::$aStructure; |
|
82
|
|
|
|
|
83
|
|
|
} |
|
84
|
|
|
/** |
|
85
|
|
|
* Retrieves the `show_debug_info` argument value of the page that this tab belongs to. |
|
86
|
|
|
* |
|
87
|
|
|
* @remark This is to inherit the value of the page that the tab belongs to. |
|
88
|
|
|
* @internal |
|
89
|
|
|
* @return boolean |
|
90
|
|
|
* @since 3.8.8 |
|
91
|
|
|
*/ |
|
92
|
|
|
private function _getPageShowDebugInfo() { |
|
93
|
|
|
return $this->getElement( |
|
94
|
|
|
$this->oFactory->oProp->aPages, |
|
95
|
|
|
array( $this->sPageSlug, 'show_debug_info' ), |
|
96
|
|
|
$this->oFactory->oProp->bShowDebugInfo |
|
97
|
|
|
); |
|
98
|
|
|
} |
|
99
|
|
|
/** |
|
100
|
|
|
* Retrieves the capability of the page that the subject tab belongs to. |
|
101
|
|
|
* |
|
102
|
|
|
* @remark This is to inherit the value of the page that the tab belongs to. |
|
103
|
|
|
* @return string |
|
104
|
|
|
* @since 3.6.0 |
|
105
|
|
|
*/ |
|
106
|
|
|
private function _getPageCapability() { |
|
107
|
|
|
return $this->getElement( |
|
108
|
|
|
$this->oFactory->oProp->aPages, |
|
109
|
|
|
array( $this->sPageSlug, 'capability' ), |
|
110
|
|
|
$this->oFactory->oProp->sCapability |
|
111
|
|
|
); |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
} |
|
115
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..