public function display($tpl = null) { $this->option = JFactory::getApplication()->input->get('option'); $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->params = $this->state->get('params'); // Get currencies $currencies = array(); foreach ($this->items as $item) { $currencies[] = $item->txn_currency; } $currencies = array_filter(array_unique($currencies)); if (count($currencies) > 0) { $options = new Joomla\Registry\Registry(); $options->set('locale_intl', $this->params->get('locale_intl')); $options->set('amount_format', $this->params->get('amount_format')); $this->currencies = new Crowdfunding\Currencies(JFactory::getDbo(), $options); $this->currencies->load(array('codes' => $currencies)); } $this->money = $this->getMoneyFormatter($this->params); // Get enabled specific plugins. $extensions = new Prism\Extensions(JFactory::getDbo(), $this->specificPlugins); $this->enabledSpecificPlugins = $extensions->getEnabled(); // Prepare sorting data $this->prepareSorting(); // Prepare actions $this->addToolbar(); $this->addSidebar(); $this->setDocument(); parent::display($tpl); }
public function display($tpl = null) { $this->state = $this->get('State'); $this->items = $this->get('Items'); $this->pagination = $this->get('Pagination'); $this->params = $this->state->get("params"); // Get currencies $currencies = array(); foreach ($this->items as $item) { $currencies[] = $item->txn_currency; } $currencies = array_unique($currencies); if (!empty($currencies)) { $options = new Joomla\Registry\Registry(); $options->set("locale_intl", $this->params->get("locale_intl")); $options->set("amount_format", $this->params->get("amount_format")); $this->currencies = new Crowdfunding\Currencies(JFactory::getDbo(), $options); $this->currencies->loadByCode($currencies); } $this->amount = new Crowdfunding\Amount($this->params); // Get enabled specefic plugins. $extensions = new Prism\Extensions(JFactory::getDbo(), $this->specificPlugins); $this->enabledSpecificPlugins = $extensions->getEnabled(); // Add submenu CrowdfundingHelper::addSubmenu($this->getName()); // Prepare sorting data $this->prepareSorting(); // Prepare actions $this->addToolbar(); $this->addSidebar(); $this->setDocument(); parent::display($tpl); }
/** * Execute and display a template script. * * @param string $tpl The name of the template file to parse; automatically searches through the template paths. * * @throws Exception * * @return mixed A string if successful, otherwise a Error object. * * @see JViewLegacy::loadTemplate() * @since 1.0 */ public function display($tpl = null) { // Get data from the models $this->state = $this->get('State'); $this->state->set('list.start', 0); $this->state->set('list.limit', 0); $this->items = $this->get('Items'); // Check for errors if (count($errors = $this->get('Errors'))) { throw new Exception(implode("\n", $errors), 500); } $this->params = $this->state->get('params'); parent::display($tpl); }
/** * Test the JFormRuleNotequals::test method with InvalidArgumentException * * @return void * * @covers JFormRuleNotequals::test * @expectedException InvalidArgumentException * @since 3.4 */ public function testNotequalsInvalidArgumentException() { $rule = new JFormRuleNotequals(); $xml = simplexml_load_string('<form><field name="foo" field="notequalsfield" /></form>'); $input = new Joomla\Registry\Registry(); $input->set('notequalsfield', 'testvalue'); $rule->test($xml->field, 'test'); }
public static function setSessionData() { $app = JFactory::getApplication(); if ($app->input->post->getVar('guild') && $app->input->post->getVar('realm') && $app->input->post->getVar('region') && $app->input->post->getVar('locale') && ($app->input->post->getVar('link') == 'wowhead.com' || $app->input->post->getVar('link') == 'battle.net')) { $data = new Joomla\Registry\Registry(JPluginHelper::getPlugin('system', 'wow')->params); $data->set('guild', $app->input->post->getVar('guild')); $data->set('realm', $app->input->post->getVar('realm')); $data->set('region', $app->input->post->getVar('region')); $data->set('locale', $app->input->post->getVar('locale')); $data->set('link', $app->input->post->getVar('link')); $check = self::checkGuildExists($data); if (!is_object($check)) { self::redirect($check, 'error'); } if ($check->code != 200) { self::redirect(JText::sprintf('MOD_WOW_DEMO_SWITCHED_ERR', $check->body->reason, $check->body->status), 'error'); } JFactory::getSession()->set('wow_demo', $data); self::redirect(JText::sprintf('MOD_WOW_DEMO_SWITCHED', $check->body->name, $check->body->realm, strtoupper($data->get('region'))), 'message'); } }
public function onAfterInitialise() { $data = JFactory::getSession()->get('wow_demo', new Joomla\Registry\Registry()); if (!class_exists('WoW')) { return false; } if (!$data->get('guild') || !$data->get('realm') || !$data->get('region') || !$data->get('locale') || !$data->get('link')) { $params = new Joomla\Registry\Registry(JPluginHelper::getPlugin('system', 'wow')->params); $data = new Joomla\Registry\Registry(); $data->set('guild', $params->get('guild')); $data->set('realm', $params->get('realm')); $data->set('region', $params->get('region')); $data->set('locale', $params->get('locale')); $data->set('link', $params->get('link')); JFactory::getSession()->set('wow_demo', $data); } WoW::getInstance()->params->set('guild', $data->get('guild')); WoW::getInstance()->params->set('realm', $data->get('realm')); WoW::getInstance()->params->set('region', $data->get('region')); WoW::getInstance()->params->set('locale', $data->get('locale')); WoW::getInstance()->params->set('link', $data->get('link')); }
protected function adjustTemplateSettings() { $extension = JTable::getInstance('extension'); if (!$extension->load(array('type' => 'component', 'element' => 'com_templates'))) { return; } $params = new Joomla\Registry\Registry($extension->params); $params->set('source_formats', $this->addParam($params->get('source_formats'), array('scss', 'yaml', 'twig'))); $params->set('font_formats', $this->addParam($params->get('font_formats'), array('eot', 'svg'))); $extension->params = $params->toString(); $extension->store(); }
/** * Use this method to set object options. * * <code> * $currencyId = 1; * * $currency = CrowdFundingCurrency::getInstance(JFactory::getDbo(), $currencyId); * $currency->setOption("intl", true); * $currency->setOption("locale", "en_GB"); * </code> * * @param string $key Options like "intl", "locale",... * @param mixed $value */ public function setOption($key, $value) { $this->options->set($key, $value); }
private function markProfilesAsNotConfiguredYet() { try { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select($db->qn('params'))->from($db->qn('#__extensions'))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q('com_akeeba')); $jsonData = $db->setQuery($query)->loadResult(); if (class_exists('JRegistry')) { $reg = new JRegistry($jsonData); } else { $reg = new \Joomla\Registry\Registry($jsonData); } $reg->set('confwiz_upgrade', 1); $jsonData = $reg->toString('JSON'); $query = $db->getQuery()->update($db->qn('#__extensions'))->set($db->qn('params') . ' = ' . $db->q($jsonData))->where($db->qn('type') . ' = ' . $db->q('component'))->where($db->qn('element') . ' = ' . $db->q('com_akeeba')); $db->setQuery($query)->execute(); } catch (Exception $e) { // If that fails it's not the end of the world. The component is still usable, so just swallow any // exception. } }
/** * Prepare credentials for sandbox or for the live server. * * @param Joomla\Registry\Registry $options */ protected function prepareCredentials(&$options) { $options->set('api.version', 109); if ($this->params->get('paypal_sandbox', 1)) { $options->set('credentials.username', JString::trim($this->params->get('paypal_sandbox_api_username'))); $options->set('credentials.password', JString::trim($this->params->get('paypal_sandbox_api_password'))); $options->set('credentials.signature', JString::trim($this->params->get('paypal_sandbox_api_signature'))); } else { $options->set('credentials.username', JString::trim($this->params->get('paypal_api_username'))); $options->set('credentials.password', JString::trim($this->params->get('paypal_api_password'))); $options->set('credentials.signature', JString::trim($this->params->get('paypal_api_signature'))); } }
/** * Entry point for CLI script * * @return void * * @since 3.0 */ public function doExecute() { // Get the version data for the script $version = new JVersion(); $helpVersion = str_replace('.', '', $version::RELEASE); $namespace = 'Help' . $helpVersion . ':'; // Set up options for JMediawiki $options = new Joomla\Registry\Registry(); $options->set('api.url', 'https://docs.joomla.org'); $mediawiki = new JMediawiki($options); // Get the category members (local hack) $this->out('Fetching data from docs wiki', true); $categoryMembers = $mediawiki->categories->getCategoryMembers('Category:Help_screen_' . $version::RELEASE, null, 'max'); $members = array(); // Loop through the result objects to get every document foreach ($categoryMembers->query->categorymembers as $catmembers) { foreach ($catmembers as $member) { $members[] = (string) $member['title']; } } // Get the language object $language = JFactory::getLanguage(); // Get the language strings via Reflection as the property is protected $refl = new ReflectionClass($language); $property = $refl->getProperty('strings'); $property->setAccessible(true); $strings = $property->getValue($language); /* * Now we start fancy processing so we can get the language key for the titles */ $cleanMembers = array(); // Strip the namespace prefix off the titles and replace spaces with underscores foreach ($members as $member) { $cleanMembers[] = str_replace(array($namespace, ' '), array('', '_'), $member); } // Make sure we only have an array of unique values before continuing $cleanMembers = array_unique($cleanMembers); /* * Loop through the cleaned up title array and the language strings array to match things up */ $matchedMembers = array(); foreach ($cleanMembers as $member) { foreach ($strings as $k => $v) { if ($member === $v) { $matchedMembers[] = $k; continue; } } } // Alpha sort the array asort($matchedMembers); // Now we strip off the JHELP_ prefix from the strings to get usable strings for both COM_ADMIN and JHELP $stripped = array(); foreach ($matchedMembers as $member) { $stripped[] = str_replace('JHELP_', '', $member); } /* * Check to make sure a COM_ADMIN_HELP string exists, don't include in the TOC if not */ // Load the admin com_admin language file $language->load('com_admin', JPATH_ADMINISTRATOR); $toc = array(); foreach ($stripped as $string) { // Validate the key exists $this->out('Validating key COM_ADMIN_HELP_' . $string, true); if ($language->hasKey('COM_ADMIN_HELP_' . $string)) { $this->out('Adding ' . $string, true); $toc[$string] = $string; } else { $this->out('Inflecting ' . $string, true); if (strpos($string, '_CATEGORIES') !== false) { $inflected = str_replace('_CATEGORIES', '_CATEGORY', $string); } elseif (strpos($string, '_USERS') !== false) { $inflected = str_replace('_USERS', '_USER', $string); } elseif (strpos($string, '_CATEGORY') !== false) { $inflected = str_replace('_CATEGORY', '_CATEGORIES', $string); } elseif (strpos($string, '_USER') !== false) { $inflected = str_replace('_USER', '_USERS', $string); } else { $inflected = ''; } // Now try to validate the key if ($inflected !== '') { $this->out('Validating key COM_ADMIN_HELP_' . $inflected, true); if ($language->hasKey('COM_ADMIN_HELP_' . $inflected)) { $this->out('Adding ' . $inflected, true); $toc[$string] = $inflected; } } } } $this->out('Number of strings: ' . count($toc), true); // JSON encode the file and write it to JPATH_ADMINISTRATOR/help/en-GB/toc.json file_put_contents(JPATH_ADMINISTRATOR . '/help/en-GB/toc.json', json_encode($toc)); $this->out('Help Screen TOC written', true); }
/** * Method to save the form data. * * @param array $data The form data. * * @return mixed The record id on success, null on failure. * @since 1.6 */ public function save($data) { $userId = Joomla\Utilities\ArrayHelper::getValue($data, 'id', 0, 'int'); $accessPicture = Joomla\Utilities\ArrayHelper::getValue($data['privacy'], 'picture', 0, 'int'); $accessBio = Joomla\Utilities\ArrayHelper::getValue($data['privacy'], 'bio', 0, 'int'); $accountState = Joomla\Utilities\ArrayHelper::getValue($data['account'], 'account_state', 0, 'int'); // Prepare privacy settings. $profileParams = new Joomla\Registry\Registry(); $profileParams->set('privacy.picture', $accessPicture); $profileParams->set('privacy.bio', $accessBio); $profileParams = $profileParams->toString(); $db = $this->getDbo(); $query = $db->getQuery(true); $query->update($db->quoteName('#__itpsc_profiles'))->set($db->quoteName('params') . '=' . $db->quote($profileParams))->set($db->quoteName('active') . '=' . (int) $accountState)->where($db->quoteName('user_id') . ' = ' . (int) $userId); $db->setQuery($query); $db->execute(); }
/** * Prepare credentials for sandbox or for the live server. * * @param Joomla\Registry\Registry $options */ protected function prepareCredentials(&$options) { $options->set("api.version", 109); if ($this->params->get("paypal_sandbox", 1)) { $options->set("credentials.username", Joomla\String\String::trim($this->params->get("paypal_sandbox_api_username"))); $options->set("credentials.password", Joomla\String\String::trim($this->params->get("paypal_sandbox_api_password"))); $options->set("credentials.signature", Joomla\String\String::trim($this->params->get("paypal_sandbox_api_signature"))); } else { $options->set("credentials.username", Joomla\String\String::trim($this->params->get("paypal_api_username"))); $options->set("credentials.password", Joomla\String\String::trim($this->params->get("paypal_api_password"))); $options->set("credentials.signature", Joomla\String\String::trim($this->params->get("paypal_api_signature"))); } }