jimport在Joomla 1.5中不起作用 [英] jimport not working in Joomla 1.5
问题描述
我已经在Joomla 1.5中下载了一些openId的示例代码.我正在学习有关Joomla的东西,并重新学习了一些PHP东西.因此,我基本上对整个Content Manager领域都是陌生的.我正在尝试使用openid制作一些用于身份验证的插件,但这似乎是错误的.
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.
我已经在eclipse中成功调试了项目,发现错误来自我的jimport.
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 [...]
我尝试将库放在php include路径中,将其放置在PEAR路径中,我尝试了required_once(它在那里制动而不是在jimport中制动),我尝试了jimport整个路径并尝试直接使用include.我还定义了目录分隔符和JPATH_BASE.似乎什么都没用.
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.
我认为这应该有一个非常简单的解决方案,因为我已经复制/粘贴了代码(不是我自己创建的),并且是简单的jimport.但是,尽管如此,我还是陌生的.所以请帮忙.
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.
非常感谢.
推荐答案
问题是jimport('openid.consumer');
更改了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)
?>
如您所见,include_path已更改.
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...
?>
这篇关于jimport在Joomla 1.5中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!