Skip to content

Commit

Permalink
UI templates & Fixes
Browse files Browse the repository at this point in the history
Roadmap Tracking Items: #2402, #2401, #2400, #2398, #2396

Also fixes a bug where tab components do not share the same instance, and fix tracking cookies not utilized.

Signed-off-by: deviance <meangczac.chan@gmail.com>
  • Loading branch information
FrederickChan committed Oct 5, 2022
1 parent 1686907 commit 40554fd
Show file tree
Hide file tree
Showing 17 changed files with 1,332 additions and 15 deletions.
54 changes: 39 additions & 15 deletions includes/theme_functions_include.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@
| written permission from the original author(s).
+--------------------------------------------------------*/

use PHPFusion\BreadCrumbs;
use PHPFusion\Database\DatabaseFactory;
use PHPFusion\OutputHandler;
use PHPFusion\Panels;
use PHPFusion\QuantumFields;
use PHPFusion\SiteLinks;

defined('IN_FUSION') || exit;

Expand Down Expand Up @@ -196,7 +199,7 @@ function showprivacypolicy() {
if (!empty(fusion_get_settings('privacy_policy'))) {
$html .= "<a href='".BASEDIR."print.php?type=P' id='privacy_policy'>".fusion_get_locale('global_176')."</a>";
$modal = openmodal('privacy_policy', fusion_get_locale('global_176'), ['button_id' => 'privacy_policy']);
$modal .= parse_text(\PHPFusion\QuantumFields::parseLabel(fusion_get_settings('privacy_policy')));
$modal .= parse_text(QuantumFields::parseLabel(fusion_get_settings('privacy_policy')));
$modal .= closemodal();
add_to_footer($modal);
}
Expand Down Expand Up @@ -584,7 +587,7 @@ function showsublinks($sep = "", $class = "navbar-default", $options = []) {
'seperator' => $sep,
'navbar_class' => $class,
];
return \PHPFusion\SiteLinks::setSubLinks($options)->showSubLinks();
return SiteLinks::setSubLinks($options)->showSubLinks();
}
}

Expand Down Expand Up @@ -1072,6 +1075,7 @@ class FusionTabs {
private $cookie_prefix = 'tab_js';
private $cookie_name = '';
private $link_mode = FALSE;
private $wrapper;

/**
* Current active tab selector.
Expand Down Expand Up @@ -1129,6 +1133,15 @@ public static function tabIndex($array, $default_active, $getname = FALSE) {
return $default_active;
}

/**
* Enable wrapper for nav-wrapper
*
* @param $value
*/
public function setWrapper($value) {
$this->wrapper = $value;
}

/**
* Automatically remember tab using cookie.
*
Expand Down Expand Up @@ -1220,7 +1233,7 @@ public function openTab($tab_title, $link_active_arrkey, $id, $link = FALSE, $cl
$('#".$id." > li').on('click', function() {
var cookieName = '".$this->cookie_name."';
var cookieValue = $(this).find(\"a[role='tab']\").attr('id');
Cookies.set(cookieName, cookieValue);
Cookies.set(cookieName, cookieValue);
});
var cookieName = 'tab_js-".$id."';
if (Cookies.get(cookieName)) {
Expand Down Expand Up @@ -1304,6 +1317,22 @@ public function closeTab($options = []) {
}
}

/**
* Creates a Tab instance
*
* @param string $id
*
* @return FusionTabs|mixed
*/
function fusion_tab($id = 'Default') {
static $tab;
if (empty($tab[$id])) {
$tab[$id] = new FusionTabs();
}
return $tab[$id];
}


/**
* Current active tab selector.
*
Expand All @@ -1314,7 +1343,7 @@ public function closeTab($options = []) {
* @return string
*/
function tab_active($array, $default_active, $getname = NULL) {
return \FusionTabs::tabActive($array, $default_active, $getname);
return FusionTabs::tabActive($array, $default_active, $getname);
}

/**
Expand Down Expand Up @@ -1359,7 +1388,8 @@ function tab_index($array, $default_active, $getname = FALSE) {
* @return string
*/
function opentab($tab_title, $link_active_arrkey, $id, $link = FALSE, $class = NULL, $getname = "section", $cleanup_get = [], $remember = FALSE) {
$fusion_tabs = new FusionTabs();
$fusion_tabs = fusion_tab();

if ($remember) {
$fusion_tabs->setRemember(TRUE);
}
Expand All @@ -1379,9 +1409,7 @@ function opentab($tab_title, $link_active_arrkey, $id, $link = FALSE, $class = N
* @return string
*/
function opentabbody($tab_title, $tab_id, $link_active_arrkey = NULL, $link = FALSE, $key = NULL) {
$fusion_tabs = new FusionTabs();

return $fusion_tabs->openTabBody($tab_id, $link_active_arrkey, $key);
return fusion_tab()->openTabBody($tab_id, $link_active_arrkey, $key);
}

/**
Expand All @@ -1390,9 +1418,7 @@ function opentabbody($tab_title, $tab_id, $link_active_arrkey = NULL, $link = FA
* @return string
*/
function closetabbody() {
$fusion_tabs = new FusionTabs();

return $fusion_tabs->closeTabBody();
return fusion_tab()->closeTabBody();
}

/**
Expand All @@ -1403,9 +1429,7 @@ function closetabbody() {
* @return string
*/
function closetab($options = []) {
$fusion_tabs = new FusionTabs();

return $fusion_tabs->closeTab($options);
return fusion_tab()->closeTab($options);
}
}

Expand Down Expand Up @@ -1615,7 +1639,7 @@ function fusion_get_function($function) {
* @return string
*/
function render_breadcrumbs($key = 'default') {
$breadcrumbs = \PHPFusion\BreadCrumbs::getInstance($key);
$breadcrumbs = BreadCrumbs::getInstance($key);
$html = '<ol class="'.$breadcrumbs->getCssClasses().'">';
foreach ($breadcrumbs->toArray() as $crumb) {
$html .= '<li class="breadcrumb-item '.$crumb['class'].($crumb['link'] ? '' : ' active').'">';
Expand Down
53 changes: 53 additions & 0 deletions themes/templates/html/adm/group-form.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{% if mode == "group_member" %}
{{ openside(title) }}
<div class="row">
<div class="col-xs-12 col-sm-6">
{{ form["open"]|raw }}
<h5>{{ locale["GRP_416"] }}</h5>
{{ form["input"]|raw }}
{{ form["button"]|raw }}
{{ form["close"]|raw }}
</div>
<div class="col-xs-12 col-sm-6">
<h5>{{ locale["GRP_468"] }}</h5>
{% if user_groups %}
{% for group in user_groups %}
<div class="well mb-2">
<div class="d-flex justify-content-between flex-sm-row flex-column">
<div class="group-info">
{% if group["users"] %}
<div class="ps-2 mb-2 position-relative">
<ul class="list-unstyled d-flex align-items-center avatar-group mb-0">
{% for user in group["users"] %}
<li>
{{ user|raw }}
</li>
{% endfor %}
</ul>
</div>
{% endif %}
<h5>{{ group[1]|raw }}</h5>
<p>{{ group[2]|raw }}</p>
</div>

<div class="d-flex flex-column justify-content-between align-content-end">
<div class="d-flex">
<a href="{{ group["manage_uri"] }}" class="btn btn-primary">{{ locale["edit"] }}</a>
<a href="{{ group["remove_uri"] }}" class="btn btn-default">{{ locale["delete"] }}</a>
</div>
<div class="text-end">
<small>{{ group[4] }}</small>
</div>
</div>

</div>

</div>
{% endfor %}
{% else %}
<div class="well text-center">{{ locale["GRP_469"]|raw }}</div>
{% endif %}
</div>
</div>
{{ closeside() }}
{% endif %}
59 changes: 59 additions & 0 deletions themes/templates/html/adm/group-list.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<p>A group provide access to predefined content and features so that depending on the assigned role given, different access can be granted to what user needs.</p>

{% if groups %}
<div class="mt-5">
<div class="row equal-height">
{% for group in groups %}
<div class="col-xs-12 col-sm-6 col-lg-4">
{{ openside() }}
<div class="d-flex">
<div>
<h5 class="font-normal">Total {{ group[4]|raw }}</h5>
<h4 class="mb-0"><a href="{{ group["manage_uri"] }}">{{ group[1]|raw }}</a></h4>
<small><a href="{{ group["edit_uri"]|raw }}">Edit Group</a></small>
</div>
<div class="ms-auto">
{% if group["users"] %}
<ul class="list-unstyled d-flex align-items-center avatar-group mb-0">
{% for user in group["users"] %}
<li>
{{ user|raw }}
</li>
{% endfor %}
</ul>
{% endif %}
</div>
</div>
{{ closeside() }}
</div>
{% endfor %}
<div class="col-xs-12 col-sm-6 col-lg-4">
{{ openside() }}
<div class="text-md-end">
{{ add_button|raw }}
<div class="mt-3">
{{ locale["GRP_413"] }}
</div>
</div>
{{ closeside() }}
</div>
</div>
</div>
{% endif %}

{{ openside("", "", "table-wrapper") }}
<table class="table" id="{{ group_table }}">
<thead>
<tr>
<th></th>
<th>{{ locale["GRP_446"] }}</th>
<th>{{ locale["GRP_447"] }}</th>
<th>{{ locale["GRP_420"] }}</th>
<th>{{ locale["GRP_453"] }}</th>
<th>{{ locale["GRP_437"] }}</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
{{ closeside() }}
42 changes: 42 additions & 0 deletions themes/templates/html/adm/group-users.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<p>Manage group members by adding or removing them from the group.</p>
{{ openside(locale["GRP_460"] ~ ': '~ title, '', 'table-wrapper', 'border-bottom') }}
{{ form["open"]|raw }}

<table class="table" id="{{ group_table }}">
<thead>
<tr>
<th></th>
<th>
{{ locale["GRP_446"] }}
</th>
<th>
{{ locale["GRP_447"] }}
</th>
<th>
{{ locale["GRP_453"] }}
</th>
<th>
{{ locale["GRP_437"] }}
</th>
</tr>
</thead>
<tbody></tbody>
</table>
{# Use with Debug script #}
{# <p><b>Selected rows data:</b></p> #}
{# <pre id="example-console-rows"></pre> #}
{# <p><b>Form data as submitted to the server:</b></p> #}
{# <pre id="example-console-form"></pre> #}
{{ tablebreak() }}
<div class="row n-row pt-0">
<div class="col-xs-12 col-sm-6">
{{ form["cancel"]|raw }}
{{ form["recount"]|raw }}
</div>
<div class="col-xs-12 col-sm-6 text-lg-end">
{{ form["button"]|raw }}
{{ form["button_all"]|raw }}
</div>
</div>
{{ form["close"]|raw }}
{{ closeside() }}

0 comments on commit 40554fd

Please sign in to comment.