2017-11-16 04:37:32 +00:00
|
|
|
<?php
|
2021-03-05 03:08:47 +00:00
|
|
|
/**
|
|
|
|
* @package Joomla.Component.Builder
|
|
|
|
*
|
|
|
|
* @created 30th April, 2015
|
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
|
|
|
|
*/
|
|
|
|
|
|
|
|
// No direct access to this file
|
|
|
|
defined('_JEXEC') or die('Restricted access');
|
|
|
|
|
2024-03-02 20:10:30 +00:00
|
|
|
use Joomla\CMS\Factory;
|
|
|
|
use Joomla\CMS\Language\Text;
|
|
|
|
use Joomla\CMS\Component\ComponentHelper;
|
|
|
|
use Joomla\CMS\HTML\HTMLHelper as Html;
|
|
|
|
use Joomla\CMS\Layout\FileLayout;
|
2022-05-25 08:30:55 +00:00
|
|
|
use Joomla\CMS\MVC\View\HtmlView;
|
2024-03-02 20:10:30 +00:00
|
|
|
use Joomla\CMS\Plugin\PluginHelper;
|
|
|
|
use Joomla\CMS\Toolbar\ToolbarHelper;
|
2021-03-08 22:36:30 +00:00
|
|
|
use Joomla\CMS\Filesystem\File;
|
2023-10-18 07:26:30 +00:00
|
|
|
use VDM\Joomla\Utilities\ArrayHelper;
|
|
|
|
use VDM\Joomla\Utilities\StringHelper;
|
2021-03-08 22:36:30 +00:00
|
|
|
|
2021-03-05 03:08:47 +00:00
|
|
|
/**
|
2022-05-25 08:30:55 +00:00
|
|
|
* Componentbuilder Html View class for the Get_snippets
|
2021-03-05 03:08:47 +00:00
|
|
|
*/
|
2022-05-25 08:30:55 +00:00
|
|
|
class ComponentbuilderViewGet_snippets extends HtmlView
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
|
|
|
// Overwriting JView display method
|
|
|
|
function display($tpl = null)
|
|
|
|
{
|
|
|
|
// get component params
|
2024-03-02 20:10:30 +00:00
|
|
|
$this->params = ComponentHelper::getParams('com_componentbuilder');
|
2021-03-05 03:08:47 +00:00
|
|
|
// get the application
|
2024-03-02 20:10:30 +00:00
|
|
|
$this->app = Factory::getApplication();
|
2021-03-05 03:08:47 +00:00
|
|
|
// get the user object
|
2024-03-02 20:10:30 +00:00
|
|
|
$this->user = Factory::getUser();
|
2021-03-05 03:08:47 +00:00
|
|
|
// get global action permissions
|
2017-12-15 01:10:10 +00:00
|
|
|
$this->canDo = ComponentbuilderHelper::getActions('get_snippets');
|
2017-11-16 04:37:32 +00:00
|
|
|
// Initialise variables.
|
2017-12-15 01:10:10 +00:00
|
|
|
$this->items = $this->get('Items');
|
2017-11-16 04:37:32 +00:00
|
|
|
|
|
|
|
// We don't need toolbar in the modal window.
|
|
|
|
if ($this->getLayout() !== 'modal')
|
|
|
|
{
|
|
|
|
// add the tool bar
|
|
|
|
$this->addToolBar();
|
|
|
|
}
|
|
|
|
|
|
|
|
// set the document
|
|
|
|
$this->setDocument();
|
|
|
|
|
|
|
|
// Check for errors.
|
|
|
|
if (count($errors = $this->get('Errors')))
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
throw new \Exception(implode(PHP_EOL, $errors), 500);
|
2017-11-16 04:37:32 +00:00
|
|
|
}
|
|
|
|
|
2021-03-05 03:08:47 +00:00
|
|
|
parent::display($tpl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Prepares the document
|
|
|
|
*/
|
|
|
|
protected function setDocument()
|
2017-11-16 04:37:32 +00:00
|
|
|
{
|
|
|
|
|
2023-10-18 07:26:30 +00:00
|
|
|
// Only load jQuery if needed. (default is true)
|
|
|
|
if ($this->params->get('add_jquery_framework', 1) == 1)
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('jquery.framework');
|
2023-10-18 07:26:30 +00:00
|
|
|
}
|
2017-11-16 04:37:32 +00:00
|
|
|
// Load the header checker class.
|
|
|
|
require_once( JPATH_COMPONENT_ADMINISTRATOR.'/helpers/headercheck.php' );
|
|
|
|
// Initialize the header checker.
|
2024-03-02 20:10:30 +00:00
|
|
|
$HeaderCheck = new componentbuilderHeaderCheck();
|
2017-12-17 09:07:51 +00:00
|
|
|
|
2017-12-14 23:10:47 +00:00
|
|
|
// Add View JavaScript File
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('script', "administrator/components/com_componentbuilder/assets/js/get_snippets.js", ['version' => 'auto']);
|
2017-11-16 04:37:32 +00:00
|
|
|
|
|
|
|
// Load uikit options.
|
|
|
|
$uikit = $this->params->get('uikit_load');
|
|
|
|
// Set script size.
|
|
|
|
$size = $this->params->get('uikit_min');
|
|
|
|
// Set css style.
|
|
|
|
$style = $this->params->get('uikit_style');
|
|
|
|
|
|
|
|
// The uikit css.
|
|
|
|
if ((!$HeaderCheck->css_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit'.$style.$size.'.css', ['version' => 'auto']);
|
2017-11-16 04:37:32 +00:00
|
|
|
}
|
|
|
|
// The uikit js.
|
|
|
|
if ((!$HeaderCheck->js_loaded('uikit.min') || $uikit == 1) && $uikit != 2 && $uikit != 3)
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit'.$size.'.js', ['version' => 'auto']);
|
2017-11-16 04:37:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Load the script to find all uikit components needed.
|
|
|
|
if ($uikit != 2)
|
|
|
|
{
|
|
|
|
// Set the default uikit components in this view.
|
2024-03-02 20:10:30 +00:00
|
|
|
$uikitComp = [];
|
2017-11-16 04:37:32 +00:00
|
|
|
$uikitComp[] = 'data-uk-grid';
|
|
|
|
}
|
|
|
|
|
|
|
|
// Load the needed uikit components in this view.
|
2024-03-02 20:10:30 +00:00
|
|
|
if ($uikit != 2 && isset($uikitComp) && ArrayHelper::check($uikitComp))
|
2017-11-16 04:37:32 +00:00
|
|
|
{
|
|
|
|
// loading...
|
|
|
|
foreach ($uikitComp as $class)
|
|
|
|
{
|
|
|
|
foreach (ComponentbuilderHelper::$uk_components[$class] as $name)
|
|
|
|
{
|
|
|
|
// check if the CSS file exists.
|
2021-03-08 22:36:30 +00:00
|
|
|
if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css'))
|
2017-11-16 04:37:32 +00:00
|
|
|
{
|
|
|
|
// load the css.
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/'.$name.$style.$size.'.css', ['version' => 'auto']);
|
2017-11-16 04:37:32 +00:00
|
|
|
}
|
|
|
|
// check if the JavaScript file exists.
|
2021-03-08 22:36:30 +00:00
|
|
|
if (File::exists(JPATH_ROOT.'/media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js'))
|
2017-11-16 04:37:32 +00:00
|
|
|
{
|
|
|
|
// load the js.
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/'.$name.$size.'.js', ['version' => 'auto'], ['type' => 'text/javascript', 'async' => 'async']);
|
2017-11-16 04:37:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-09-11 20:28:17 +00:00
|
|
|
}
|
2017-11-16 04:37:32 +00:00
|
|
|
// load the local snippets
|
2023-10-18 07:26:30 +00:00
|
|
|
if (ArrayHelper::check($this->items))
|
2017-11-16 04:37:32 +00:00
|
|
|
{
|
|
|
|
$local_snippets = array();
|
|
|
|
foreach ($this->items as $item)
|
|
|
|
{
|
2023-10-18 07:26:30 +00:00
|
|
|
$path = StringHelper::safe($item->library . ' - (' . $item->type . ') ' . $item->name, 'filename', '', false). '.json';
|
2017-11-16 04:37:32 +00:00
|
|
|
$local_snippets[$path] = $item;
|
|
|
|
}
|
|
|
|
}
|
2020-01-03 01:41:55 +00:00
|
|
|
|
2017-11-16 04:37:32 +00:00
|
|
|
// Add the JavaScript for JStore
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('script', 'media/com_componentbuilder/js/jquery.json.min.js', ['version' => 'auto']);
|
|
|
|
Html::_('script', 'media/com_componentbuilder/js/jstorage.min.js', ['version' => 'auto']);
|
|
|
|
Html::_('script', 'media/com_componentbuilder/js/strtotime.js', ['version' => 'auto']);
|
2017-11-16 04:37:32 +00:00
|
|
|
// check if we should use browser storage
|
|
|
|
$setBrowserStorage = $this->params->get('set_browser_storage', null);
|
|
|
|
if ($setBrowserStorage)
|
|
|
|
{
|
|
|
|
// check what (Time To Live) show we use
|
|
|
|
$storageTimeToLive = $this->params->get('storage_time_to_live', 'global');
|
|
|
|
if ('global' == $storageTimeToLive)
|
|
|
|
{
|
|
|
|
// use the global session time
|
2024-03-02 20:10:30 +00:00
|
|
|
$session = Factory::getSession();
|
2017-11-16 04:37:32 +00:00
|
|
|
// must have itin milliseconds
|
|
|
|
$expire = ($session->getExpire()*60)* 1000;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// use the Componentbuilder Global setting
|
|
|
|
if (0 != $storageTimeToLive)
|
|
|
|
{
|
|
|
|
// this will convert the time into milliseconds
|
|
|
|
$storageTimeToLive = $storageTimeToLive * 1000;
|
|
|
|
}
|
|
|
|
$expire = $storageTimeToLive;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// set to use no storage
|
2017-12-03 18:09:04 +00:00
|
|
|
$expire = 30000; // only 30 seconds
|
2017-11-16 04:37:32 +00:00
|
|
|
}
|
2020-01-03 01:41:55 +00:00
|
|
|
// Set the Time To Live To JavaScript
|
|
|
|
$this->document->addScriptDeclaration("var expire = ". (int) $expire.";");
|
2017-11-20 12:35:30 +00:00
|
|
|
// set snippet path
|
|
|
|
$this->document->addScriptDeclaration("var snippetPath = '". ComponentbuilderHelper::$snippetPath ."';");
|
|
|
|
$this->document->addScriptDeclaration("var snippetsPath = '". ComponentbuilderHelper::$snippetsPath ."';");
|
2017-11-16 04:37:32 +00:00
|
|
|
// token
|
2024-03-04 06:54:03 +00:00
|
|
|
$this->document->addScriptDeclaration("var token = '". \JSession::getFormToken() ."';");
|
2017-11-17 17:51:35 +00:00
|
|
|
// add some global items buckets for bulk updating
|
|
|
|
$this->document->addScriptDeclaration("var bulkItems = {};");
|
|
|
|
$this->document->addScriptDeclaration("bulkItems.new = [];");
|
|
|
|
$this->document->addScriptDeclaration("bulkItems.diverged = [];");
|
|
|
|
$this->document->addScriptDeclaration("bulkItems.ahead = [];");
|
|
|
|
$this->document->addScriptDeclaration("bulkItems.behind = [];");
|
2017-11-16 04:37:32 +00:00
|
|
|
// set an error message if needed
|
2024-03-02 20:10:30 +00:00
|
|
|
$this->document->addScriptDeclaration("var returnError = '<div class=\"uk-alert uk-alert-warning\"><h1>".Text::_('COM_COMPONENTBUILDER_AN_ERROR_HAS_OCCURRED')."!</h1><p>".Text::_('COM_COMPONENTBUILDER_PLEASE_TRY_AGAIN_LATER').".</p></div>';");
|
2017-11-17 16:18:47 +00:00
|
|
|
// need to add some language strings
|
2024-03-02 20:10:30 +00:00
|
|
|
Text::script('COM_COMPONENTBUILDER_JCB_COMMUNITY_SNIPPETS');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_SNIPPETS');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_SNIPPET');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_VIEW_SNIPPET_OF_COMMUNITY_VERSION');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_GET_SNIPPET');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_LOCAL_SNIPPET');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_UPDATE_THE_LOCAL_VERSION');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_GET_THE_SNIPPET_FROM_GITHUB_AND_INSTALL_IT_LOCALLY');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_NO_NEED_TO_GET_IT_SINCE_IT_IS_ALREADY_IN_SYNC_WITH_YOUR_LOCAL_VERSION');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_USAGE');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_VIEW_USAGE_OF_COMMUNITY_VERSION');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_DESCRIPTION');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_VIEW_DESCRIPTION_OF_COMMUNITY_VERSION');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_VIEW_BLAME');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_VIEW_WHO_CONTRIBUTED_TO_THIS_SNIPPET');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_VIEW_SNIPPET_REFERENCE_URL');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_SNIPPET_COULD_NOT_BE_UPDATEDSAVED');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_SNIPPETS_COULD_NOT_BE_UPDATEDSAVED');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_LINK_TO_THE_CONTRIBUTOR');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_VIEW_THE_CONTRIBUTOR_DETAILS');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_JCB_COMMUNITY');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_COMPANY_NAME');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_AUTHOR_NAME');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_AUTHOR_EMAIL');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_AUTHOR_WEBSITE');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_THERE_ARE_NO_NEW_SNIPPETS_AT_THIS_TIME');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_THERE_ARE_NO_DIVERGED_SNIPPETS_AT_THIS_TIME');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_THERE_ARE_NO_AHEAD_SNIPPETS_AT_THIS_TIME');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_THERE_ARE_NO_OUT_OF_DATE_SNIPPETS_AT_THIS_TIME');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_THERE_ARE_NO_SNIPPETS_TO_UPDATE_AT_THIS_TIME');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_AVAILABLE_LIBRARIES');
|
|
|
|
Text::script('COM_COMPONENTBUILDER_OPEN_LIBRARY_SNIPPETS');
|
2017-11-17 16:18:47 +00:00
|
|
|
// add some lang verfy messages
|
|
|
|
$this->document->addScriptDeclaration("
|
|
|
|
// set the snippet from gitHub
|
|
|
|
function getConfirmUpdate(status) {
|
|
|
|
switch(status) {
|
|
|
|
case 'new':
|
2024-03-02 20:10:30 +00:00
|
|
|
return '".Text::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_ADD_THIS_NEW_JCB_COMMUNITY_SNIPPET_TO_YOUR_LOCAL_SNIPPETS')."';
|
2017-11-17 16:18:47 +00:00
|
|
|
break;
|
|
|
|
case 'behind':
|
2024-03-02 20:10:30 +00:00
|
|
|
return '".Text::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_UPDATE_YOUR_LOCAL_SNIPPET_WITH_THIS_NEWER_JCB_COMMUNITY_SNIPPET')."';
|
2017-11-17 16:18:47 +00:00
|
|
|
break;
|
|
|
|
case 'ahead':
|
2024-03-02 20:10:30 +00:00
|
|
|
return '".Text::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_UPDATE_YOUR_LOCAL_SNIPPET_WITH_THIS_OLDER_JCB_COMMUNITY_SNIPPET')."';
|
2017-11-17 16:18:47 +00:00
|
|
|
break;
|
|
|
|
case 'diverged':
|
2024-03-02 20:10:30 +00:00
|
|
|
return '".Text::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_REPLACE_YOUR_LOCAL_SNIPPET_WITH_THIS_JCB_COMMUNITY_SNIPPET')."';
|
2017-11-17 16:18:47 +00:00
|
|
|
break;
|
|
|
|
default:
|
2024-03-02 20:10:30 +00:00
|
|
|
return '".Text::_('COM_COMPONENTBUILDER_ARE_YOU_SURE_YOU_WOULD_LIKE_TO_CONTINUE')."';
|
2017-11-17 16:18:47 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
");
|
2017-11-16 04:37:32 +00:00
|
|
|
// load the local snippets
|
2023-10-18 07:26:30 +00:00
|
|
|
if (ArrayHelper::check($this->items))
|
2017-11-16 04:37:32 +00:00
|
|
|
{
|
|
|
|
// Set the local snippets array
|
|
|
|
$this->document->addScriptDeclaration("var local_snippets = ". json_encode($local_snippets).";");
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
// add the document default css file
|
2024-03-02 20:10:30 +00:00
|
|
|
Html::_('stylesheet', 'administrator/components/com_componentbuilder/assets/css/get_snippets.css', ['version' => 'auto']);
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Setting the toolbar
|
|
|
|
*/
|
|
|
|
protected function addToolBar()
|
2020-04-23 21:15:07 +00:00
|
|
|
{
|
|
|
|
// hide the main menu
|
2021-03-05 03:08:47 +00:00
|
|
|
$this->app->input->set('hidemainmenu', true);
|
|
|
|
// add title to the page
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::title(Text::_('COM_COMPONENTBUILDER_GET_SNIPPETS'),'search');
|
2020-04-23 21:15:07 +00:00
|
|
|
// add cpanel button
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::custom('get_snippets.dashboard', 'grid-2', '', 'COM_COMPONENTBUILDER_DASH', false);
|
2017-11-20 12:35:30 +00:00
|
|
|
if ($this->canDo->get('get_snippets.custom_admin_views'))
|
|
|
|
{
|
|
|
|
// add Custom Admin Views button.
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::custom('get_snippets.openCustomAdminViews', 'screen custom-button-opencustomadminviews', '', 'COM_COMPONENTBUILDER_CUSTOM_ADMIN_VIEWS', false);
|
2017-11-20 12:35:30 +00:00
|
|
|
}
|
|
|
|
if ($this->canDo->get('get_snippets.site_views'))
|
|
|
|
{
|
|
|
|
// add Site Views button.
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::custom('get_snippets.openSiteViews', 'palette custom-button-opensiteviews', '', 'COM_COMPONENTBUILDER_SITE_VIEWS', false);
|
2017-11-20 12:35:30 +00:00
|
|
|
}
|
|
|
|
if ($this->canDo->get('get_snippets.templates'))
|
|
|
|
{
|
|
|
|
// add Templates button.
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::custom('get_snippets.openTemplates', 'brush custom-button-opentemplates', '', 'COM_COMPONENTBUILDER_TEMPLATES', false);
|
2017-11-20 12:35:30 +00:00
|
|
|
}
|
|
|
|
if ($this->canDo->get('get_snippets.layouts'))
|
|
|
|
{
|
|
|
|
// add Layouts button.
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::custom('get_snippets.openLayouts', 'brush custom-button-openlayouts', '', 'COM_COMPONENTBUILDER_LAYOUTS', false);
|
2017-11-20 12:35:30 +00:00
|
|
|
}
|
2017-11-16 04:37:32 +00:00
|
|
|
if ($this->canDo->get('get_snippets.snippets'))
|
|
|
|
{
|
|
|
|
// add Snippets button.
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::custom('get_snippets.openSnippets', 'pin custom-button-opensnippets', '', 'COM_COMPONENTBUILDER_SNIPPETS', false);
|
2017-12-03 18:09:04 +00:00
|
|
|
}
|
|
|
|
if ($this->canDo->get('get_snippets.libraries'))
|
|
|
|
{
|
|
|
|
// add Libraries button.
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::custom('get_snippets.openLibraries', 'puzzle custom-button-openlibraries', '', 'COM_COMPONENTBUILDER_LIBRARIES', false);
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// set help url for this view if found
|
2022-02-12 22:28:17 +00:00
|
|
|
$this->help_url = ComponentbuilderHelper::getHelpUrl('get_snippets');
|
2024-03-02 20:10:30 +00:00
|
|
|
if (StringHelper::check($this->help_url))
|
2021-03-05 03:08:47 +00:00
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url);
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// add the options comp button
|
|
|
|
if ($this->canDo->get('core.admin') || $this->canDo->get('core.options'))
|
|
|
|
{
|
2024-03-02 20:10:30 +00:00
|
|
|
ToolbarHelper::preferences('com_componentbuilder');
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Escapes a value for output in a view script.
|
|
|
|
*
|
|
|
|
* @param mixed $var The output to escape.
|
|
|
|
*
|
|
|
|
* @return mixed The escaped value.
|
|
|
|
*/
|
|
|
|
public function escape($var)
|
|
|
|
{
|
|
|
|
// use the helper htmlEscape method instead.
|
2024-03-02 20:10:30 +00:00
|
|
|
return StringHelper::html($var, $this->_charset);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the Document (helper method toward Joomla 4 and 5)
|
|
|
|
*/
|
|
|
|
public function getDocument()
|
|
|
|
{
|
|
|
|
$this->document ??= JFactory::getDocument();
|
|
|
|
|
|
|
|
return $this->document;
|
2021-03-05 03:08:47 +00:00
|
|
|
}
|
|
|
|
}
|