/
AdminPageFramework_Form_Model___Format_CollapsibleSection.php
50 lines (49 loc) · 2.85 KB
/
AdminPageFramework_Form_Model___Format_CollapsibleSection.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
<?php
/**
Admin Page Framework v3.8.19 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-2019, Michael Uno; Licensed under MIT <http://opensource.org/licenses/MIT> */
class AdminPageFramework_Form_Model___Format_CollapsibleSection extends AdminPageFramework_FrameworkUtility {
static public $aStructure = array('title' => null, 'is_collapsed' => true, 'toggle_all_button' => null, 'collapse_others_on_expand' => true, 'container' => 'sections', 'type' => 'box',);
public $abCollapsible = false;
public $sTitle = '';
public $aSection = array();
public function __construct() {
$_aParameters = func_get_args() + array($this->abCollapsible, $this->sTitle, $this->aSection,);
$this->abCollapsible = $_aParameters[0];
$this->sTitle = $_aParameters[1];
$this->aSection = $_aParameters[2];
}
public function get() {
if (empty($this->abCollapsible)) {
return $this->abCollapsible;
}
return $this->_getArguments($this->abCollapsible, $this->sTitle, $this->aSection);
}
private function _getArguments($abCollapsible, $sTitle, array $aSection) {
$_aCollapsible = $this->getAsArray($this->abCollapsible) + array('title' => $sTitle,) + self::$aStructure;
$_aCollapsible['toggle_all_button'] = implode(',', $this->getAsArray($_aCollapsible['toggle_all_button']));
if (!empty($aSection)) {
$_aCollapsible['toggle_all_button'] = $this->_getToggleAllButtonArgument($_aCollapsible['toggle_all_button'], $aSection);
}
$_aCollapsible['toggle_all_button'] = $this->getAOrB('' === $_aCollapsible['toggle_all_button'], false, $_aCollapsible['toggle_all_button']);
return $_aCollapsible;
}
private function _getToggleAllButtonArgument($sToggleAll, array $aSection) {
if (!$aSection['repeatable']) {
return $sToggleAll;
}
if ($aSection['_is_first_index'] && $aSection['_is_last_index']) {
return $sToggleAll;
}
if (!$aSection['_is_first_index'] && !$aSection['_is_last_index']) {
return 0;
}
$_aToggleAll = $this->getAOrB(true === $sToggleAll || 1 === $sToggleAll, array('top-right', 'bottom-right'), explode(',', $sToggleAll));
$_aToggleAll = $this->getAOrB($aSection['_is_first_index'], $this->dropElementByValue($_aToggleAll, array(1, true, 0, false, 'bottom-right', 'bottom-left')), $_aToggleAll);
$_aToggleAll = $this->getAOrB($aSection['_is_last_index'], $this->dropElementByValue($_aToggleAll, array(1, true, 0, false, 'top-right', 'top-left')), $_aToggleAll);
$_aToggleAll = $this->getAOrB(empty($_aToggleAll), array(0), $_aToggleAll);
return implode(',', $_aToggleAll);
}
}