本文整理汇总了PHP中XenForo_CodeEvent::fire方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_CodeEvent::fire方法的具体用法?PHP XenForo_CodeEvent::fire怎么用?PHP XenForo_CodeEvent::fire使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_CodeEvent
的用法示例。
在下文中一共展示了XenForo_CodeEvent::fire方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupRoutes
/**
* Setups all default routes for [bd] Api. Also fires the code event
* `api_setup_routes` and let any other add-ons to setup extra
* routes for the system.
*
* @param array $routes the target routes array
*/
public static function setupRoutes(array &$routes)
{
self::addRoute($routes, 'index', 'bdApi_Route_PrefixApi_Index');
self::addRoute($routes, 'oauth', 'bdApi_Route_PrefixApi_OAuth');
self::addRoute($routes, 'categories', 'bdApi_Route_PrefixApi_Categories', 'data_only');
self::addRoute($routes, 'conversations', 'bdApi_Route_PrefixApi_Conversations', 'data_only');
self::addRoute($routes, 'conversation-messages', 'bdApi_Route_PrefixApi_ConversationMessages', 'data_only');
self::addRoute($routes, 'forums', 'bdApi_Route_PrefixApi_Forums', 'data_only');
self::addRoute($routes, 'navigation', 'bdApi_Route_PrefixApi_Navigation');
self::addRoute($routes, 'notifications', 'bdApi_Route_PrefixApi_Notifications');
self::addRoute($routes, 'pages', 'bdApi_Route_PrefixApi_Pages', 'data_only');
self::addRoute($routes, 'posts', 'bdApi_Route_PrefixApi_Posts', 'data_only');
self::addRoute($routes, 'profile-posts', 'bdApi_Route_PrefixApi_ProfilePosts', 'data_only');
self::addRoute($routes, 'tags', 'bdApi_Route_PrefixApi_Tags');
self::addRoute($routes, 'threads', 'bdApi_Route_PrefixApi_Threads', 'data_only');
self::addRoute($routes, 'users', 'bdApi_Route_PrefixApi_Users', 'data_only');
self::addRoute($routes, 'search', 'bdApi_Route_PrefixApi_Search', 'data_only');
self::addRoute($routes, 'assets', 'bdApi_Route_PrefixApi_Assets');
self::addRoute($routes, 'batch', 'bdApi_Route_PrefixApi_Batch');
self::addRoute($routes, 'subscriptions', 'bdApi_Route_PrefixApi_Subscriptions');
self::addRoute($routes, 'tools', 'bdApi_Route_PrefixApi_Tools');
// backward compatibility
self::addRoute($routes, 'all-threads', 'bdApi_Route_PrefixApi_Threads');
XenForo_CodeEvent::fire('api_setup_routes', array(&$routes));
}
示例2: __construct
public function __construct()
{
$renderers = array();
$this->_registerDefaultRenderers($renderers);
XenForo_CodeEvent::fire('widget_framework_ready', array(&$renderers));
foreach ($renderers as $renderer) {
$this->_renderers[] = $renderer;
}
}
示例3: renderTree
public function renderTree(array $tree, array $extraStates = array())
{
if (XenForo_Application::get('options')->get('Bbm_PreCache_Enable')) {
if (!empty($extraStates['bbmPreCacheInit']) && !$this->_bbmPreCacheDone) {
parent::renderTree($tree, $extraStates);
unset($extraStates['bbmPreCacheInit']);
XenForo_CodeEvent::fire('bbm_callback_precache', array(&$this->_bbmPreCache, &$extraStates, 'wysiwyg'));
XenForo_Application::set('bbm_preCache_wysiwyg', array($this->_bbmPreCache, $extraStates));
$this->_bbmPreCacheDone = true;
return '';
}
if (XenForo_Application::isRegistered('bbm_preCache_wysiwyg')) {
list($_bbmPreCache, $_extraStates) = XenForo_Application::get('bbm_preCache_wysiwyg');
$this->_bbmPreCache = $_bbmPreCache;
$extraStates['bbmPreCacheComplete'] = true;
$extraStates += $_extraStates;
}
}
return parent::renderTree($tree, $extraStates);
}
示例4: controllerPostDispatch
/**
* Get the data and determine if we need to change the response code to 410.
*
* @param XenForo_Controller $controller
* @param XenForo_ControllerResponse_Abstract|false $controllerResponse
* @param string $controllerName
* @param string $action
*
* @throws XenForo_Exception
*/
public static final function controllerPostDispatch(XenForo_Controller $controller, $controllerResponse, $controllerName, $action)
{
if ($controller instanceof XenForo_ControllerPublic_Abstract && $controllerResponse instanceof XenForo_ControllerResponse_Error && $controllerResponse->responseCode == 404) {
$data = array();
XenForo_CodeEvent::fire('410_gone_data', array(&$data, $controller, $controllerName, $action));
$table = $field = '';
foreach ($data as $_controllerName => $info) {
if ($_controllerName == $controllerName) {
list($table, $field) = $info;
break;
}
}
if (($id = $controller->getInput()->filterSingle($field, XenForo_Input::UINT)) && $table && $field) {
$db = XenForo_Application::getDb();
try {
if (!$db->fetchOne("SELECT {$field} FROM {$table} WHERE {$field} = ?", $id) && $db->fetchOne("SELECT COUNT(*) FROM {$table} WHERE {$field} > ?", $id) > 0) {
$controllerResponse->responseCode = 410;
}
} catch (Throwable $e) {
XenForo_Error::logException($e, false, "410 Query Failed (Field: {$field}, Table: {$table}): ");
}
}
}
}
示例5: postDispatch
/**
* This function is called immediately after an action is dispatched.
*
* @param mixed The response from the controller. Generally, a XenForo_ControllerResponse_Abstract object.
* @param string The name of the final controller that was invoked
* @param string The name of the final action that was invoked
*/
public final function postDispatch($controllerResponse, $controllerName, $action)
{
$this->updateSession($controllerResponse, $controllerName, $action);
$this->updateSessionActivity($controllerResponse, $controllerName, $action);
$this->_postDispatchType($controllerResponse, $controllerName, $action);
$this->_postDispatch($controllerResponse, $controllerName, $action);
XenForo_CodeEvent::fire('controller_post_dispatch', array($this, $controllerResponse, $controllerName, $action), $controllerName);
}
示例6: export
public function export($overwrite = false)
{
if (!$this->_addOnId) {
throw new XenForo_Exception('Please specify an add-on id.');
}
$filename = str_replace('_', '/', $this->_className) . '.php';
$existingContents = '';
$fullFilename = XenForo_Autoloader::getInstance()->getRootDir() . '/' . $filename;
if (file_exists($fullFilename)) {
$existingContents = file_get_contents($fullFilename);
$existingContentsArray = preg_split('/(\\r\\n|\\n|\\r)/', $existingContents);
foreach ($existingContentsArray as $key => $value) {
if (rtrim($value) != $value) {
$existingContentsArray[$key] = rtrim($value);
}
}
$existingContents = implode("\n", $existingContentsArray);
$existingContents = str_replace("\t", ' ', $existingContents);
file_put_contents($fullFilename, $existingContents);
$existingPhpFile = self::createFromContents($this->_className, $existingContents);
} else {
if (!file_exists(dirname($fullFilename))) {
XenForo_Helper_File::createDirectory(dirname($fullFilename));
}
$existingPhpFile = self::createFromContents($this->_className);
}
$contents = $this->getHeader();
$this->mergeConstants($existingPhpFile->getConstants());
if (isset($this->_constants) && !empty($this->_constants)) {
foreach ($this->_constants as $constantName => $constant) {
$contents .= $constant->getPhpDocAsString();
$contents .= "\n\t";
$contents .= 'const ' . $constant->getConstantName() . ' = ' . $constant->getValue() . ';' . "\n";
}
}
$this->mergeVariables($existingPhpFile->getVariables());
if (isset($this->_variables) && !empty($this->_variables)) {
/* @var $variable ThemeHouse_PhpFile_Variable */
foreach ($this->_variables as $variableName => $variable) {
$contents .= $variable->getPhpDocAsString();
$contents .= "\n\t";
$contents .= $variable->getFullSignatureAsString() . ' = ' . $variable->getValue() . ';' . "\n";
}
}
$this->mergeFunctions($existingPhpFile->getFunctions());
if (isset($this->_functions) && !empty($this->_functions)) {
/* @var $function ThemeHouse_PhpFile_Function */
foreach ($this->_functions as $functionName => $function) {
$contents .= $function->getPhpDocAsString();
$contents .= "\n\t";
$contents .= $function->getFullSignatureAsString();
$contents .= "\n\t{";
$contents .= $function->getBodyAsString();
$contents .= "\n\t}\n";
}
}
$contents .= "}";
$export = XenForo_CodeEvent::fire('phpfile_export_th', array(&$filename, &$contents, $existingContents, $overwrite, $this->_addOnId));
if ($export) {
if (!file_exists(dirname(XenForo_AutoLoader::getInstance()->getRootDir() . '/' . $filename))) {
mkdir(dirname(XenForo_AutoLoader::getInstance()->getRootDir() . '/' . $filename), 0, true);
}
file_put_contents(XenForo_AutoLoader::getInstance()->getRootDir() . '/' . $filename, $contents);
}
}
示例7: preDispatch
/**
* This function is called immediately before an action is dispatched.
*
* @param string Action that is requested
*/
public final function preDispatch($action)
{
$this->_preDispatchFirst($action);
$this->_setupSession($action);
$this->_checkCsrf($action);
$this->_handlePost($action);
$this->_preDispatchType($action);
$this->_preDispatch($action);
XenForo_CodeEvent::fire('controller_pre_dispatch', array($this, $action));
}
示例8: 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));
}
示例9: resolveDynamicClass
/**
* Resolves dynamic, run time inheritance for the specified class.
* The classes to be loaded for this base class are grabbed via the event.
* These classes must inherit from from XFCP_x, which is a non-existant
* class that is dynamically created, inheriting from the correct class
* as needed.
*
* If a fake base is needed when the base class doesn't exist, and there
* are no classes extending it, false will still be returned! This prevents
* an unnecessary eval.
*
* @param string $class Name of class
* @param string $type Type of class (for determining event to fire)
* @param string|false $fakeBase If the specified class doesn't exist, an alternative base can be specified
*
* @return false|string False or name of class to instantiate
*/
public static function resolveDynamicClass($class, $type, $fakeBase = false)
{
if (!XenForo_Application::autoload($class)) {
if ($fakeBase) {
$fakeNeeded = true;
} else {
return false;
}
} else {
$fakeNeeded = false;
}
if (!empty(self::$_classCache[$class])) {
return self::$_classCache[$class];
}
$createClass = $class;
$extend = array();
XenForo_CodeEvent::fire('load_class_' . $type, array($class, &$extend));
if ($fakeNeeded) {
if (!$extend) {
return false;
}
eval('class ' . $class . ' extends ' . $fakeBase . ' {}');
}
if ($extend) {
try {
foreach ($extend as $dynamicClass) {
// XenForo Class Proxy, in case you're wondering
$proxyClass = 'XFCP_' . $dynamicClass;
eval('class ' . $proxyClass . ' extends ' . $createClass . ' {}');
XenForo_Application::autoload($dynamicClass);
$createClass = $dynamicClass;
}
} catch (Exception $e) {
self::$_classCache[$class] = $class;
throw $e;
}
}
self::$_classCache[$class] = $createClass;
return $createClass;
}
示例10: pageMatchesCriteria
/**
* Determines if the given page matches the criteria. The provided page data takes the form of
* $params and $containerData from XenForo_ViewRenderer_HtmlPublic::_getNoticesContainerParams().
*
* @param array|string $criteria List of criteria, format: [] with keys rule and data; may be serialized
* @param boolean $matchOnEmpty If true and there's no criteria, true is returned; otherwise, false
* @param array $params
* @param array $containerData
*
* @return boolean
*/
public static function pageMatchesCriteria($criteria, $matchOnEmpty = false, array $params, array $containerData)
{
if (!($criteria = self::unserializeCriteria($criteria))) {
return (bool) $matchOnEmpty;
}
foreach ($criteria as $criterion) {
$data = $criterion['data'];
switch ($criterion['rule']) {
// browsing within one of the specified nodes
case 'nodes':
if (!isset($containerData['navigation']) || !is_array($containerData['navigation'])) {
return false;
}
if (empty($data['node_ids'])) {
return false;
// no node ids specified
}
if (empty($data['node_only'])) {
foreach ($containerData['navigation'] as $i => $navItem) {
if (isset($navItem['node_id']) && in_array($navItem['node_id'], $data['node_ids'])) {
break 2;
// break out of case 'nodes'...
}
}
}
if (isset($containerData['quickNavSelected'])) {
$quickNavSelected = $containerData['quickNavSelected'];
} else {
$quickNavSelected = false;
foreach ($containerData['navigation'] as $i => $navItem) {
if (isset($navItem['node_id'])) {
$quickNavSelected = 'node-' . $navItem['node_id'];
}
}
}
if ($quickNavSelected && in_array(preg_replace('/^.+-(\\d+)$/', '$1', $quickNavSelected), $data['node_ids'])) {
break 1;
}
return false;
break;
// browsing within the specified controller (and action)
// browsing within the specified controller (and action)
case 'controller':
if (!isset($params['controllerName']) || strtolower($params['controllerName']) != strtolower($data['name'])) {
return false;
}
if (!empty($data['action']) && isset($params['controllerAction'])) {
if (strtolower($params['controllerAction']) != strtolower($data['action'])) {
return false;
}
}
break;
// browsing within the specified view
// browsing within the specified view
case 'view':
if (!isset($params['viewName']) || strtolower($params['viewName']) != strtolower($data['name'])) {
return false;
}
break;
// viewing the specified content template
// viewing the specified content template
case 'template':
if (!isset($params['contentTemplate']) || strtolower($params['contentTemplate']) != strtolower($data['name'])) {
return false;
}
break;
// browsing within the specified tab
// browsing within the specified tab
case 'tab':
if (!isset($params['selectedTabId']) || strtolower($params['selectedTabId']) != strtolower($data['id'])) {
return false;
}
break;
// unknown criteria, assume failed unless something from a code event takes it
// unknown criteria, assume failed unless something from a code event takes it
default:
$eventReturnValue = false;
XenForo_CodeEvent::fire('criteria_page', array($criterion['rule'], $data, $params, $containerData, &$eventReturnValue));
if ($eventReturnValue === false) {
return false;
}
}
}
return true;
}
示例11: 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));
}
示例12: setup
/**
* Setup the visitor singleton.
*
* @param integer $userId User ID to setup as
* @param array $options
*
* @return XenForo_Visitor
*/
public static function setup($userId, array $options = array())
{
$userId = intval($userId);
$options = array_merge(array('languageId' => 0, 'permissionUserId' => 0), $options);
/* @var $userModel XenForo_Model_User */
$userModel = XenForo_Model::create('XenForo_Model_User');
$object = new self();
if ($userId && ($user = $userModel->getVisitingUserById($userId))) {
if ($user['is_admin'] && $options['permissionUserId']) {
// force permissions for testing
$user = $userModel->setPermissionsFromUserId($user, $options['permissionUserId']);
}
$object->_user = $user;
} else {
$object->_user = $userModel->getVisitingGuestUser();
if ($options['languageId']) {
$object->_user['language_id'] = $options['languageId'];
}
}
$object->_user['referer'] = !empty($options['referer']) ? $options['referer'] : null;
$object->_user['from_search'] = !empty($options['fromSearch']);
$object->_user['is_robot'] = !empty($options['isRobot']);
$object->_user['permissions'] = XenForo_Permission::unserializePermissions($object->_user['global_permission_cache']);
$object->setVisitorLanguage($object->_user['language_id']);
XenForo_Locale::setDefaultTimeZone($object->_user['timezone']);
self::$_instance = $object;
XenForo_CodeEvent::fire('visitor_setup', array(&self::$_instance));
return self::$_instance;
}
示例13: preLoadTemplates
public function preLoadTemplates(XenForo_View $view)
{
//Preload Bbm Templates
$bbmListenerTemplateCache = array();
XenForo_CodeEvent::fire('bbm_callback_template_cache', array(&$bbmListenerTemplateCache));
if (!empty($bbmListenerTemplateCache) && is_array($bbmListenerTemplateCache) && is_array($this->_preloadBbmTemplates)) {
$this->_preloadBbmTemplates = array_unique(array_merge($this->_preloadBbmTemplates, $bbmListenerTemplateCache));
}
if ($this->_view && is_array($this->_preloadBbmTemplates)) {
foreach ($this->_preloadBbmTemplates as $templateName) {
$this->_view->preLoadTemplate($templateName);
}
}
$this->_view->preLoadTemplate('bbm_viewer_content_protected');
return parent::preLoadTemplates($view);
}
示例14: renderOption
/**
* Renders the captcha option.
*
* @param XenForo_View $view View object
* @param string $fieldPrefix Prefix for the HTML form field name
* @param array $preparedOption Prepared option info
* @param boolean $canEdit True if an "edit" link should appear
*
* @return XenForo_Template_Abstract Template object
*/
public static function renderOption(XenForo_View $view, $fieldPrefix, array $preparedOption, $canEdit)
{
$preparedOption['extraChoices'] = array();
XenForo_CodeEvent::fire('option_captcha_render', array(&$preparedOption['extraChoices'], $view, $preparedOption));
return XenForo_ViewAdmin_Helper_Option::renderOptionTemplateInternal('option_template_captcha', $view, $fieldPrefix, $preparedOption, $canEdit);
}
示例15: prepareField
public function prepareField(array $field)
{
XenForo_CodeEvent::fire('prepare_user_change_log_field', array($this, &$field));
$field = $this->_getHelper()->prepareField($field);
return array('field' => $field['field'], 'name' => $field['name'], 'old_value' => $field['old_value'], 'new_value' => $field['new_value']);
}