public function boot() { \JHtml::_('behavior.keepalive'); $app = \JFactory::getApplication(); $input = $app->input; /** @var Request $request */ $request = $this->container['request']; $this->method = $request->getMethod(); $this->path = explode('/', $input->getString('view')); $this->resource = array_shift($this->path) ?: 'themes'; $this->format = $input->getCmd('format', 'html'); $ajax = $this->format == 'json'; $this->params = ['user' => \JFactory::getUser(), 'ajax' => $ajax, 'location' => $this->resource, 'method' => $this->method, 'format' => $this->format, 'params' => isset($_POST['params']) && is_string($_POST['params']) ? json_decode($_POST['params'], true) : []]; // If style is set, resolve the template and load it. $style = $input->getInt('style', 0); if ($style) { \JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_templates/tables'); $table = \JTable::getInstance('Style', 'TemplatesTable'); $table->load($style); $template = $table->template; $path = JPATH_SITE . '/templates/' . $template; $this->container['theme.path'] = $path; $this->container['theme.name'] = $template; // Load language file for the template. $languageFile = 'tpl_' . $template; $lang = \JFactory::getLanguage(); $lang->load($languageFile, JPATH_SITE) || $lang->load($languageFile, $path) || $lang->load($languageFile, $path, 'en-GB'); } $this->container['base_url'] = \JUri::base(true) . '/index.php?option=com_gantry5'; $this->container['ajax_suffix'] = '&format=json'; $token = \JSession::getFormToken(); $this->container['routes'] = ['1' => "&view=%s&style={$style}&{$token}=1", 'themes' => '&view=themes', 'picker/layouts' => "&view=layouts&style={$style}&{$token}=1", 'picker/particles' => "&view=particles&style={$style}&{$token}=1"]; }
public function onBeforeInstanceLoaded(&$params) { $app = JFactory::getApplication(); $option = $app->input->get('option'); if ($app->isSite()) { $id = $app->input->get('a_id', 0); } else { $id = $app->input->get('id', 0); } if ($option == 'com_content') { $typeid = 1; $type = 'com_content.article'; } else { if ($option == 'com_modules') { $typeTable = JTable::getInstance('Contenttype', 'JTable'); $typeid = $typeTable->getTypeId('com_modules.custom'); $type = 'com_module.custom'; } else { $typeid = 6; $type = 'com_content.category'; } } $temp = JComponentHelper::getParams('com_arkeditor'); $params->merge($this->params); //merge with plugin parameters $temp->merge($params); //merge with editor parameters return " \t\r\n\t\t editor.on( 'configLoaded', function()\r\n\t\t {\r\n\t\t\t editor.config.enableModuleHistory = " . (int) $temp->get('enable_modulehistory', 1) . ";\r\n\t\t });\t\r\n\t\t\t \r\n\t\t editor.on('instanceReady', function()\r\n\t\t {\r\n\t\t\tvar editable = this.editable();\r\n\t\t\tvar versionsURL = 'index.php?option=com_contenthistory&view=history&layout=modal&tmpl=component&item_id=" . $id . "&type_id=" . $typeid . "&type_alias=" . $type . "&" . JSession::getFormToken() . "=1';\r\n\t\t\teditable.setCustomData('versionsURL',versionsURL); \r\n\t\t });\r\n\t\t"; }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // Load the modal behavior script. JHtml::_('behavior.modal', 'a.modal'); // Build the script. $script = array(); $script[] = ' function onBulletsSelect(data){'; $script[] = ' alert("do something: " + data)'; $script[] = ' SqueezeBox.close();'; $script[] = ' }'; // Add the script to the document head. JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); // Setup variables for display. $html = array(); $link = 'index.php?option=com_unitehcarousel&view=slider&layout=bullets&tmpl=component'; $html[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . $this->value . '" />'; $bulletsText = "Change Bullets"; $buttonID = $this->id . "-btn"; $desc = UniteFunctionsHCar::getVal($this->element, "description"); $htmlAddon = ""; if (!empty($desc)) { $htmlAddon = ' title="' . $desc . '"'; //$class .= " hasTip"; //making problems with rel } // The user select button. $html[] = ' <a id="' . $buttonID . '" class="modal panel_button" ' . $htmlAddon . ' href="' . $link . '&' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 900, y: 450}}">' . $bulletsText . '</a>'; $html = implode("\n", $html); return $html; }
public function display($cachable = false, $urlparams = false) { require_once JPATH_COMPONENT . '/helpers/jnotification.php'; $view = JRequest::getCmd('view', 'inbox'); $layout = JRequest::getCmd('layout', 'default'); $id = JRequest::getInt('id'); $model = $this->getModel('Domains', 'JNotificationModel'); $numberofdomains = (int) count($model->getItems()); $app = JFactory::getApplication(); $flagNotification = $app->getUserState('notification.flag'); $flagDomains = $app->getUserState('domains.flag'); if ($view != 'domain') { // Load the submenu. JNotificationHelper::addSubmenu(JRequest::getCmd('view', 'inbox')); } // Check for edit form. if ($view == 'notification' && $layout == 'edit' && !$this->checkEditId('com_jnotification.edit.notification', $id) || $view == 'notification' && $layout == 'edit' && $numberofdomains == 0) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_jnotification&view=inbox', false)); return false; } // Check for edit form. if ($view == 'notification' && $layout == 'viewMessage') { $model1 = $model = $this->getModel('Inbox', 'JNotificationModel'); $items = $model1->getItems(); for ($i = 0; $i < count($items); $i++) { if ((int) $items[$i]->id == (int) JRequest::getInt('id')) { $app->setUserState('com_jnotification.edit.notification.id', (int) JRequest::getInt('id')); } } // Somehow the person just went to the form - we don't allow that. if (!$this->checkEditId('com_jnotification.edit.notification', $id)) { $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_jnotification&view=inbox', false)); return false; } } if ($view == 'notification' && $layout == 'edit' && $flagNotification) { $flagNotification = $app->setUserState('notification.flag', false); //$this->releaseEditId('com_jnotification.edit.notification', $id); $this->setRedirect(JRoute::_('index.php?option=com_jnotification&view=domains&layout=default&id=' . (int) $postId . '&' . JSession::getFormToken() . '=1', false)); } // Check for edit form. if ($view == 'domains' && $layout == 'default' && $flagDomains) { $app->setUserState('domains.flag', false); } else { if ($view == 'domains' && $layout == 'default' && !$flagDomains) { // Somehow the person just went to the form - we don't allow that. $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id)); $this->setMessage($this->getError(), 'error'); $this->setRedirect(JRoute::_('index.php?option=com_jnotification&view=inbox', false)); return false; } } parent::display(); return $this; }
protected function getInput() { // Load the modal behavior script. JHtml::_('behavior.modal', 'a.modal'); // Build the script. $script = array(); $script[] = ' function jSelectArticle_' . $this->id . '(id, title, catid, object) {'; $script[] = ' document.id("' . $this->id . '_id").value = id;'; $script[] = ' document.id("' . $this->id . '_name").value = title;'; $script[] = ' SqueezeBox.close();'; $script[] = ' }'; // Add the script to the document head. JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); // Setup variables for display. $html = array(); $link = 'index.php?option=com_articles&view=articles&layout=modal&tmpl=component&function=jSelectArticle_' . $this->id; $title = KService::get('com://site/articles.model.articles')->id($this->value)->getItem()->title; $html[] = '<span class="input-append">'; $html[] = '<input type="text" class="inoutbox input=medium" id="' . $this->id . '_name" value="' . $title . '" readonly="readonly" disabled="disabled" size="40" placeholder="' . JText::_('COM_ARTICLES_SELECT_AN_ITEM') . '" /><a class="btn btn-primary modal" href="' . $link . '&' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-list icon-white"></i> ' . JText::_('Select') . '</a>'; // The active article id field. if (0 == (int) $this->value) { $value = ''; } else { $value = (int) $this->value; } // class='required' for client side validation $class = ''; if ($this->required) { $class = ' class="required modal-value"'; } $html[] = '<input type="hidden" id="' . $this->id . '_id"' . $class . ' name="' . $this->name . '" value="' . $value . '" />'; return implode("\n", $html); }
public function onDisplay($name, $asset, $author) { $app = JFactory::getApplication(); $document = JFactory::getDocument(); $allowed_in_frontend = $this->params->get('frontend', 0); $document->addStyleSheet(JURI::root() . 'plugins/editors-xtd/jdownloads/assets/css/jdownloads.css', 'text/css', null, array()); /* * Javascript to insert the link * View element calls jSelectDownloadContent when an download is clicked * jSelectDownload creates the content tag, sends it to the editor, * and closes the select frame. */ $js = "\n function jSelectDownload(id, title, catid, object, link, lang)\n {\n var tag = '{jd_file file=='+ id + '}';\n jInsertEditorText(tag, '" . $name . "');\n SqueezeBox.close();\n }"; $document->addScriptDeclaration($js); $link = 'index.php?option=com_jdownloads&view=list&layout=modallist&tmpl=component&e_name=' . $name . '&' . JSession::getFormToken() . '=1'; JHtml::_('behavior.modal'); $button = new JObject(); $button->modal = true; $button->class = 'btn'; $button->link = $link; $button->text = JText::_('PLG_EDITORS-XTD_JDOWNLOADS_CAT_BUTTON_TEXT'); $button->name = 'file-add'; $button->options = "{handler: 'iframe', size: {x: 950, y: 500}}"; if ($allowed_in_frontend == 0 && !$app->isAdmin()) { $button = null; } return $button; }
public function setTheme($theme, $style) { if ($style) { \JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_templates/tables'); $table = \JTable::getInstance('Style', 'TemplatesTable'); $table->load(['id' => $style, 'client_id' => 0]); $theme = $table->template; } if (!$theme) { $theme = StyleHelper::getDefaultStyle()->template; } $path = JPATH_SITE . '/templates/' . $theme; if (!is_file("{$path}/gantry/theme.yaml")) { $theme = null; $this->container['streams']->register(); /** @var UniformResourceLocator $locator */ $locator = $this->container['locator']; $this->container['file.yaml.cache.path'] = $locator->findResource('gantry-cache://theme/compiled/yaml', true, true); } $this->container['base_url'] = \JUri::base(true) . '/index.php?option=com_gantry5'; $this->container['ajax_suffix'] = '&format=json'; $token = \JSession::getFormToken(); $this->container['routes'] = ['1' => "&view=%s&theme={$theme}&{$token}=1", 'themes' => '&view=themes', 'picker/layouts' => "&view=layouts&theme={$theme}&{$token}=1"]; if (!$theme) { return $this; } $this->container['theme.path'] = $path; $this->container['theme.name'] = $theme; // Load language file for the template. $languageFile = 'tpl_' . $theme; $lang = \JFactory::getLanguage(); $lang->load($languageFile, JPATH_SITE) || $lang->load($languageFile, $path) || $lang->load($languageFile, $path, 'en-GB'); return $this; }
/** * Method to get the field input markup for a generic list. * Use the multiple attribute to enable multiselect. * * @return string The field input markup. */ protected function getInput() { // Receive ajax URL $ajaxUrl = isset($this->element['url']) ? (string) $this->element['url'] : null; if ($ajaxUrl) { $siteUrl = JUri::root(); $adminUrl = $siteUrl . 'administrator'; $this->ajaxchildOptions['ajaxUrl'] = str_replace(array('{admin}', '{backend}', '{site}', '{frontend}'), array($adminUrl, $adminUrl, $siteUrl, $siteUrl), $ajaxUrl); // Automatically attach a token $this->ajaxchildOptions['ajaxUrl'] .= '&' . JSession::getFormToken() . '=1'; } // Receive child field selector $childSelector = isset($this->element['child_selector']) ? (string) $this->element['child_selector'] : null; if ($childSelector) { $this->ajaxchildOptions['childSelector'] = $childSelector; } // Receive parent field selector $parentSelector = isset($this->element['parent_selector']) ? (string) $this->element['parent_selector'] : null; if ($parentSelector) { $this->ajaxchildOptions['parentSelector'] = $parentSelector; } // Receive parent request var $parentVarName = isset($this->element['parent_varname']) ? (string) $this->element['parent_varname'] : null; if ($parentVarName) { $this->ajaxchildOptions['parentVarName'] = $parentVarName; } return parent::getInput(); }
/** * Method to return array of actions sublayout * * @return array */ public function getCategoryActions() { $category = $this->category; $token = '&' . JSession::getFormToken() . '=1'; $actions = array(); // Is user allowed to post new topic? $url = $category->getNewTopicUrl(); if ($url) { $actions['create'] = $this->subLayout('Widget/Button')->setProperties(array('url' => $url, 'name' => 'create', 'scope' => 'topic', 'type' => 'communication', 'success' => true, 'icon' => 'icon-edit icon-white')); } if ($category->getTopics() > 0) { // Is user allowed to mark forums as read? $url = $category->getMarkReadUrl(); if ($url) { $actions['markread'] = $this->subLayout('Widget/Button')->setProperties(array('url' => $url, 'name' => 'markread', 'scope' => 'category', 'type' => 'user', 'icon' => 'icon-drawer')); } // Is user allowed to subscribe category? if ($category->isAuthorised('subscribe')) { $subscribed = $category->getSubscribed($this->me->userid); if (!$subscribed) { $url = "index.php?option=com_kunena&view=category&task=subscribe&catid={$category->id}{$token}"; $actions['subscribe'] = $this->subLayout('Widget/Button')->setProperties(array('url' => $url, 'name' => 'subscribe', 'scope' => 'category', 'type' => 'user', 'icon' => 'icon-bookmark')); } else { $url = "index.php?option=com_kunena&view=category&task=unsubscribe&catid={$category->id}{$token}"; $actions['unsubscribe'] = $this->subLayout('Widget/Button')->setProperties(array('url' => $url, 'name' => 'unsubscribe', 'scope' => 'category', 'type' => 'user')); } } } return $actions; }
function onDisplay($name) { /* * Javascript to insert the link * View element calls jSelectArticle when an article is clicked * jSelectArticle creates the link tag, sends it to the editor, * and closes the select frame. */ $js = "\n\t\tfunction jSelectPerson(id, title, appid, apptitle, treeid) {\n\t\t\tvar tag = '{joaktree person|' + appid + '|' + id + '|extended}';\n\t\t\tjInsertEditorText(tag, '" . $name . "');\n\t\t\tSqueezeBox.close();\n\t\t}"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); JHtml::_('behavior.modal'); /* * Use the built-in element view to select the article. * Currently uses blank class. */ $link = 'index.php?option=com_joaktree&view=jt_persons&layout=element&select=1&tmpl=component&' . JSession::getFormToken() . '=1'; $button = new JObject(); $button->set('modal', true); $button->class = 'btn'; $button->set('link', $link); $button->set('text', JText::_('PLG_JOAKTREE_BUTTON_PERSONLINK')); $button->set('name', 'person_link'); $button->set('options', "{handler: 'iframe', size: {x: 770, y: 400}}"); return $button; }
/** * 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 = JDispatcher::getInstance(); $dispatcher->trigger('onKunenaGetButtons', array('category.action', $this->categoryButtons, $this)); }
/** * Method to save data * (non-PHPdoc) * @see F0FController::save() */ public function save() { //security check JSession::checkToken() or die('Invalid Token'); $app = JFactory::getApplication(); $model = $this->getModel('configurations'); $data = $app->input->getArray($_POST); $task = $this->getTask(); $token = JSession::getFormToken(); unset($data['option']); unset($data['task']); unset($data['view']); unset($data[$token]); if ($task == 'populatedata') { $this->getPopulatedData($data); } $db = JFactory::getDbo(); $config = J2Store::config(); $query = 'REPLACE INTO #__j2store_configurations (config_meta_key,config_meta_value) VALUES '; jimport('joomla.filter.filterinput'); $filter = JFilterInput::getInstance(null, null, 1, 1); $conditions = array(); foreach ($data as $metakey => $value) { if (is_array($value)) { $value = implode(',', $value); } //now clean up the value if ($metakey == 'store_billing_layout' || $metakey == 'store_shipping_layout' || $metakey == 'store_payment_layout') { $value = $app->input->get($metakey, '', 'raw'); $clean_value = $filter->clean($value, 'html'); } else { $clean_value = $filter->clean($value, 'string'); } $config->set($metakey, $clean_value); $conditions[] = '(' . $db->q(strip_tags($metakey)) . ',' . $db->q($clean_value) . ')'; } $query .= implode(',', $conditions); try { $db->setQuery($query); $db->execute(); //update currencies F0FModel::getTmpInstance('Currencies', 'J2StoreModel')->updateCurrencies(false); $msg = JText::_('J2STORE_CHANGES_SAVED'); } catch (Exception $e) { $msg = $e->getMessage(); $msgType = 'Warning'; } switch ($task) { case 'apply': $url = 'index.php?option=com_j2store&view=configuration'; break; case 'populatedata': $url = 'index.php?option=com_j2store&view=configuration'; break; case 'save': $url = 'index.php?option=com_j2store&view=cpanels'; break; } $this->setRedirect($url, $msg, $msgType); }
/** * Display the button * * @param string $name The name of the button to add * * @return array A four element array of (article_id, article_title, category_id, object) */ public function onDisplay($name) { $app = JFactory::getApplication(); if (!$app->isSite()) { return false; } /* * Javascript to insert the link * View element calls jSelectEvent when an event is clicked * jSelectEvent creates the link tag, sends it to the editor, * and closes the select frame. */ $js = "\n\t\tfunction jSelectEvent(id, title, object, link, lang)\n\t\t{\n\t\t\tvar hreflang = '';\n\t\t\tif (lang !== '')\n\t\t\t{\n\t\t\t\tvar hreflang = ' hreflang = \"' + lang + '\"';\n\t\t\t}\n\t\t\tvar tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';\n\t\t\tjInsertEditorText(tag, '" . $name . "');\n\t\t\tSqueezeBox.close();\n\t\t}"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); JHtml::_('behavior.modal'); /* * Use the built-in element view to select the event. * Currently uses blank class. */ $app = JFactory::getApplication(); if ($app->isSite()) { $link = 'index.php?option=com_jem&view=eventslist&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1'; } else { $link = 'index.php?option=com_jem&view=events&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1'; } $button = new JObject(); $button->modal = true; $button->class = 'btn'; $button->link = $link; $button->text = JText::_('PLG_EVENT_BUTTON_EVENT'); $button->name = 'calendar'; $button->options = "{handler: 'iframe', size: {x: 800, y: 500}}"; return $button; }
/** * Display the button * * @param string $name The name of the button to add * * @return array A four element array of (article_id, article_title, category_id, object) */ public function onDisplay($name) { /* * Javascript to insert the link * View element calls jSelectArticle when an article is clicked * jSelectArticle creates the link tag, sends it to the editor, * and closes the select frame. */ $js = "\n\t\tfunction jSelectArticle(id, title, catid, object, link, lang)\n\t\t{\n\t\t\tvar hreflang = '';\n\t\t\tif (lang !== '')\n\t\t\t{\n\t\t\t\tvar hreflang = ' hreflang = \"' + lang + '\"';\n\t\t\t}\n\t\t\tvar tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';\n\t\t\tjInsertEditorText(tag, '" . $name . "');\n\t\t\tjModalClose();\n\t\t}"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); /* * Use the built-in element view to select the article. * Currently uses blank class. */ $link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1'; $button = new JObject(); $button->modal = true; $button->class = 'btn'; $button->link = $link; $button->text = JText::_('PLG_ARTICLE_BUTTON_ARTICLE'); $button->name = 'file-add'; $button->options = "{handler: 'iframe', size: {x: 800, y: 500}}"; return $button; }
/** * Method for logging out with Magento (Single Sign On) * * @param string $username * @return bool|exit */ public static function doSSOLogout($username = null) { // Abort if the input is not valid if (empty($username)) { return false; } // Get system variables $application = JFactory::getApplication(); $session = JFactory::getSession(); // Determine the application $application_name = $application->isAdmin() ? 'admin' : 'frontend'; // Get the security token $token = method_exists('JSession', 'getFormToken') ? JSession::getFormToken() : JUtility::getToken(); // Set the redirection URL if ($application_name == 'admin') { $redirect = JURI::current(); } else { $redirect = MageBridgeUrlHelper::current(); } // Construct the URL $arguments = array('sso=logout', 'app=' . $application_name, 'redirect=' . base64_encode($redirect), 'userhash=' . MageBridgeEncryptionHelper::encrypt($username), 'token=' . $token); $url = MageBridgeModelBridge::getInstance()->getMagentoBridgeUrl() . '?' . implode('&', $arguments); // Redirect the browser to Magento MageBridgeModelDebug::getInstance()->notice("SSO: Logout of '{$username}' from " . $application_name); $application->redirect($url); return true; }
/** * Display the button * * @return array A four element array of (article_id, article_title, category_id, object) */ function onDisplay($name) { /* * Javascript to insert the link * View element calls jSelectArticle when an article is clicked * jSelectArticle creates the link tag, sends it to the editor, * and closes the select frame. */ $js = "\r\r\n\t\tfunction jSelectArticle(id, title, catid, object, link, lang) {\r\r\n\t\t\tvar hreflang = '';\r\r\n\t\t\tif (lang !== '') {\r\r\n\t\t\t\tvar hreflang = ' hreflang = \"' + lang + '\"';\r\r\n\t\t\t}\r\r\n\t\t\tvar tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';\r\r\n\t\t\tjInsertEditorText(tag, '" . $name . "');\r\r\n\t\t\tSqueezeBox.close();\r\r\n\t\t}"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); JHtml::_('behavior.modal'); /* * Use the built-in element view to select the article. * Currently uses blank class. */ $link = 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1'; $button = new JObject(); $button->set('modal', true); $button->set('link', $link); $button->set('text', JText::_('PLG_ARTICLE_BUTTON_ARTICLE')); $button->set('name', 'article'); $button->set('options', "{handler: 'iframe', size: {x: 770, y: 400}}"); return $button; }
/** * Method to get the field input markup. * * @return string The field input markup. * @since 1.6 */ protected function getInput() { // Load the modal behavior script. JHtml::_('behavior.modal', 'a.modal'); // Build the script. $script = array(); $script[] = ' function onArrowsSelect(data){'; $script[] = ' UniteAdminRev.onArrowsChange(data);'; $script[] = ' SqueezeBox.close();'; $script[] = ' }'; // Add the script to the document head. JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); // Setup variables for display. $html = array(); $link = 'index.php?option=' . GlobalsUniteRev::COMPONENT_NAME . '&view=slider&layout=arrows&tmpl=component&settingid=' . $this->id; $buttonType = $this->value; $arrArrowSet = HelperUniteRev::getArrowSet($buttonType); $arrowName = $arrArrowSet["name"]; $html[] = '<input type="hidden" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . $this->value . '" />'; $buttonID = $this->id . "-btn"; $desc = UniteFunctionsRev::getVal($this->element, "description"); // The the arrow $imageArrow = $arrArrowSet["url_right"]; $html[] = '<span class="chooser-image-wrapper"><img id="' . $this->id . '-img" title="' . $arrowName . '" src="' . $imageArrow . '"></span>'; //put select button $html[] = ' <a id="' . $buttonID . '" class="modal button-secondary button-chooser" href="' . $link . '&' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 900, y: 450}}">Change</a>'; $html = implode("\n", $html); return $html; }
public function help() { $user = JFactory::getUser(); $jinput = JFactory::getApplication()->input; // Check Token! $token = JSession::getFormToken(); $call_token = $jinput->get('token', 0, 'ALNUM'); if ($user->id != 0 && $token == $call_token) { $task = $this->getTask(); switch ($task) { case 'getText': try { $idValue = $jinput->get('id', 0, 'INT'); if ($idValue) { $result = $this->getHelpDocumentText($idValue); } else { $result = ''; } echo $result; // stop execution gracefully jexit(); } catch (Exception $e) { // stop execution gracefully jexit(); } break; } } else { // stop execution gracefully jexit(); } }
/** * Constructor for the JSON response * * @param mixed $data Exception if there is an error, otherwise, the session data * * @since 3.1 */ public function __construct($data) { // The old token is invalid so send a new one. $this->token = JSession::getFormToken(true); // Get the language and send it's tag along $this->lang = JFactory::getLanguage()->getTag(); // Get the message queue $messages = JFactory::getApplication()->getMessageQueue(); // Build the sorted message list if (is_array($messages) && count($messages)) { foreach ($messages as $msg) { if (isset($msg['type']) && isset($msg['message'])) { $lists[$msg['type']][] = $msg['message']; } } } // If messages exist add them to the output if (isset($lists) && is_array($lists)) { $this->messages = $lists; } // Check if we are dealing with an error. if ($data instanceof Exception) { // Prepare the error response. $this->error = true; $this->header = JText::_('INSTL_HEADER_ERROR'); $this->message = $data->getMessage(); } else { // Prepare the response data. $this->error = false; $this->data = $data; } }
/** * Get a list of logged users. * * @param JObject The module parameters. * @return mixed An array of articles, or false on error. */ public static function getList($params) { $db = JFactory::getDbo(); $user = JFactory::getUser(); $query = $db->getQuery(true); $query->select('s.time, s.client_id, u.id, u.name, u.username'); $query->from('#__session AS s'); $query->leftJoin('#__users AS u ON s.userid = u.id'); $query->where('s.guest = 0'); $db->setQuery($query, 0, $params->get('count', 5)); try { $results = $db->loadObjectList(); } catch (RuntimeException $e) { JError::raiseError(500, $e->getMessage()); return false; } foreach ($results as $k => $result) { $results[$k]->logoutLink = ''; if ($user->authorise('core.manage', 'com_users')) { $results[$k]->editLink = JRoute::_('index.php?option=com_users&task=user.edit&id=' . $result->id); $results[$k]->logoutLink = JRoute::_('index.php?option=com_login&task=logout&uid=' . $result->id . '&' . JSession::getFormToken() . '=1'); } if ($params->get('name', 1) == 0) { $results[$k]->name = $results[$k]->username; } } return $results; }
/** * Display the button * * @param string $name The name of the button to add * * @return array A four element array of (field-id, field-title, field-type) */ public function onDisplay($name) { $app = JFactory::getApplication(); $o = $app->input->get('option'); $v = $app->input->get('view'); if ($o == 'com_visforms' && $v == 'visform') { $id = $app->input->getCmd('id', 0); /* * Javascript to insert the link * View element calls jSelectVisformsfield when an field is clicked * jSelectVisformsfield creates the Placeholder for the field, sends it to the editor, * and closes the select frame. */ $js = "\n function jSelectVisformfield(field)\n {\n var tag = '[' + field.toUpperCase() + ']';\n jInsertEditorText(tag, '" . $name . "');\n SqueezeBox.close();\n }"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); JHtml::_('behavior.modal'); /* * Use the built-in element view to select the field. * Currently uses blank class. */ $link = 'index.php?option=com_visforms&view=visfields&fid=' . $id . '&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1'; $button = new JObject(); $button->modal = true; $button->class = 'btn'; $button->link = $link; $button->text = JText::_('PLG_VISFORMFIELDS_BUTTON_VISFORMFIELDS'); $button->name = 'file-add'; $button->options = "{handler: 'iframe', size: {x: 800, y: 500}}"; return $button; } }
/** * Display the button * * @param string $name The name of the button to add * * @since __DEPLOY_VERSION__ * @return array */ public function onDisplay($name) { /* * Javascript to insert the link * View element calls jSelectMenuItem when a menu item is clicked * jSelectMenuItem creates the link tag, sends it to the editor, * and closes the select frame. */ $js = "\n\t\tfunction jSelectMenuItem(id, title, tree, object, uri, language)\n\t\t{\n\t\t\tvar thislang = '';\n\t\t\tif (language !== '')\n\t\t\t{\n\t\t\t\tvar thislang = '&lang=';\n\t\t\t}\n\t\t\tvar tag = '<a href=\"' + uri + thislang + language + '\">' + title + '</a>';\n\t\t\tjInsertEditorText(tag, '" . $name . "');\n\t\t\tjModalClose();\n\t\t}"; $doc = JFactory::getDocument(); $doc->addScriptDeclaration($js); /* * Use the built-in element view to select the menu item. * Currently uses blank class. */ $link = 'index.php?option=com_menus&view=items&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1'; $button = new JObject(); $button->modal = true; $button->class = 'btn'; $button->link = $link; $button->text = JText::_('PLG_EDITORS-XTD_MENU_BUTTON_MENU'); $button->name = 'share-alt'; $button->options = "{handler: 'iframe', size: {x: 800, y: 500}}"; return $button; }
protected function getInput() { $document = JFactory::getDocument(); $app = JFactory::getApplication(); $id = $app->input->getInt('id', 0); $attachments = array(); if ($this->value) { $registry = new JRegistry(); $registry->loadString($this->value); $attachments = $registry->toObject(); } $token = JSession::getFormToken(); $script = "jQuery(document).ready(function(\$){\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\$('#add_attachments').click(function() {\n\t\t\t\t\t\t\t\t\$('<tr><td><input type=\"file\" name=\"attachmentfiles[]\" multiple /></td><td><a href=\"#\" class=\"remove_attachment\" onclick=\"return false;\">" . JText::_('COM_JUDIRECTORY_REMOVE') . "</a></td></tr>').appendTo(\"#juemail table\");\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t\$('#juemail').on('click', '.remove_attachment', function() {\n\t\t\t\t\t\t\t\t\$(this).parent().parent().remove();\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\$(\"#email-lists\").dragsort({ dragSelector: \"li\", dragEnd: saveOrder, placeHolderTemplate: \"<li class='placeHolder'></li>\", dragSelectorExclude: \"input, textarea, span\"});\n\t\t\t\t\t function saveOrder() {\n\t\t\t\t\t\t\t\tvar data = \$(\"#juemail li\").map(function() { return \$(this).data(\"itemid\"); }).get();\n\t\t\t\t\t };\n\t\t\t\t\t\t});"; $document->addScriptDeclaration($script); $html = '<div id="juemail" class="juemail" style="float: left">'; if ($attachments) { $html .= '<ul id="email-lists" class="email-lists">'; foreach ($attachments as $attachment) { $html .= '<li>'; $html .= '<a class="drag-icon"></a>'; $html .= '<input type="checkbox" name="' . $this->name . '[]" checked value="' . $attachment . '" />'; $html .= '<a href="index.php?option=com_judirectory&task=email.downloadattachment&id=' . $id . '&file=' . $attachment . '&' . $token . '=1"><span class="attachment">' . $attachment . '</span></a>'; $html .= '</li>'; } $html .= '</ul>'; } $html .= '<table></table>'; $html .= '<a href="#" class="btn btn-mini btn-primary add_attachments" id="add_attachments" onclick="return false;"><i class="icon-new"></i> ' . JText::_('COM_JUDIRECTORY_ADD_ATTACHMENT') . '</a>'; $html .= '</div>'; return $html; }
protected function getInput() { JLoader::register('JEVHelper', JPATH_SITE . "/components/com_jevents/libraries/helper.php"); JEVHelper::ConditionalFields($this->element, $this->form->getName()); if ($this->fieldname == "rp_id") { // The active event id field. if (0 == (int) $this->value) { $value = ''; } else { $value = (int) $this->value; } return '<input type="text" id="selectedrepeat" name="' . $this->name . '" value="' . $value . '" />'; } // Load the modal behavior script. JevHtmlBootstrap::modal('a.modal'); $js = "\n\t\tfunction jSelectEvent_" . $this->id . "(link, title, Itemid, evid, rpid) {\n\t\t\t\$('selectedeventtitle').value = title;\n\t\t\t\$('selectedevent').value = evid;\n\t\t\t\$('selectedrepeat').value = rpid;\n\t\t\tSqueezeBox.close();\n\t\t\treturn false;\n\t\t}"; // Add the script to the document head. JFactory::getDocument()->addScriptDeclaration($js); // Setup variables for display. $html = array(); $link = 'index.php?option=com_jevents&task=icalevent.select&tmpl=component&' . JSession::getFormToken() . '=1&nomenu=1&function=jSelectEvent_' . $this->id; // get the repeat id $rpidfield = $this->form->getField("rp_id", "request"); $rp_id = $rpidfield->value; $db = JFactory::getDBO(); $db->setQuery('SELECT det.summary as title' . ' FROM #__jevents_vevdetail as det ' . ' LEFT JOIN #__jevents_repetition as rep ON rep.eventdetail_id = det.evdet_id' . ' WHERE rep.rp_id = ' . (int) $rp_id); $title = $db->loadResult(); echo $db->getErrorMsg(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); } if (empty($title)) { $title = JText::_('COM_JEVENTS_FIELD_SELECT_EVENT_LABEL'); } $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); // The current user display field. $html[] = '<div class="fltlft">'; $html[] = ' <input type="text" id="selectedeventtitle" value="' . $title . '" disabled="disabled" size="35" />'; $html[] = '</div>'; // The user select button. $html[] = '<div class="button2-left">'; $html[] = ' <div class="blank">'; $html[] = ' <a class="modal" title="' . JText::_('COM_JEVENTS_CHANGE_EVENT') . '" href="' . $link . '" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">' . JText::_('COM_JEVENTS_CHANGE_EVENT_BUTTON') . '</a>'; $html[] = ' </div>'; $html[] = '</div>'; // The active event id field. if (0 == (int) $this->value) { $value = ''; } else { $value = (int) $this->value; } // class='required' for client side validation $class = ''; if ($this->required) { $class = ' class="required modal-value"'; } $html[] = '<input type="hidden" id="selectedevent" ' . $class . ' name="' . $this->name . '" value="' . $value . '" />'; return implode("\n", $html); }
/** * * @return void **/ function _default($tpl = null) { Citruscart::load('CitruscartSelect', 'library.select'); Citruscart::load('CitruscartGrid', 'library.grid'); Citruscart::load('CitruscartTools', 'library.tools'); /* Get the application */ $app = JFactory::getApplication(); // check config $row = Citruscart::getInstance(); $this->assign('row', $row); // add toolbar buttons JToolBarHelper::apply('save'); JToolBarHelper::cancel('close', 'COM_CITRUSCART_CLOSE'); // plugins $filtered = array(); $items = CitruscartTools::getPlugins(); for ($i = 0; $i < count($items); $i++) { $item = $items[$i]; // Check if they have an event if ($hasEvent = CitruscartTools::hasEvent($item, 'onListConfigCitruscart')) { // add item to filtered array $filtered[] = $item; } } $items = $filtered; $this->assign('items_sliders', $items); // Add pane jimport('joomla.html.pane'); //$sliders = JPane::getInstance( 'sliders' ); //$this->assign('sliders', $sliders); // form //$validate = JSession::getFormToken(); $validate = JSession::getFormToken(); $form = array(); $view = strtolower($app->input->get('view')); //$view = strtolower( JRequest::getVar('view') ); $form['action'] = "index.php?option=com_citruscart&controller={$view}&view={$view}"; $form['validate'] = "<input type='hidden' name='{$validate}' value='1' />"; $this->assign('form', $form); // set the required image // TODO Fix this to use defines $required = new stdClass(); $required->text = JText::_('COM_CITRUSCART_REQUIRED'); $required->image = "<img src='" . JURI::root() . "/media/citruscart/images/required_16.png' alt='{$required->text}'>"; $this->assign('required', $required); // Elements $elementArticleModel = JModelLegacy::getInstance('ElementArticle', 'CitruscartModel'); $this->assign('elementArticleModel', $elementArticleModel); // terms $elementArticle_terms = $elementArticleModel->fetchElement('article_terms', $row->get('article_terms')); $resetArticle_terms = $elementArticleModel->clearElement('article_terms', '0'); $this->assign('elementArticle_terms', $elementArticle_terms); $this->assign('resetArticle_terms', $resetArticle_terms); // shipping $elementArticle_shipping = $elementArticleModel->fetchElement('article_shipping', $row->get('article_shipping')); $resetArticle_shipping = $elementArticleModel->clearElement('article_shipping', '0'); $this->assign('elementArticle_shipping', $elementArticle_shipping); $this->assign('resetArticle_shipping', $resetArticle_shipping); }
protected function getInput() { // Load language JFactory::getLanguage()->load('com_sppagebuilder', JPATH_ADMINISTRATOR); // Build the script. $script = array(); // Select button script $script[] = ' function jSelectPage_' . $this->id . '(id, title, catid, object) {'; $script[] = ' document.getElementById("' . $this->id . '_id").value = id;'; $script[] = ' document.getElementById("' . $this->id . '_name").value = title;'; $script[] = ' jQuery("#modalPage' . $this->id . '").modal("hide");'; if ($this->required) { $script[] = ' document.formvalidator.validate(document.getElementById("' . $this->id . '_id"));'; $script[] = ' document.formvalidator.validate(document.getElementById("' . $this->id . '_name"));'; } $script[] = ' }'; // Add the script to the document head. JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); // Setup variables for display. $html = array(); $link = 'index.php?option=com_sppagebuilder&view=pages&layout=modal&tmpl=component&function=jSelectPage_' . $this->id; if (isset($this->element['language'])) { $link .= '&forcedLanguage=' . $this->element['language']; } if ((int) $this->value > 0) { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select($db->quoteName('title'))->from($db->quoteName('#__sppagebuilder'))->where($db->quoteName('id') . ' = ' . (int) $this->value); $db->setQuery($query); try { $title = $db->loadResult(); } catch (RuntimeException $e) { JError::raiseWarning(500, $e->getMessage()); } } if (empty($title)) { $title = JText::_('COM_SPPAGEBUILDER_SELECT_AN_PAGE'); } $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); // The active page id field. if (0 == (int) $this->value) { $value = ''; } else { $value = (int) $this->value; } $url = $link . '&' . JSession::getFormToken() . '=1'; // The current article display field. $html[] = '<span class="input-append">'; $html[] = '<input type="text" class="input-medium" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="35" />'; $html[] = '<a href="#modalPage' . $this->id . '" class="btn hasTooltip" role="button" data-toggle="modal" title="' . JHtml::tooltipText('COM_SPPAGEBUILDER_CHANGE_PAGE') . '">' . '<span class="icon-file"></span> ' . JText::_('JSELECT') . '</a>'; $html[] = '</span>'; // The class='required' for client side validation $class = ''; if ($this->required) { $class = ' class="required modal-value"'; } $html[] = '<input type="hidden" id="' . $this->id . '_id"' . $class . ' name="' . $this->name . '" value="' . $value . '" />'; $html[] = JHtml::_('bootstrap.renderModal', 'modalPage' . $this->id, array('url' => $url, 'title' => JText::_('COM_SPPAGEBUILDER_SELECT_AN_PAGE'), 'width' => '800px', 'height' => '400px', 'footer' => '<button class="btn" data-dismiss="modal" aria-hidden="true">' . JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '</button>')); return implode("\n", $html); }
public static function getToken() { if (method_exists('JSession', 'getFormToken')) { return JSession::getFormToken(); } else { return JFactory::getSession()->getToken(); } }
/** * Test getFormToken * * @covers JSession::getFormToken * * @return void */ public function testGetFormToken() { // Set the factory session object for getting the token JFactory::$session = $this->object; $user = JFactory::getUser(); $expected = md5($user->get('id', 0) . $this->object->getToken(false)); $this->assertEquals($expected, $this->object->getFormToken(false), 'Form token should be calculated as above.'); }
/** * Test... * * @covers JSession::getFormToken * * @return void */ public function testGetFormToken() { $user = JFactory::getUser(); JFactory::$application = $this->getMock('JInputCookie', array('set', 'get')); JFactory::$application->expects($this->once())->method('get')->with($this->equalTo('secret'))->will($this->returnValue('abc')); $expected = md5('abc' . $user->get('id', 0) . $this->object->getToken(false)); $this->assertEquals($expected, $this->object->getFormToken(), 'Form token should be calculated as above'); }
protected function getInput() { $app = JFactory::getApplication(); JHtml::_('behavior.modal', 'a.modal'); $script = array(); $script[] = ' function jSelectListing_' . $this->id . '(id, title, object) {'; $script[] = ' document.id("' . $this->id . '").value = id;'; $script[] = ' document.id("' . $this->id . '_name").value = title;'; $script[] = ' SqueezeBox.close();'; $script[] = ' }'; JFactory::getDocument()->addScriptDeclaration(implode("\n", $script)); $html = array(); $link = 'index.php?option=com_judirectory&view=listings&layout=modal&tmpl=component&function=jSelectListing_' . $this->id; $db = JFactory::getDbo(); $db->setQuery('SELECT title' . ' FROM #__judirectory_listings' . ' WHERE id = ' . (int) $this->value); $title = $db->loadResult(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); } if (empty($title)) { $title = JText::_('COM_JUDIRECTORY_SELECT_LISTING'); } $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); $joomla_version_arr = explode(".", JVERSION); $priVersion = $joomla_version_arr[0]; $view = $app->input->get('view', ''); if ($priVersion == 3) { $html[] = '<span class="' . ($view != 'modcomment' ? 'input-append' : '') . '">'; $html[] = '<input type="text" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="' . $this->element['size'] . '"/>'; if ($view != 'modcomment') { $html[] = '<a class="modal btn hasTooltip" title="' . JHtml::tooltipText('COM_JUDIRECTORY_SELECT_LISTING') . '" href="' . $link . '&' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}"><i class="icon-list"></i> ' . JText::_('COM_JUDIRECTORY_SELECT') . '</a>'; } $html[] = '</span>'; } else { $html[] = '<div class="fltlft">'; $html[] = '<input type="text" id="' . $this->id . '_name" value="' . $title . '" disabled="disabled" size="' . $this->element['size'] . '" />'; $html[] = '</div>'; if ($view != 'modcomment') { $html[] = '<div class="button2-left">'; $html[] = '<div class="blank">'; $html[] = '<a class="modal" title="' . JText::_('COM_JUDIRECTORY_SELECT_LISTING') . '" href="' . $link . '&' . JSession::getFormToken() . '=1" rel="{handler: \'iframe\', size: {x: 800, y: 450}}">' . JText::_('COM_JUDIRECTORY_SELECT_LISTING') . '</a>'; $html[] = '</div>'; $html[] = '</div>'; } } if (0 == (int) $this->value) { $value = ''; } else { $value = (int) $this->value; } $class = ''; if ($this->required) { $class = ' class="required modal-value"'; } $html[] = '<input type="hidden" id="' . $this->id . '"' . $class . ' name="' . $this->name . '" value="' . $value . '" />'; return implode("\n", $html); }