how to convert a joomla 2.5 plugin to 3 - joomla

I have a plugin for joomla 2.5
I want install it in joomla 3 but after installing I see this error :
Fatal error: Call to undefined method JController::getInstance() in /home/xxx/public_html/administrator/components/xxx/xxx.php on line 21
Line of error:
// Require specific controller if requested
if($controller = JRequest::getCmd('controller'))
{
$path = JPATH_COMPONENT.DS.'controllers'.DS.$controller.'.php';
if(file_exists($path))
{
require_once $path;
}
else
{
$controller = '';
}
}

JController::getInstance() has been removed. Use JControllerLegacy::getInstance() instead.

Related

PHPExcel_Writer_Exception in DomPDF.php line 34: Unable to load PDF Rendering library

error in exporting to pdf. i tried composer update and adding stuffs to app.php anf composer.json
public function exportPDF($request, $orgid)
{
/*$pdf = App::make('snappy.pdf.wrapper');
$pdf->loadHTML('<h1>Test</h1>');
return $pdf->inline();*/
$data = User::get()->toArray();
return Excel::create('itsolutionstuff_example', function($excel) use ($data) {
$excel->sheet('mySheet', function($sheet) use ($data)
{
$sheet->fromArray($data);
});
})->download("pdf");
}
Wich pdf renderer have you set up? Acording to the documentation, you have 3 choices, tcpdf, mPdf and DomPDF.
You have to install at least one of them.
composer require mpdf/mpdf
and then direct PHPExcel to use it
$renderer = PHPExcel_Settings::PDF_RENDERER_MPDF;
$rendererPath = dirname(__FILE__).'/../../../libraries/PDF/mPDF6.1'
if (!PHPExcel_Settings::setPdfRenderer(
$renderer,
$rendererPath
)) {
die('Wrong setup of PDF libraries');
}
Please comment this line in DomPDF.php
if (file_exists($pdfRendererClassFile)) {
require_once $pdfRendererClassFile;
} else {
throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
}
to
/** Require DomPDF library */
//$pdfRendererClassFile = PHPExcel_Settings::getPdfRendererPath() . '/dompdf_config.inc.php';
//if (file_exists($pdfRendererClassFile)) {
// require_once $pdfRendererClassFile;
//} else {
// throw new PHPExcel_Writer_Exception('Unable to load PDF Rendering library');
//}
Hope it will works.

Fatal error: Call to a member function loadByOption() on a non-object

I am facing a problem. I have installed Vodes 1.5 in website. In admin panel, when I click on the save button I get the error "
Fatal error: Call to a member function loadByOption() on a non-object in /var/www/Joomla/administrator/components/com_vodes/models/config.php on line 58 ".
This is the code we are using :
function save(){
// initialize variables.
$table = JTable::getInstance('component');
$params = JRequest::getVar('params', array(), 'post', 'array');
$row = array();
$row['option'] = 'com_vodes';
$row['params'] = $params;
// load the component data for com_ajaxregister
if (!$table->loadByOption('com_vodes')) {
$this->setError($table->getError());
return false;
}
// bind the new values
$table->bind($row);
// check the row.
if (!$table->check()) {
$this->setError($table->getError());
return false;
}
// store the row.
if (!$table->store()) {
$this->setError($table->getError());
return false;
}
return true;
}
Please help to sought it out.
Just had a look at the developer site for Vodes. The extension is only compatible with Joomla 1.0 and 1.5 with a possibility or running on Joomla 2.5, but most definitely not Joomla 3.x
There are extreme coding differences between Joomla 1.5 and 3.x therefore extensions will throw errors all over the place, or worse, not work at all.
You will have to find an alternative to Vodes or make the whole extensions Joomla 3.x compatible which I can assure you, will not be a 5 minute job

Getting Error in Library inclusion in Codeigniter controller

When i run my aaplication in external server i get eror ,
Message: Login::include_once(application/third_party/mpdf/mpdf.php) [function.Login-include-once]: failed to open stream: No such file or directory.
The same application was running perfect in local server. Can anyone please suggest what could be wrong with it. My controller function ,
function pdfapp() //for test run individually
{
$this->load->model('Registration_model');
$appno='4/SCSELB/2013/KL01';
$data['table'] = $this->Registration_model->getall_app($appno);
$data['own_land'] = $this->Registration_model->get_ownland($appno);
$data['loan_data'] = $this->Registration_model->getloan_data($appno);
$apppdf='4_SCSELB_2013_KL01';
$data['apppdf']=$apppdf;
$pdfFilePath = FCPATH."reports/application/$apppdf.pdf";
if (file_exists($pdfFilePath) == FALSE)
{
ini_set('memory_limit','32M');
$html = $this->load->view('pdf_report2', $data, true);
include_once APPPATH.'third_party/mpdf/mpdf.php';
$mpdf=new mPDF('c');
$mpdf->SetFooter(' copyright# KSDC'.'|{PAGENO}|'.'Applied on '.date('d-M-Y H.i.s'));
$mpdf->WriteHTML($html);
$mpdf->Output($pdfFilePath, 'F');
}
$this->load->view('pdf_report2',$data);
}
The error you're getting is of a file not existing, Did you you debug this line ?
APPPATH.'third_party/mpdf/mpdf.php'; ?
what path do you get if you var_dump it?

Codeigniter Flexi Auth library loads sometimes

I am working on the log in system for a site using Flexi Auth in Codeigniter V 2.1.4. I am trying to pass a user's log in status to a menu that changes dynamically depending whether a user is logged in or not. This is the code i am using:
public function create_page($pgName = 'home')
{
$this->config->load('tera_site', TRUE);
$this->load->library('flexi_auth_lite');
// Cunstruct Page data
$data['pgName'] = $pgName;
if ($this->session->userdata('admin') === FALSE){$data['admin'] = 0;}else{$data['admin'] = $this->session->userdata('admin');}
$data['siteTitle'] = $this->config->item('siteTitle','tera_site');
// This is the line the Error is thrown from:
$data['loggedIn'] = $this->flexi_auth_lite->is_logged_in();
$data['header'] = $this->load->view('include/header', $data, TRUE);
$data['pages'] = $this->config->item('pages','tera_site');
$data['footer'] = $this->load->view('include/footer', False, TRUE);
$data['sideBar'] = $this->load->view('include/side_bar_view', $data, TRUE);
$this->load->model('page_model');
$data['pgData'] = $this->page_model->getPage($pgName);
// load the Catcha Library
$this->load->library('captcha_my');
if($data['pgData']['Captcha'] = 1) {
$data['Captcha'] = $this->captcha_my->createCaptcha();
} else if ($this->session->userdata('captchaCheck') == true) {
$data['Captcha'] = $this->captcha_my->createCaptcha();
}
return $data;
This is the error:
Severity: Notice
Message: Undefined property: Main::$flexi_auth_lite
Fatal error: Call to a member function is_logged_in() on a non-object
The code worked at one time, but even when it did it threw the same error when i called the function is_admen() from flexi_auth. Flexi_auth.php and Flexi_auth_lite.php are in application/libraries directory.
if you look into the demo files, there is a controller 'auth_lite.php'
it says
// IMPORTANT! This global must be defined BEFORE the flexi auth library is loaded!
// It is used as a global that is accessible via both models and both libraries, without it, flexi auth will not work.
$this->auth = new stdClass;
// Load 'lite' flexi auth library by default.
// If preferable, functions from this library can be referenced using 'flexi_auth' as done below.
// This prevents needing to reference 'flexi_auth_lite' in some files, and 'flexi_auth' in others, everything can be referenced by 'flexi_auth'.
$this->load->library('flexi_auth_lite', FALSE, 'flexi_auth');

Code Igniter - error when trying to config database.php to use PDO driver

I am trying to get the new PDO driver running in Code Igniter 2.1.1 in (to start with) the local (Mac OS 10.7) copy of my app.
I initially coded it using Active Record for all db operations, and I am now thinking I want to use PDO prepared statements in my model files, going forward.
I modified 'application/config/database.php' like so:
(note a couple minor embedded questions)
[snip]
$active_group = 'local_dev';
$active_record = TRUE;//<---BTW, will this need to stay TRUE to make CI sessions work? For better security, don't we want db-based CI sessions to use PDO too?
//http://codeigniter.com/user_guide/database/configuration.html:
//Note: that some CodeIgniter classes such as Sessions require Active Records be enabled to access certain functionality.
//this is the config setting that I am guessing (?) is my main problem:
$db['local_dev']['hostname'] = 'localhost:/tmp/mysql.sock';
// 1.) if $db['local_dev']['dbdriver']='mysql', then here ^^^ 'localhost:/tmp/mysql.sock' works, 2.) but if $db['local_dev']['dbdriver']='pdo', then it fails with error msg. shown below.
$db['local_dev']['username'] = 'root';
$db['local_dev']['password'] = '';
$db['local_dev']['database'] = 'mydbname';
$db['local_dev']['dbdriver'] = 'pdo';
$db['local_dev']['dbprefix'] = '';
$db['local_dev']['pconnect'] = TRUE;
$db['local_dev']['db_debug'] = TRUE;//TRUE
$db['local_dev']['cache_on'] = FALSE;
$db['local_dev']['cachedir'] = '';
$db['local_dev']['char_set'] = 'utf8';
$db['local_dev']['dbcollat'] = 'utf8_general_ci';
$db['local_dev']['swap_pre'] = '';
$db['local_dev']['autoinit'] = TRUE;
$db['local_dev']['stricton'] = FALSE;
[snip]
With the above config., as soon as I load a controller, I get this error message:
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in
/Library/WebServer/Documents/system/database/drivers/pdo/pdo_driver.php:114 Stack trace: #0
/Library/WebServer/Documents/system/database/drivers/pdo/pdo_driver.php(114): PDO->__construct('localhost:/tmp/...', 'root', '', Array) #1 /Library/WebServer/Documents/system/database/DB_driver.php(115): CI_DB_pdo_driver->db_pconnect() #2
/Library/WebServer/Documents/system/database/DB.php(148): CI_DB_driver->initialize() #3
/Library/WebServer/Documents/system/core/Loader.php(346): DB('', NULL) #4
/Library/WebServer/Documents/system/core/Loader.php(1171): CI_Loader->database() #5
/Library/WebServer/Documents/system/core/Loader.php(152): CI_Loader->_ci_autoloader() #6
/Library/WebServer/Documents/system/core/Con in
/Library/WebServer/Documents/system/database/drivers/pdo/pdo_driver.php on line 114
I tried swapping out the 'pdo_driver.php' file from the one on github, as per this:
http://codeigniter.com/forums/viewthread/206124/
...but that just generates other errors, not to mention is disturbing to a newbie who does not want to touch the system files if at all possible.
This thread also seems to imply the need to be hacking the 'pdo_driver.php' system file:
CodeIgniter PDO database driver not working
It seems odd to me, though, that (someone thought that) a hack to a system file is needed to make PDO work in CI v.2.1.1, huh?
Thanks for any suggestions I can try.
I don't know if this might be helpful for you since you already started using the CI functions, but I made my own library for PDO with sqlite and just auto load it. My needs were simple, so it serves its purpose.
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
* CodeIgniter PDO Library
*
*
* #author Michael Cruz
* #version 1.0
*/
class Sqlite_pdo
{
var $DB;
public function connect($path) {
try {
$this->DB = new PDO('sqlite:' . $path);
}
catch(PDOException $e) {
print "Error: " . $e->getMessage();
die();
}
}
public function simple_query($SQL) {
$results = $this->DB->query($SQL)
or die('SQL Error: ' . print_r($this->DB->errorInfo()));
return $results;
}
public function prepared_query($SQL, $bind = array()) {
$q = $this->DB->prepare($SQL)
or die('Prepare Error: ' . print_r($this->DB->errorInfo()));
$q->execute($bind)
or die('Execute Error: ' . print_r($this->DB->errorInfo()));
$q->setFetchMode(PDO::FETCH_BOTH);
return $q;
}
public function my_prepare($SQL) {
$q = $this->DB->prepare($SQL)
or die('Error: ' . print_r($this->DB->errorInfo()));
return $q;
}
public function my_execute($q, $bind) {
$q->execute($bind)
or die('Error: ' . print_r($this->DB->errorInfo()));
$q->setFetchMode(PDO::FETCH_BOTH);
return $q;
}
public function last_insert_id() {
return $this->DB->lastInsertId();
}
}
/* End of file Sqlite_pdo.php */
thanks to the noob thread http://codeigniter.com/forums/viewthread/180277/ (InsiteFX’s answer)..
I figured out the below seems to work (need to test more to be 100%... but at least the error messages are gone:
$db['local_dev']['hostname'] = 'mysql:host=127.0.0.1';

Resources