简体   繁体   English

jimport在Joomla 1.5中不起作用

[英]jimport not working in Joomla 1.5

I have downloaded some sample code for openId in Joomla 1.5. 我已经在Joomla 1.5中下载了一些openId的示例代码。 I am learning as I go with this Joomla thing and re-learning some PHP things. 我正在学习有关Joomla的东西,并重新学习了一些PHP东西。 So I'm basically terribly new to this entire Content Manager world. 因此,我基本上对整个Content Manager领域都是陌生的。 I am trying to make a little plug-in for authentication with openid but it seems to be just wrong. 我正在尝试使用openid制作一些用于身份验证的插件,但这似乎是错误的。

I have successfully debugged the project in eclipse and found that the error comes from my jimport. 我已经在eclipse中成功调试了项目,发现错误来自我的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. 我尝试将库放在php include路径中,将其放置在PEAR路径中,我尝试了required_once(它在那里制动而不是在jimport中制动),我尝试了jimport整个路径,并尝试直接使用include 。 I have also defined the directory separator and the JPATH_BASE. 我还定义了目录分隔符和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. 我认为这应该是一个非常简单的解决方案,因为我已经复制/粘贴了代码(不是我自己创建的),并且是简单的jimport。 But nevertheless I'm new to this and stuck. 但是,尽管如此,我还是陌生的。 So please, help. 所以请帮忙。

Thanks a lot. 非常感谢。

Problem is that jimport('openid.consumer'); 问题是jimport('openid.consumer'); changed include_path 更改了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. 如您所见,include_path已更改。

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...
?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM