2017-08-20 17:52:35 +00:00
|
|
|
<?php
|
2021-03-05 03:08:47 +00:00
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
2024-03-09 19:47:28 +00:00
|
|
|
* @created 4th September 2022
|
2022-07-09 15:45:08 +00:00
|
|
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
|
|
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
2021-03-05 03:08:47 +00:00
|
|
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
|
|
|
*/
|
|
|
|
|
2024-03-09 19:47:28 +00:00
|
|
|
// No direct access to this JCB template file (EVER)
|
|
|
|
defined('_JCB_TEMPLATE') or die;
|
|
|
|
?>
|
|
|
|
###BOM###
|
|
|
|
namespace ###NAMESPACEPREFIX###\Component\###ComponentNameSpace###\Administrator\Controller;
|
2021-03-05 03:08:47 +00:00
|
|
|
|
2024-03-09 19:47:28 +00:00
|
|
|
use Joomla\CMS\Factory;
|
2022-05-25 08:30:55 +00:00
|
|
|
use Joomla\CMS\MVC\Controller\BaseController;
|
2024-03-09 19:47:28 +00:00
|
|
|
use Joomla\Database\DatabaseInterface;
|
|
|
|
use Joomla\CMS\Uri\Uri;
|
|
|
|
use Joomla\CMS\Session\Session;
|
2021-03-05 03:08:47 +00:00
|
|
|
use Joomla\Utilities\ArrayHelper;
|
|
|
|
|
2024-03-09 19:47:28 +00:00
|
|
|
// No direct access to this file
|
|
|
|
\defined('_JEXEC') or die;
|
|
|
|
|
2021-03-05 03:08:47 +00:00
|
|
|
/**
|
2024-03-09 19:47:28 +00:00
|
|
|
* ###Component### Help Base Controller
|
|
|
|
*
|
|
|
|
* @since 1.6
|
2021-03-05 03:08:47 +00:00
|
|
|
*/
|
2024-03-09 19:47:28 +00:00
|
|
|
class HelpController extends BaseController
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
|
|
|
public function __construct($config)
|
|
|
|
{
|
|
|
|
parent::__construct($config);
|
|
|
|
// load the tasks
|
|
|
|
$this->registerTask('getText', 'help');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function help()
|
|
|
|
{
|
2024-03-09 19:47:28 +00:00
|
|
|
$user = Factory::getApplication()->getIdentity();
|
|
|
|
$jinput = Factory::getApplication()->input;
|
2021-03-05 03:08:47 +00:00
|
|
|
// Check Token!
|
2024-03-09 19:47:28 +00:00
|
|
|
$token = Session::getFormToken();
|
|
|
|
$call_token = $jinput->get('token', 0, 'ALNUM');
|
|
|
|
if($user->id != 0 && ($jinput->get($token, 0, 'ALNUM') || $token === $call_token))
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
|
|
|
$task = $this->getTask();
|
|
|
|
switch($task){
|
|
|
|
case 'getText':
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$idValue = $jinput->get('id', 0, 'INT');
|
|
|
|
if($idValue)
|
|
|
|
{
|
|
|
|
$result = $this->getHelpDocumentText($idValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = '';
|
|
|
|
}
|
|
|
|
echo $result;
|
|
|
|
// stop execution gracefully
|
|
|
|
jexit();
|
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
|
|
|
// stop execution gracefully
|
|
|
|
jexit();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2024-03-09 19:47:28 +00:00
|
|
|
else
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
|
|
|
// stop execution gracefully
|
|
|
|
jexit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function getHelpDocumentText($id)
|
|
|
|
{
|
2024-03-09 19:47:28 +00:00
|
|
|
$db = Factory::getContainer()->get(DatabaseInterface::class);
|
|
|
|
$query = $db->getQuery(true);
|
2021-03-05 03:08:47 +00:00
|
|
|
$query->select(array('a.title','a.content'));
|
2024-03-09 19:47:28 +00:00
|
|
|
$query->from('#__###component###_help_document AS a');
|
2021-03-05 03:08:47 +00:00
|
|
|
$query->where('a.id = '.(int) $id);
|
|
|
|
$query->where('a.published = 1');
|
|
|
|
$db->setQuery($query);
|
|
|
|
$db->execute();
|
|
|
|
if($db->getNumRows())
|
|
|
|
{
|
2024-03-09 19:47:28 +00:00
|
|
|
$text = [];
|
2021-03-05 03:08:47 +00:00
|
|
|
$document = $db->loadObject();
|
|
|
|
// fix image issue
|
2024-03-09 19:47:28 +00:00
|
|
|
$images['src="images'] = 'src="'.Uri::root().'images';
|
|
|
|
$images["src='images"] = "src='".Uri::root()."images";
|
|
|
|
$images['src="/images'] = 'src="'.Uri::root().'images';
|
|
|
|
$images["src='/images"] = "src='".Uri::root()."images";
|
2021-03-05 03:08:47 +00:00
|
|
|
// set document template
|
|
|
|
$text[] = "<!doctype html>";
|
|
|
|
$text[] = '<html>';
|
|
|
|
$text[] = "<head>";
|
|
|
|
$text[] = '<meta charset="utf-8">';
|
|
|
|
$text[] = "<title>".$document->title."</title>";
|
2024-03-09 19:47:28 +00:00
|
|
|
$text[] = '<link type="text/css" href="'.Uri::root().'media/com_###component###/uikit/css/uikit.gradient.min.css" rel="stylesheet"></link>';
|
|
|
|
$text[] = '<script type="text/javascript" src="'.Uri::root().'media/com_###component###/uikit/js/uikit.min.js"></script>';
|
2021-03-05 03:08:47 +00:00
|
|
|
$text[] = "</head>";
|
|
|
|
$text[] = '<body><br />';
|
|
|
|
$text[] = '<div class="uk-container uk-container-center uk-grid-collapse">';
|
|
|
|
$text[] = '<div class="uk-panel uk-width-1-1 uk-panel-box uk-panel-box-primary">';
|
|
|
|
// build the help text
|
|
|
|
$text[] = '<h1 class="uk-panel-title">'.$document->title."</h1>";
|
|
|
|
$text[] = str_replace(array_keys($images),array_values($images),$document->content);
|
|
|
|
// end template
|
|
|
|
$text[] = '</div><br /><br />';
|
|
|
|
$text[] = '</div>';
|
|
|
|
$text[] = "</body>";
|
|
|
|
$text[] = "</html>";
|
|
|
|
|
|
|
|
return implode("\n",$text);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|