17 protected $compass_params = [];
20 protected $json_array = [];
35 ->setMenuJsonArray($menu_json)
36 ->setCompassParamsArray($json_path)
38 ->makeMenu($this->compass_params);
42 }
catch (Exception $e) {
43 return "<p>Exception creating menu: {$e->getMessage()}</p>";
47 public function singleCompassMenuNode($json_path =
'', $menu_json =
'', $node_id =
'', $full_node =
false)
50 ->setMenuJsonArray($menu_json)
51 ->setCompassParamsArray($json_path)
53 ->makeSingleMenuNode($node_id, $this->compass_params, $full_node);
65 if (empty($append_html)) {
70 <div id=\"compass-append-menu\" style=\"display:none;\"> 84 isset($this->HB_ENV[
'Cu']) &&
85 (strlen($this->HB_ENV[
'Cu']) > 0) &&
86 isset($this->HB_ENV[
'Uid']) &&
87 (strlen($this->HB_ENV[
'Uid']) > 0)
100 $this->json_array = json_decode($json, 1);
102 if ($this->json_array ===
false) {
103 throw new Exception(
"Could not decode global JSON array in CompassMenu.");
134 $this->compass_params = [
135 'json_path' => $json_path,
136 'substitute_values' => [
137 'compass-menu-badge.display' => ($compass_count > 0)?
true :
false,
140 'user-activity.attributes.class.hcu-navbar-alert' => $this->
setBoolFromCount(
'activity'),
141 'user-activity-link.attributes.href' => $this->
setMenuUrl(
'activity'),
142 'activity-link-text.content' => $this->
getNestedTwoDeep(
'activity',
'display'),
144 'user-activity-badge.content' => $this->
setDisplayNum(
'activity', 9),
145 'secure-email-item.attributes.class.hcu-navbar-alert' => $this->
setBoolFromCount(
'messages'),
146 'secure-email-link.attributes.href' => $this->
setMenuUrl(
'messages'),
147 'secure-email-link-text.content' => $this->
getNestedTwoDeep(
'messages',
'display'),
149 'secure-email-badge.content' => $this->
setDisplayNum(
'messages', 9),
150 'user-status.attributes.class.hcu-navbar-alert' => $this->
setBoolFromCount(
'status'),
152 'user-status-badge.content' => $this->
setDisplayNum(
'status', 9),
153 'user-status-dropdown-link.attributes.href' => $this->
getNestedTwoDeep(
'status',
'endpoint'),
155 'failed-login-k-b.attributes.class.hcu-warning-color' => $this->
isErrorEnableClass(
'status',
'fail',
true),
156 'failed-login-summary-desc-label.content' => $this->
getNestedThreeDeep(
'status',
'fail',
'title'),
157 'failed-login-summary-desc-p.content' => $this->
getNestedThreeDeep(
'status',
'fail',
'date'),
158 'last-login-summary-desc-label.content' => $this->
getNestedThreeDeep(
'status',
'prior',
'title'),
159 'last-login-summary-value-label.content' => $this->
getNestedThreeDeep(
'status',
'prior',
'date'),
161 'acct-status-summary-desc-label.content' => $this->
getNestedThreeDeep(
'status',
'system',
'title'),
162 'acct-status-summary-p.content' => $this->
getNestedThreeDeep(
'status',
'system',
'date'),
163 'user-dropdown.attributes.class.hcu-navbar-alert' => $this->
setBoolFromCount(
'user'),
165 'user-menu-badge.content' => $this->
setDisplayNum(
'user', 9),
168 'update-password-icon-block' => $this->
getNestedThreeDeep(
'user',
'password',
'icon'),
169 'update-password-alert-text.content' => $this->
getNestedThreeDeep(
'user',
'password',
'message'),
170 'update-password-link.attributes.href' => $this->
getNestedThreeDeep(
'user',
'password',
'url'),
171 'update-password-link.content' => $this->
getNestedThreeDeep(
'user',
'password',
'link'),
173 'security-expiring-text.content' => $this->
getNestedThreeDeep(
'user',
'security',
'message'),
174 'update-security-link.attributes.href' => $this->
getNestedThreeDeep(
'user',
'security',
'url'),
175 'update-security-link.content' => $this->
getNestedThreeDeep(
'user',
'security',
'link'),
178 'update-email-link.attributes.href' => $this->
getNestedThreeDeep(
'user',
'email',
'url'),
180 'quicknav-logout-link.attributes.href' => $this->
setMenuUrl(
'logout'),
196 'security' =>
'security-expiring-icon',
197 'password' =>
'update-password-icon',
198 'email' =>
'email-alert-icon' 201 foreach ($icon_ids as $key => $icon_id) {
205 $icon =
'fa-' . $this->json_array[
'user'][$key][
'icon'];
206 $level = $this->json_array[
'user'][$key][
'level'];
208 if (in_array($level, [
'warning',
'error'])) {
210 $parent =
'update-' . $key;
211 $parent_class = ($level ==
'error')?
'k-error-colored' :
'hcu-warning-color';
212 $this->compass_params[
'substitute_values'][
"$parent.attributes.class.$parent_class"] =
true;
215 $this->compass_params[
'substitute_values'][
"$icon_id.attributes.class.$icon"] =
true;
230 isset($this->json_array[
'user'][$key][
'level']) &&
231 isset($this->json_array[
'user'][$key][
'icon']) &&
232 in_array($this->json_array[
'user'][$key][
'level'], [
'info',
'warning',
'error']);
244 $arr = [
'logout',
'activity',
'messages',
'status',
'user'];
246 foreach ($arr as $key) {
249 if (! array_key_exists($key, $this->json_array)) {
255 foreach ($this->json_array[$key] as $value) {
256 if (is_array($value)) {
277 if (isset($arr[
'count'])) {
278 return $arr[
'count'];
291 if (! isset($this->json_array[$key][
'count'])) {
295 return ($this->json_array[$key][
'count'] > 0)? true :
false;
305 if (isset($this->json_array[$key][
'url'])) {
306 return $this->json_array[$key][
'url'];
309 if (isset($this->json_array[$key][
'script'])) {
310 return "{$this->HB_ENV['loginpath']}/{$this->json_array[$key]['script']}?{$this->HB_ENV['cuquery']}";
324 if (! isset($this->json_array[$key][
'count'])) {
328 return ($this->json_array[$key][
'count'] > $max)? $max .
'+' : $this->json_array[$key][
'count'];
339 if (isset($this->json_array[$parent][$key])) {
341 return $this->json_array[$parent][$key];
357 if (isset($this->json_array[$parent][$child][$key])) {
359 if ($key ==
'icon') {
360 return 'fa-' . $this->json_array[$parent][$child][$key];
363 return $this->json_array[$parent][$child][$key];
375 return $this->HB_ENV[
'live'];
393 if (isset($array[
'level']) && in_array($array[
'level'], [
'warning',
'error'])) {
394 return ($enable_if_error)? true :
false;
397 return ($enable_if_error)? false :
true;
409 isset($this->json_array[$parent]) &&
410 isset($this->json_array[$parent][$child]) &&
413 return $this->json_array[$parent][$child];
416 if (isset($this->json_array[$parent])) {
417 return $this->json_array[$parent];
430 return isset($this->json_array[
'user'][$key]) && is_array($this->json_array[
'user'][$key]);