6

I'm trying to understand how to component com_installer (the componenent for installing the extensions) in the administrator folder in joomla works under the hood. In particular, I'm trying to understand what happens when you submit the uploaded extension zip.

In default.php in

com_installer/views/install/tmpl

I've found the following code:

 <form enctype="multipart/form-data" action="<?php echo JRoute::_('index.php?option=com_installer&view=install');?>" method="post" name="adminForm" id="adminForm" class="form-horizontal">

which seems to indicate that the uploaded file is sent to the same install view itself (the same view you are in when you upload the file). Now in the controller that corresponds to the view, it seems like it takes the corresponding model and calls the relevant function in the model to install the extension.

Now what I suspected, is that when you request a certain view, Joomla will first go to the corresponding controller (if any exists) and see if there exists a function with the same name as the view (in the case of the installer, the view is install, there is a controller install with a function install() inside).

However making a simple test for this, where I have a view called contentimporter, and the corresponding controller:

class ContentImporterControllerContentImporter extends JControllerLegacy
{
    public function contentImporter() {
        $redirect_url = 'index.php?option=com_installer';
        $this->setRedirect($redirect_url);
    }

now if this function did indeed get called when going to index.php?component=com_contentimporter&view=contentimporter then I would be redirected to the installer component, but I'm not.

Any help as to how I'm thinking wrong would be greatly appreciated!

5

You also need to take into account the data that is posted with the form. So if you look at line 179 of that default.php template file you will see:

<input type="hidden" name="task" value="install.install" />

The string is in the format "controller.method". This tells Joomla load the install controller (com_installer/controllers/install.php) and call it's install() method.

You can see how the controller instance is generated and loads the controller based on the task value by looking at libraries/legacy/controller/legacy.php line 230 onwards:

public static function getInstance($prefix, $config = array()) 

One last thing to note is often JavaScript on the 'save' button will also set/alter the task input's value, so that is worth double checking when trying to figure out what task is being submitted.

  • Thank you! I tested it, and now it works. Thank you for helping me understand! – user1306192 Apr 1 '15 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.