Skip to content

Commit

Permalink
System: complete UI refresh (#1867)
Browse files Browse the repository at this point in the history
  • Loading branch information
SKuipers authored Oct 30, 2024
1 parent 003c1aa commit 5a2db44
Show file tree
Hide file tree
Showing 446 changed files with 10,274 additions and 5,904 deletions.
53 changes: 23 additions & 30 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

use Gibbon\Locale;
use Gibbon\UI\Icon;
use Gibbon\Http\Url;
use Gibbon\Forms\Form;
use Gibbon\Services\Format;
Expand All @@ -27,7 +29,6 @@
use Gibbon\Domain\System\AlertLevelGateway;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Forms\Input\Editor;
use Gibbon\Locale;

function getIPAddress()
{
Expand Down Expand Up @@ -179,6 +180,21 @@ function __m(string $text, array $params = [], array $options = [])
return $gibbon->locale->translate($text, $params, $options);
}

/**
* Return an SVG icon from a specified icon library.
* Many of the icons come from: https://heroicons.com
*
* @param string $library One of: basic, solid, outline
* @param string $icon The name of an icon
* @param string $class Applies a class to the svg returned
* @param array $options Eg: strokeWidth for outline icons
* @return string
*/
function icon(string $library, string $icon, string $class = '', array $options = []) : string
{
return Icon::get($library, $icon, $class, $options);
}

//$valueMode can be "value" or "id" according to what goes into option's value field
//$selectMode can be "value" or "id" according to what is used to preselect an option
//$honourDefault can TRUE or FALSE, and determines whether or not the default grade is selected
Expand Down Expand Up @@ -362,8 +378,8 @@ function getFastFinder($connection2, $guid)
{
global $session;

$form = Form::create('fastFinder', Url::fromHandlerRoute('indexFindRedirect.php'), 'get');
$form->setClass('blank fullWidth');
$form = Form::createBlank('fastFinder', Url::fromHandlerRoute('indexFindRedirect.php'), 'get');
$form->setClass('w-full');

$form->addHiddenValue('address', $session->get('address'));

Expand Down Expand Up @@ -702,40 +718,17 @@ function msort($array, $id = 'id', $sort_ascending = true)
/**
* Returns preformatted HTML indicator of max file upload size
*
* Deprecated. Built into FileUpload class now.
*
* @deprecated v28
* @since 2013
* @version v26
*
* @param bool $multiple Whether to show text about multiple files.
*/
function getMaxUpload($multiple = false)
{
// For backwards compatibilty
global $guid;
if ($multiple === $guid) {
$multiple = func_get_args()[1] ?? false;
}

$output = '';
$post = substr(ini_get('post_max_size'), 0, (strlen(ini_get('post_max_size')) - 1));
$file = substr(ini_get('upload_max_filesize'), 0, (strlen(ini_get('upload_max_filesize')) - 1));

$output .= "<div style='margin-top: 10px; font-style: italic; color: #c00'>";
if ($multiple == true) {
if ($post < $file) {
$output .= sprintf(__('Maximum size for all files: %1$sMB'), $post) . '<br/>';
} else {
$output .= sprintf(__('Maximum size for all files: %1$sMB'), $file) . '<br/>';
}
} else {
if ($post < $file) {
$output .= sprintf(__('Maximum file size: %1$sMB'), $post) . '<br/>';
} else {
$output .= sprintf(__('Maximum file size: %1$sMB'), $file) . '<br/>';
}
}
$output .= '</div>';

return $output;
return '';
}

//Encode strring using htmlentities with the ENT_QUOTES option
Expand Down
47 changes: 28 additions & 19 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
along with this program. If not, see <http:// www.gnu.org/licenses/>.
*/

use Gibbon\Http\Url;
use Gibbon\Domain\User\UserGateway;
use Gibbon\Domain\System\HookGateway;
use Gibbon\Domain\System\ModuleGateway;
use Gibbon\Domain\System\SettingGateway;
use Gibbon\Domain\Students\StudentGateway;
use Gibbon\Domain\Messenger\MessengerGateway;
use Gibbon\Domain\DataUpdater\DataUpdaterGateway;
use Gibbon\Domain\User\UserGateway;
use Gibbon\Http\Url;

/**
* BOOTSTRAP
Expand Down Expand Up @@ -288,7 +287,10 @@
'config' => [
'tinymce' => [
'valid_elements' => $settingGateway->getSettingByScope('System', 'allowableHTML'),
]
],
'htmx' => [
'unload_confirm' => __("Are you sure you want to leave this page? Information you've entered may not be saved."),
],
],
];

Expand All @@ -301,36 +303,41 @@

// Set page scripts: head
$page->scripts->addMultiple([
'lv' => 'lib/LiveValidation/livevalidation_standalone.compressed.js',
// 'lv' => 'lib/LiveValidation/livevalidation_standalone.compressed.js',
'jquery' => 'lib/jquery/jquery.js',
'htmx' => 'lib/htmx/htmx.min.js',
'core' => 'resources/assets/js/core.min.js',

], ['context' => 'head']);

$page->scripts->addMultiple([
'jquery-migrate' => 'lib/jquery/jquery-migrate.min.js',
'jquery-ui' => 'lib/jquery-ui/js/jquery-ui.min.js',
'jquery-time' => 'lib/jquery-timepicker/jquery.timepicker.min.js',
'jquery-chained' => 'lib/chained/jquery.chained.min.js',
'core' => 'resources/assets/js/core.min.js',
'htmx' => 'lib/htmx/htmx.min.js',

], ['context' => 'head']);
'alpineFocus' => 'lib/htmx/alpine.focus.min.js',
'alpineCollapse' => 'lib/htmx/alpine.collapse.min.js',
'alpineValidate' => 'lib/htmx/alpine.validate.min.js',
'alpine' => 'lib/htmx/alpine.min.js',
], ['context' => 'head', 'type' => 'defer']);

// Set page scripts: foot - core
$page->scripts->add('core-config', 'window.Gibbon = '.json_encode($javascriptConfig).';', ['type' => 'inline']);

// Set page scripts: foot - jquery
$page->scripts->addMultiple([
'jquery-latex' => 'lib/jquery-jslatex/jquery.jslatex.js',
'jquery-form' => 'lib/jquery-form/jquery.form.js',
'jquery-autosize' => 'lib/jquery-autosize/jquery.autosize.min.js',
'jquery-token' => 'lib/jquery-tokeninput/src/jquery.tokeninput.js',
], ['context' => 'foot']);
], ['context' => 'foot', 'type' => 'defer']);

// Set page scripts: foot - misc
$page->scripts->addMultiple([
'tinymce' => 'lib/tinymce/tinymce.min.js',
'alpineFocus' => 'lib/htmx/alpine.focus.min.js',
'alpine' => 'lib/htmx/alpine.min.js',
'core-setup' => 'resources/assets/js/setup.js',
'tinymce' => 'lib/tinymce/tinymce.min.js',
], ['context' => 'foot', 'type' => 'defer']);

// Set page scripts: foot - core
$page->scripts->add('core-config', 'window.Gibbon = '.json_encode($javascriptConfig).';', ['type' => 'inline']);
$page->scripts->add('core-setup', 'resources/assets/js/setup.js');

// Register scripts available to the core, but not included by default
$page->scripts->add('chart', 'lib/Chart.js/3.0/chart.min.js', ['context' => 'head']);
$page->scripts->register('instascan', 'lib/instascan/instascan.min.js', ['context' => 'head']);
Expand Down Expand Up @@ -478,7 +485,8 @@
$menuItemActive = $item['active'] ? $item['actionName'] : $menuItemActive;
}
}



$session->set('menuModuleItems', $menuModuleItems);
$session->set('menuModuleName', $currentModule);
$session->set('menuItemActive', $menuItemActive);
Expand Down Expand Up @@ -543,7 +551,8 @@
$page->addData([
'menuMain' => $session->get('menuMainItems', []),
'menuModule' => $session->get('menuModuleItems', []),
'menuItemActive' => $session->get('menuItemActive', []),
'menuModuleName' => $session->get('menuModuleName', ''),
'menuItemActive' => $session->get('menuItemActive', ''),
]);
}

Expand Down
2 changes: 1 addition & 1 deletion index_fastFinder_ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@

$name = preg_replace('/'.$searchTermSafe.'/i', '<strong>$0</strong>', $name);

$output .= '<a href="'.($URL ?? '').'" class="block cursor-pointer px-4 py-2 text-sm text-gray-800 hover:bg-indigo-500 hover:text-white" role="menuitem" tabindex="-1" id="menu-item-0">'.htmlPrep(__($type)).' - '.$name.'</a>';
$output .= '<a @click="finderOpen = false" hx-boost="true" hx-target="#content-wrap" hx-select="#content-wrap" hx-swap="outerHTML show:no-scroll swap:0s" href="'.($URL ?? '').'" class="block cursor-pointer px-4 py-2 text-sm text-gray-800 hover:bg-indigo-500 hover:text-white" role="menuitem" tabindex="-1" id="menu-item-0">'.htmlPrep(__($type)).' - '.$name.'</a>';
$outputCount++;

}
Expand Down
4 changes: 3 additions & 1 deletion installer/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@

// Show success message if the installation is a complete success.
if ($message === null) {
$absoluteURL = $session->get('absoluteURL');
if (!$absoluteURL = $installer->getSetting('absoluteURL')) {
$absoluteURL = $session->get('absoluteURL', InstallController::guessAbsoluteUrl());
}
$page->addSuccess(sprintf(__('Congratulations, your installation is complete. Feel free to %1$sgo to your Gibbon homepage%2$s and login with the username and password you created.'), "<a href='$absoluteURL'>", '</a>'));
echo $page->fetchFromTemplate('ui/gettingStarted.twig.html', ['postInstall' => true]);
}
Expand Down
1 change: 1 addition & 0 deletions lib/htmx/alpine.collapse.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 5a2db44

Please sign in to comment.