나는 Joomla를 사용하는 것에 익숙하지 않고 v1.5에 대해 쓴 외부 PHP 클래스를 적용하려고합니다. 기본적으로 Joomla 환경을로드하기 위해 Joomla의 모든 기능을 클래스에 사용할 수있는 기능을 사용합니다. 이것은 기본적으로 index.php 파일을 사용하여 수행됩니다.Joomla 1.6 외부 PHP 상호 작용 문제
v1.5에서는 제대로 작동하고 잠시 동안했지만 v1.6에 맞게 조정하려고 시도했지만 넘어졌습니다.
이 같이 말했다private function loadJoomla() {
$path_base = rtrim($this->joomFullPath, '/');
// Set flag that this is a parent file
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);
switch ($joomlaVersion) {
case 'v1.6':
if (file_exists($path_base . '/defines.php')) {
include_once $path_base . '/defines.php';
}
if (!defined('_JDEFINES')) {
define('JPATH_BASE', $path_base);
require_once JPATH_BASE.'/includes/defines.php';
}
require_once JPATH_BASE.'/includes/framework.php';
// Mark afterLoad in the profiler.
JDEBUG ? $_PROFILER->mark('afterLoad') : null;
// Instantiate the application.
$app = JFactory::getApplication('site');
// Initialise the application.
$app->initialise();
// Mark afterIntialise in the profiler.
JDEBUG ? $_PROFILER->mark('afterInitialise') : null;
// Route the application.
$app->route();
// Mark afterRoute in the profiler.
JDEBUG ? $_PROFILER->mark('afterRoute') : null;
// Dispatch the application.
$app->dispatch();
// Mark afterDispatch in the profiler.
JDEBUG ? $_PROFILER->mark('afterDispatch') : null;
// Render the application.
$app->render();
// Mark afterRender in the profiler.
JDEBUG ? $_PROFILER->mark('afterRender') : null;
// Return the response.
return $app;
break;
case 'v1.5':
// PREPARE
define('JPATH_BASE', $path_base);
require_once (JPATH_BASE .DS.'includes'.DS.'defines.php');
require_once (JPATH_BASE .DS.'includes'.DS.'framework.php');
JDEBUG ? $_PROFILER->mark('afterLoad') : NULL;
// CREATE THE APPLICATION
$GLOBALS['mainframe'] =& JFactory::getApplication('site');
// INITIALISE THE APPLICATION
/* set the language */
$GLOBALS['mainframe']->initialise();
JPluginHelper::importPlugin('system');
/* trigger the onAfterInitialise events */
JDEBUG ? $_PROFILER->mark('afterInitialise') : NULL;
$GLOBALS['mainframe']->triggerEvent('onAfterInitialise');
// ROUTE THE APPLICATION
$GLOBALS['mainframe']->route();
/* authorization */
$GLOBALS['Itemid'] = JRequest::getInt('Itemid');
$GLOBALS['mainframe']->authorize($GLOBALS['Itemid']);
/* trigger the onAfterRoute events */
JDEBUG ? $_PROFILER->mark('afterRoute') : NULL;
$GLOBALS['mainframe']->triggerEvent('onAfterRoute');
// DISPATCH THE APPLICATION
$GLOBALS['option'] = JRequest::getCmd('option');
$GLOBALS['mainframe']->dispatch($GLOBALS['option']);
/* trigger the onAfterDispatch events */
JDEBUG ? $_PROFILER->mark('afterDispatch') : NULL;
$GLOBALS['mainframe']->triggerEvent('onAfterDispatch');
// RENDER THE APPLICATION
$GLOBALS['mainframe']->render();
/* trigger the onAfterRender events */
JDEBUG ? $_PROFILER->mark('afterRender') : NULL;
$GLOBALS['mainframe']->triggerEvent('onAfterRender');
// RETURN THE RESPONSE
return JResponse::toString($GLOBALS['mainframe']->getCfg('gzip'));
break;
default:
return NULL;
break;
}
의 v1.5에 비트가 잘 작동 및 글로벌 만든 메인 프레임 변수를 그냥 index.php 파일입니다 : 여기
는 기능입니다. v1.6 비트는 '$ app-> dispatch();'에서 넘어집니다.'die'를 사용하여 흐름을 디버깅하는 것은 /libraries/joomla/application.php의 함수 디스패치로 이동했습니다. 여기서 fall over point는 '$ contents = JComponentHelper :: renderComponent ($ component);'였습니다. 어떤 기능이 필요한지 알았습니다. /libraries/joomla/application/component/helper.php의 renderComponent
나중에 '죽는다'는 것을 알기를 기다리면서, 'ob_start();'를 기다립니다. 특히 v1.5 코드를 체크인 한 이후로 완전히 당혹 스러웠습니다.이 코드는 v1.6과 정확히 동일합니다.
$ app 범위가이 문제의 원인 일 수 있다고 생각하며 도움을 얻을 수 있습니다. 기쁨없이 "$ GLOBALS [ 'app']"을 시도했습니다.
시간과 조언을 주셔서 감사드립니다.
나는 내가 아는 모든 것을 시험해 보았고 다른 곳에서 같은 질문을했지만 매번 침묵의 벽을 만났다. 나는이 문제의 원인을 어떻게 표현했는지 궁금합니다. 가능한 경우 도와주세요. 감사 – Dayo