Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Admin app - Use the autoloader #10881

Merged
merged 6 commits into from
Jul 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion administrator/components/com_admin/models/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

require_once JPATH_ADMINISTRATOR . '/components/com_users/models/user.php';
JLoader::register('UsersModelUser', JPATH_ADMINISTRATOR . '/components/com_users/models/user.php');

/**
* User model.
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_banners/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

JLoader::register('BannersHelper', JPATH_COMPONENT . '/helpers/banners.php');
JLoader::register('BannersHelper', JPATH_ADMINISTRATOR . '/components/com_banners/helpers/banners.php');

/**
* Banners master display controller.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<fields name="filter" addfieldpath="/administrator/components/com_banners/models/fields">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you only use these forms going through JModelForm objects then sure. If
they load any other way the dependency wouldn't be loaded. I equate it to
relying on something else to load jQuery when you depend on it.

On Monday, June 20, 2016, Dimitri Grammatikogianni notifications@github.com
wrote:

In administrator/components/com_banners/models/forms/filter_banners.xml
#10881 (comment):

@@ -1,6 +1,6 @@

- -

@mbabker https://github.com/mbabker isn't this supposed to autoload by
https://github.com/joomla/joomla-cms/blob/staging/libraries/legacy/model/form.php#L203-L206
?


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/joomla/joomla-cms/pull/10881/files/5f19de3d1f3851054f65ed03611262be65340315#r67783423,
or mute the thread
https://github.com/notifications/unsubscribe/AAWfoeL9oXQo7eQDLYLivxj4CStNBLhUks5qNx3ngaJpZM4I6I8J
.

<field
name="search"
type="text"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fields name="filter">
<fields name="filter" addfieldpath="/administrator/components/com_banners/models/fields">
<field
name="search"
type="text"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

JLoader::register('BannersHelper', JPATH_COMPONENT . '/helpers/banners.php');
JLoader::register('BannersHelper', JPATH_ADMINISTRATOR . '/components/com_banners/helpers/banners.php');

/**
* View to edit a banner.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ public function display($tpl = null)
BannersHelper::addSubmenu('banners');

$this->addToolbar();
require_once JPATH_COMPONENT . '/models/fields/bannerclient.php';

// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
Expand All @@ -92,7 +91,7 @@ public function display($tpl = null)
*/
protected function addToolbar()
{
require_once JPATH_COMPONENT . '/helpers/banners.php';
JLoader::register('BannersHelper', JPATH_ADMINISTRATOR . '/components/com_banners/helpers/banners.php');

$canDo = JHelperContent::getActions('com_banners', 'category', $this->state->get('filter.category_id'));
$user = JFactory::getUser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

JLoader::register('BannersHelper', JPATH_COMPONENT . '/helpers/banners.php');
JLoader::register('BannersHelper', JPATH_ADMINISTRATOR . '/components/com_banners/helpers/banners.php');

/**
* View to edit a client.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

JLoader::register('BannersHelper', JPATH_COMPONENT . '/helpers/banners.php');
JLoader::register('BannersHelper', JPATH_ADMINISTRATOR . '/components/com_banners/helpers/banners.php');

/**
* View class for a list of clients.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

JLoader::register('BannersHelper', JPATH_COMPONENT . '/helpers/banners.php');
JLoader::register('BannersHelper', JPATH_ADMINISTRATOR . '/components/com_banners/helpers/banners.php');

/**
* View class for a list of tracks.
Expand Down Expand Up @@ -66,8 +66,6 @@ public function display($tpl = null)

$this->addToolbar();

require_once JPATH_COMPONENT . '/models/fields/bannerclient.php';

$this->sidebar = JHtmlSidebar::render();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @mbabker
Why JLoader::register() is not used after removing this code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find a direct use of the class that this was loading in the code. Meaning either it's being loaded as part of a form (where the lookup path should be included in the XML or added with a JFormHelper::addFieldPath() call) or it was being loaded needlessly.

return parent::display($tpl);
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_cache/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class CacheController extends JControllerLegacy
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/cache.php';
JLoader::register('CacheHelper', JPATH_ADMINISTRATOR . '/components/com_cache/helpers/cache.php');

// Get the document object.
$document = JFactory::getDocument();
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_categories/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function display($cachable = false, $urlparams = array())
$view->document = $document;

// Load the submenu.
require_once JPATH_COMPONENT . '/helpers/categories.php';
JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php');

CategoriesHelper::addSubmenu($model->getState('filter.extension'));
$view->display();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
}

require_once JPATH_ROOT . '/components/com_content/helpers/route.php';
JLoader::register('ContentHelperRoute', JPATH_ROOT . '/components/com_content/helpers/route.php');

// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ protected function addToolbar()
|| $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component, null, false, true);

// Load the category helper.
require_once JPATH_COMPONENT . '/helpers/categories.php';
JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php');

// If a component categories title string is present, let's use it.
if ($lang->hasKey($component_title_key = strtoupper($component . ($section ? "_$section" : '')) . '_CATEGORIES_TITLE'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ protected function addToolbar()
|| $lang->load($component, JPATH_ADMINISTRATOR . '/components/' . $component, null, false, true);

// Load the category helper.
require_once JPATH_COMPONENT . '/helpers/categories.php';
JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php');

// Get the results for each action.
$canDo = $this->canDo;
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_contact/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ContactController extends JControllerLegacy
*/
public function display($cachable = false, $urlparams = array())
{
require_once JPATH_COMPONENT . '/helpers/contact.php';
JLoader::register('ContactHelper', JPATH_ADMINISTRATOR . '/components/com_contact/helpers/contact.php');

$view = $this->input->get('view', 'contacts');
$layout = $this->input->get('layout', 'default');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

require_once JPATH_ROOT . '/components/com_contact/helpers/route.php';
JLoader::register('ContactHelperRoute', JPATH_ROOT . '/components/com_contact/helpers/route.php');

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

require_once __DIR__ . '/articles.php';
JLoader::register('ContentControllerArticles', __DIR__ . '/articles.php');

/**
* Featured content controller class.
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_content/models/feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

require_once __DIR__ . '/article.php';
JLoader::register('ContentModelArticle', __DIR__ . '/article.php');

/**
* Feature model.
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_content/models/featured.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

require_once __DIR__ . '/articles.php';
JLoader::register('ContentModelArticles', __DIR__ . '/articles.php');

/**
* About Page Model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
JSession::checkToken('get') or die(JText::_('JINVALID_TOKEN'));
}

require_once JPATH_ROOT . '/components/com_content/helpers/route.php';
JLoader::register('ContentHelperRoute', JPATH_ROOT . '/components/com_content/helpers/route.php');

// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ public function display($tpl = null)
// Display the cpanel modules
$this->modules = JModuleHelper::getModules('cpanel');

// Load the RAD layer and count the number of post-installation messages
if (!defined('FOF_INCLUDED'))
{
require_once JPATH_LIBRARIES . '/fof/include.php';
}

try
{
$messages_model = FOFModel::getTmpInstance('Messages', 'PostinstallModel')->eid(700);
Expand Down
8 changes: 3 additions & 5 deletions administrator/components/com_finder/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ class FinderController extends JControllerLegacy
* @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController A JController object to support chaining.
* @return FinderController A JControllerLegacy object to support chaining.
*
* @since 2.5
*/
public function display($cachable = false, $urlparams = array())
{
include_once JPATH_COMPONENT . '/helpers/finder.php';
JLoader::register('FinderHelper', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/finder.php');

$view = $this->input->get('view', 'index', 'word');
$layout = $this->input->get('layout', 'index', 'word');
Expand All @@ -51,8 +51,6 @@ public function display($cachable = false, $urlparams = array())
return false;
}

parent::display();

return $this;
return parent::display();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
defined('_JEXEC') or die;

// Register dependent classes.
JLoader::register('FinderIndexer', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/indexer/indexer.php');
JLoader::register('FinderIndexer', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/indexer.php');

/**
* Indexer controller class for Finder.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
JFormHelper::loadFieldClass('list');

// Load the base adapter.
require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php';
JLoader::register('FinderIndexerAdapter', JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php');

/**
* Renders a list of directories.
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_installer/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class InstallerController extends JControllerLegacy
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php';
JLoader::register('InstallerHelper', JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php');

// Get the document object.
$document = JFactory::getDocument();
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_installer/models/discover.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

require_once __DIR__ . '/extension.php';
JLoader::register('InstallerModel', __DIR__ . '/extension.php');

/**
* Installer Discover Model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

JFormHelper::loadFieldClass('list');

require_once __DIR__ . '/../../helpers/installer.php';
JLoader::register('InstallerHelper', JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php');
Copy link
Contributor

@ggppdk ggppdk Jul 18, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is right, but it is now using JPATH_ADMINISTRATOR+component_folder, it could have kept the usage of __ DIR __

JLoader::register('InstallerHelper', dirname(__DIR__, 2)  .  '/helpers/installer.php');

I say this because in other cases you keep the usage of __ DIR __, but in some you do not

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I personally prefer absolute paths over relative when practical. I
    dislike trying to read paths in include statements with directory traversal
    like that because I think it makes it harder to follow.

  2. The second param on dirname() is only present as of PHP 7.0.

On Monday, July 18, 2016, Georgios Papadakis notifications@github.com
wrote:

In
administrator/components/com_installer/models/fields/extensionstatus.php
#10881 (comment):

@@ -11,7 +11,7 @@

JFormHelper::loadFieldClass('list');

-require_once DIR . '/../../helpers/installer.php';
+JLoader::register('InstallerHelper', JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php');

This is right, but it is now absolute path, it could have remain a
"relative" using the DIR:

JLoader::register('InstallerHelper', dirname(DIR, 2) . '/helpers/installer.php');

I say this because in other cases you keep the usage of DIR, but in
some you do not


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/joomla/joomla-cms/pull/10881/files/ec8218c23101f868671104e3c8505f357337677d#r71102143,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAWfoRDLWy8U5Vzyv4f6C78Q2lDDpyBoks5qWxSvgaJpZM4I6I8J
.


/**
* Status Field class for the Joomla Framework.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

JFormHelper::loadFieldClass('list');

require_once __DIR__ . '/../../helpers/installer.php';
JLoader::register('InstallerHelper', JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php');

/**
* Folder Field class for the Joomla Framework.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

JFormHelper::loadFieldClass('list');

require_once __DIR__ . '/../../helpers/installer.php';
JLoader::register('InstallerHelper', JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php');

/**
* Location Field class for the Joomla Framework.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

JFormHelper::loadFieldClass('list');

require_once __DIR__ . '/../../helpers/installer.php';
JLoader::register('InstallerHelper', JPATH_ADMINISTRATOR . '/components/com_installer/helpers/installer.php');

/**
* Type Field class for the Joomla Framework.
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_installer/models/manage.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

require_once __DIR__ . '/extension.php';
JLoader::register('InstallerModel', __DIR__ . '/extension.php');

/**
* Installer Manage Model
Expand Down
6 changes: 2 additions & 4 deletions administrator/components/com_installer/models/updatesites.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,12 @@

defined('_JEXEC') or die;

require_once __DIR__ . '/extension.php';
JLoader::register('InstallerModel', __DIR__ . '/extension.php');

/**
* Installer Update Sites Model
*
* @package Joomla.Administrator
* @subpackage com_installer
* @since 3.4
* @since 3.4
*/
class InstallerModelUpdatesites extends InstallerModel
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

include_once __DIR__ . '/../default/view.php';
JLoader::register('InstallerViewDefault', dirname(__DIR__) . '/default/view.php');

/**
* Extension Manager Manage View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

include_once __DIR__ . '/../default/view.php';
JLoader::register('InstallerViewDefault', dirname(__DIR__) . '/default/view.php');

/**
* Extension Manager Discover View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

include_once __DIR__ . '/../default/view.php';
JLoader::register('InstallerViewDefault', dirname(__DIR__) . '/default/view.php');

/**
* Extension Manager Install View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

include_once __DIR__ . '/../default/view.php';
JLoader::register('InstallerViewDefault', dirname(__DIR__) . '/default/view.php');

/**
* Language installer view
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

include_once __DIR__ . '/../default/view.php';
JLoader::register('InstallerViewDefault', dirname(__DIR__) . '/default/view.php');

/**
* Extension Manager Manage View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

include_once __DIR__ . '/../default/view.php';
JLoader::register('InstallerViewDefault', dirname(__DIR__) . '/default/view.php');

/**
* Extension Manager Update View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

defined('_JEXEC') or die;

include_once __DIR__ . '/../default/view.php';
JLoader::register('InstallerViewDefault', dirname(__DIR__) . '/default/view.php');

/**
* Extension Manager Update Sites View
Expand Down
Loading