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:
2024-03-02 22:10:30 +02:00
parent 3c91a5cdbb
commit d1e1a56671
1786 changed files with 73608 additions and 37437 deletions

View File

@ -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;
/**
* Custom_code Html View class
@ -26,7 +38,7 @@ class ComponentbuilderViewCustom_code 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 ComponentbuilderViewCustom_code extends HtmlView
// get action permissions
$this->canDo = ComponentbuilderHelper::getActions('custom_code', $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 ComponentbuilderViewCustom_code extends HtmlView
// Set the toolbar
$this->addToolBar();
// Check for errors.
if (count($errors = $this->get('Errors')))
{
@ -80,34 +92,34 @@ class ComponentbuilderViewCustom_code 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_CUSTOM_CODE_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_CODE_EDIT'), 'pencil-2 article-add');
ToolbarHelper::title( Text::_($isNew ? 'COM_COMPONENTBUILDER_CUSTOM_CODE_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_CODE_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('custom_code.create') && $isNew)
{
// We can create the record.
JToolBarHelper::save('custom_code.save', 'JTOOLBAR_SAVE');
ToolbarHelper::save('custom_code.save', 'JTOOLBAR_SAVE');
}
elseif ($this->canDo->get('custom_code.edit'))
{
// We can save the record.
JToolBarHelper::save('custom_code.save', 'JTOOLBAR_SAVE');
ToolbarHelper::save('custom_code.save', 'JTOOLBAR_SAVE');
}
if ($isNew)
{
// Do not creat but cancel.
JToolBarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CANCEL');
ToolbarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CANCEL');
}
else
{
// We can close it.
JToolBarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CLOSE');
ToolbarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CLOSE');
}
}
else
@ -117,44 +129,44 @@ class ComponentbuilderViewCustom_code extends HtmlView
// For new records, check the create permission.
if ($this->canDo->get('custom_code.create'))
{
JToolBarHelper::apply('custom_code.apply', 'JTOOLBAR_APPLY');
JToolBarHelper::save('custom_code.save', 'JTOOLBAR_SAVE');
JToolBarHelper::custom('custom_code.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
ToolbarHelper::apply('custom_code.apply', 'JTOOLBAR_APPLY');
ToolbarHelper::save('custom_code.save', 'JTOOLBAR_SAVE');
ToolbarHelper::custom('custom_code.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
};
JToolBarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CANCEL');
ToolbarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CANCEL');
}
else
{
if ($this->canDo->get('custom_code.edit'))
{
// We can save the new record
JToolBarHelper::apply('custom_code.apply', 'JTOOLBAR_APPLY');
JToolBarHelper::save('custom_code.save', 'JTOOLBAR_SAVE');
ToolbarHelper::apply('custom_code.apply', 'JTOOLBAR_APPLY');
ToolbarHelper::save('custom_code.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('custom_code.create'))
{
JToolBarHelper::custom('custom_code.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
ToolbarHelper::custom('custom_code.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
}
}
$canVersion = ($this->canDo->get('core.version') && $this->canDo->get('custom_code.version'));
if ($this->state->params->get('save_history', 1) && $this->canDo->get('custom_code.edit') && $canVersion)
{
JToolbarHelper::versions('com_componentbuilder.custom_code', $this->item->id);
ToolbarHelper::versions('com_componentbuilder.custom_code', $this->item->id);
}
if ($this->canDo->get('custom_code.create'))
{
JToolBarHelper::custom('custom_code.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
ToolbarHelper::custom('custom_code.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
}
JToolBarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CLOSE');
ToolbarHelper::cancel('custom_code.cancel', 'JTOOLBAR_CLOSE');
}
}
JToolbarHelper::divider();
ToolbarHelper::divider();
// set help url for this view if found
$this->help_url = ComponentbuilderHelper::getHelpUrl('custom_code');
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 ComponentbuilderViewCustom_code 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,35 +196,41 @@ class ComponentbuilderViewCustom_code 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_CUSTOM_CODE_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_CODE_EDIT'));
$this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/custom_code.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
$this->getDocument()->setTitle(Text::_($isNew ? 'COM_COMPONENTBUILDER_CUSTOM_CODE_NEW' : 'COM_COMPONENTBUILDER_CUSTOM_CODE_EDIT'));
Html::_('stylesheet', "administrator/components/com_componentbuilder/assets/css/custom_code.css", ['version' => 'auto']);
// Add Ajax Token
$this->document->addScriptDeclaration("var token = '".JSession::getFormToken()."';");
$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/custom_code/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
$this->getDocument()->addScriptDeclaration("var token = '" . Session::getFormToken() . "';");
Html::_('script', $this->script, ['version' => 'auto']);
Html::_('script', "administrator/components/com_componentbuilder/views/custom_code/submitbutton.js", ['version' => 'auto']);
// add the Uikit v2 style sheets
$this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/uikit.gradient.min.css', ['version' => 'auto']);
// add Uikit v2 JavaScripts
$this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/uikit.min.js' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
Html::_('script', 'media/com_componentbuilder/uikit-v2/js/uikit.min.js', ['version' => 'auto']);
// add the Uikit v2 extra style sheets
$this->document->addStyleSheet( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css' , (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
Html::_('stylesheet', 'media/com_componentbuilder/uikit-v2/css/components/notify.gradient.min.css', ['version' => 'auto']);
// add Uikit v2 extra JavaScripts
$this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true);
$this->document->addScript( JURI::root(true) .'/media/com_componentbuilder/uikit-v2/js/components/notify.min.js', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript', (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('type' => 'text/javascript', 'async' => 'async') : true);
Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/lightbox.min.js', ['version' => 'auto']);
Html::_('script', 'media/com_componentbuilder/uikit-v2/js/components/notify.min.js', ['version' => 'auto']);
// add var key
$this->document->addScriptDeclaration("var vastDevMod = '" . $this->get('VDM') . "';");
// add return_here
$this->document->addScriptDeclaration("var return_here = '" . urlencode(base64_encode((string) JUri::getInstance())) . "';");
// need to add some language strings
JText::script('COM_COMPONENTBUILDER_FUNCTION_NAME_ALREADY_TAKEN_PLEASE_TRY_AGAIN');
JText::script('COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_FUNCTION_NAME');
JText::script('view not acceptable. Error');
Text::script('COM_COMPONENTBUILDER_FUNCTION_NAME_ALREADY_TAKEN_PLEASE_TRY_AGAIN');
Text::script('COM_COMPONENTBUILDER_YOU_MUST_ADD_AN_UNIQUE_FUNCTION_NAME');
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;
}
}