コード例 #1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return  void
  *
  * @since   3.6
  */
 protected function setUp()
 {
     parent::setUp();
     $this->saveFactoryState();
     JFactory::$application = $this->getMockCmsApp();
     JFactory::$session = $this->getMockSession();
     $this->dispatcher = new JEventDispatcher();
     TestReflection::setValue($this->dispatcher, 'instance', $this->dispatcher);
     $this->dispatcher->register('onAfterRenderModules', array($this, 'eventCallback'));
 }
コード例 #2
0
ファイル: attendees.php プロジェクト: JKoelman/JEM-3
 /**
  * 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();
 }
コード例 #3
0
 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>';
 }
コード例 #4
0
 /**
  * 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));
 }
コード例 #5
0
ファイル: scores.php プロジェクト: Tfrez/jVarcade
 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;
 }
コード例 #6
0
ファイル: view.html.php プロジェクト: sankam-nikolya/lptt
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $user = JFactory::getUser();
     $dispatcher = JEventDispatcher::getInstance();
     $this->item = $this->get('Item');
     $alt_layout = $this->get('Alt_layout');
     //echo'<pre>';var_dump($alt_layout);die;
     if (!empty($alt_layout)) {
         $this->setLayout($alt_layout);
     }
     if ($this->item !== false) {
         $this->state = $this->get('State');
         //$this->user		= $user;
         $this->elements = $this->get('Elements');
         // Check for errors.
         if (count($errors = $this->get('Errors'))) {
             JError::raiseWarning(500, implode("\n", $errors));
             return false;
         }
         $this->authorised = $user->authorise('core.edit', 'com_azurapagebuilder.page.' . $this->item->id);
         //echo'<pre>';var_dump($this->item->id);var_dump($user);die;
         $item = $this->item;
         $this->params = $this->state->get('params');
         $temp = clone $this->params;
         // Current view is not a single product, so the product params take priority here
         // Merge the menu item params with the product params so that the product params take priority
         $temp->merge($item->params);
         $item->params = $temp;
         //Escape strings for HTML output
         //$this->pageclass_sfx = htmlspecialchars($this->item->params->get('pageclass_sfx'));
         $this->_prepareDocument();
         parent::display($tpl);
     }
 }
コード例 #7
0
ファイル: results.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * 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;
     }
 }
コード例 #8
0
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/');
    }
}
コード例 #9
0
ファイル: nextend2.php プロジェクト: RenatoToasa/Pagina-Web
 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);
         }
     }
 }
コード例 #10
0
ファイル: Theme.php プロジェクト: legutierr/gantry5
 /**
  * @see AbstractTheme::init()
  */
 protected function init()
 {
     parent::init();
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     \JPluginHelper::importPlugin('gantry5');
     // Trigger the onGantryThemeInit event.
     $dispatcher = \JEventDispatcher::getInstance();
     $dispatcher->trigger('onGantry5ThemeInit', ['theme' => $this]);
     $lang = \JFactory::getLanguage();
     // FIXME: Do not hardcode this file.
     $lang->load('files_gantry5_nucleus', JPATH_SITE);
     if (\JFactory::getApplication()->isSite()) {
         // Load our custom positions file as frontend requires the strings to be there.
         $filename = $locator("gantry-theme://language/en-GB/en-GB.tpl_{$this->name}_positions.ini");
         if ($filename) {
             $lang->load("tpl_{$this->name}_positions", dirname(dirname(dirname($filename))), 'en-GB');
         }
     }
     $doc = \JFactory::getDocument();
     $this->language = $doc->language;
     $this->direction = $doc->direction;
     $this->url = \JUri::root(true) . '/templates/' . $this->name;
 }
コード例 #11
0
ファイル: mail.php プロジェクト: gorgozilla/Estivole
 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('*****@*****.**', $mailModel->email_responsable);
     $mail->addRecipient($recipient);
     $mail->Send('*****@*****.**');
 }
コード例 #12
0
ファイル: view.vcf.php プロジェクト: exntu/joomla-cms
 public function display()
 {
     // Get model data.
     $state = $this->get('State');
     $item = $this->get('Item');
     // Check for errors.
     if (count($errors = $this->get('Errors'))) {
         JError::raiseWarning(500, implode("\n", $errors));
         return false;
     }
     $doc = JFactory::getDocument();
     $doc->setMetaData('Content-Type', 'text/directory', true);
     // Initialise variables.
     $app = JFactory::getApplication();
     $params = $app->getParams();
     $user = JFactory::getUser();
     $dispatcher = JEventDispatcher::getInstance();
     // Compute lastname, firstname and middlename
     $item->name = trim($item->name);
     // "Lastname, Firstname Midlename" format support
     // e.g. "de Gaulle, Charles"
     $namearray = explode(',', $item->name);
     if (count($namearray) > 1) {
         $lastname = $namearray[0];
         $card_name = $lastname;
         $name_and_midname = trim($namearray[1]);
         $firstname = '';
         if (!empty($name_and_midname)) {
             $namearray = explode(' ', $name_and_midname);
             $firstname = $namearray[0];
             $middlename = count($namearray) > 1 ? $namearray[1] : '';
             $card_name = $firstname . ' ' . ($middlename ? $middlename . ' ' : '') . $card_name;
         }
     } else {
         $namearray = explode(' ', $item->name);
         $middlename = count($namearray) > 2 ? $namearray[1] : '';
         $firstname = array_shift($namearray);
         $lastname = count($namearray) ? end($namearray) : '';
         $card_name = $firstname . ($middlename ? ' ' . $middlename : '') . ($lastname ? ' ' . $lastname : '');
     }
     $rev = date('c', strtotime($item->modified));
     JResponse::setHeader('Content-disposition', 'attachment; filename="' . $card_name . '.vcf"', true);
     $vcard = array();
     $vcard[] .= 'BEGIN:VCARD';
     $vcard[] .= 'VERSION:3.0';
     $vcard[] = 'N:' . $lastname . ';' . $firstname . ';' . $middlename;
     $vcard[] = 'FN:' . $item->name;
     $vcard[] = 'TITLE:' . $item->con_position;
     $vcard[] = 'TEL;TYPE=WORK,VOICE:' . $item->telephone;
     $vcard[] = 'TEL;TYPE=WORK,FAX:' . $item->fax;
     $vcard[] = 'TEL;TYPE=WORK,MOBILE:' . $item->mobile;
     $vcard[] = 'ADR;TYPE=WORK:;;' . $item->address . ';' . $item->suburb . ';' . $item->state . ';' . $item->postcode . ';' . $item->country;
     $vcard[] = 'LABEL;TYPE=WORK:' . $item->address . "\n" . $item->suburb . "\n" . $item->state . "\n" . $item->postcode . "\n" . $item->country;
     $vcard[] = 'EMAIL;TYPE=PREF,INTERNET:' . $item->email_to;
     $vcard[] = 'URL:' . $item->webpage;
     $vcard[] = 'REV:' . $rev . 'Z';
     $vcard[] = 'END:VCARD';
     echo implode("\n", $vcard);
     return true;
 }
コード例 #13
0
 public function onStylesSave(Event $event)
 {
     \JPluginHelper::importPlugin('gantry5');
     // Trigger the onGantryThemeUpdateCss event.
     $dispatcher = \JEventDispatcher::getInstance();
     $dispatcher->trigger('onGantry5UpdateCss', ['theme' => $event->theme]);
 }
コード例 #14
0
ファイル: menutypes.php プロジェクト: Tommar/vino2
 /**
  * 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
0
ファイル: display.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * 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;
 }
コード例 #16
0
ファイル: helper.php プロジェクト: dnaoverride/RaidPlanner
 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;
         }
     }
 }
コード例 #17
0
 /**
  * Calls all handlers associated with an event group.
  *
  * @param   string  $event  The event name.
  * @param   array   $args   An array of arguments (optional).
  *
  * @return  array   An array of results from each function call, or null if no dispatcher is defined.
  *
  * @since   12.1
  */
 public function triggerEvent($event, array $args = null)
 {
     if ($this->dispatcher instanceof Dispatcher) {
         return $this->dispatcher->trigger($event, $args);
     }
     return null;
 }
コード例 #18
0
ファイル: dispatcher.php プロジェクト: 01J/skazkipronebo
 /**
  * Returns the global Event Dispatcher object, only creating it
  * if it doesn't already exist.
  *
  * @return  JEventDispatcher  The EventDispatcher object.
  *
  * @since   11.1
  */
 public static function getInstance()
 {
     if (self::$instance === null) {
         self::$instance = new static();
     }
     return self::$instance;
 }
コード例 #19
0
ファイル: display.php プロジェクト: Ruud68/Kunena-Forum
 /**
  * Prepare message actions display.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     $catid = $this->input->getInt('id');
     $me = KunenaUserHelper::getMyself();
     $this->category = KunenaForumCategory::getInstance($catid);
     $token = JSession::getFormToken();
     $task = "index.php?option=com_kunena&view=category&task=%s&catid={$catid}&{$token}=1";
     $layout = "index.php?option=com_kunena&view=topic&layout=%s&catid={$catid}";
     $this->template = KunenaFactory::getTemplate();
     $this->categoryButtons = new JObject();
     // Is user allowed to post new topic?
     if ($this->category->getNewTopicCategory()->exists()) {
         $this->categoryButtons->set('create', $this->getButton(sprintf($layout, 'create'), 'create', 'topic', 'communication', true));
     }
     // Is user allowed to mark forums as read?
     if ($me->exists()) {
         $this->categoryButtons->set('markread', $this->getButton(sprintf($task, 'markread'), 'markread', 'category', 'user', true));
     }
     // Is user allowed to subscribe category?
     if ($this->category->isAuthorised('subscribe')) {
         $subscribed = $this->category->getSubscribed($me->userid);
         if (!$subscribed) {
             $this->categoryButtons->set('subscribe', $this->getButton(sprintf($task, 'subscribe'), 'subscribe', 'category', 'user', true));
         } else {
             $this->categoryButtons->set('unsubscribe', $this->getButton(sprintf($task, 'unsubscribe'), 'unsubscribe', 'category', 'user', true));
         }
     }
     JPluginHelper::importPlugin('kunena');
     $dispatcher = JEventDispatcher::getInstance();
     $dispatcher->trigger('onKunenaGetButtons', array('category.action', $this->categoryButtons, $this));
 }
コード例 #20
0
ファイル: view.html.php プロジェクト: bellodox/UserIdeas
 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);
 }
コード例 #21
0
 /**
  * Test JEventDispatcher::detach().
  *
  * @since 11.3
  *
  * @return void
  */
 public function testDetach()
 {
     // Adding 3 events to detach later
     $observer1 = array('handler' => 'fakefunction', 'event' => 'onTestEvent');
     $observer2 = array('handler' => 'JEventMockFunction', 'event' => 'onTestEvent');
     $this->object->attach($observer2);
     $observer3 = new JEventInspector($this->object);
     $this->object->attach($observer3);
     // Test removing a non-existing observer
     $this->assertThat(TestReflection::getValue($this->object, '_methods'), $this->equalTo(array('ontestevent' => array(0, 1))));
     $this->assertThat(TestReflection::getValue($this->object, '_observers'), $this->equalTo(array($observer2, $observer3)));
     $return = $this->object->detach($observer1);
     $this->assertFalse($return);
     $this->assertThat(TestReflection::getValue($this->object, '_methods'), $this->equalTo(array('ontestevent' => array(0, 1))));
     $this->assertThat(TestReflection::getValue($this->object, '_observers'), $this->equalTo(array($observer2, $observer3)));
     // Test removing a functional observer
     $return = $this->object->detach($observer2);
     $this->assertTrue($return);
     $this->assertThat(TestReflection::getValue($this->object, '_methods'), $this->equalTo(array('ontestevent' => array(1 => 1))));
     $this->assertThat(TestReflection::getValue($this->object, '_observers'), $this->equalTo(array(1 => $observer3)));
     // Test removing an object observer with more than one event
     $return = $this->object->detach($observer3);
     $this->assertTrue($return);
     $this->assertThat(TestReflection::getValue($this->object, '_methods'), $this->equalTo(array('ontestevent' => array())));
     $this->assertThat(TestReflection::getValue($this->object, '_observers'), $this->equalTo(array()));
 }
コード例 #22
0
ファイル: factory.php プロジェクト: thangredweb/redCORE
 /**
  * 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;
 }
コード例 #23
0
ファイル: plugin.php プロジェクト: glauberm/cinevi
 /**
  * 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);
 }
コード例 #24
0
 public function delete(&$pks)
 {
     $dispatcher = JEventDispatcher::getInstance();
     $pks = (array) $pks;
     $table = $this->getTable();
     jimport('joomla.filesystem.file');
     jimport('joomla.filesystem.folder');
     $db = JFactory::getDbo();
     // Include the content plugins for the on delete events.
     JPluginHelper::importPlugin('content');
     // Iterate the items to delete each one.
     foreach ($pks as $i => $pk) {
         if ($table->load($pk)) {
             if ($this->canDelete($table)) {
                 $context = $this->option . '.' . $this->name;
                 // Trigger the onContentBeforeDelete event.
                 $result = $dispatcher->trigger($this->event_before_delete, array($context, $table));
                 if (in_array(false, $result, true)) {
                     $this->setError($table->getError());
                     return false;
                 }
                 $query = $db->getQuery(true);
                 $query->select($db->quoteName('file_name'))->from($db->quoteName('#__simplefilemanager'))->where($db->quoteName('id') . ' = ' . $pk);
                 $db->setQuery($query);
                 $file_name = $db->loadResult();
                 if (!$table->delete($pk)) {
                     $this->setError($table->getError());
                     return false;
                 } else {
                     if (!JFile::delete($file_name)) {
                         JFactory::getApplication()->enqueueMessage(JText::_('COM_SIMPLEFILEMANAGER_ERROR_DELETING') . ': ' . $file_name, 'error');
                     } else {
                         $path_parts = pathinfo($file_name);
                         JFolder::delete($path_parts['dirname']);
                     }
                 }
                 // Trigger the onContentAfterDelete event.
                 $dispatcher->trigger($this->event_after_delete, array($context, $table));
             } else {
                 // Prune items that you can't change.
                 unset($pks[$i]);
                 $error = $this->getError();
                 if ($error) {
                     JLog::add($error, JLog::WARNING, 'jerror');
                     return false;
                 } else {
                     JLog::add(JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'), JLog::WARNING, 'jerror');
                     return false;
                 }
             }
         } else {
             $this->setError($table->getError());
             return false;
         }
     }
     // Clear the component's cache
     $this->cleanCache();
     return true;
 }
コード例 #25
0
ファイル: Gantry.php プロジェクト: legutierr/gantry5
 /**
  * @return array
  */
 protected function loadGlobal()
 {
     $global = null;
     // Trigger the event.
     $dispatcher = \JEventDispatcher::getInstance();
     $dispatcher->trigger('onGantryGlobalConfig', ['global' => &$global]);
     return $global;
 }
コード例 #26
0
ファイル: Theme.php プロジェクト: Acidburn0zzz/gantry5
 public function init()
 {
     parent::init();
     \JPluginHelper::importPlugin('gantry5');
     // Trigger the onGantryThemeInit event.
     $dispatcher = \JEventDispatcher::getInstance();
     $dispatcher->trigger('onGantry5ThemeInit', ['theme' => $this]);
 }
コード例 #27
0
ファイル: view.html.php プロジェクト: adjaika/J3Base
 /**
  * Execute and display a template script.
  *
  * @param   string  $tpl  The name of the template file to parse; automatically searches through the template paths.
  *
  * @return  mixed  A string if successful, otherwise an Error object.
  */
 public function display($tpl = null)
 {
     $user = JFactory::getUser();
     $state = $this->get('State');
     $items = $this->get('Items');
     $pagination = $this->get('Pagination');
     // Get the page/component configuration
     $params =& $state->params;
     foreach ($items as $item) {
         $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid;
         $item->parent_slug = $item->parent_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id;
         // No link for ROOT category
         if ($item->parent_alias == 'root') {
             $item->parent_slug = null;
         }
         $item->event = new stdClass();
         $dispatcher = JEventDispatcher::getInstance();
         // Old plugins: Ensure that text property is available
         if (!isset($item->text)) {
             $item->text = $item->introtext;
         }
         JPluginHelper::importPlugin('content');
         $dispatcher->trigger('onContentPrepare', array('com_content.archive', &$item, &$item->params, 0));
         // Old plugins: Use processed text as introtext
         $item->introtext = $item->text;
         $results = $dispatcher->trigger('onContentAfterTitle', array('com_content.archive', &$item, &$item->params, 0));
         $item->event->afterDisplayTitle = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content.archive', &$item, &$item->params, 0));
         $item->event->beforeDisplayContent = trim(implode("\n", $results));
         $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content.archive', &$item, &$item->params, 0));
         $item->event->afterDisplayContent = trim(implode("\n", $results));
     }
     $form = new stdClass();
     // Month Field
     $months = array('' => JText::_('COM_CONTENT_MONTH'), '01' => JText::_('JANUARY_SHORT'), '02' => JText::_('FEBRUARY_SHORT'), '03' => JText::_('MARCH_SHORT'), '04' => JText::_('APRIL_SHORT'), '05' => JText::_('MAY_SHORT'), '06' => JText::_('JUNE_SHORT'), '07' => JText::_('JULY_SHORT'), '08' => JText::_('AUGUST_SHORT'), '09' => JText::_('SEPTEMBER_SHORT'), '10' => JText::_('OCTOBER_SHORT'), '11' => JText::_('NOVEMBER_SHORT'), '12' => JText::_('DECEMBER_SHORT'));
     $form->monthField = JHtml::_('select.genericlist', $months, 'month', array('list.attr' => 'size="1" class="inputbox"', 'list.select' => $state->get('filter.month'), 'option.key' => null));
     // Year Field
     $this->years = $this->getModel()->getYears();
     $years = array();
     $years[] = JHtml::_('select.option', null, JText::_('JYEAR'));
     for ($i = 0; $i < count($this->years); $i++) {
         $years[] = JHtml::_('select.option', $this->years[$i], $this->years[$i]);
     }
     $form->yearField = JHtml::_('select.genericlist', $years, 'year', array('list.attr' => 'size="1" class="inputbox"', 'list.select' => $state->get('filter.year')));
     $form->limitField = $pagination->getLimitBox();
     // Escape strings for HTML output
     $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx'));
     $this->filter = $state->get('list.filter');
     $this->form =& $form;
     $this->items =& $items;
     $this->params =& $params;
     $this->user =& $user;
     $this->pagination =& $pagination;
     $this->pagination->setAdditionalUrlParam("month", $state->get('filter.month'));
     $this->pagination->setAdditionalUrlParam("year", $state->get('filter.year'));
     $this->_prepareDocument();
     parent::display($tpl);
 }
コード例 #28
0
 /**
  * Check for oAuth authentication/authorization requests and fire
  * appropriate oAuth events.
  *
  * @return  void
  */
 public function onAfterRoute()
 {
     if (JFactory::getApplication()->getName() == 'site') {
         $app = JFactory::getApplication();
         $session = JFactory::getSession();
         $uri = clone JUri::getInstance();
         $task = JArrayHelper::getValue($uri->getQuery(true), 'task');
         $task = $session->get('oauth.task', $task);
         $session->clear('oauth.task');
         $plugin = $session->get('oauth.plugin', $app->input->get('plugin'));
         $session->clear('oauth.plugin');
         if ($task) {
             JPluginHelper::importPlugin('authentication', $plugin);
             $dispatcher = JEventDispatcher::getInstance();
             if ($task == 'oauth.authenticate') {
                 $data = $app->getUserState('users.login.form.data', array());
                 $data['return'] = $app->input->get('return', null);
                 $app->setUserState('users.login.form.data', $data);
                 // update the current task and pass the plugin to the session.
                 $session->set('oauth.task', 'oauth.authorize');
                 $session->set('oauth.plugin', $plugin);
                 $dispatcher->trigger('onOauthAuthenticate', array());
             } else {
                 if ($task == 'oauth.authorize') {
                     $array = $dispatcher->trigger('onOauthAuthorize', array());
                     // redirect user to appropriate area of site.
                     if ($array[0] === true) {
                         $data = $app->getUserState('users.login.form.data', array());
                         $app->setUserState('users.login.form.data', array());
                         $user = JFactory::getUser();
                         if ($this->params->get('review_profile', false) && !(bool) $user->getParam("profile.reviewed", false)) {
                             $item = JFactory::getApplication()->getMenu('site')->getItems(array('link'), array('index.php?option=com_users&view=profile&layout=edit'), true);
                             if ($item) {
                                 $redirect = 'index.php?Itemid=' . $item->id;
                             } else {
                                 $redirect = 'index.php?option=com_users&view=profile&layout=edit';
                             }
                             if ($return) {
                                 $redirect .= '&return=' . $return;
                             }
                             $user->setParam('profile.reviewed', (int) true);
                             $user->save();
                         } else {
                             if ($return = JArrayHelper::getValue($data, 'return')) {
                                 $redirect = base64_decode($return);
                             } else {
                                 $redirect = JUri::current();
                             }
                         }
                         $app->redirect(JRoute::_($redirect, false));
                     } else {
                         $app->redirect(JRoute::_('index.php?option=com_users&view=login', false));
                     }
                 }
             }
         }
     }
 }
コード例 #29
0
 /**
  * Plugin that loads module positions within content.
  *
  * @param   string   $context   The context of the content being passed to the plugin.
  * @param   object   &$article  The article object.  Note $article->text is also available.
  * @param   object   &$params   The article params.
  * @param   integer  $page      The 'page' number.
  *
  * @return  string
  *
  * @since   3.2
  */
 public function onContentPrepare($context, &$article, &$params, $page = 0)
 {
     // Get the event dispatcher.
     $dispatcher = JEventDispatcher::getInstance();
     // Load the shortcode plugin group.
     JPluginHelper::importPlugin('shortcode');
     // Trigger the onShortcodePrepare event.
     $dispatcher->trigger('onShortcodePrepare', array($context, &$article, &$params));
 }
コード例 #30
0
ファイル: data.php プロジェクト: lyrasoft/lyrasoft.github.io
 /**
  * Method to get the data to be passed to the layout for rendering.
  *
  * @return  array
  *
  * @since   3.5
  */
 protected function getLayoutData()
 {
     $data = parent::getLayoutData();
     $dispatcher = JEventDispatcher::getInstance();
     JPluginHelper::importPlugin('system', 'stats');
     $result = $dispatcher->trigger('onGetStatsData', array('stats.field.data'));
     $data['statsData'] = $result ? reset($result) : array();
     return $data;
 }