所以情况如下: - 我有一个论坛软件,XenForo供客户嬉戏 - 我有一个会员软件,一个会员,负责处理客户付款和提供数字产品。 (两者都在同一个网站上)
aMember有一个模板系统,允许您(理想情况下)轻松自定义脚本,使其看起来像是您网站的一部分。
XenForo有一个脚本插件,可让您使用PHP“include”功能使用自定义的XenForo页眉和页脚。
基本上,我可以使用常规的php文件,使用php include调用XenForo页眉和页脚,并使该页面看起来像是论坛软件的一部分(几乎像一个wordpress页眉/页脚)。到目前为止,我提到的所有内容都经过测试并在aMember系统之外工作,因此我目前有一个index.php文件,它使用include调用XenForo页眉和页脚,效果很好。
这是令人讨厌的地方,我试图在aMember模板系统中使用PHP include脚本。我得到了它主要工作,但随后出现以下错误与之后产生的有趣批次代码:
Error: Registry is already initialized
Exception Zend_Exception
Zend_Registry::setClassName [ /home/content/p/p/o/ppowers/html/forum/library/XenForo/Application.php : 244 ]
XenForo_Application::initialize [ /home/content/p/p/o/ppowers/html/forum/library/Dark/Kotomi/KotomiHeader.php : 5 ]
include_once [ /home/content/p/p/o/ppowers/html/header.php : 6 ]
include_once [ library/Am/View.php : 419 ]
Am_View->printLayoutHead [ application/default/themes/sample/layout.phtml : 8 ]
include [ library/Am/View.php : 352 ]
Am_View->_run [ library/Zend/View/Abstract.php : 888 ]
Zend_View_Abstract->render [ library/Am/View.php : 326 ]
Am_View->display [ application/default/controllers/IndexController.php : 7 ]
IndexController->indexAction [ library/Am/Controller.php : 139 ]
Am_Controller->_runAction [ library/Am/Controller.php : 116 ]
Am_Controller->dispatch [ library/Zend/Controller/Dispatcher/Standard.php : 295 ]
Zend_Controller_Dispatcher_Standard->dispatch [ library/Zend/Controller/Front.php : 954 ]
Zend_Controller_Front->dispatch [ library/Am/App.php : 1372 ]
Am_App->run [ index.php : 41 ]
从我所知道的和我有限的编程知识来看,看起来像会员和XenForo正在争论谁将使用Zend Registry。
无论如何,我可以让他们一起玩,而不雇用一名全职程序员6个月?非常感谢!
............................................... .........回复评论:
添加评论没有足够的字符,所以这里有一些代码。
据我所知,XenForo使用它作为它的主要......等等......这里是Application.php的START,是XenForo源代码的一部分。这个文件超过1000行,所有这些都构成了从顶部开始的类...这似乎是唯一使用Zend_Registry的文件,它不属于Zend源本身。
class XenForo_Application extends Zend_Registry
{
const URL_ID_DELIMITER = '.';
public static $version = '1.1.0';
public static $versionId = 1010070; // abbccde = a.b.c d (alpha: 1, beta: 3, RC: 5, stable: 7, PL: 9) e
public static $jsVersion = '';
public static $jQueryVersion = '1.5.2';
protected $_configDir = '.';
protected $_rootDir = '.';
protected $_initialized = false;
protected $_lazyLoaders = array();
protected static $_handlePhpError = true;
protected static $_debug;
protected static $_randomData = '';
protected static $_classCache = array();
public static $time = 0;
public static $host = 'localhost';
aMember在几个文件中使用它,这里有几个例子:
这是在form.php ...
中public function findRuleMessage(HTML_QuickForm2_Rule $rule, HTML_QuickForm2_Node $el)
{
$strings = array(
'rule.required' => ___('This is a required field'),
);
$type = lcfirst(preg_replace('/^.+rule_/i', '', get_class($rule)));
$tr = Zend_Registry::get('Zend_Translate');
$fuzzy = sprintf('rule.%s', $type);
if (array_key_exists($fuzzy, $strings))
return $strings[$fuzzy];
}
这是app.php ....
function amDate($string) {
if ($string == null) return '';
return date(Zend_Registry::get('Am_Locale')->getDateFormat(), amstrtotime($string));
}
function amDatetime($string) {
if ($string == null) return '';
return date(Zend_Registry::get('Am_Locale')->getDateTimeFormat(), amstrtotime($string));
}
function amTime($string) {
if ($string == null) return '';
return date(Zend_Registry::get('Am_Locale')->getTimeFormat(), amstrtotime($string));
}
好吧,我最好不要发布任何更多的源代码,否则他们会在我之后发送黑衣人。
看起来它可能更容易从一个会员中编程,但这很快就会成为一项难以逾越的任务,特别是在我(缺乏)技能水平时。
其他信息:
public static function initialize($configDir = '.', $rootDir = '.', $loadDefaultData = true)
{
(244)self::setClassName(__CLASS__);
self::getInstance()->beginApplication($configDir, $rootDir, $loadDefaultData);
}
评论第244行产生了以下错误:
Fatal error: Call to undefined method Zend_Registry::beginApplication() in /home/content/p/p/o/ppowers/html/forum/library/XenForo/Application.php on line 245
将您建议的代码添加到aMember index.php文件中会产生此错误:
Fatal error: Class 'XenForo_Application' not found in /home/content/p/p/o/ppowers/html/amember/index.php on line 40
答案 0 :(得分:0)
244
的{{1}}行是什么?如果它只是/home/content/p/p/o/ppowers/html/forum/library/XenForo/Application.php
这是默认的类名,如果您不害怕修改源,只需在Zend_Registry
行注释掉该号码即可。但是,如果您希望将来更新XenForo,则不建议这样做。
检查是否可以以某种方式配置传递给244
行setClassName()
的任何内容。粘贴一些代码。获得更多答案。
与XenForo的战斗可能需要相当多的编码,所以我建议采用一种截然不同的方法。由于aMemeber似乎使用了vanilla 244
,因此您可以尝试确保Zend_Registry
的{{1}}扩展版本首先实例化。在XenForo
(可能位于Zend_Registry
目录中)找到index.php
或类似的行, 此行添加如下内容:
public
并注明$application->bootstrap();
的{{1}}行。
如果这样做,请记住评论更改,交叉引用两个修改过的文件。
答案 1 :(得分:0)
我构建我的网站我正在使用Zend framework v1.5:http://www.panpic.vn(**)| 使用xenforo的论坛:http://www.panpic.vn/forum(*)
在主页(**)我是身份验证用户Xenforo 我的编码:
define('XF_ROOT', '/home/www/lighttpd/my_web/forum'); // set this (absolute path)!
define('STARTTIME', microtime(true) );
define('SESSION_BYPASS', false); // if true: logged in user info and sessions are not needed
require_once(XF_ROOT . '/library/XenForo/Autoloader.php');
XenForo_Autoloader::getInstance()->setupAutoloader(XF_ROOT . '/library');
XenForo_Application::initialize(XF_ROOT . '/library', XF_ROOT);
XenForo_Application::set('page_start_time', STARTTIME );
XenForo_Application::setDebugMode(false);
if (!SESSION_BYPASS)
{
$dependencies = new XenForo_Dependencies_Public();
$dependencies->preLoadData();
$session = XenForo_Session::startPublicSession(new Zend_Controller_Request_Http);
XenForo_Visitor::setup($session->get('user_id'));
$visitor = XenForo_Visitor::getInstance();
if ($visitor->getUserId())
{
$userModel = XenForo_Model::create('XenForo_Model_User');
$userinfo = $userModel->getFullUserById($visitor->getUserId());
}
}
错误:注册表已初始化
你能解决我的问题吗?