本文整理汇总了PHP中JEventDispatcher::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP JEventDispatcher::getInstance方法的具体用法?PHP JEventDispatcher::getInstance怎么用?PHP JEventDispatcher::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JEventDispatcher
的用法示例。
在下文中一共展示了JEventDispatcher::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: displayRows
/**
* Method to display the layout of search results
*
* @return void
*/
public function displayRows()
{
// Run events
$params = new JRegistry();
$params->set('ksource', 'kunena');
$params->set('kunena_view', 'search');
$params->set('kunena_layout', 'default');
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('kunena');
$dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->results, &$params, 0));
foreach ($this->results as $this->message) {
$this->topic = $this->message->getTopic();
$this->category = $this->message->getCategory();
$this->categoryLink = $this->getCategoryLink($this->category->getParent()) . ' / ' . $this->getCategoryLink($this->category);
$ressubject = KunenaHtmlParser::parseText($this->message->subject);
$resmessage = KunenaHtmlParser::parseBBCode($this->message->message, 500);
$profile = KunenaFactory::getUser((int) $this->message->userid);
$this->useravatar = $profile->getAvatarImage('kavatar', 'post');
foreach ($this->searchwords as $searchword) {
if (empty($searchword)) {
continue;
}
$ressubject = preg_replace("/" . preg_quote($searchword, '/') . "/iu", '<span class="searchword" >' . $searchword . '</span>', $ressubject);
// FIXME: enable highlighting, but only after we can be sure that we do not break html
// $resmessage = preg_replace ( "/" . preg_quote ( $searchword, '/' ) . "/iu", '<span class="searchword" >' . $searchword . '</span>', $resmessage );
}
$this->author = $this->message->getAuthor();
$this->topicAuthor = $this->topic->getAuthor();
$this->topicTime = $this->topic->first_post_time;
$this->subjectHtml = $ressubject;
$this->messageHtml = $resmessage;
$contents = $this->subLayout('Search/Results/Row')->setProperties($this->getProperties());
echo $contents;
}
}
示例2: DefaultViewHelperFooter16
function DefaultViewHelperFooter16($view)
{
if (JRequest::getInt('pop', 0)) {
?>
<div class="ev_noprint"><p align="center">
<a href="#close" onclick="if (window.parent==window){self.close();} else {try {window.parent.jQuery('#myEditModal').modal('hide');}catch (e){}try {window.parent.SqueezeBox.close(); return false;} catch(e) {self.close();return false;}}" title="<?php
echo JText::_('JEV_CLOSE');
?>
"><?php
echo JText::_('JEV_CLOSE');
?>
</a>
</p></div>
<?php
}
$view->loadHelper("JevViewCopyright");
JevViewCopyright();
?>
</div>
</div> <!-- close #jevents //-->
<?php
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onJEventsFooter');
$task = JRequest::getString("jevtask");
$view->loadModules("jevpostjevents");
$view->loadModules("jevpostjevents_" . $task);
JEVHelper::componentStylesheet($view, "extra.css");
jimport('joomla.filesystem.file');
// Lets check if we have editted before! if not... rename the custom file.
if (JFile::exists(JPATH_SITE . "/components/com_jevents/assets/css/jevcustom.css")) {
// It is definitely now created, lets load it!
JEVHelper::stylesheet('jevcustom.css', 'components/' . JEV_COM_COMPONENT . '/assets/css/');
}
}
示例3: display
public function display($tpl = null)
{
$app = JFactory::getApplication();
/** @var $app JApplicationSite */
$this->option = JFactory::getApplication()->input->getCmd('option');
$this->state = $this->get('State');
$this->item = $this->get('Item');
$this->params = $this->state->get('params');
$this->category = new Userideas\Category\Category(JFactory::getDbo());
$this->category->load($this->item->catid);
$user = JFactory::getUser();
$this->userId = $user->get('id');
// Set permission state. Is it possible to be edited items?
$this->canEdit = $user->authorise('core.edit.own', 'com_userideas');
$this->commentsEnabled = $this->params->get('comments_enabled', 1);
$this->canComment = $user->authorise('userideas.comment.create', 'com_userideas');
$this->canEditComment = $user->authorise('userideas.comment.edit.own', 'com_userideas');
// Get the model of the comments
// that I will use to load all comments for this item.
$modelComments = JModelLegacy::getInstance('Comments', 'UserIdeasModel');
$this->comments = $modelComments->getItems();
// Get the model of the comment
$commentModelForm = JModelLegacy::getInstance('Comment', 'UserIdeasModel');
// Validate the owner of the comment,
// If someone wants to edit it.
$commentId = (int) $commentModelForm->getState('comment_id');
if ($commentId > 0) {
$comment = $commentModelForm->getItem($commentId, $this->userId);
if (!$comment) {
$app->enqueueMessage(JText::_('COM_USERIDEAS_ERROR_INVALID_COMMENT'), 'error');
$app->redirect(JRoute::_(UserIdeasHelperRoute::getItemsRoute(), false));
return;
}
}
// Get comment form
$this->form = $commentModelForm->getForm();
// Prepare integration. Load avatars and profiles.
$this->prepareIntegration($this->params);
// Prepare the link to the details page.
$this->item->link = UserIdeasHelperRoute::getDetailsRoute($this->item->slug, $this->item->catslug);
$this->item->text = $this->item->description;
$this->prepareDebugMode();
$this->prepareDocument();
// Events
JPluginHelper::importPlugin('content');
$dispatcher = JEventDispatcher::getInstance();
$this->item->event = new stdClass();
$offset = 0;
$dispatcher->trigger('onContentPrepare', array('com_userideas.details', &$this->item, &$this->params, $offset));
$results = $dispatcher->trigger('onContentBeforeDisplay', array('com_userideas.details', &$this->item, &$this->params, $offset));
$this->item->event->beforeDisplayContent = trim(implode("\n", $results));
$results = $dispatcher->trigger('onContentAfterDisplay', array('com_userideas.details', &$this->item, &$this->params, $offset));
$this->item->event->onContentAfterDisplay = trim(implode("\n", $results));
$this->item->description = $this->item->text;
unset($this->item->text);
// Count hits
$model = $this->getModel();
$model->hit($this->item->id);
parent::display($tpl);
}
示例4: sendMemberDaytimeToAdmin
function sendMemberDaytimeToAdmin($member_id, $service_id, $daytime_id)
{
define("BodyMemberDaytimeToAdmin", "<h1>Nouvelle inscription à une tranche horaire</h1><p>Un bénévole s'est inscrit à un secteur / tranche horaire.</p><p><strong>Nom :</strong> %s <br /><strong>Secteur :</strong> %s<br /><strong>Date :</strong> %s<br /><strong>Tranche horaire :</strong> %s</p><p><a href=\"" . JURI::root() . "/administrator/index.php?option=com_estivole&view=member&layout=edit&member_id=%s\">Cliquez ici</a> pour valider l'inscription et/ou recontacter le bénévole.</p>");
define("SubjectMemberDaytimeToAdmin", "Nouvelle inscription à une tranche horaire");
$db = JFactory::getDBO();
$query = $db->getQuery(TRUE);
$this->user = JFactory::getUser();
// Get the dispatcher and load the user's plugins.
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('user');
$data = new JObject();
$data->id = $this->user->id;
// Trigger the data preparation event.
$dispatcher->trigger('onContentPrepareData', array('com_users.profilestivole', &$data));
$userProfilEstivole = $data;
$userName = $userProfilEstivole->profilestivole['firstname'] . ' ' . $userProfilEstivole->profilestivole['lastname'];
$query->select('*');
$query->from('#__estivole_members as b, #__estivole_services as s, #__estivole_daytimes as d');
$query->where('b.member_id = ' . (int) $member_id);
$query->where('s.service_id = ' . (int) $service_id);
$query->where('d.daytime_id = ' . (int) $daytime_id);
$db->setQuery($query);
$mailModel = $db->loadObject();
$mail = JFactory::getMailer();
$mail->setBody(sprintf(constant("BodyMemberDaytimeToAdmin"), $userName, $mailModel->service_name, date('d-m-Y', strtotime($mailModel->daytime_day)), date('H:i', strtotime($mailModel->daytime_hour_start)) . ' - ' . date('H:i', strtotime($mailModel->daytime_hour_end)), $mailModel->member_id));
$mail->setSubject(constant("SubjectMemberDaytimeToAdmin"));
$mail->isHtml();
$recipient = array('benevoles@estivale.ch', $mailModel->email_responsable);
$mail->addRecipient($recipient);
$mail->Send('estivole@estivale.ch');
}
示例5: attendeetoggle
/**
* toggletask
*/
function attendeetoggle()
{
$jinput = JFactory::getApplication()->input;
$id = $jinput->getInt('id');
$fid = $jinput->getInt('Itemid');
$model = $this->getModel('attendee');
$model->setId($id);
$attendee = $model->getData();
$res = $model->toggle();
$type = 'message';
if ($res) {
JPluginHelper::importPlugin('jem');
$dispatcher = JEventDispatcher::getInstance();
$res = $dispatcher->trigger('onUserOnOffWaitinglist', array($id));
if ($attendee->waiting) {
$msg = JText::_('COM_JEM_ADDED_TO_ATTENDING');
} else {
$msg = JText::_('COM_JEM_ADDED_TO_WAITING');
}
} else {
$msg = JText::_('COM_JEM_WAITINGLIST_TOGGLE_ERROR') . ': ' . $model->getError();
$type = 'error';
}
$this->setRedirect(JRoute::_('index.php?option=com_jem&view=attendees&id=' . $attendee->event . '&Itemid=' . $fid, false), $msg, $type);
$this->redirect();
}
示例6: testGetInstance
/**
* Tests the JEventDispatcher::getInstance method.
*
* @return void
*
* @since 11.3
* @covers JEventDispatcher::getInstance
*/
public function testGetInstance()
{
$mock = JEventDispatcher::getInstance();
$this->assertInstanceOf(
'JEventDispatcherInspector',
$mock
);
$this->object->setInstance(null);
$instance = JEventDispatcher::getInstance();
$this->assertInstanceOf(
'JEventDispatcher',
$instance,
'Tests that getInstance returns a JEventDispatcher object.'
);
// Push a new instance into the class.
JEventDispatcherInspector::setInstance('foo');
$this->assertThat(
JEventDispatcher::getInstance(),
$this->equalTo('foo'),
'Tests that a subsequent call to JEventDispatcher::getInstance returns the cached singleton.'
);
JEventDispatcherInspector::setInstance($mock);
}
示例7: showEndForm
function showEndForm($pmconfigs, $order)
{
$jshopConfig = JSFactory::getConfig();
$pm_method = $this->getPmMethod();
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->clear();
$query->update('#__jshopping_orders')->set($db->quoteName('order_created') . ' = 1 ')->where($db->quoteName('order_id') . ' = ' . (int) $order->order_id);
$db->setQuery($query);
echo '<div id="begateway_erip">';
try {
$db->execute();
$model = JSFactory::getModel('orderMail', 'jshop');
$model->setData($order->order_id, 0);
$model->send();
if ($pmconfigs['auto'] == '1') {
JPluginHelper::importPlugin('PlgSystemJoomShoppingErip');
$dispatcher = JEventDispatcher::getInstance();
$result = $dispatcher->trigger('onBeforeChangeOrderStatusAdmin', array($order->order_id, $this->getStatusId(), 'auto'));
if (!$result) {
throw new Exception(JText::_('PLG_JSERIPPAYMENT_ORDER_ERROR'));
}
$instruction = JText::_('PLG_JSERIPPAYMENT_ERIP_INSTRUCTION');
$instruction = str_replace('#TABS#', '<strong>' . $pmconfigs['tree_path_email'] . '</strong>', $instruction);
$instruction = str_replace('#ORDER_ID#', '<strong>' . $order->order_id . '</strong>', $instruction);
echo nl2br($instruction);
} else {
echo nl2br(JText::_('PLG_JSERIPPAYMENT_ORDER_CONFIRMATION'));
}
} catch (RuntimeException $e) {
echo JText::_('PLG_JSERIPPAYMENT_ORDER_ERROR');
}
echo '</div>';
}
示例8: addSubmenu
/**
* Configure the Link bar.
*
* @param string $vName The name of the active view.
*
* @return void
*/
public static function addSubmenu($vName)
{
JHtmlSidebar::addEntry(JText::_('COM_FBIMPORTER_TOOL'), 'index.php?option=com_fbimporter&view=items', $vName == 'items');
JHtmlSidebar::addEntry(JText::_('COM_FBIMPORTER_FORMAT_SETTING'), 'index.php?option=com_fbimporter&view=formats', $vName == 'formats');
$dispatcher = \JEventDispatcher::getInstance();
$dispatcher->trigger('onAfterAddSubmenu', array('com_fbimporter', $vName));
}
示例9: getDispatcher
/**
* Get the event dispatcher
*
* @return JEventDispatcher
*/
public static function getDispatcher()
{
if (!self::$dispatcher) {
self::$dispatcher = version_compare(JVERSION, '3.0', 'lt') ? JDispatcher::getInstance() : JEventDispatcher::getInstance();
}
return self::$dispatcher;
}
示例10: saveScore
public function saveScore($game_id, $game_title, $userid, $username, $score, $highestscore, $trigger)
{
$app = JFactory::getApplication();
$player_ip = $app->input->server->get('REMOTE_ADDR', '0.0.0.0', 'raw');
$res = 0;
if ($highestscore != 0) {
$this->dbo->setQuery('SELECT id FROM #__jvarcade ' . ' WHERE ' . $this->dbo->quoteName('gameid') . ' = ' . $this->dbo->Quote($game_id) . ' AND ' . $this->dbo->quoteName('userid') . ' = ' . $this->dbo->Quote($userid));
$scoreid = (int) $this->dbo->loadResult();
$this->dbo->setQuery('UPDATE #__jvarcade SET ' . $this->dbo->quoteName('score') . ' = ' . $this->dbo->Quote($score) . ', ' . $this->dbo->quoteName('ip') . ' = ' . $this->dbo->Quote($player_ip) . ', ' . $this->dbo->quoteName('date') . ' = ' . $this->dbo->Quote(date('Y-m-d H:i:s')) . ' WHERE ' . $this->dbo->quoteName('id') . ' = ' . $this->dbo->Quote($scoreid));
if (!$scoreid || !$this->dbo->execute()) {
$res = 0;
} else {
$res = 1;
}
} elseif ($highestscore == 0 || $highestscore == false) {
$this->dbo->setQuery('INSERT INTO #__jvarcade (' . $this->dbo->quoteName('userid') . ', ' . $this->dbo->quoteName('score') . ', ' . $this->dbo->quoteName('ip') . ', ' . $this->dbo->quoteName('gameid') . ', ' . $this->dbo->quoteName('date') . ') ' . ' VALUES (' . $this->dbo->Quote($userid) . ',' . $this->dbo->Quote($score) . ',' . $this->dbo->Quote($player_ip) . ',' . $this->dbo->Quote($game_id) . ',' . $this->dbo->Quote(date('Y-m-d H:i:s')) . ')');
if (!$this->dbo->execute()) {
$res = 0;
} else {
$scoreid = $this->dbo->insertid();
$res = 1;
}
} else {
$res = 1;
}
if ($res == 1) {
$this->setUpdateLeaderBoard();
if ($trigger) {
$dispatcher = JEventDispatcher::getInstance();
// trigger the contest score event
$dispatcher->trigger('onPUAScoreSaved', array($game_id, $game_title, $userid, $username, $score));
}
}
return $res;
}
示例11: onAfterRender
function onAfterRender()
{
if (class_exists('JEventDispatcher', false)) {
$dispatcher = JEventDispatcher::getInstance();
} else {
$dispatcher = JDispatcher::getInstance();
}
$dispatcher->trigger('onNextendBeforeCompileHead');
ob_start();
if (class_exists('N2AssetsManager')) {
echo N2AssetsManager::getCSS();
echo N2AssetsManager::getJs();
}
$head = ob_get_clean();
if ($head != '') {
$application = JFactory::getApplication();
if (class_exists('JApplicationWeb') && method_exists($application, 'getBody')) {
$body = $application->getBody();
$mode = 'JApplicationWeb';
} else {
$body = JResponse::getBody();
$mode = 'JResponse';
}
$body = preg_replace('/<\\/head>/', $head . '</head>', $body, 1);
switch ($mode) {
case 'JResponse':
JResponse::setBody($body);
break;
default:
$application->setBody($body);
}
}
}
示例12: getGuildPlugin
public static function getGuildPlugin($guild_id)
{
if (array_key_exists($guild_id, self::$rp_plugin) && self::$rp_plugin[$guild_id]->guild_id == $guild_id) {
return self::$rp_plugin[$guild_id];
} else {
$db = JFactory::getDBO();
$query = "SELECT guild_id, guild_name, sync_plugin, params FROM #__raidplanner_guild WHERE guild_id=" . intval($guild_id);
$db->setQuery($query);
if ($guild = $db->loadObject()) {
$guild->params = json_decode($guild->params, true);
if (JPluginHelper::importPlugin('raidplanner', $guild->sync_plugin)) {
/* Plugin loaded */
if (self::getJVersion() < '3.0') {
$plugin = JDispatcher::getInstance();
} else {
$plugin = JEventDispatcher::getInstance();
}
$plugin->trigger('onRPInitGuild', array($guild_id, $guild->params));
self::$rp_plugin[$guild_id] = $plugin;
return self::$rp_plugin[$guild_id];
}
} else {
return false;
}
}
}
示例13: before
/**
* Prepare reply history display.
*
* @return void
*/
protected function before()
{
parent::before();
$id = $this->input->getInt('id');
$this->topic = KunenaForumTopicHelper::get($id);
$this->history = KunenaForumMessageHelper::getMessagesByTopic($this->topic, 0, (int) $this->config->historylimit, 'DESC');
$this->replycount = $this->topic->getReplies();
$this->historycount = count($this->history);
KunenaAttachmentHelper::getByMessage($this->history);
$userlist = array();
foreach ($this->history as $message) {
$userlist[(int) $message->userid] = (int) $message->userid;
}
KunenaUserHelper::loadUsers($userlist);
// Run events
$params = new JRegistry();
$params->set('ksource', 'kunena');
$params->set('kunena_view', 'topic');
$params->set('kunena_layout', 'history');
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('kunena');
$dispatcher->trigger('onKunenaPrepare', array('kunena.messages', &$this->history, &$params, 0));
// FIXME: need to improve BBCode class on this...
$this->attachments = KunenaAttachmentHelper::getByMessage($this->history);
$this->inline_attachments = array();
$this->headerText = JText::_('COM_KUNENA_POST_EDIT') . ' ' . $this->topic->subject;
}
示例14: getTypeOptions
/**
* Method to get the available menu item type options.
*
* @return array Array of groups with menu item types.
* @since 1.6
*/
public function getTypeOptions()
{
jimport('joomla.filesystem.file');
$lang = JFactory::getLanguage();
$list = array();
// Get the list of components.
$db = JFactory::getDbo();
$query = $db->getQuery(true)->select('name, element AS ' . $db->quoteName('option'))->from('#__extensions')->where('type = ' . $db->quote('component'))->where('enabled = 1')->order('name ASC');
$db->setQuery($query);
$components = $db->loadObjectList();
foreach ($components as $component) {
if ($options = $this->getTypeOptionsByComponent($component->option)) {
$list[$component->name] = $options;
// Create the reverse lookup for link-to-name.
foreach ($options as $option) {
if (isset($option->request)) {
$this->addReverseLookupUrl($option);
if (isset($option->request['option'])) {
$lang->load($option->request['option'] . '.sys', JPATH_ADMINISTRATOR, null, false, true) || $lang->load($option->request['option'] . '.sys', JPATH_ADMINISTRATOR . '/components/' . $option->request['option'], null, false, true);
}
}
}
}
}
// Allow a system plugin to insert dynamic menu types to the list shown in menus:
JEventDispatcher::getInstance()->trigger('onAfterGetMenuTypeOptions', array(&$list, $this));
return $list;
}
示例15: pluginAjax
/**
* Ajax action called from element
* 11/07/2011 - I've updated things so that any plugin ajax call uses 'view=plugin' rather than controller=plugin
* this means that the controller used is now plugin.php and not plugin.raw.php
*
* @return null
*/
public function pluginAjax()
{
$app = JFactory::getApplication();
$input = $app->input;
$plugin = $input->get('plugin', '');
$method = $input->get('method', '');
$group = $input->get('g', 'element');
$pluginManager = FabrikWorker::getPluginManager();
try {
// First lets try the fabrik plugin manager - needed when loading namespaced plugins
$pluginManager->loadPlugIn($plugin, $group);
} catch (Exception $e) {
if (!JPluginHelper::importPlugin('fabrik_' . $group, $plugin)) {
$o = new stdClass();
$o->err = 'unable to import plugin fabrik_' . $group . ' ' . $plugin;
echo json_encode($o);
return;
}
}
if (substr($method, 0, 2) !== 'on') {
$method = 'on' . JString::ucfirst($method);
}
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger($method);
}