本文整理汇总了PHP中JModuleHelper::addIncludePath方法的典型用法代码示例。如果您正苦于以下问题:PHP JModuleHelper::addIncludePath方法的具体用法?PHP JModuleHelper::addIncludePath怎么用?PHP JModuleHelper::addIncludePath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JModuleHelper
的用法示例。
在下文中一共展示了JModuleHelper::addIncludePath方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addCodePath
/**
* Add a code pool to override
*
* @param string $path
*/
public static function addCodePath($path = null)
{
if (is_null($path)) {
return self::$_paths;
}
settype($path, 'array');
foreach ($path as $codePool) {
$codePool = JPath::clean($codePool);
JModuleHelper::addIncludePath($codePool);
array_push(self::$_paths, $codePool);
}
return self::$_paths;
}
示例2: onAfterRoute
/**
* onAfterRoute function.
*
* @access public
* @return void
*/
public function onAfterRoute()
{
$option = $this->getOption();
if ($option === false || !isset(self::$componentList[$option])) {
return;
}
MVCOverrideHelperCodepool::initialize();
// Add override paths for the current component files
foreach (MVCOverrideHelperCodepool::addCodePath() as $codePool) {
if (version_compare(JVERSION, '3.0', '>=')) {
JViewLegacy::addViewHelperPath($codePool . '/' . $option);
JViewLegacy::addViewTemplatePath($codePool . '/' . $option);
} else {
JView::addViewHelperPath($codePool . '/' . $option);
JView::addViewTemplatePath($codePool . '/' . $option);
}
JModuleHelper::addIncludePath($codePool . '/modules');
JTable::addIncludePath($codePool . '/' . $option . '/tables');
JModelForm::addComponentFormPath($codePool . '/' . $option . '/models/forms');
JModelForm::addComponentFieldPath($codePool . '/' . $option . '/models/fields');
}
}
示例3: onAfterRoute
/**
* onAfterRoute function.
*
* @access public
* @return void
*/
public function onAfterRoute()
{
$app = JFactory::getApplication();
$option = $app->input->get('option');
if (empty($option) && $app->isSite()) {
$menuDefault = $app->getMenu()->getDefault();
if ($menuDefault == 0) {
return;
}
$componentID = $menuDefault->componentid;
$db = JFactory::getDBO();
$db->setQuery('SELECT * FROM #__extensions WHERE extension_id =' . $db->quote($componentID));
$component = $db->loadObject();
$option = $component->element;
}
//get files that can be overrided
$componentOverrideFiles = $this->loadComponentFiles($option);
//application name
$applicationName = $app->getName();
//template name
$template = $app->getTemplate();
//code paths
$includePath = array();
//template code path
$includePath[] = JPATH_THEMES . '/' . $template . '/code';
//base extensions path
$includePath[] = JPATH_BASE . '/code';
JModuleHelper::addIncludePath(JPATH_BASE . '/code');
JModuleHelper::addIncludePath(JPATH_THEMES . '/' . $template . '/code');
//constants to replace JPATH_COMPONENT, JPATH_COMPONENT_SITE and JPATH_COMPONENT_ADMINISTRATOR
define('JPATH_SOURCE_COMPONENT', JPATH_BASE . '/components/' . $option);
define('JPATH_SOURCE_COMPONENT_SITE', JPATH_SITE . '/components/' . $option);
define('JPATH_SOURCE_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/' . $option);
//loading override files
if (!empty($componentOverrideFiles)) {
foreach ($componentOverrideFiles as $componentFile) {
if ($filePath = $this->findPath($includePath, $componentFile)) {
//include the original code and replace class name add a Default on
if ($this->params->get('extendDefault', 0)) {
$bufferFile = file_get_contents(JPATH_BASE . '/components/' . $componentFile);
//detect if source file use some constants
preg_match_all('/JPATH_COMPONENT(_SITE|_ADMINISTRATOR)|JPATH_COMPONENT/i', $bufferFile, $definesSource);
$bufferOverrideFile = file_get_contents($filePath);
//detect if override file use some constants
preg_match_all('/JPATH_COMPONENT(_SITE|_ADMINISTRATOR)|JPATH_COMPONENT/i', $bufferOverrideFile, $definesSourceOverride);
// Append "Default" to the class name (ex. ClassNameDefault). We insert the new class name into the original regex match to get
$rx = '/class *[a-z0-0]* *(extends|{)/i';
preg_match($rx, $bufferFile, $classes);
$originalClass = '';
if (!empty($classes)) {
$parts = explode(' ', $classes[0]);
$originalClass = $parts[1];
}
$replaceClass = $originalClass . 'Default';
if (count($definesSourceOverride[0])) {
throw new Exception(JText::_('Plugin MVC Override', 'Your override file use constants, please replace code constants<br />JPATH_COMPONENT -> JPATH_SOURCE_COMPONENT,<br />JPATH_COMPONENT_SITE -> JPATH_SOURCE_COMPONENT_SITE and<br />JPATH_COMPONENT_ADMINISTRATOR -> JPATH_SOURCE_COMPONENT_ADMINISTRATOR'));
} else {
//replace original class name by default
$bufferContent = str_replace($originalClass, $replaceClass, $bufferFile);
//replace JPATH_COMPONENT constants if found, because we are loading before define these constants
if (count($definesSource[0])) {
$bufferContent = preg_replace(array('/JPATH_COMPONENT/', '/JPATH_COMPONENT_SITE/', '/JPATH_COMPONENT_ADMINISTRATOR/'), array('JPATH_SOURCE_COMPONENT', 'JPATH_SOURCE_COMPONENT_SITE', 'JPATH_SOURCE_COMPONENT_ADMINISTRATOR'), $bufferContent);
}
// Change private methods to protected methods
if ($this->params->get('changePrivate', 0)) {
$bufferContent = preg_replace('/private *function/i', 'protected function', $bufferContent);
}
// Finally we can load the base class
eval('?>' . $bufferContent . PHP_EOL . '?>');
require_once $filePath;
}
} else {
require_once $filePath;
}
}
}
}
}
示例4: allowModulesOverrides
private function allowModulesOverrides()
{
$jV = new JVersion();
if (version_compare($jV->getShortVersion(), "3", "lt")) {
$loc = '/joomla/application/module/';
} else {
$loc = '/cms/module/';
}
//override JModuleHelper library class
$moduleHelperContent = JFile::read(JPATH_LIBRARIES . $loc . 'helper.php');
$moduleHelperContent = str_replace('JModuleHelper', 'JModuleHelperLibraryDefault', $moduleHelperContent);
$moduleHelperContent = str_replace('<?php', '', $moduleHelperContent);
eval($moduleHelperContent);
jimport('joomla.application.module.helper');
JLoader::register('jmodulehelper', dirname(__FILE__) . '/module/helper.php', true);
JModuleHelper::addIncludePath(JPATH_BASE . '/code/modules');
JModuleHelper::addIncludePath(JPATH_THEMES . '/' . JFactory::getApplication()->getTemplate() . '/code/modules');
}