2010-10-06 80 views
0

我已經在Joomla 1.5下載了一些openId的示例代碼。我正在學習這個Joomla的事情,並重新學習一些PHP的東西。所以對於整個內容管理器領域來說,我基本上都非常陌生。我正在嘗試使用openid進行身份驗證,但它似乎只是錯誤的插件。jimport不工作在Joomla 1.5

我已經在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 [...] 

我曾試圖把庫中的PHP包含路徑,把它放在PEAR路徑,我已經(在jimport它剎車了,而不是)嘗試required_once,我試圖jimport全並試圖直接使用include。我還定義了目錄分隔符和JPATH_BASE。似乎沒有任何工作。

我認爲這應該有一個非常簡單的解決方案,因爲我有複製/粘貼代碼(不是自己創建的),並且是一個簡單的jimport。但是,我是新來的,並且卡住了。所以,請幫助。

非常感謝。

回答

1

問題是,改變了jimport('openid.consumer');include_path

下面是測試以證明它。

<?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已更改。

您可以嘗試以下解決方法。

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

感謝您的回覆。但是我沒有看到我可以如何改變我的代碼來使其工作。我輸出了include_path(它是在我的xampp中的php/PEAR中),我已經在我的php.ini中將其更改爲項目的Joomla庫文件夾。我有複製/粘貼openid文件夾到梨路徑,它在我的Joomla庫文件夾。兩者都不起作用。謝謝你的幫助! :) – Random 2010-10-13 16:21:08

+0

由於'jimport('openid.cunsumer')'包含路徑首次更改後,它對Joomla不好。解決方法很簡單,在jimport('openid.consumer');'和'jimport('openid.Auth.OpenID.AX')之後;'將包含路徑更改爲舊路徑。基本上重用我發佈的代碼。 – Alex 2010-10-13 17:36:43

+0

我必須道歉。我沒有正確解釋自己。我的問題是,當它執行指令jimport('openid.consumer')時,代碼會中斷。它不會改變我的include_path,因爲它只是在該指令之後沒有做任何事情。 – Random 2010-10-14 07:35:00