I am trying to upgrade a component from 2.5 to 3.x. But while doing so I am getting error from controller.php file. Error message is like the following: Fatal error: Call to a member function get() on a non-object in /home/abs/public_html/joomla34/administrator/components/com_refix/controller.php on line 20 Here is the code of controller.php file:
defined('_JEXEC') or die;
class PrefixController extends JControllerLegacy {
/**
* constructor
*
* @access public
*/
public function __construct() {
require_once JPATH_COMPONENT . '/helpers/prefix.php';
JFactory::getApplication()->input->get('view', $this->input->get('view', 'tableprefix'));
parent::__construct();
$view = $this->input->get('view');
PrefixHelper::addSubMenu((isset($view)) ? $view : '');
}
/**
* check new table prefix
*
* @access private
* @return boolean
*/
private function checkTablePrefix() {
$new_prefix = $this->input->get('new_prefix');
if(!preg_match('/^[a-zA-Z]+[a-zA-Z0-9_]*$/',$new_prefix)) {
return false;
} else {
return true;
}
}
/**
* rename table prefix and update configuration.php file
*
* @access public
*/
public function update() {
$msg = '';
if(!$this->checkTablePrefix()) {
$msg = '<span class="prefix_error">' . JText::_('COM_PREFIX_PREFIX_NEW_PREFIX_DESC') . '</span>';
} else {
$model = $this->getModel('tableprefix');
$new_prefix = $this->input->get('new_prefix');
if($model->renamePrefix($new_prefix)) {
$msg .= JText::_('COM_PREFIX_SUCCESS:TABLE_PREFIX_ALREADY_UPDATED');
// update configuration file
if($this->input->get("update_config") == '1') {
// backup configuration file
if($this->input->get("backup_before") == '1') {
$msg .= "<br />";
if($model->backupConfig()) {
$msg .= JText::_('COM_PREFIX_SUCCESS:BACKUP_THE_CONFIGURATION.PHP_FILE');
} else {
$msg .= '<span class="prefix_error">' . JText::_('COM_PREFIX_ERROR:CONFIGURATION.PHP_FILE_COULD_NOT_BE_BACKUP') . '</span>';
}
}
$msg .= "<br />";
if($model->editConfig($new_prefix)) {
$msg .= JText::_('COM_PREFIX_SUCCESS:CONFIGURATION_FILE_HAS_BEEN_UPDATED');
} else {
$msg .= '<span class="prefix_error">' . JText::_('COM_PREFIX_ERROR:CONFIGURATION_FILE_COULD_NOT_BE_UPDATE,PLEASE_MANUAL_UPDATE') . '</span>';
}
}
} else {
$msg .= '<span class="prefix_error">' . JText::_('COM_PREFIX_ERROR:TABLE_PREFIX_COULD_NOT_BE_UPDATE') . '</span>';
}
}
ob_end_clean();
JResponse::setHeader("Pragma", "no-cache");
JResponse::setHeader("Expires","0");
echo $msg;
exit;
} // end function
}