问题
I have downloaded some sample code for openId in Joomla 1.5. I am learning as I go with this Joomla thing and re-learning some PHP things. So I'm basically terribly new to this entire Content Manager world. I am trying to make a little plug-in for authentication with openid but it seems to be just wrong.
I have successfully debugged the project in eclipse and found that the error comes from my jimport.
class plgAuthenticationOpenId extends JPlugin{
/**
* OpenId Atributes.
*/
private static $attribute;
private static $proxyHost;
private static $proxyPort;
private static $proxyUser;
private static $proxyPassword;
private static $appId;
private static $appPassword;
function plgAuthenticationOpenId(& $subject, $config){
parent::__construct($subject, $config);
plgAuthenticationOpenId::$appId=$this->params->get('userKey', '');
plgAuthenticationOpenId::$appPassword = $this->params->get('apiKey', '');
define('Auth_OpenID_RAND_SOURCE', null);
jimport('openid.consumer');
jimport('openid.Auth.OpenID.AX');
//Basic Attributes
plgAuthenticationOpenId::$attribute = array();
//more code messing with plgAuthenticationOpenId [...]
I have tried to put the library in the php include path, put it in the PEAR path, I have tried the required_once (it brakes there instead of in the jimport), I have tried to jimport the whole path and tried to use include directly. I have also defined the directory separator and the JPATH_BASE. Nothing seems to work.
I think this should have a very easy solution, as I have copy/pasted the code (not created it myself) and is a simple jimport. But nevertheless I’m new to this and stuck. So please, help.
Thanks a lot.
回答1:
Problem is that jimport('openid.consumer');
changed include_path
Here is a test to demonstrate it.
<?php
// I executed code below in the view to obtain output
var_dump(ini_get('include_path'));
jimport('openid.consumer');
jimport('openid.Auth.OpenID.AX');
var_dump(ini_get('include_path'));
// OUTPUT
string '.:/opt/lampp/lib/php' (length=20)
string '/opt/lampp/htdocs/promark_eblaster/libraries/openid/.:/opt/lampp/lib/php' (length=72)
?>
As you can see the include_path changed.
You can try the following workaround.
<?php
// Remember the Original Path
$oldPath = ini_get('include_path');
// Include OpenID Stuff
jimport('openid.consumer');
jimport('openid.Auth.OpenID.AX');
// Set back the include_path so Joomla can import files with old include path
ini_set('include_path', $oldPath);
// Check if Success
JFactory::getApplication()->enqueueMessage("Hellow World");
// The rest of your code...
?>
来源:https://stackoverflow.com/questions/3871800/jimport-not-working-in-joomla-1-5