Skip to content

Commit

Permalink
Issue fixes techjoomla#62,techjoomla#122,techjoomla#80 - Joomla 4 & P…
Browse files Browse the repository at this point in the history
…HP 8.0 compatibility
  • Loading branch information
Vinayak Patil committed Mar 2, 2023
1 parent 0c85b39 commit e1e49cc
Show file tree
Hide file tree
Showing 15 changed files with 87 additions and 87 deletions.
2 changes: 1 addition & 1 deletion code/admin/helpers/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

// No direct access.
defined('_JEXEC') or die();
use Joomla\CMS\HTML\HTMLHelper;

use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Factory;

Expand Down
1 change: 1 addition & 0 deletions code/admin/language/en-GB/en-GB.com_api.sys.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ COM_API_XML_DESCRIPTION="Multi"
COM_API_TEST_LABEL="Test label"

COM_API_TITLE_KEYS="API Keys"
COM_API_TITLE_LOGS="Request Logs"

COM_API_SHOW_TABLES_SQL_STATEMENT="SHOW FULL TABLES WHERE tables_in_%s LIKE %s"

Expand Down
3 changes: 1 addition & 2 deletions code/admin/models/fields/createdby.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

defined('JPATH_BASE') or die();

use Joomla\CMS\Form\FormField;
use Joomla\CMS\Factory;

Expand All @@ -16,7 +15,7 @@
*
* @since 1.0
*/
class JFormFieldCreatedby extends JFormField
class FormFieldCreatedby extends FormField
{
/**
* The form field type.
Expand Down
8 changes: 4 additions & 4 deletions code/admin/views/cpanel/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/

defined('_JEXEC') or die();

use Joomla\CMS\MVC\View\HtmlView;

use Joomla\CMS\Language\Text;
use Joomla\CMS\Toolbar\ToolbarHelper;

/**
* Cpanel class
Expand Down Expand Up @@ -54,7 +54,7 @@ public function display($tpl = null)
*/
private function generateToolbar()
{
JToolBarHelper::title(Text::_('COM_API') . ': ' . Text::_('COM_API_CONTROL_PANEL'));
JToolBarHelper::preferences('com_api', 500, 500);
ToolbarHelper::title(Text::_('COM_API') . ': ' . Text::_('COM_API_CONTROL_PANEL'));
ToolbarHelper::preferences('com_api', 500, 500);
}
}
40 changes: 20 additions & 20 deletions code/admin/views/key/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,36 @@
HTMLHelper::_('behavior.keepalive');

// Import CSS
$document = Factory::getDocument();
$document->addStyleSheet('components/com_api/assets/css/api.css');
?>
HTMLHelper::_('stylesheet','components/com_api/assets/css/api.css');

<script type="text/javascript">
js = jQuery.noConflict();
js(document).ready(function()
{

});

Joomla.submitbutton = function(task)
{
if (task == 'key.cancel')
Factory::getDocument()->addScriptDeclaration(
"
js = jQuery.noConflict();
js(document).ready(function()
{
Joomla.submitform(task, document.getElementById('key-form'));
}
else
});
Joomla.submitbutton = function(task)
{
if (task != 'key.cancel' && document.formvalidator.isValid(document.getElementById('key-form')))
if (task == 'key.cancel')
{
Joomla.submitform(task, document.getElementById('key-form'));
}
else
{
alert('<?php echo $this->escape(Text::_('JGLOBAL_VALIDATION_FORM_FAILED')); ?>');
if (task != 'key.cancel' && document.formvalidator.isValid(document.getElementById('key-form')))
{
Joomla.submitform(task, document.getElementById('key-form'));
}
else
{
alert('".$this->escape(Text::_('JGLOBAL_VALIDATION_FORM_FAILED'))."');
}
}
}
}
</script>
");
?>

<div class="<?php echo COM_APIS_WRAPPER_CLASS; ?> api-key">
<form action="<?php echo Route::_('index.php?option=com_api&layout=edit&id=' . (int) $this->item->id); ?>" method="post" enctype="multipart/form-data" name="adminForm" id="key-form" class="form-validate">
Expand Down
18 changes: 10 additions & 8 deletions code/admin/views/key/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Joomla\CMS\Form\Form;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Toolbar\ToolbarHelper;


/**
* View class key form.
Expand Down Expand Up @@ -95,11 +97,11 @@ protected function addToolbar()

if (JVERSION >= '3.0')
{
JToolBarHelper::title($viewTitle, 'pencil-2');
ToolBarHelper::title($viewTitle, 'pencil-2');
}
else
{
JToolBarHelper::title($viewTitle, 'key.png');
ToolBarHelper::title($viewTitle, 'key.png');
}

if (isset($this->item->checked_out))
Expand All @@ -116,28 +118,28 @@ protected function addToolbar()
// If not checked out, can save the item.
if (! $checkedOut && ($canDo->get('core.edit') || ($canDo->get('core.create'))))
{
JToolBarHelper::apply('key.apply', 'JTOOLBAR_APPLY');
JToolBarHelper::save('key.save', 'JTOOLBAR_SAVE');
ToolBarHelper::apply('key.apply', 'JTOOLBAR_APPLY');
ToolBarHelper::save('key.save', 'JTOOLBAR_SAVE');
}

if (! $checkedOut && ($canDo->get('core.create')))
{
JToolBarHelper::custom('key.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
ToolBarHelper::custom('key.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
}

// If an existing item, can save to a copy.
if (! $isNew && $canDo->get('core.create'))
{
JToolBarHelper::custom('key.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
ToolBarHelper::custom('key.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
}

if (empty($this->item->id))
{
JToolBarHelper::cancel('key.cancel', 'JTOOLBAR_CANCEL');
ToolBarHelper::cancel('key.cancel', 'JTOOLBAR_CANCEL');
}
else
{
JToolBarHelper::cancel('key.cancel', 'JTOOLBAR_CLOSE');
ToolBarHelper::cancel('key.cancel', 'JTOOLBAR_CLOSE');
}
}
}
16 changes: 6 additions & 10 deletions code/admin/views/keys/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@
HTMLHelper::addIncludePath(JPATH_COMPONENT . '/helpers/html');

// Import CSS
$document = Factory::getDocument();
$document->addStyleSheet('components/com_api/assets/css/api.css');
HTMLHelper::_('stylesheet','components/com_api/assets/css/api.css');

$user = Factory::getUser();
$userId = $user->get('id');
Expand All @@ -38,29 +37,26 @@
}

$sortFields = $this->getSortFields();
?>

<script type="text/javascript">
Factory::getDocument()->addScriptDeclaration('
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;

if (order !== '<?php echo $listOrder; ?>')
if (order !== "' . $listOrder . '")
{
dirn = 'asc';
dirn = "asc";
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
Joomla.tableOrdering(order, dirn, "");
}
</script>
');

<?php
if (! empty($this->extra_sidebar))
{
$this->sidebar .= $this->extra_sidebar;
Expand Down
25 changes: 12 additions & 13 deletions code/admin/views/keys/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@
*/

// No direct access.
defined('_JEXEC') or die();

defined('_JEXEC') or die();
use Joomla\CMS\MVC\View\HtmlView;
use Joomla\CMS\Object\CMSObject;
use Joomla\CMS\Pagination\Pagination;
use Joomla\CMS\Language\Text;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Toolbar\ToolbarHelper;

/**
* View class for list of keys
Expand Down Expand Up @@ -97,11 +96,11 @@ protected function addToolbar()

if (JVERSION >= '3.0')
{
JToolBarHelper::title(Text::_('COM_API_TITLE_KEYS'), 'key');
ToolBarHelper::title(Text::_('COM_API_TITLE_KEYS'), 'key');
}
else
{
JToolBarHelper::title(Text::_('COM_API_TITLE_KEYS'), 'keys.png');
ToolBarHelper::title(Text::_('COM_API_TITLE_KEYS'), 'keys.png');
}

// Check if the form exists before showing the add/edit buttons
Expand All @@ -111,22 +110,22 @@ protected function addToolbar()
{
if ($canDo->get('core.create'))
{
JToolBarHelper::addNew('key.add', 'JTOOLBAR_NEW');
ToolBarHelper::addNew('key.add', 'JTOOLBAR_NEW');
}

if ($canDo->get('core.edit') && isset($this->items[0]))
{
JToolBarHelper::editList('key.edit', 'JTOOLBAR_EDIT');
ToolBarHelper::editList('key.edit', 'JTOOLBAR_EDIT');
}
}

if ($canDo->get('core.edit.state'))
{
if (isset($this->items[0]->state))
{
JToolBarHelper::divider();
JToolBarHelper::custom('keys.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
JToolBarHelper::custom('keys.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
ToolBarHelper::divider();
ToolBarHelper::custom('keys.publish', 'publish.png', 'publish_f2.png', 'JTOOLBAR_PUBLISH', true);
ToolBarHelper::custom('keys.unpublish', 'unpublish.png', 'unpublish_f2.png', 'JTOOLBAR_UNPUBLISH', true);
}
}

Expand All @@ -135,14 +134,14 @@ protected function addToolbar()
{
if ($canDo->get('core.delete'))
{
JToolBarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'keys.delete', 'JTOOLBAR_DELETE');
JToolBarHelper::divider();
ToolBarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'keys.delete', 'JTOOLBAR_DELETE');
ToolBarHelper::divider();
}
}

if ($canDo->get('core.admin'))
{
JToolBarHelper::preferences('com_api');
ToolBarHelper::preferences('com_api');
}

// Set sidebar action - New in 3.0
Expand Down
15 changes: 6 additions & 9 deletions code/admin/views/logs/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
HTMLHelper::addIncludePath(JPATH_COMPONENT.'/helpers/html');

// Import CSS
$document = Factory::getDocument();
$document->addStyleSheet('components/com_api/assets/css/api.css');
HTMLHelper::_('stylesheet','components/com_api/assets/css/api.css');

$user = Factory::getUser();
$userId = $user->get('id');
Expand All @@ -36,29 +35,27 @@
}

$sortFields = $this->getSortFields();
?>

<script type="text/javascript">
Factory::getDocument()->addScriptDeclaration('
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order !== '<?php echo $listOrder; ?>')
if (order !== "' . $listOrder . '")
{
dirn = 'asc';
dirn = "asc";
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
Joomla.tableOrdering(order, dirn, "");
}
</script>
');

<?php
if (! empty($this->extra_sidebar))
{
$this->sidebar .= $this->extra_sidebar;
Expand Down
Loading

0 comments on commit e1e49cc

Please sign in to comment.