/** * @param object $subject * @param array $params */ public function __construct(&$subject, $params) { $this->app = JFactory::getApplication(); // Do not register plug-in in administration. if ($this->app->isAdmin()) { return; } // If scope isn't articles or Kunena, do not register plug-in. if ($this->app->scope != 'com_content' && $this->app->scope != 'com_kunena') { return; } // Kunena detection and version check $minKunenaVersion = '3.0'; if (!class_exists('KunenaForum') || !KunenaForum::isCompatible($minKunenaVersion)) { $this->loadLanguage(); $this->app->enqueueMessage(JText::sprintf('PLG_KUNENADISCUSS_DEPENDENCY_FAIL', $minKunenaVersion)); return; } // Kunena online check if (!KunenaForum::enabled()) { return; } // Initialize variables $this->db = JFactory::getDbo(); $this->user = KunenaFactory::getUser(); $this->config = KunenaFactory::getConfig(); // Initialize plugin parent::__construct($subject, $params); $this->debug("Constructor called in {$this->app->scope}"); }
/** * Determine if this is an edit form for content and set the return value * */ public function onAfterRoute() { // don't run in admin if ($this->app->isAdmin()) { return; } // check that this is an edit form if (!('com_content' == $this->input->get('option') && 'form' == $this->input->get('view'))) { return; } // check if id is empty $isNew = !(bool) (int) $this->input->get('a_id'); // set the return return $this->processReturn($this->input->get('Itemid', 0), $isNew); }
/** This trigger function to help customize layout of some pages **/ public function onAfterInitialise() { if (!$this->_application->isAdmin()) { return; } if ($this->_application->isAdmin() && $this->_user->id > 0 && JRequest::getVar('tmpl') != 'component' && $this->_params->get('enable_adminbar', true) == true) { $this->_sendCookies(); $this->_target = JRequest::getBool('hidemainmenu') == true ? '_blank' : '_parent'; } if ($this->_user->id > 0) { PowerAdminHistoryHelper::onAfterInitialise(); } if (JRequest::getVar('format', '') == 'raw' || JRequest::getVar('format', '') == 'rss') { return; } $this->_helper = JSNPLGHelper::getInstance(); }
/** * Get the template style params * * @param string $param The param name * @return string The param value */ public function getParam($param) { if (!isset($this->templateParams)) { if (self::$isJ15) { $template = $this->template->name; $cont = null; $ini = JPATH_THEMES . '/' . $template . '/params.ini'; $xml = JPATH_THEMES . '/' . $template . '/templateDetails.xml'; jimport('joomla.filesystem.file'); if (JFile::exists($ini)) { $cont = JFile::read($ini); } else { $cont = null; } $this->templateParams = new JParameter($cont, $xml, $template); } else { if ($this->app->isAdmin()) { jimport('joomla.environment.request'); $id = JRequest::getInt('id'); // Load the site template params from the database $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('params'); $query->from('#__template_styles'); $query->where('id = ' . $id); $db->setQuery($query); $result = $db->loadObject(); $this->templateParams = new JRegistry($result->params); } else { $template = $this->app->getTemplate(true); $this->templateParams = $template->params; } } } $value = $this->templateParams->get($param); if ($value) { return $value; } else { return false; } }
/** This trigger function to help customize layout of some pages **/ public function onAfterInitialise() { $config = JFactory::getConfig(); $secret = $config->get('secret'); $offline = $config->get('offline'); $input = $this->_application->input; if ($this->_application->isSite() && $input->get->get('poweradmin', '0') == '1' && $input->get->get('jsnpa_key', '') == md5($secret) && $offline == '1') { $this->_online(); } if (!$this->_application->isAdmin()) { return; } if ($this->_application->isAdmin() && $this->_user->id > 0 && $input->getVar('tmpl', '') != 'component' && $this->_params->get('enable_adminbar', true) == true) { $this->_sendCookies(); $this->_target = JRequest::getBool('hidemainmenu') == true ? '_blank' : '_parent'; } if ($this->_user->id > 0) { PowerAdminHistoryHelper::onAfterInitialise(); } if ($input->getVar('format', '') == 'raw' || $input->getVar('format', '') == 'rss') { return; } $this->_helper = JSNPLGHelper::getInstance(); }
/** * Ask user to review JoomlaShine product on JED. * * @return void */ private function askForReview() { // Continue only if this is admin page of JoomlaShine product if (self::$_app->isAdmin() and in_array($this->option, JSNVersion::$products)) { // Get product options $config = JSNConfigHelper::get($this->option); if ($config->get('review_popup', 1)) { // Get time difference $time = time(); $last = $config->get('last_ask_for_review', 0); if ($last == 0) { $last = filemtime(JPATH_ROOT . "/administrator/components/{$this->option}/" . substr($this->option, 4) . '.xml'); } // Check if it's time to ask for review if ($time - $last >= REVIEW_POPUP_PERIOD) { // Load script to popup a modal ask user for review JSNHtmlAsset::loadScript('jsn/askforreview', array('url' => JUri::root() . "plugins/system/jsnframework/libraries/joomlashine/choosers/review/index.php?component={$this->option}", 'language' => JSNUtilsLanguage::getTranslated(array('JSN_EXTFW_CHOOSERS_REVIEW_ON_JED')))); // Get config model $model = new JSNConfigModel(); // Store time of last popup $form = $model->getForm(array(), true, JPATH_ROOT . '/administrator/components/' . $this->option . '/config.xml'); $data = array('last_ask_for_review' => $time); try { // Save new configuration $model->save($form, $data); } catch (Exception $e) { // Do nothing as this is a background process } } } } }