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 1 commit
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
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 @@ -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_COMPONENT . '/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 @@ -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_COMPONENT . '/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_COMPONENT . '/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_COMPONENT . '/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_COMPONENT . '/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_COMPONENT . '/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 @@ -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
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
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
JHtml::_('behavior.keepalive');
JHtml::_('bootstrap.tooltip');

require_once JPATH_ADMINISTRATOR . '/modules/mod_login/helper.php';
JLoader::register('ModLoginHelper', JPATH_ADMINISTRATOR . '/modules/mod_login/helper.php');

$twofactormethods = ModLoginHelper::getTwoFactorMethods();

Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_languages/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class LanguagesController extends JControllerLegacy
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/languages.php';
JLoader::register('LanguagesHelper', JPATH_COMPONENT . '/helpers/languages.php');

$view = $this->input->get('view', 'languages');
$layout = $this->input->get('layout', 'default');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function save($key = null, $urlVar = null)
}

// Require helper for filter functions called by JForm.
require_once JPATH_COMPONENT . '/helpers/languages.php';
JLoader::register('LanguagesHelper', JPATH_COMPONENT . '/helpers/languages.php');

// Test whether the data is valid.
$validData = $model->validate($form, $data);
Expand Down
7 changes: 4 additions & 3 deletions administrator/components/com_languages/models/override.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ protected function loadFormData()
*/
public function getItem($pk = null)
{
require_once JPATH_COMPONENT . '/helpers/languages.php';
JLoader::register('LanguagesHelper', JPATH_COMPONENT . '/helpers/languages.php');

$input = JFactory::getApplication()->input;
$pk = (!empty($pk)) ? $pk : $input->get('id');
Expand Down Expand Up @@ -122,10 +122,11 @@ public function getItem($pk = null)
*/
public function save($data, $opposite_client = false)
{
$app = JFactory::getApplication();
require_once JPATH_COMPONENT . '/helpers/languages.php';
JLoader::register('LanguagesHelper', JPATH_COMPONENT . '/helpers/languages.php');
jimport('joomla.filesystem.file');

$app = JFactory::getApplication();

$client = $app->getUserState('com_languages.overrides.filter.client', 0);
$language = $app->getUserState('com_languages.overrides.filter.language', 'en-GB');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public function delete($cids)
}

jimport('joomla.filesystem.file');
require_once JPATH_COMPONENT . '/helpers/languages.php';
JLoader::register('LanguagesHelper', JPATH_COMPONENT . '/helpers/languages.php');

$filterclient = JFactory::getApplication()->getUserState('com_languages.overrides.filter.client');
$client = $filterclient == 0 ? 'SITE' : 'ADMINISTRATOR';
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_languages/models/strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LanguagesModelStrings extends JModelLegacy
*/
public function refresh()
{
require_once JPATH_COMPONENT . '/helpers/languages.php';
JLoader::register('LanguagesHelper', JPATH_COMPONENT . '/helpers/languages.php');

$app = JFactory::getApplication();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function display($tpl = null)
*/
protected function addToolbar()
{
require_once JPATH_COMPONENT . '/helpers/languages.php';
JLoader::register('LanguagesHelper', JPATH_COMPONENT . '/helpers/languages.php');

JFactory::getApplication()->input->set('hidemainmenu', 1);
$isNew = empty($this->item->lang_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class LanguagesViewMultilangstatus extends JViewLegacy
*/
public function display($tpl = null)
{
require_once JPATH_COMPONENT . '/helpers/multilangstatus.php';
JLoader::register('MultilangstatusHelper', JPATH_COMPONENT . '/helpers/multilangstatus.php');

$this->homes = MultilangstatusHelper::getHomes();
$this->language_filter = JLanguageMultilang::isEnabled();
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_media/media.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
$params = JComponentHelper::getParams('com_media');

// Load the helper class
require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/media.php';
JLoader::register('MediaHelper', JPATH_COMPONENT_ADMINISTRATOR . '/helpers/media.php');

// Set the path definitions
$popup_upload = $input->get('pop_up', null);
Expand Down
6 changes: 2 additions & 4 deletions administrator/components/com_menus/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@ class MenusController extends JControllerLegacy
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/menus.php';
JLoader::register('MenusHelper', JPATH_COMPONENT . '/helpers/menus.php');

parent::display();

return $this;
return parent::display();
}
}
2 changes: 1 addition & 1 deletion administrator/components/com_menus/models/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use Joomla\Registry\Registry;

jimport('joomla.filesystem.path');
require_once JPATH_COMPONENT . '/helpers/menus.php';
JLoader::register('MenusHelper', JPATH_COMPONENT . '/helpers/menus.php');
Copy link
Contributor

Choose a reason for hiding this comment

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

@mbabker please see #11164

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In general that's why the JPATH_COMPONENT path constants should only serve one purpose in Joomla until 4.0 is released; raise deprecation notices. Those are in part why it is so freakin' difficult to work between different components, because that path is not constant by any means.


/**
* Menu Item Model for Menus.
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_messages/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class MessagesController extends JControllerLegacy
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/messages.php';
JLoader::register('MessagesHelper', JPATH_COMPONENT . '/helpers/messages.php');

$view = $this->input->get('view', 'messages');
$layout = $this->input->get('layout', 'default');
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_modules/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function display($cachable = false, $urlparams = false)
return $view->display();
}

require_once JPATH_COMPONENT . '/helpers/modules.php';
JLoader::register('ModulesHelper', JPATH_COMPONENT . '/helpers/modules.php');

$layout = $this->input->get('layout', 'edit');
$id = $this->input->getInt('id');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ public static function state($value, $i, $enabled = true, $checkbox = 'cb')

public static function positions($clientId, $state = 1, $selectedPosition = '')
{
require_once JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php';
JLoader::register('TemplatesHelper', JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php');

$templates = array_keys(ModulesHelper::getTemplates($clientId, $state));
$templateGroups = array();

Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_modules/models/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -872,7 +872,7 @@ protected function preprocessForm(JForm $form, $data, $group = 'content')
*/
public function validate($form, $data, $group = null)
{
require_once JPATH_ADMINISTRATOR . '/components/com_content/helpers/content.php';
JLoader::register('ContentHelper', JPATH_ADMINISTRATOR . '/components/com_content/helpers/content.php');

return parent::validate($form, $data, $group);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

defined('_JEXEC') or die;

// Initiasile related data.
require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php';
// Initialise related data.
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
$menuTypes = MenusHelper::getMenuLinks();

JHtml::_('script', 'jui/treeselectmenu.jquery.min.js', false, true);
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_ADMINISTRATOR . '/components/com_templates/helpers/templates.php';
JLoader::register('TemplatesHelper', JPATH_ADMINISTRATOR . '/components/com_templates/helpers/templates.php');

JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
$clientId = $this->item->client_id;
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_newsfeeds/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class NewsfeedsController extends JControllerLegacy
*/
public function display($cachable = false, $urlparams = array())
{
require_once JPATH_COMPONENT . '/helpers/newsfeeds.php';
JLoader::register('NewsfeedsHelper', JPATH_COMPONENT . '/helpers/newsfeeds.php');

$view = $this->input->get('view', 'newsfeeds');
$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_newsfeeds/helpers/route.php';
JLoader::register('NewsfeedsHelperRoute', JPATH_ROOT . '/components/com_newsfeeds/helpers/route.php');

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

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

// Load the submenu.
PluginsHelper::addSubmenu($this->input->get('view', 'plugins'));
Expand Down
6 changes: 0 additions & 6 deletions administrator/components/com_postinstall/postinstall.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,5 @@

defined('_JEXEC') or die;

// Load the RAD layer.
if (!defined('FOF_INCLUDED'))
{
require_once JPATH_LIBRARIES . '/fof/include.php';
}

// Dispatch the component.
FOFDispatcher::getTmpInstance('com_postinstall')->dispatch();
2 changes: 1 addition & 1 deletion administrator/components/com_redirect/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class RedirectController extends JControllerLegacy
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/redirect.php';
JLoader::register('RedirectHelper', JPATH_COMPONENT . '/helpers/redirect.php');

// Load the submenu.
RedirectHelper::addSubmenu($this->input->get('view', 'links'));
Expand Down
2 changes: 1 addition & 1 deletion administrator/components/com_search/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class SearchController extends JControllerLegacy
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/search.php';
JLoader::register('SearchHelper', JPATH_COMPONENT . '/helpers/search.php');

// Load the submenu.
SearchHelper::addSubmenu($this->input->get('view', 'searches'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
defined('_JEXEC') or die;

// Initiasile related data.
require_once JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php';
JLoader::register('MenusHelper', JPATH_ADMINISTRATOR . '/components/com_menus/helpers/menus.php');
$menuTypes = MenusHelper::getMenuLinks();
$user = JFactory::getUser();
?>
Expand Down
Loading