Skip to content
Open
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c40e2e1
New Joomla! Help page
ceford Oct 23, 2025
e900ced
Fixed code style issues
ceford Oct 23, 2025
c916c1f
Corrected case in use statement
ceford Oct 23, 2025
4389fed
Added suggested changes and changed menu order.
ceford Oct 24, 2025
ce6507b
Changes admin-hlp.js as suggested
ceford Oct 24, 2025
659dc53
Updated javascript and styles.
ceford Oct 24, 2025
981a310
Merge branch '6.1-dev' into helptoc
richard67 Oct 24, 2025
2949e75
Moved inline styles to css
ceford Oct 24, 2025
34e85b7
Fixed spacing in admin-help.css
ceford Oct 24, 2025
1f91630
Set build helpurl minor version to 0. Fixed css syntax.
ceford Oct 24, 2025
2914721
Revert changes helpurl minor version.
ceford Oct 24, 2025
c866a7f
Updated frame title, created help/en-GB/index.html.
ceford Oct 25, 2025
b3e8657
Adjusted padding-inline-end of item links.
ceford Oct 25, 2025
523c037
Set css margin before color.
ceford Oct 25, 2025
007b0bb
Removed class from toc-build.php, revised js and css.
ceford Oct 26, 2025
50990d3
Fixed style and javascript problems.
ceford Oct 27, 2025
9872cee
Fix css and move include as suggested.
ceford Oct 27, 2025
92603e9
Trying a new menu build structure.
ceford Oct 27, 2025
1c3c847
Recoded to avoid function in template.
ceford Oct 28, 2025
c5c4755
Fixed php missing spaces.
ceford Oct 28, 2025
c6b917e
Fixed problems in HtmlView.php
ceford Oct 28, 2025
d732975
Fixed JavaScript affecting 'active' removal.
ceford Oct 28, 2025
7aca11f
Fixed layout problems.
ceford Oct 28, 2025
d70cfe7
Fixed css order.
ceford Oct 28, 2025
4bcdae8
Added page reload after viewport change.
ceford Oct 28, 2025
84cddd9
More elaborate viewport size change reload page.
ceford Oct 28, 2025
edd7026
Changed behaviour so scroll to top only works on article links.
ceford Oct 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 0 additions & 138 deletions administrator/components/com_admin/src/Model/HelpModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

use Joomla\CMS\Factory;
use Joomla\CMS\Help\Help;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\Filesystem\Folder;
use Joomla\String\StringHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand All @@ -28,14 +25,6 @@
*/
class HelpModel extends BaseDatabaseModel
{
/**
* The search string
*
* @var string
* @since 1.6
*/
protected $help_search = null;

/**
* The page to be viewed
*
Expand All @@ -44,46 +33,6 @@ class HelpModel extends BaseDatabaseModel
*/
protected $page = null;

/**
* The ISO language tag
*
* @var string
* @since 1.6
*/
protected $lang_tag = null;

/**
* Table of contents
*
* @var array
* @since 1.6
*/
protected $toc = [];

/**
* URL for the latest version check
*
* @var string
* @since 1.6
*/
protected $latest_version_check = null;

/**
* Method to get the help search string
*
* @return string Help search string
*
* @since 1.6
*/
public function &getHelpSearch()
{
if (\is_null($this->help_search)) {
$this->help_search = Factory::getApplication()->getInput()->getString('helpsearch');
}

return $this->help_search;
}

/**
* Method to get the page
*
Expand All @@ -99,91 +48,4 @@ public function &getPage()

return $this->page;
}

/**
* Method to get the lang tag
*
* @return string lang iso tag
*
* @since 1.6
*/
public function getLangTag()
{
if (\is_null($this->lang_tag)) {
$this->lang_tag = Factory::getLanguage()->getTag();

if (!is_dir(JPATH_BASE . '/help/' . $this->lang_tag)) {
// Use English as fallback
$this->lang_tag = 'en-GB';
}
}

return $this->lang_tag;
}

/**
* Method to get the table of contents
*
* @return array Table of contents
*/
public function &getToc()
{
if (\count($this->toc)) {
return $this->toc;
}

// Get vars
$lang_tag = $this->getLangTag();
$help_search = $this->getHelpSearch();

// New style - Check for a TOC \JSON file
if (file_exists(JPATH_BASE . '/help/' . $lang_tag . '/toc.json')) {
$data = json_decode(file_get_contents(JPATH_BASE . '/help/' . $lang_tag . '/toc.json'));

// Loop through the data array
foreach ($data as $key => $value) {
$this->toc[$key] = Text::_('COM_ADMIN_HELP_' . $value);
}

// Sort the Table of Contents
asort($this->toc);

return $this->toc;
}

// Get Help files
$files = Folder::files(JPATH_BASE . '/help/' . $lang_tag, '\.xml$|\.html$');

foreach ($files as $file) {
$buffer = file_get_contents(JPATH_BASE . '/help/' . $lang_tag . '/' . $file);

if (!preg_match('#<title>(.*?)</title>#', $buffer, $m)) {
continue;
}

$title = trim($m[1]);

if (!$title) {
continue;
}

// Translate the page title
$title = Text::_($title);

// Strip the extension
$file = preg_replace('#\.xml$|\.html$#', '', $file);

if ($help_search && StringHelper::strpos(StringHelper::strtolower(strip_tags($buffer)), StringHelper::strtolower($help_search)) === false) {
continue;
}

// Add an item in the Table of Contents
$this->toc[$file] = $title;
}

// Sort the Table of Contents
asort($this->toc);

return $this->toc;
}
}
35 changes: 20 additions & 15 deletions administrator/components/com_admin/src/View/Help/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,11 @@ class HtmlView extends BaseHtmlView
protected $page = null;

/**
* The iso language tag
* The level of each submenu
*
* @var string
* @since 1.6
*/
protected $languageTag = null;

/**
* Table of contents
*
* @var array
* @since 1.6
* @var integer
*/
protected $toc = [];
protected $toclevel = 0;

/**
* Execute and display a template script.
Expand All @@ -73,10 +64,7 @@ public function display($tpl = null): void
{
/** @var HelpModel $model */
$model = $this->getModel();
$this->helpSearch = $model->getHelpSearch();
$this->page = $model->getPage();
$this->toc = $model->getToc();
$this->languageTag = $model->getLangTag();

$this->addToolbar();

Expand All @@ -94,4 +82,21 @@ protected function addToolbar(): void
{
ToolbarHelper::title(Text::_('COM_ADMIN_HELP'), 'support help_header');
}

/**
* Method to render a given level of a menu using provided layout file
*
* @param string $layoutFile The layout file to be used to render
* @param array $menu The menu to render the children of
*
* @return void
*
* @since 3.8.0
*/
public function renderSubmenu($layoutFile, $menu)
{
if (is_file($layoutFile)) {
require $layoutFile;
}
}
}
59 changes: 27 additions & 32 deletions administrator/components/com_admin/tmpl/help/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,44 +10,39 @@

defined('_JEXEC') or die;

use Joomla\CMS\Help\Help;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;

/** @var \Joomla\Component\Admin\Administrator\View\Help\HtmlView $this */

/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->getDocument()->getWebAssetManager();
$wa->useScript('com_admin.admin-help');
$wa->useScript('com_admin.admin-help')
->useStyle('com_admin.admin-help');

// Get the HTML for the Table of Contents from a separate file.
include_once 'toc-src.php';

?>
<form action="<?php echo Route::_('index.php?option=com_admin&amp;view=help'); ?>" method="post" name="adminForm" id="adminForm" class="main-card">
<div class="row mt-sm-3">
<div id="sidebar" class="col-md-3">
<button class="btn btn-sm btn-secondary my-2 options-menu d-md-none" type="button" data-bs-toggle="collapse" data-bs-target=".sidebar-nav" aria-controls="help-index" aria-expanded="false">
<span class="icon-align-justify" aria-hidden="true"></span>
<?php echo Text::_('JTOGGLE_SIDEBAR_MENU'); ?>
</button>
<div class="sidebar-nav" id="help-index">
<ul class="nav flex-column">
<li class="item"><?php echo HTMLHelper::_('link', Help::createUrl('Start_Here'), Text::_('COM_ADMIN_START_HERE'), ['target' => 'helpFrame']); ?></li>
<li class="item"><?php echo HTMLHelper::_('link', 'https://help.joomla.org/proxy?keyref=Help4.x:License', Text::_('COM_ADMIN_LICENSE'), ['target' => 'helpFrame']); ?></li>
<li class="item"><?php echo HTMLHelper::_('link', Help::createUrl('Glossary'), Text::_('COM_ADMIN_GLOSSARY'), ['target' => 'helpFrame']); ?></li>
<li class="divider"></li>
<li class="nav-header"><?php echo Text::_('COM_ADMIN_ALPHABETICAL_INDEX'); ?></li>
<?php foreach ($this->toc as $k => $v) : ?>
<li class="item">
<?php $url = Help::createUrl($k); ?>
<?php echo HTMLHelper::_('link', $url, $v, ['target' => 'helpFrame']); ?>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
<div class="col-md-9">
<iframe onLoad="var x = getElementById('help-index'); x.classList.remove('show');" name="helpFrame" title="helpFrame" height="2100px" src="<?php echo $this->page; ?>" class="helpFrame table table-bordered"></iframe>
</div>
<div class="d-flex flex-column flex-md-row">
<div id="help-sidebar" class="flex-shrink-0 mt-md-2">
<!-- Left menu -->
<button class="btn btn-sm btn-secondary my-md-2 options-menu d-md-none" type="button" data-bs-toggle="collapse" data-bs-target="#help-index" aria-controls="help-index" aria-expanded="false">
<span class="icon-align-justify" aria-hidden="true"></span>
<?php echo Text::_('JTOGGLE_SIDEBAR_MENU'); ?>
</button>
<nav id="help-index" class="main-nav help-nav sidebar-wrapper">
<h2><?php echo Text::_('COM_ADMIN_HELP_INDEX'); ?></h2>
<ul id="helpmenu" class="help-nav flex-column pt-2">
<?php
// WARNING: Do not use direct 'include' or 'require' as it is important to isolate the scope for each call
$this->renderSubmenu(JPATH_ADMINISTRATOR . '/components/com_admin/tmpl/help/toc-build.php', $menu);
?>
<?php //echo renderHelpMenu(); ?>
</ul>
</nav>
</div>
<div class="flex-grow-1 mt-2">
<!-- Right content -->
<iframe name="helpFrame" title="<?php echo Text::_('COM_ADMIN_HELP_FRAME_TITLE'); ?>" height="2100px" src="" class="helpFrame table table-bordered"></iframe>
</div>
<input class="textarea" type="hidden" name="option" value="com_admin">
</form>
</div>
51 changes: 51 additions & 0 deletions administrator/components/com_admin/tmpl/help/toc-build.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

/**
* @package Joomla.Administrator
* @subpackage com_admin
*
* @copyright (C) 2025 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

use Joomla\CMS\Help\Help;
use Joomla\CMS\Language\Text;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
// phpcs:enable PSR1.Files.SideEffects

// Increase the toclevel on entry
$this->toclevel += 1;
if ($this->toclevel > 1) {
$collapse = ' mm-collapse';
echo "<ul class=\"collapse-level-1{$collapse}\">\n";
}
foreach ($menu as $label => $value) {
$text = Text::_('COM_ADMIN_HELP_' . $label);
$lclabel = strtolower(str_replace('_', '-', $label));

if (is_array($value)) {
// This is a folder list item
$icon = "<span class=\"icon-folder icon-fw\" aria-hidden=\"true\"></span>";
$wrap_label = "<span class=\"item-title\">{$text}</span>";
echo "<li class=\"item parent item-level-{$this->toclevel}\">";
echo "<a href=\"#\" class=\"has-arrow\">";
echo "{$icon}{$wrap_label}</a>\n";
if (!empty($value)) {
// Recursively build sublist.
$this->renderSubmenu(JPATH_ADMINISTRATOR . '/components/com_admin/tmpl/help/toc-build.php', $value);
}
echo "</li>\n";
} else {
// This is an article list item.
$icon = "<span class=\"icon-file-alt icon-fw\" aria-hidden=\"true\"></span>";
// The url is help.joomla.org + $label (the help key).
$url = Help::createUrl($label);
$link = "<a data-id=\"{$lclabel}\" href=\"{$url}\" target=\"helpFrame\">{$icon}{$text}</a>\n";
echo "<li class=\"item item-level-{$this->toclevel}\">{$link}</li>\n";
}
}
echo "</ul>\n";
// On return decrease the toclevel
$this->toclevel -= 1;
Loading