本文整理汇总了PHP中Phpfox_Plugin::_aPlugins方法的典型用法代码示例。如果您正苦于以下问题:PHP Phpfox_Plugin::_aPlugins方法的具体用法?PHP Phpfox_Plugin::_aPlugins怎么用?PHP Phpfox_Plugin::_aPlugins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Phpfox_Plugin
的用法示例。
在下文中一共展示了Phpfox_Plugin::_aPlugins方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* Build and cache all the plug-ins for future use.
*
*/
public static function set()
{
$aPlugins = array();
$oCache = Phpfox::getLib('cache');
$iCacheId = $oCache->set(array('plugin', 'plugin'));
if (Phpfox::getParam('core.cache_plugins') && !(self::$_aPlugins = $oCache->get($iCacheId)) || !Phpfox::getParam('core.cache_plugins')) {
$oDb = Phpfox_Database::instance();
$aRows = $oDb->select('p.call_name, p.php_code')->from(Phpfox::getT('plugin'), 'p')->join(Phpfox::getT('product'), 'product', 'p.product_id = product.product_id AND product.is_active = 1')->join(Phpfox::getT('plugin_hook'), 'ph', 'ph.call_name = p.call_name AND ph.is_active = 1')->join(Phpfox::getT('module'), 'm', 'm.module_id = p.module_id AND m.is_active = 1')->where('p.is_active = 1')->order('p.ordering ASC')->execute('getRows');
$oDb->freeResult();
foreach ($aRows as $aRow) {
$aRow['call_name'] = strtolower($aRow['call_name']);
if (isset($aPlugins[$aRow['call_name']])) {
$aPlugins[$aRow['call_name']] .= self::_cleanPhp($aRow['php_code']) . " ";
} else {
$aPlugins[$aRow['call_name']] = self::_cleanPhp($aRow['php_code']) . " ";
}
}
foreach ((new Core\App())->all() as $app) {
$dir = $app->path . 'hooks/';
if (is_dir($dir)) {
foreach (scandir($dir) as $file) {
if (substr($file, -4) == '.php') {
$code = self::_cleanPhp(file_get_contents($dir . $file));
$name = substr_replace($file, '', -4);
if (isset($aPlugins[$name])) {
$aPlugins[$name] .= $code . " ";
} else {
$aPlugins[$name] = $code . " ";
}
}
}
}
}
$aModules = Phpfox_Module::instance()->getModules();
foreach ($aModules as $sModule => $iModuleId) {
if (is_dir(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_PLUGIN . PHPFOX_DS)) {
if (!Phpfox::isModule($sModule)) {
continue;
}
$rHooks = opendir(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_PLUGIN . PHPFOX_DS);
while (($sHook = readdir($rHooks)) !== false) {
if (substr($sHook, -4) != '.php') {
continue;
}
$sHookContent = self::_cleanPhp(file_get_contents(PHPFOX_DIR_MODULE . $sModule . PHPFOX_DS . PHPFOX_DIR_MODULE_PLUGIN . PHPFOX_DS . $sHook));
$sHookVarName = substr_replace($sHook, '', -4);
if (isset($aPlugins[$sHookVarName])) {
$aPlugins[$sHookVarName] .= $sHookContent . " ";
} else {
$aPlugins[$sHookVarName] = $sHookContent . " ";
}
}
closedir($rHooks);
}
}
$hPlugin = opendir(PHPFOX_DIR_PLUGIN);
while ($sProduct = readdir($hPlugin)) {
if ($sProduct == '.' || $sProduct == '..') {
continue;
}
if (is_dir(PHPFOX_DIR_PLUGIN . $sProduct)) {
if (!Admincp_Service_Product_Product::instance()->isProduct($sProduct)) {
continue;
}
$hProduct = opendir(PHPFOX_DIR_PLUGIN . $sProduct);
while ($sHook = readdir($hProduct)) {
if (substr($sHook, -4) != '.php') {
continue;
}
$sHookContent = self::_cleanPhp(file_get_contents(PHPFOX_DIR_PLUGIN . $sProduct . PHPFOX_DS . $sHook));
$sHookVarName = substr_replace($sHook, '', -4);
if (isset($aPlugins[$sHookVarName])) {
$aPlugins[$sHookVarName] .= $sHookContent . " ";
} else {
$aPlugins[$sHookVarName] = $sHookContent . " ";
}
}
closedir($hProduct);
}
}
foreach (array_keys($aPlugins) as $sKey) {
self::$_aPlugins[$sKey] = $sKey;
$iPluginCacheId = $oCache->set(array('plugin', 'plugin_data_' . $sKey));
if (Phpfox::getParam('core.cache_plugins') && !$oCache->get($iPluginCacheId) || !Phpfox::getParam('core.cache_plugins')) {
$oCache->save($iPluginCacheId, $aPlugins[$sKey]);
}
$oCache->close($iPluginCacheId);
}
$oCache->save($iCacheId, self::$_aPlugins);
}
}