Source for file removefolder.php
Documentation is available at removefolder.php
* @package Joomla.Installation
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* Controller class to set the FTP data for the Joomla Installer.
* @package Joomla.Installation
* Execute the controller.
/* @var InstallationApplicationWeb $app */
// Check for request forgeries.
// Check whether the folder still exists
$app->sendJsonResponse(new Exception(JText::sprintf('INSTL_COMPLETE_ERROR_FOLDER_ALREADY_REMOVED'), 500));
// Check whether we need to use FTP
// Enable/Disable override
if (!isset
($options->ftpEnable) ||
($options->ftpEnable !=
1))
// Connect the FTP client
$ftp->login($options->ftp_user, $options->ftp_pass);
// Translate path for the FTP account
$return =
$ftp->delete($file);
// Delete the extra XML file while we're at it
$file =
JPath::clean($options->ftp_root .
'/joomla.xml');
$return =
$ftp->delete($file);
// Rename the robots.txt.dist file to robots.txt
$robotsFile =
JPath::clean($options->ftp_root .
'/robots.txt');
$distFile =
JPath::clean($options->ftp_root .
'/robots.txt.dist');
$return =
$ftp->rename($distFile, $robotsFile);
* Try to delete the folder.
* We use output buffering so that any error message echoed JFolder::delete
* doesn't land in our JSON output.
// Rename the robots.txt.dist file if robots.txt doesn't exist
// If an error was encountered return an error.
$app->sendJsonResponse(new Exception(JText::_('INSTL_COMPLETE_ERROR_FOLDER_DELETE'), 500));
// Create a response body.
$r->text =
JText::_('INSTL_COMPLETE_FOLDER_REMOVED');
* This is a hack since by now, the rest of the folder is deleted and we can't make a new request
* Method to send a JSON response. The data parameter
* can be a Exception object for when an error has occurred or
* a stdClass for a good response.
* @param mixed $response stdClass on success, Exception on failure.
// Check if we need to send an error code.
if ($response instanceof
Exception)
// Send the appropriate error code response.
$this->setHeader('status', $response->getCode());
$this->setHeader('Content-Type', 'application/json; charset=utf-8');
// Send the JSON response.
// Close the application.
* JSON Response class for the Joomla Installer.
* @package Joomla.Installation
* Constructor for the JSON response
* @param mixed $data Exception if there is an error, otherwise, the session data
// The old token is invalid so send a new one.
// Get the language and send it's tag along
// Build the sorted message list
foreach ($messages as $msg)
if (isset
($msg['type']) && isset
($msg['message']))
$lists[$msg['type']][] =
$msg['message'];
// If messages exist add them to the output
$this->messages =
$lists;
// Check if we are dealing with an error.
if ($data instanceof
Exception)
// Prepare the error response.
$this->header =
JText::_('INSTL_HEADER_ERROR');
$this->message =
$data->getMessage();
// Prepare the response data.
Documentation generated on Tue, 19 Nov 2013 15:11:47 +0100 by phpDocumentor 1.4.3