PluginProbe
User Access Manager / 2.2.23
User Access Manager v2.2.23
2.3.20 2.3.19 2.3.18 2.3.17 2.3.16 2.3.15 2.3.14 2.3.13 trunk 0.6 0.6.1 0.6.2 0.7 0.7 Beta 0.7.0.1 0.8 0.8.0.1 0.8.0.2 0.9 0.9.1 0.9.1.1 0.9.1.2 0.9.1.3 0.9.1.4 1.0 All 136 releases
← All changes | src/Controller/Backend/ControllerTabNavigationTrait.php +61 -1 2.3.162.2.23 View file →
@@ -1,5 +1,18 @@
1 1 <?php
2 +/**
3 + * ControllerTabNavigationTrait.php
4 + *
5 + * The ControllerTabNavigationTrait class file.
6 + *
7 + * PHP versions 5
8 + *
9 + * @author Alexander Schneider <alexanderschneider85@gmail.com>
10 + * @copyright 2008-2017 Alexander Schneider
11 + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2
12 + * @version SVN: $id$
13 + * @link http://wordpress.org/extend/plugins/user-access-manager/
14 + */
2 15
3 16 declare(strict_types=1);
4 17
5 18 namespace UserAccessManager\Controller\Backend;
@@ -10,18 +23,46 @@
10 23 * @package UserAccessManager\Controller
11 24 */
12 25 trait ControllerTabNavigationTrait
13 26 {
27 + /**
28 + * Returns the current request url.
29 + * @return string
30 + */
14 31 abstract public function getRequestUrl(): string;
15 32
16 - abstract public function getRequestParameter(string $name, $default = null): mixed;
33 + /**
34 + * Returns the request parameter.
35 + * @param string $name
36 + * @param mixed $default
37 + * @return mixed
38 + */
39 + abstract public function getRequestParameter(string $name, $default = null);
17 40
41 + /**
42 + * Translates the given group by the group key.
43 + * @param string $key
44 + * @return string
45 + */
18 46 abstract public function getGroupText(string $key): string;
19 47
48 + /**
49 + * Translates the given group section by the group key.
50 + * @param string $key
51 + * @return string
52 + */
20 53 abstract public function getGroupSectionText(string $key): string;
21 54
55 + /**
56 + * Returns the tab groups.
57 + * @return array
58 + */
22 59 abstract public function getTabGroups(): array;
23 60
61 + /**
62 + * Returns the current tab group.
63 + * @return string
64 + */
24 65 public function getCurrentTabGroup(): string
25 66 {
26 67 $groups = $this->getTabGroups();
27 68 $keys = array_keys($groups);
@@ -28,8 +69,12 @@
28 69
29 70 return (string) $this->getRequestParameter('tab_group', reset($keys));
30 71 }
31 72
73 + /**
74 + * Returns the tab group sections.
75 + * @return array
76 + */
32 77 public function getSections(): array
33 78 {
34 79 $groups = $this->getTabGroups();
35 80 $group = $this->getCurrentTabGroup();
@@ -36,8 +81,12 @@
36 81
37 82 return isset($groups[$group]) === true ? $groups[$group] : [];
38 83 }
39 84
85 + /**
86 + * Returns the current tab group section.
87 + * @return string
88 + */
40 89 public function getCurrentTabGroupSection(): string
41 90 {
42 91 $groups = $this->getTabGroups();
43 92 $group = $this->getCurrentTabGroup();
@@ -51,8 +100,13 @@
51 100
52 101 return (string) $this->getRequestParameter('tab_group_section', $default);
53 102 }
54 103
104 + /**
105 + * Returns the settings group link by the given group key.
106 + * @param string $groupKey
107 + * @return string
108 + */
55 109 public function getTabGroupLink(string $groupKey): string
56 110 {
57 111 $rawUrl = $this->getRequestUrl();
58 112 $url = preg_replace('/&amp;tab_group[^&]*/i', '', $rawUrl);
@@ -58,8 +112,14 @@
58 112 $url = preg_replace('/&amp;tab_group[^&]*/i', '', $rawUrl);
59 113 return $url . '&tab_group=' . $groupKey;
60 114 }
61 115
116 + /**
117 + * Returns the settings section link by the given group and section key.
118 + * @param string $groupKey
119 + * @param string $sectionKey
120 + * @return string
121 + */
62 122 public function getTabGroupSectionLink(string $groupKey, string $sectionKey): string
63 123 {
64 124 $rawUrl = $this->getTabGroupLink($groupKey);
65 125 $url = preg_replace('/&amp;tab_group_section[^&]*/i', '', $rawUrl);