本文整理汇总了PHP中XenForo_CodeEvent::setListeners方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_CodeEvent::setListeners方法的具体用法?PHP XenForo_CodeEvent::setListeners怎么用?PHP XenForo_CodeEvent::setListeners使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_CodeEvent
的用法示例。
在下文中一共展示了XenForo_CodeEvent::setListeners方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init_dependencies
public static function init_dependencies(XenForo_Dependencies_Abstract $dependencies, array $data)
{
if ($dependencies instanceof XenForo_Dependencies_Public and ChipXF_MobileSwitcher_Detecter::isMobile()) {
foreach ($data['codeEventListeners'] as $event => &$callbackList) {
foreach ($callbackList as $key => $callback) {
if (in_array($callback[0], XenForo_Application::get('options')->ChipXF_MS_AddonsDisabled)) {
unset($data['codeEventListeners'][$event][$key]);
}
}
}
XenForo_CodeEvent::removeListeners();
XenForo_CodeEvent::setListeners($data['codeEventListeners']);
ChipXF_MobileSwitcher_Detecter::$isMobile = true;
}
}
示例2: _disableListeners
protected function _disableListeners()
{
if (isset($this->_data['addon_id'])) {
$this->_db->query('
UPDATE xf_addon SET active = 0
WHERE addon_id = ?
', $this->_data['addon_id']);
$cache = $this->getModelFromCache('XenForo_Model_CodeEvent')->rebuildEventListenerCache();
XenForo_CodeEvent::setListeners($cache, false);
}
}
示例3: _checkAddOnsNeedUpgrading
/**
*
* @param array $addOns
*/
protected function _checkAddOnsNeedUpgrading(array $addOns, $checkDisabled = false)
{
if (empty($addOns)) {
return false;
}
if (XenForo_Application::$versionId < 1020000 || $checkDisabled) {
/* @var $addOnModel XenForo_Model_AddOn */
$addOnModel = XenForo_Model::create('XenForo_Model_AddOn');
$allAddOns = $addOnModel->getAllAddOns();
} else {
$allAddOns = XenForo_Application::get('addOns');
}
$lastXmlUploadDate = $this->_getLastXmlUploadDate();
foreach ($addOns as $addOnId) {
if (isset($allAddOns[$addOnId])) {
$addOn = $allAddOns[$addOnId];
try {
$addOnXML = new SimpleXMLElement(file_get_contents(XenForo_Application::getInstance()->getRootDir() . '/install/data/addon-' . $addOnId . '.xml'));
$versionId = (string) $addOnXML->attributes()->version_id;
} catch (Exception $e) {
$versionId = '';
}
if (is_array($addOn) && $versionId > $addOn['version_id'] || !is_array($addOn) && $versionId > $addOn) {
self::$_upgradeAddOns[$addOnId] = $addOn;
} else {
$xmlUploadDate = filemtime(XenForo_Application::getInstance()->getRootDir() . '/install/data/addon-' . $addOnId . '.xml');
if ($xmlUploadDate > $lastXmlUploadDate) {
$lastXmlUploadDate = $xmlUploadDate;
}
}
}
}
eval('
class Waindigo_Listener_ControllerPreDispatch_TemplatePostRender
{
public static function templatePostRender($templateName, &$content, array &$containerData, XenForo_Template_Abstract $template)
{
if ($templateName == "PAGE_CONTAINER") {
$upgradeAddOns = Waindigo_Listener_ControllerPreDispatch::getUpgradeAddOns();
if (!empty($upgradeAddOns)) {
$params = $template->getParams();
if (!$params[\'showUpgradePendingNotice\']) {
$pattern = \'#<noscript><p class="importantMessage">.*</p></noscript>#U\';
$replacement = \'<p class="importantMessage"><a href="\'.XenForo_Link::buildAdminLink(\'add-ons/upgrade-all-from-xml\').\'">\' . new XenForo_Phrase(\'upgrade_add_on\') . \'</a></p>\';
$content = preg_replace($pattern, \'${1}\' . $replacement, $content);
}
}
}
}
}');
$tprListeners = XenForo_CodeEvent::getEventListeners('template_post_render');
if (!$tprListeners || XenForo_Application::$versionId >= 1020052) {
$tprListeners = array();
}
$newListener = array('Waindigo_Listener_ControllerPreDispatch_TemplatePostRender', 'templatePostRender');
if (XenForo_Application::$versionId < 1020000) {
$tprListeners[] = $newListener;
} else {
$tprListeners['_'][] = $newListener;
}
XenForo_CodeEvent::setListeners(array('template_post_render' => $tprListeners));
if (empty(self::$_upgradeAddOns)) {
$this->_setLastXmlUploadDate($lastXmlUploadDate);
return false;
}
return true;
}
示例4: preLoadData
/**
* Pre-loads globally required data for the system.
*/
public function preLoadData()
{
$required = array_merge(array('options', 'languages', 'contentTypes', 'codeEventListeners', 'deferredRun', 'simpleCache', 'addOns', 'defaultStyleProperties', 'routeFiltersIn', 'routeFiltersOut'), $this->_dataPreLoadFromRegistry);
$dr = new XenForo_Model_DataRegistry();
// this is a slight hack to prevent the class from being cached
$data = $dr->getMulti($required);
if (XenForo_Application::get('config')->enableListeners) {
if (!is_array($data['codeEventListeners'])) {
$data['codeEventListeners'] = XenForo_Model::create('XenForo_Model_CodeEvent')->rebuildEventListenerCache();
}
XenForo_CodeEvent::setListeners($data['codeEventListeners']);
}
if (!is_array($data['options'])) {
$data['options'] = XenForo_Model::create('XenForo_Model_Option')->rebuildOptionCache();
}
$options = new XenForo_Options($data['options']);
XenForo_Application::setDefaultsFromOptions($options);
XenForo_Application::set('options', $options);
if (!is_array($data['languages'])) {
$data['languages'] = XenForo_Model::create('XenForo_Model_Language')->rebuildLanguageCache();
}
XenForo_Application::set('languages', $data['languages']);
if (!is_array($data['defaultStyleProperties'])) {
$data['defaultStyleProperties'] = XenForo_Model::create('XenForo_Model_StyleProperty')->rebuildPropertyCacheInStyleAndChildren(0, true);
}
XenForo_Application::set('defaultStyleProperties', $data['defaultStyleProperties']);
if (!is_array($data['contentTypes'])) {
$data['contentTypes'] = XenForo_Model::create('XenForo_Model_ContentType')->rebuildContentTypeCache();
}
XenForo_Application::set('contentTypes', $data['contentTypes']);
if (!is_int($data['deferredRun'])) {
$data['deferredRun'] = XenForo_Model::create('XenForo_Model_Deferred')->updateNextDeferredTime();
}
XenForo_Application::set('deferredRun', $data['deferredRun']);
if (!is_array($data['addOns'])) {
$data['addOns'] = XenForo_Model::create('XenForo_Model_AddOn')->rebuildActiveAddOnCache();
}
XenForo_Application::set('addOns', $data['addOns']);
if (!is_array($data['simpleCache'])) {
$data['simpleCache'] = array();
XenForo_Model::create('XenForo_Model_DataRegistry')->set('simpleCache', $data['simpleCache']);
}
XenForo_Application::set('simpleCache', $data['simpleCache']);
if (!is_array($data['routeFiltersIn']) || !is_array($data['routeFiltersOut'])) {
$filterCache = XenForo_Model::create('XenForo_Model_RouteFilter')->rebuildRouteFilterCache();
$data['routeFiltersIn'] = $filterCache['in'];
$data['routeFiltersOut'] = $filterCache['out'];
}
XenForo_Application::set('routeFiltersIn', $data['routeFiltersIn']);
XenForo_Application::set('routeFiltersOut', $data['routeFiltersOut']);
XenForo_Link::setRouteFiltersOut($data['routeFiltersOut']);
$this->_handleCustomPreloadedData($data);
XenForo_CodeEvent::fire('init_dependencies', array($this, $data));
}
示例5: preLoadData
/**
* Pre-loads globally required data for the system.
*/
public function preLoadData()
{
$required = array_merge(array('options', 'languages', 'contentTypes', 'codeEventListeners', 'cron', 'simpleCache'), $this->_dataPreLoadFromRegistry);
$data = XenForo_Model::create('XenForo_Model_DataRegistry')->getMulti($required);
if (XenForo_Application::get('config')->enableListeners) {
if (!is_array($data['codeEventListeners'])) {
$data['codeEventListeners'] = XenForo_Model::create('XenForo_Model_CodeEvent')->rebuildEventListenerCache();
}
XenForo_CodeEvent::setListeners($data['codeEventListeners']);
}
if (!is_array($data['options'])) {
$data['options'] = XenForo_Model::create('XenForo_Model_Option')->rebuildOptionCache();
}
$options = new XenForo_Options($data['options']);
XenForo_Application::setDefaultsFromOptions($options);
XenForo_Application::set('options', $options);
if (!is_array($data['languages'])) {
$data['languages'] = XenForo_Model::create('XenForo_Model_Language')->rebuildLanguageCache();
}
XenForo_Application::set('languages', $data['languages']);
if (!is_array($data['contentTypes'])) {
$data['contentTypes'] = XenForo_Model::create('XenForo_Model_ContentType')->rebuildContentTypeCache();
}
XenForo_Application::set('contentTypes', $data['contentTypes']);
if (!is_int($data['cron'])) {
$data['cron'] = XenForo_Model::create('XenForo_Model_Cron')->updateMinimumNextRunTime();
}
XenForo_Application::set('cron', $data['cron']);
if (!is_array($data['simpleCache'])) {
$data['simpleCache'] = array();
XenForo_Model::create('XenForo_Model_DataRegistry')->set('simpleCache', $data['simpleCache']);
}
XenForo_Application::set('simpleCache', $data['simpleCache']);
$this->_handleCustomPreloadedData($data);
XenForo_CodeEvent::fire('init_dependencies', array($this, $data));
}