Stable release of v3.2.0-beta1
Move beta to main repo. Fix #1053 so that the right and left tabs display correctly in Joomla 4&5.
This commit is contained in:
@ -12,7 +12,19 @@
|
||||
// No direct access to this file
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Form\FormHelper;
|
||||
use Joomla\CMS\Session\Session;
|
||||
use Joomla\CMS\Uri\Uri;
|
||||
use Joomla\CMS\Toolbar\Toolbar;
|
||||
use Joomla\CMS\Component\ComponentHelper;
|
||||
use Joomla\CMS\HTML\HTMLHelper as Html;
|
||||
use Joomla\CMS\Layout\FileLayout;
|
||||
use Joomla\CMS\MVC\View\HtmlView;
|
||||
use Joomla\CMS\Plugin\PluginHelper;
|
||||
use Joomla\CMS\Toolbar\ToolbarHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
|
||||
/**
|
||||
* Snippet Html View class
|
||||
@ -26,7 +38,7 @@ class ComponentbuilderViewSnippet extends HtmlView
|
||||
public function display($tpl = null)
|
||||
{
|
||||
// set params
|
||||
$this->params = JComponentHelper::getParams('com_componentbuilder');
|
||||
$this->params = ComponentHelper::getParams('com_componentbuilder');
|
||||
// Assign the variables
|
||||
$this->form = $this->get('Form');
|
||||
$this->item = $this->get('Item');
|
||||
@ -35,7 +47,7 @@ class ComponentbuilderViewSnippet extends HtmlView
|
||||
// get action permissions
|
||||
$this->canDo = ComponentbuilderHelper::getActions('snippet', $this->item);
|
||||
// get input
|
||||
$jinput = JFactory::getApplication()->input;
|
||||
$jinput = Factory::getApplication()->input;
|
||||
$this->ref = $jinput->get('ref', 0, 'word');
|
||||
$this->refid = $jinput->get('refid', 0, 'int');
|
||||
$return = $jinput->get('return', null, 'base64');
|
||||
@ -60,7 +72,7 @@ class ComponentbuilderViewSnippet extends HtmlView
|
||||
|
||||
// Set the toolbar
|
||||
$this->addToolBar();
|
||||
|
||||
|
||||
// Check for errors.
|
||||
if (count($errors = $this->get('Errors')))
|
||||
{
|
||||
@ -80,34 +92,34 @@ class ComponentbuilderViewSnippet extends HtmlView
|
||||
*/
|
||||
protected function addToolBar()
|
||||
{
|
||||
JFactory::getApplication()->input->set('hidemainmenu', true);
|
||||
$user = JFactory::getUser();
|
||||
Factory::getApplication()->input->set('hidemainmenu', true);
|
||||
$user = Factory::getUser();
|
||||
$userId = $user->id;
|
||||
$isNew = $this->item->id == 0;
|
||||
|
||||
JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_EDIT'), 'pencil-2 article-add');
|
||||
ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_EDIT'), 'pencil-2 article-add');
|
||||
// Built the actions for new and existing records.
|
||||
if (ComponentbuilderHelper::checkString($this->referral))
|
||||
if (StringHelper::check($this->referral))
|
||||
{
|
||||
if ($this->canDo->get('core.create') && $isNew)
|
||||
{
|
||||
// We can create the record.
|
||||
JToolBarHelper::save('snippet.save', 'JTOOLBAR_SAVE');
|
||||
ToolbarHelper::save('snippet.save', 'JTOOLBAR_SAVE');
|
||||
}
|
||||
elseif ($this->canDo->get('core.edit'))
|
||||
{
|
||||
// We can save the record.
|
||||
JToolBarHelper::save('snippet.save', 'JTOOLBAR_SAVE');
|
||||
ToolbarHelper::save('snippet.save', 'JTOOLBAR_SAVE');
|
||||
}
|
||||
if ($isNew)
|
||||
{
|
||||
// Do not creat but cancel.
|
||||
JToolBarHelper::cancel('snippet.cancel', 'JTOOLBAR_CANCEL');
|
||||
ToolbarHelper::cancel('snippet.cancel', 'JTOOLBAR_CANCEL');
|
||||
}
|
||||
else
|
||||
{
|
||||
// We can close it.
|
||||
JToolBarHelper::cancel('snippet.cancel', 'JTOOLBAR_CLOSE');
|
||||
ToolbarHelper::cancel('snippet.cancel', 'JTOOLBAR_CLOSE');
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -117,44 +129,44 @@ class ComponentbuilderViewSnippet extends HtmlView
|
||||
// For new records, check the create permission.
|
||||
if ($this->canDo->get('core.create'))
|
||||
{
|
||||
JToolBarHelper::apply('snippet.apply', 'JTOOLBAR_APPLY');
|
||||
JToolBarHelper::save('snippet.save', 'JTOOLBAR_SAVE');
|
||||
JToolBarHelper::custom('snippet.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
|
||||
ToolbarHelper::apply('snippet.apply', 'JTOOLBAR_APPLY');
|
||||
ToolbarHelper::save('snippet.save', 'JTOOLBAR_SAVE');
|
||||
ToolbarHelper::custom('snippet.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
|
||||
};
|
||||
JToolBarHelper::cancel('snippet.cancel', 'JTOOLBAR_CANCEL');
|
||||
ToolbarHelper::cancel('snippet.cancel', 'JTOOLBAR_CANCEL');
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($this->canDo->get('core.edit'))
|
||||
{
|
||||
// We can save the new record
|
||||
JToolBarHelper::apply('snippet.apply', 'JTOOLBAR_APPLY');
|
||||
JToolBarHelper::save('snippet.save', 'JTOOLBAR_SAVE');
|
||||
ToolbarHelper::apply('snippet.apply', 'JTOOLBAR_APPLY');
|
||||
ToolbarHelper::save('snippet.save', 'JTOOLBAR_SAVE');
|
||||
// We can save this record, but check the create permission to see
|
||||
// if we can return to make a new one.
|
||||
if ($this->canDo->get('core.create'))
|
||||
{
|
||||
JToolBarHelper::custom('snippet.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
|
||||
ToolbarHelper::custom('snippet.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
|
||||
}
|
||||
}
|
||||
$canVersion = ($this->canDo->get('core.version') && $this->canDo->get('snippet.version'));
|
||||
if ($this->state->params->get('save_history', 1) && $this->canDo->get('core.edit') && $canVersion)
|
||||
{
|
||||
JToolbarHelper::versions('com_componentbuilder.snippet', $this->item->id);
|
||||
ToolbarHelper::versions('com_componentbuilder.snippet', $this->item->id);
|
||||
}
|
||||
if ($this->canDo->get('core.create'))
|
||||
{
|
||||
JToolBarHelper::custom('snippet.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
|
||||
ToolbarHelper::custom('snippet.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
|
||||
}
|
||||
JToolBarHelper::cancel('snippet.cancel', 'JTOOLBAR_CLOSE');
|
||||
ToolbarHelper::cancel('snippet.cancel', 'JTOOLBAR_CLOSE');
|
||||
}
|
||||
}
|
||||
JToolbarHelper::divider();
|
||||
ToolbarHelper::divider();
|
||||
// set help url for this view if found
|
||||
$this->help_url = ComponentbuilderHelper::getHelpUrl('snippet');
|
||||
if (ComponentbuilderHelper::checkString($this->help_url))
|
||||
if (StringHelper::check($this->help_url))
|
||||
{
|
||||
JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url);
|
||||
ToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $this->help_url);
|
||||
}
|
||||
}
|
||||
|
||||
@ -169,11 +181,11 @@ class ComponentbuilderViewSnippet extends HtmlView
|
||||
{
|
||||
if(strlen($var) > 30)
|
||||
{
|
||||
// use the helper htmlEscape method instead and shorten the string
|
||||
return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30);
|
||||
// use the helper htmlEscape method instead and shorten the string
|
||||
return StringHelper::html($var, $this->_charset, true, 30);
|
||||
}
|
||||
// use the helper htmlEscape method instead.
|
||||
return ComponentbuilderHelper::htmlEscape($var, $this->_charset);
|
||||
return StringHelper::html($var, $this->_charset);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -184,14 +196,20 @@ class ComponentbuilderViewSnippet extends HtmlView
|
||||
protected function setDocument()
|
||||
{
|
||||
$isNew = ($this->item->id < 1);
|
||||
if (!isset($this->document))
|
||||
{
|
||||
$this->document = JFactory::getDocument();
|
||||
}
|
||||
$this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_EDIT'));
|
||||
$this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/snippet.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
|
||||
$this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
|
||||
$this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/snippet/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
|
||||
JText::script('view not acceptable. Error');
|
||||
$this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_SNIPPET_NEW' : 'COM_COMPONENTBUILDER_SNIPPET_EDIT'));
|
||||
Html::_('stylesheet', "administrator/components/com_componentbuilder/assets/css/snippet.css", ['version' => 'auto']);
|
||||
Html::_('script', $this->script, ['version' => 'auto']);
|
||||
Html::_('script', "administrator/components/com_componentbuilder/views/snippet/submitbutton.js", ['version' => 'auto']);
|
||||
Text::script('view not acceptable. Error');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Document (helper method toward Joomla 4 and 5)
|
||||
*/
|
||||
public function getDocument()
|
||||
{
|
||||
$this->document ??= JFactory::getDocument();
|
||||
|
||||
return $this->document;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user