32
1
mirror of https://github.com/joomla-extensions/weblinks.git synced 2025-01-28 23:08:27 +00:00

Replace JFactory

This commit is contained in:
Tuan Pham Ngoc 2021-07-01 21:46:35 +07:00
parent bab5787a77
commit d42ef8dbdf
7 changed files with 23 additions and 15 deletions

View File

@ -10,6 +10,7 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
/** /**
* Installation class to perform additional changes during install/uninstall/update * Installation class to perform additional changes during install/uninstall/update
@ -46,7 +47,7 @@ class Com_WeblinksInstallerScript
$category->metadesc = ''; $category->metadesc = '';
$category->metakey = ''; $category->metakey = '';
$category->language = '*'; $category->language = '*';
$category->checked_out_time = JFactory::getDbo()->getNullDate(); $category->checked_out_time = Factory::getDbo()->getNullDate();
$category->version = 1; $category->version = 1;
$category->hits = 0; $category->hits = 0;
$category->modified_user_id = 0; $category->modified_user_id = 0;
@ -58,7 +59,7 @@ class Com_WeblinksInstallerScript
// Check to make sure our data is valid // Check to make sure our data is valid
if (!$category->check()) if (!$category->check())
{ {
JFactory::getApplication()->enqueueMessage(Text::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError())); Factory::getApplication()->enqueueMessage(Text::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError()));
return; return;
} }
@ -66,7 +67,7 @@ class Com_WeblinksInstallerScript
// Now store the category // Now store the category
if (!$category->store(true)) if (!$category->store(true))
{ {
JFactory::getApplication()->enqueueMessage(Text::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError())); Factory::getApplication()->enqueueMessage(Text::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError()));
return; return;
} }
@ -89,7 +90,7 @@ class Com_WeblinksInstallerScript
public function postflight($type, $parent) public function postflight($type, $parent)
{ {
// Only execute database changes on MySQL databases // Only execute database changes on MySQL databases
$dbName = JFactory::getDbo()->name; $dbName = Factory::getDbo()->name;
if (strpos($dbName, 'mysql') !== false) if (strpos($dbName, 'mysql') !== false)
{ {
@ -114,7 +115,7 @@ class Com_WeblinksInstallerScript
private function insertMissingUcmRecords() private function insertMissingUcmRecords()
{ {
// Insert the rows in the #__content_types table if they don't exist already // Insert the rows in the #__content_types table if they don't exist already
$db = JFactory::getDbo(); $db = Factory::getDbo();
// Get the type ID for a Weblink // Get the type ID for a Weblink
$query = $db->getQuery(true); $query = $db->getQuery(true);
@ -241,7 +242,7 @@ class Com_WeblinksInstallerScript
'approved', 'approved',
); );
$db = JFactory::getDbo(); $db = Factory::getDbo();
$table = $db->getTableColumns('#__weblinks'); $table = $db->getTableColumns('#__weblinks');
$columns = array_intersect($oldColumns, array_keys($table)); $columns = array_intersect($oldColumns, array_keys($table));
@ -263,7 +264,7 @@ class Com_WeblinksInstallerScript
*/ */
private function addColumnsIfNeeded() private function addColumnsIfNeeded()
{ {
$db = JFactory::getDbo(); $db = Factory::getDbo();
$table = $db->getTableColumns('#__weblinks'); $table = $db->getTableColumns('#__weblinks');
if (!array_key_exists('version', $table)) if (!array_key_exists('version', $table))

View File

@ -11,10 +11,11 @@ defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
HTMLHelper::_('behavior.formvalidator'); HTMLHelper::_('behavior.formvalidator');
$app = JFactory::getApplication(); $app = Factory::getApplication();
$input = $app->input; $input = $app->input;
$assoc = JLanguageAssociations::isEnabled(); $assoc = JLanguageAssociations::isEnabled();

View File

@ -9,14 +9,15 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Factory;
HTMLHelper::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom')); HTMLHelper::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
// @deprecated 4.0 the function parameter, the inline js and the buttons are not needed since 3.7.0. // @deprecated 4.0 the function parameter, the inline js and the buttons are not needed since 3.7.0.
$function = JFactory::getApplication()->input->getCmd('function', 'jEditWeblink_' . (int) $this->item->id); $function = Factory::getApplication()->input->getCmd('function', 'jEditWeblink_' . (int) $this->item->id);
// Function to update input title when changed // Function to update input title when changed
JFactory::getDocument()->addScriptDeclaration(' Factory::getDocument()->addScriptDeclaration('
function jEditWeblinkModal() { function jEditWeblinkModal() {
if (window.parent && document.formvalidator.isValid(document.getElementById("weblink-form"))) { if (window.parent && document.formvalidator.isValid(document.getElementById("weblink-form"))) {
return window.parent.' . $this->escape($function) . '(document.getElementById("jform_title").value); return window.parent.' . $this->escape($function) . '(document.getElementById("jform_title").value);

View File

@ -9,7 +9,9 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
JFactory::getDocument()->addScriptDeclaration(" use Joomla\CMS\Factory;
Factory::getDocument()->addScriptDeclaration("
jQuery(function($) { jQuery(function($) {
$('.categories-list').find('[id^=category-btn-]').each(function(index, btn) { $('.categories-list').find('[id^=category-btn-]').each(function(index, btn) {
var btn = $(btn); var btn = $(btn);

View File

@ -11,6 +11,7 @@ defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
// HTMLHelper::_('behavior.framework'); // HTMLHelper::_('behavior.framework');
@ -18,7 +19,7 @@ use Joomla\CMS\Language\Text;
$params = &$this->category->params; $params = &$this->category->params;
// Get the user object. // Get the user object.
$user = JFactory::getUser(); $user = Factory::getUser();
// Check if user is allowed to add/edit based on weblinks permissinos. // Check if user is allowed to add/edit based on weblinks permissinos.
$canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $this->category->id); $canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $this->category->id);

View File

@ -11,13 +11,14 @@ defined('_JEXEC') or die;
use Joomla\CMS\HTML\HTMLHelper; use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text; use Joomla\CMS\Language\Text;
use Joomla\CMS\Factory;
HTMLHelper::_('behavior.keepalive'); HTMLHelper::_('behavior.keepalive');
HTMLHelper::_('behavior.formvalidator'); HTMLHelper::_('behavior.formvalidator');
// HTMLHelper::_('behavior.modal', 'a.modal_jform_contenthistory'); // HTMLHelper::_('behavior.modal', 'a.modal_jform_contenthistory');
$captchaEnabled = false; $captchaEnabled = false;
$captchaSet = $this->params->get('captcha', JFactory::getApplication()->get('captcha', '0')); $captchaSet = $this->params->get('captcha', Factory::getApplication()->get('captcha', '0'));
foreach (JPluginHelper::getPlugin('captcha') as $plugin) foreach (JPluginHelper::getPlugin('captcha') as $plugin)
{ {

View File

@ -9,11 +9,12 @@
defined('_JEXEC') or die; defined('_JEXEC') or die;
$weblinkUrl = JStringPunycode::urlToUTF8($this->item->url); use Joomla\CMS\Factory;
$weblinkUrl = JStringPunycode::urlToUTF8($this->item->url);
?> ?>
<div class="item-page"> <div class="item-page">
<meta itemprop="inLanguage" content="<?php echo ($this->item->language === '*') ? JFactory::getConfig()->get('language') : $this->item->language; ?>" /> <meta itemprop="inLanguage" content="<?php echo ($this->item->language === '*') ? Factory::getConfig()->get('language') : $this->item->language; ?>" />
<div class="page-header"> <div class="page-header">
<h2 itemprop="headline"> <h2 itemprop="headline">
<?php echo $this->escape($this->item->title); ?> <?php echo $this->escape($this->item->title); ?>