2015-08-24 20:22:07 +00:00
|
|
|
<?php
|
|
|
|
/*----------------------------------------------------------------------------------| www.vdm.io |----/
|
|
|
|
Vast Development Method
|
|
|
|
/-------------------------------------------------------------------------------------------------------/
|
|
|
|
|
2015-12-29 19:39:38 +00:00
|
|
|
@version 1.0.5
|
2016-03-20 06:12:02 +00:00
|
|
|
@build 20th March, 2016
|
2015-12-03 02:17:44 +00:00
|
|
|
@created 5th August, 2015
|
2015-08-24 20:22:07 +00:00
|
|
|
@package Demo
|
|
|
|
@subpackage help.php
|
|
|
|
@author Llewellyn van der Merwe <https://www.vdm.io/>
|
|
|
|
@copyright Copyright (C) 2015. All Rights Reserved
|
|
|
|
@license GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
____ _____ _____ __ __ __ __ ___ _____ __ __ ____ _____ _ _ ____ _ _ ____
|
|
|
|
(_ _)( _ )( _ )( \/ )( ) /__\ / __)( _ )( \/ )( _ \( _ )( \( )( ___)( \( )(_ _)
|
|
|
|
.-_)( )(_)( )(_)( ) ( )(__ /(__)\ ( (__ )(_)( ) ( )___/ )(_)( ) ( )__) ) ( )(
|
|
|
|
\____) (_____)(_____)(_/\/\_)(____)(__)(__) \___)(_____)(_/\/\_)(__) (_____)(_)\_)(____)(_)\_) (__)
|
|
|
|
|
|
|
|
/------------------------------------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
|
|
|
// import Joomla controllerform library
|
|
|
|
jimport('joomla.application.component.controller');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Demo Help Controller
|
|
|
|
*/
|
|
|
|
class DemoControllerHelp extends JControllerLegacy
|
|
|
|
{
|
|
|
|
public function __construct($config)
|
|
|
|
{
|
|
|
|
parent::__construct($config);
|
2015-12-03 02:17:44 +00:00
|
|
|
// load the tasks
|
2015-08-24 20:22:07 +00:00
|
|
|
$this->registerTask('getText', 'help');
|
|
|
|
}
|
2015-12-03 02:17:44 +00:00
|
|
|
|
2015-08-24 20:22:07 +00:00
|
|
|
public function help()
|
|
|
|
{
|
|
|
|
$user = JFactory::getUser();
|
|
|
|
$jinput = JFactory::getApplication()->input;
|
|
|
|
// Check Token!
|
|
|
|
$token = JSession::getFormToken();
|
|
|
|
$call_token = $jinput->get('token', 0, 'ALNUM');
|
|
|
|
if($user->id != 0 && $token == $call_token){
|
|
|
|
$task = $this->getTask();
|
|
|
|
switch($task){
|
|
|
|
case 'getText':
|
|
|
|
try
|
|
|
|
{
|
|
|
|
$idValue = $jinput->get('id', 0, 'INT');
|
|
|
|
if($idValue)
|
|
|
|
{
|
|
|
|
$result = $this->getHelpDocumentText($idValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = '';
|
|
|
|
}
|
|
|
|
echo $result;
|
2015-12-03 02:17:44 +00:00
|
|
|
// stop execution gracefully
|
|
|
|
jexit();
|
2015-08-24 20:22:07 +00:00
|
|
|
}
|
|
|
|
catch(Exception $e)
|
|
|
|
{
|
2015-12-03 02:17:44 +00:00
|
|
|
// stop execution gracefully
|
2015-08-24 20:22:07 +00:00
|
|
|
jexit();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2015-12-03 02:17:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// stop execution gracefully
|
2015-08-24 20:22:07 +00:00
|
|
|
jexit();
|
|
|
|
}
|
|
|
|
}
|
2015-12-03 02:17:44 +00:00
|
|
|
|
|
|
|
protected function getHelpDocumentText($id)
|
2015-08-24 20:22:07 +00:00
|
|
|
{
|
|
|
|
$db = JFactory::getDbo();
|
|
|
|
$query = $db->getQuery(true);
|
|
|
|
$query->select(array('a.title','a.content'));
|
|
|
|
$query->from('#__demo_help_document AS a');
|
|
|
|
$query->where('a.id = '.(int) $id);
|
|
|
|
$query->where('a.published = 1');
|
|
|
|
$db->setQuery($query);
|
|
|
|
$db->execute();
|
|
|
|
if($db->getNumRows())
|
|
|
|
{
|
|
|
|
$text = array();
|
|
|
|
$document = $db->loadObject();
|
|
|
|
// fix image issue
|
|
|
|
$images['src="images'] = 'src="'.JURI::root().'images';
|
|
|
|
$images["src='images"] = "src='".JURI::root()."images";
|
|
|
|
$images['src="/images'] = 'src="'.JURI::root().'images';
|
|
|
|
$images["src='/images"] = "src='".JURI::root()."images";
|
|
|
|
// set document template
|
|
|
|
$text[] = "<!doctype html>";
|
|
|
|
$text[] = '<html>';
|
|
|
|
$text[] = "<head>";
|
|
|
|
$text[] = '<meta charset="utf-8">';
|
|
|
|
$text[] = "<title>".$document->title."</title>";
|
|
|
|
$text[] = '<link type="text/css" href="'.JURI::root().'media/com_demo/uikit/css/uikit.gradient.min.css" rel="stylesheet"></link>';
|
|
|
|
$text[] = '<script type="text/javascript" src="'.JURI::root().'media/com_demo/uikit/js/uikit.min.js"></script>';
|
|
|
|
$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
|
2016-03-05 22:57:11 +00:00
|
|
|
$text[] = '<h1 class="uk-panel-title">'.$document->title."</h1>";
|
2015-08-24 20:22:07 +00:00
|
|
|
$text[] = str_replace(array_keys($images),array_values($images),$document->content);
|
|
|
|
// end template
|
2016-03-05 22:57:11 +00:00
|
|
|
$text[] = '</div><br /><br />';
|
2015-08-24 20:22:07 +00:00
|
|
|
$text[] = '</div>';
|
|
|
|
$text[] = "</body>";
|
|
|
|
$text[] = "</html>";
|
2015-12-03 02:17:44 +00:00
|
|
|
|
2015-08-24 20:22:07 +00:00
|
|
|
return implode("\n",$text);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|