-
Notifications
You must be signed in to change notification settings - Fork 70
/
AdminPageFramework_Property_Base.php
171 lines (170 loc) · 10.5 KB
/
AdminPageFramework_Property_Base.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
<?php
/**
Admin Page Framework v3.8.26 by Michael Uno
Generated by PHP Class Files Script Generator <https://github.com/michaeluno/PHP-Class-Files-Script-Generator>
<http://en.michaeluno.jp/admin-page-framework>
Copyright (c) 2013-2021, Michael Uno; Licensed under MIT <http://opensource.org/licenses/MIT> */
abstract class AdminPageFramework_Property_Base extends AdminPageFramework_FrameworkUtility {
private static $_aStructure_CallerInfo = array('sPath' => null, 'sType' => null, 'sName' => null, 'sURI' => null, 'sVersion' => null, 'sThemeURI' => null, 'sScriptURI' => null, 'sAuthorURI' => null, 'sAuthor' => null, 'sDescription' => null,);
static public $_aLibraryData;
public $_sPropertyType = '';
public $oCaller;
public $sCallerPath;
public $aScriptInfo;
public $aOptions;
public $sClassName;
public $sClassHash;
public $sScript = '';
public $sStyle = '';
public $sStyleIE = '';
public $aFieldTypeDefinitions = array();
public static $_sDefaultScript = "";
public static $_sDefaultStyle = "";
public static $_sDefaultStyleIE = '';
public $aEnqueuingScripts = array();
public $aEnqueuingStyles = array();
public $aResourceAttributes = array();
public $iEnqueuedScriptIndex = 0;
public $iEnqueuedStyleIndex = 0;
public $bIsAdmin;
public $bIsMinifiedVersion;
public $sCapability;
public $sStructureType;
public $sTextDomain;
public $sPageNow;
public $_bSetupLoaded;
public $bIsAdminAjax;
public $sAjaxReferrer = '';
public $sLabelPluginSettingsLink = null;
public $aFooterInfo = array('sLeft' => '__SCRIPT_CREDIT__', 'sRight' => '__FRAMEWORK_CREDIT__',);
public $_sFormRegistrationHook = 'current_screen';
public $aFormArguments = array('caller_id' => '', 'structure_type' => '', 'action_hook_form_registration' => '',);
public $aFormCallbacks = array('hfID' => null, 'hfTagID' => null, 'hfName' => null, 'hfNameFlat' => null, 'hfInputName' => null, 'hfInputNameFlat' => null, 'hfClass' => null,);
public $sScriptType = 'unknown';
public $sSettingNoticeActionHook = 'admin_notices';
public $aHelpTabText = array();
public $aHelpTabTextSide = array();
public $sTitle = '';
public $bShowDebugInfo = true;
public $aQuery = array();
public function __construct($oCaller, $sCallerPath, $sClassName, $sCapability, $sTextDomain, $sStructureType) {
$this->___setProperties($oCaller, $sCallerPath, $sClassName, $sCapability, $sTextDomain, $sStructureType);
$this->___setGlobals();
}
private function ___setProperties($oCaller, $sCallerPath, $sClassName, $sCapability, $sTextDomain, $sStructureType) {
$this->oCaller = $oCaller;
$this->sCallerPath = $sCallerPath;
$this->sClassName = $sClassName;
$this->sCapability = empty($sCapability) ? 'manage_options' : $sCapability;
$this->sTextDomain = empty($sTextDomain) ? 'admin-page-framework' : $sTextDomain;
$this->sStructureType = $sStructureType;
$this->sPageNow = $this->getPageNow();
$this->bIsAdmin = is_admin();
$this->bIsAdminAjax = 'admin-ajax.php' === $this->sPageNow;
$this->sAjaxReferrer = $this->bIsAdminAjax ? $this->___getReferrer() : '';
$this->bShowDebugInfo = $this->isDebugMode();
$this->aQuery = $this->___getURLQuery();
unset($this->aScriptInfo, $this->aOptions, $this->sScriptType, $this->sClassHash);
}
static private $___sCacheReferrer;
private function ___getReferrer() {
self::$___sCacheReferrer = isset(self::$___sCacheReferrer) ? self::$___sCacheReferrer : wp_get_referer();
return self::$___sCacheReferrer;
}
private function ___getURLQuery() {
if (!$this->bIsAdminAjax) {
return $this->getHTTPRequestSanitized($_GET, true);
}
parse_str(parse_url($this->___getReferrer(), PHP_URL_QUERY), $_aQuery);
return $this->getHTTPRequestSanitized($_GET + $_aQuery, true);
}
private function ___setGlobals() {
if (!isset($GLOBALS['aAdminPageFramework'])) {
$GLOBALS['aAdminPageFramework'] = array('aFieldFlags' => array());
}
}
public function setFormProperties() {
$this->aFormArguments = $this->getFormArguments();
$this->aFormCallbacks = $this->getFormCallbacks();
}
public function getFormArguments() {
return array('caller_id' => $this->sClassName, 'structure_type' => $this->_sPropertyType, 'action_hook_form_registration' => $this->bIsAdminAjax ? 'admin_init' : $this->_sFormRegistrationHook,) + $this->aFormArguments;
}
public function getFormCallbacks() {
return array('is_in_the_page' => array($this->oCaller, '_replyToDetermineWhetherToProcessFormRegistration'), 'load_fieldset_resource' => array($this->oCaller, '_replyToFieldsetResourceRegistration'), 'is_fieldset_registration_allowed' => null, 'capability' => array($this->oCaller, '_replyToGetCapabilityForForm'), 'saved_data' => array($this->oCaller, '_replyToGetSavedFormData'), 'section_head_output' => array($this->oCaller, '_replyToGetSectionHeaderOutput'), 'fieldset_output' => array($this->oCaller, '_replyToGetFieldOutput'), 'sectionset_before_output' => array($this->oCaller, '_replyToFormatSectionsetDefinition'), 'fieldset_before_output' => array($this->oCaller, '_replyToFormatFieldsetDefinition'), 'fieldset_after_formatting' => array($this->oCaller, '_replyToModifyFieldsetDefinitionAfterFormatting'), 'fieldsets_before_formatting' => array($this->oCaller, '_replyToModifyFieldsetsDefinitions'), 'is_sectionset_visible' => array($this->oCaller, '_replyToDetermineSectionsetVisibility'), 'is_fieldset_visible' => array($this->oCaller, '_replyToDetermineFieldsetVisibility'), 'secitonsets_before_registration' => array($this->oCaller, '_replyToModifySectionsets'), 'fieldsets_before_registration' => array($this->oCaller, '_replyToModifyFieldsets'), 'handle_form_data' => array($this->oCaller, '_replyToHandleSubmittedFormData'), 'show_debug_info' => array($this->oCaller, '_replyToDetermineWhetherToShowDebugInfo'), 'hfID' => array($this->oCaller, '_replyToGetInputID'), 'hfTagID' => array($this->oCaller, '_replyToGetInputTagIDAttribute'), 'hfName' => array($this->oCaller, '_replyToGetFieldNameAttribute'), 'hfNameFlat' => array($this->oCaller, '_replyToGetFlatFieldName'), 'hfInputName' => array($this->oCaller, '_replyToGetInputNameAttribute'), 'hfInputNameFlat' => array($this->oCaller, '_replyToGetFlatInputName'), 'hfClass' => array($this->oCaller, '_replyToGetInputClassAttribute'), 'hfSectionName' => array($this->oCaller, '_replyToGetSectionName'),) + $this->aFormCallbacks;
}
static public function _setLibraryData() {
self::$_aLibraryData = array('sName' => AdminPageFramework_Registry::NAME, 'sURI' => AdminPageFramework_Registry::URI, 'sScriptName' => AdminPageFramework_Registry::NAME, 'sLibraryName' => AdminPageFramework_Registry::NAME, 'sLibraryURI' => AdminPageFramework_Registry::URI, 'sPluginName' => '', 'sPluginURI' => '', 'sThemeName' => '', 'sThemeURI' => '', 'sVersion' => AdminPageFramework_Registry::getVersion(), 'sDescription' => AdminPageFramework_Registry::DESCRIPTION, 'sAuthor' => AdminPageFramework_Registry::AUTHOR, 'sAuthorURI' => AdminPageFramework_Registry::AUTHOR_URI, 'sTextDomain' => AdminPageFramework_Registry::TEXT_DOMAIN, 'sDomainPath' => AdminPageFramework_Registry::TEXT_DOMAIN_PATH, 'sNetwork' => '', '_sitewide' => '',);
return self::$_aLibraryData;
}
static public function _getLibraryData() {
return isset(self::$_aLibraryData) ? self::$_aLibraryData : self::_setLibraryData();
}
protected function getCallerInfo($sCallerPath = '') {
if (isset(self::$_aScriptDataCaches[$sCallerPath])) {
return self::$_aScriptDataCaches[$sCallerPath];
}
$_aCallerInfo = self::$_aStructure_CallerInfo;
$_aCallerInfo['sPath'] = $sCallerPath;
$_aCallerInfo['sType'] = $this->_getCallerType($_aCallerInfo['sPath']);
if ('unknown' == $_aCallerInfo['sType']) {
self::$_aScriptDataCaches[$sCallerPath] = $_aCallerInfo;
return $_aCallerInfo;
}
if ('plugin' == $_aCallerInfo['sType']) {
self::$_aScriptDataCaches[$sCallerPath] = $this->getScriptData($_aCallerInfo['sPath'], $_aCallerInfo['sType']) + $_aCallerInfo;
return self::$_aScriptDataCaches[$sCallerPath];
}
if ('theme' == $_aCallerInfo['sType']) {
$_oTheme = wp_get_theme();
self::$_aScriptDataCaches[$sCallerPath] = array('sName' => $_oTheme->Name, 'sVersion' => $_oTheme->Version, 'sThemeURI' => $_oTheme->get('ThemeURI'), 'sURI' => $_oTheme->get('ThemeURI'), 'sAuthorURI' => $_oTheme->get('AuthorURI'), 'sAuthor' => $_oTheme->get('Author'),) + $_aCallerInfo;
return self::$_aScriptDataCaches[$sCallerPath];
}
self::$_aScriptDataCaches[$sCallerPath] = array();
return self::$_aScriptDataCaches[$sCallerPath];
}
static private $_aScriptDataCaches = array();
protected function _getCallerType($sScriptPath) {
if (isset(self::$_aCallerTypeCache[$sScriptPath])) {
return self::$_aCallerTypeCache[$sScriptPath];
}
$sScriptPath = str_replace('\\', '/', $sScriptPath);
if (false !== strpos($sScriptPath, '/themes/')) {
self::$_aCallerTypeCache[$sScriptPath] = 'theme';
return 'theme';
}
if (false !== strpos($sScriptPath, '/plugins/')) {
self::$_aCallerTypeCache[$sScriptPath] = 'plugin';
return 'plugin';
}
self::$_aCallerTypeCache[$sScriptPath] = 'unknown';
return 'unknown';
}
static private $_aCallerTypeCache = array();
protected function _getOptions() {
return array();
}
public function __get($sName) {
if ('aScriptInfo' === $sName) {
$this->sCallerPath = $this->sCallerPath ? $this->sCallerPath : $this->getCallerScriptPath(__FILE__);
$this->aScriptInfo = $this->getCallerInfo($this->sCallerPath);
return $this->aScriptInfo;
}
if ('aOptions' === $sName) {
$this->aOptions = $this->_getOptions();
return $this->aOptions;
}
if ('sClassHash' === $sName) {
$this->sClassHash = md5($this->sClassName);
return $this->sClassHash;
}
if ('sScriptType' === $sName) {
$this->sScriptType = $this->_getCallerType($this->sCallerPath);
return $this->sScriptType;
}
if ('oUtil' === $sName) {
$this->oUtil = new AdminPageFramework_WPUtility;
return $this->oUtil;
}
}
}