mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2024-12-26 01:57:30 +00:00
Clean up code
This commit is contained in:
parent
8d714ace8d
commit
9107b7e1de
@ -9,7 +9,6 @@
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Extension\ExtensionHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
@ -93,8 +92,8 @@ class Com_WeblinksInstallerScript
|
||||
public function install($parent)
|
||||
{
|
||||
// Initialize a new category
|
||||
/** @type JTableCategory $category */
|
||||
$category = Table::getInstance('Category');
|
||||
/** @type Joomla\CMS\Table\Category $category */
|
||||
$category = Table::getInstance('Category', 'Joomla\\CMS\\Table\\');
|
||||
|
||||
// Check if the Uncategorised category exists before adding it
|
||||
if (!$category->load(array('extension' => 'com_weblinks', 'title' => 'Uncategorised')))
|
||||
|
@ -44,19 +44,23 @@ return new class implements ServiceProviderInterface
|
||||
{
|
||||
$container->set(AssociationExtensionInterface::class, new AssociationsHelper);
|
||||
|
||||
$container->registerServiceProvider(new CategoryFactory('\\Joomla\\Component\\Weblinks'));
|
||||
$container->registerServiceProvider(new MVCFactory('\\Joomla\\Component\\Weblinks'));
|
||||
$container->registerServiceProvider(new ComponentDispatcherFactory('\\Joomla\\Component\\Weblinks'));
|
||||
$container->registerServiceProvider(new RouterFactory('\\Joomla\\Component\\Weblinks'));
|
||||
$componentNamespace = '\\Joomla\\Component\\Weblinks';
|
||||
|
||||
$container->registerServiceProvider(new CategoryFactory($componentNamespace));
|
||||
$container->registerServiceProvider(new MVCFactory($componentNamespace));
|
||||
$container->registerServiceProvider(new ComponentDispatcherFactory($componentNamespace));
|
||||
$container->registerServiceProvider(new RouterFactory($componentNamespace));
|
||||
|
||||
$container->set(
|
||||
ComponentInterface::class,
|
||||
function (Container $container) {
|
||||
$component = new WeblinksComponent($container->get(ComponentDispatcherFactoryInterface::class));
|
||||
|
||||
$component->setRegistry($container->get(Registry::class));
|
||||
$component->setMVCFactory($container->get(MVCFactoryInterface::class));
|
||||
$component->setCategoryFactory($container->get(CategoryFactoryInterface::class));
|
||||
$component->setRouterFactory($container->get(RouterFactoryInterface::class));
|
||||
$component->setAssociationExtension($container->get(AssociationExtensionInterface::class));
|
||||
$component->setRouterFactory($container->get(RouterFactoryInterface::class));
|
||||
|
||||
return $component;
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ class WeblinkController extends FormController
|
||||
$this->checkToken();
|
||||
|
||||
// Set the model
|
||||
$model = $this->getModel('Weblink', '', array());
|
||||
$model = $this->getModel('Weblink', 'Administrator', array());
|
||||
|
||||
// Preset the redirect
|
||||
$this->setRedirect(Route::_('index.php?option=com_weblinks&view=weblinks' . $this->getRedirectToListAppend(), false));
|
||||
|
@ -128,7 +128,7 @@ class AssociationsHelper extends AssociationExtensionHelper
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
$table = Table::getInstance('Category');
|
||||
$table = Table::getInstance('Category', 'Joomla\\CMS\\Table\\');
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -36,6 +36,20 @@ class CategoryModel extends ListModel
|
||||
*/
|
||||
protected $_item = null;
|
||||
|
||||
/**
|
||||
* Category left of this one
|
||||
*
|
||||
* @var CategoryNode|null
|
||||
*/
|
||||
protected $_leftsibling = null;
|
||||
|
||||
/**
|
||||
* Category right right of this one
|
||||
*
|
||||
* @var CategoryNode|null
|
||||
*/
|
||||
protected $_rightsibling = null;
|
||||
|
||||
/**
|
||||
* Array of child-categories
|
||||
*
|
||||
@ -114,7 +128,7 @@ class CategoryModel extends ListModel
|
||||
$viewLevels = Factory::getApplication()->getIdentity()->getAuthorisedViewLevels();
|
||||
|
||||
// Create a new query object.
|
||||
$db = $this->getDbo();
|
||||
$db = $this->getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
// Select required fields from the categories.
|
||||
@ -174,7 +188,7 @@ class CategoryModel extends ListModel
|
||||
if ($this->getState('filter.publish_date'))
|
||||
{
|
||||
$nullDate = $db->getNullDate();
|
||||
$nowDate = Factory::getDate()->toSql();
|
||||
$nowDate = Factory::getDate()->toSql();
|
||||
$query->where('(a.publish_up = :publishUpNullDate OR a.publish_up <= :publishUpNowDate)')
|
||||
->where('(a.publish_down = :publishDownNullDate OR a.publish_down >= :publishDownNowDate)')
|
||||
->bind(':publishUpNullDate', $nullDate)
|
||||
@ -231,7 +245,7 @@ class CategoryModel extends ListModel
|
||||
*/
|
||||
protected function populateState($ordering = null, $direction = null)
|
||||
{
|
||||
$app = Factory::getApplication();
|
||||
$app = Factory::getApplication();
|
||||
$params = ComponentHelper::getParams('com_weblinks');
|
||||
|
||||
// List state information
|
||||
@ -304,17 +318,17 @@ class CategoryModel extends ListModel
|
||||
$params = new Registry;
|
||||
}
|
||||
|
||||
$options = array();
|
||||
$options = array();
|
||||
$options['countItems'] = $params->get('show_cat_num_links_cat', 1)
|
||||
|| $params->get('show_empty_categories', 0);
|
||||
|
||||
$categories = Categories::getInstance('Weblinks', $options);
|
||||
$categories = Categories::getInstance('Weblinks', $options);
|
||||
$this->_item = $categories->get($this->getState('category.id', 'root'));
|
||||
|
||||
if (is_object($this->_item))
|
||||
{
|
||||
$this->_children = $this->_item->getChildren();
|
||||
$this->_parent = false;
|
||||
$this->_parent = false;
|
||||
|
||||
if ($this->_item->getParent())
|
||||
{
|
||||
@ -322,12 +336,12 @@ class CategoryModel extends ListModel
|
||||
}
|
||||
|
||||
$this->_rightsibling = $this->_item->getSibling();
|
||||
$this->_leftsibling = $this->_item->getSibling(false);
|
||||
$this->_leftsibling = $this->_item->getSibling(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_children = false;
|
||||
$this->_parent = false;
|
||||
$this->_parent = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -409,8 +423,8 @@ class CategoryModel extends ListModel
|
||||
|
||||
if ($hitcount)
|
||||
{
|
||||
$pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id');
|
||||
$table = Table::getInstance('Category', 'JTable');
|
||||
$pk = (!empty($pk)) ? $pk : (int) $this->getState('category.id');
|
||||
$table = Table::getInstance('Category', 'Joomla\\CMS\\Table\\');
|
||||
$table->load($pk);
|
||||
$table->hit($pk);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user