Skip to content

Commit

Permalink
Merge pull request #8572 from RonakParmar/8470_help_site_link_per_user
Browse files Browse the repository at this point in the history
#8470 fixed help site link per user issue
  • Loading branch information
Kubik-Rubik committed Dec 16, 2015
2 parents c7964b1 + 9b1b7a4 commit a0fbc2d
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,9 @@
name="helpurl"
type="helpsite"
label="COM_CONFIG_FIELD_HELP_SERVER_LABEL"
description="COM_CONFIG_FIELD_HELP_SERVER_DESC" />
description="COM_CONFIG_FIELD_HELP_SERVER_DESC"
showDefault="false"
/>
</fieldset>

<fieldset
Expand Down
21 changes: 21 additions & 0 deletions administrator/components/com_users/controllers/profile.json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
* @package Joomla.Administrator
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

require_once JPATH_SITE . '/components/com_users/controllers/profile_base_json.php';

/**
* Profile controller class for Users.
*
* @since 3.5
*/
class UsersControllerProfile extends UsersControllerProfile_Base_Json
{
}
8 changes: 2 additions & 6 deletions administrator/help/helpsites.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<joshelp>
<sites>
<site
tag="en-GB"
url="https://help.joomla.org/proxy/index.php?option=com_help&amp;keyref=Help{major}{minor}:{keyref}">English (GB) - Joomla help wiki</site>
<site
tag="fr-FR"
url="http://help.joomla.fr/3/index.php?option=com_help&amp;keyref=Help{major}{minor}:{keyref}">Français (FR) - Aide de Joomla!</site>
<site tag="en-GB" url="https://help.joomla.org/proxy/index.php?option=com_help&amp;keyref=Help{major}{minor}:{keyref}">English (GB) - Joomla help wiki</site>
<site tag="fr-FR" url="http://help.joomla.fr/3/index.php?option=com_help&amp;keyref=Help{major}{minor}:{keyref}">Français (FR) - Aide de Joomla!</site>
</sites>
</joshelp>
32 changes: 2 additions & 30 deletions components/com_users/controllers/profile.json.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,41 +9,13 @@

defined('_JEXEC') or die;

require_once JPATH_COMPONENT . '/controller.php';
require_once JPATH_SITE . '/components/com_users/controllers/profile_base_json.php';

/**
* Profile controller class for Users.
*
* @since 1.6
*/
class UsersControllerProfile extends UsersController
class UsersControllerProfile extends UsersControllerProfile_Base_Json
{
/**
* Returns the updated options for help site selector
*
* @return void
*
* @since 3.2
* @throws Exception
*/
public function gethelpsites()
{
jimport('joomla.filesystem.file');

// Set FTP credentials, if given
JClientHelper::setCredentialsFromRequest('ftp');

if (($data = file_get_contents('http://update.joomla.org/helpsites/helpsites.xml')) === false)
{
throw new Exception(JText::_('COM_CONFIG_ERROR_HELPREFRESH_FETCH'), 500);
}
elseif (!JFile::write(JPATH_ADMINISTRATOR . '/help/helpsites.xml', $data))
{
throw new Exception(JText::_('COM_CONFIG_ERROR_HELPREFRESH_ERROR_STORE'), 500);
}

$options = JHelp::createSiteList(JPATH_ADMINISTRATOR . '/help/helpsites.xml');
echo json_encode($options);
JFactory::getApplication()->close();
}
}
53 changes: 53 additions & 0 deletions components/com_users/controllers/profile_base_json.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?php
/**
* @package Joomla.Site
* @subpackage com_users
*
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

/**
* Profile controller class for Users.
*
* @since 3.5
*/
class UsersControllerProfile_Base_Json extends JControllerLegacy
{
/**
* Returns the updated options for help site selector
*
* @return void
*
* @since 3.5
* @throws Exception
*/
public function gethelpsites()
{
jimport('joomla.filesystem.file');

// Set FTP credentials, if given
JClientHelper::setCredentialsFromRequest('ftp');

if (($data = file_get_contents('http://update.joomla.org/helpsites/helpsites.xml')) === false)
{
throw new Exception(JText::_('COM_CONFIG_ERROR_HELPREFRESH_FETCH'), 500);
}
elseif (!JFile::write(JPATH_ADMINISTRATOR . '/help/helpsites.xml', $data))
{
throw new Exception(JText::_('COM_CONFIG_ERROR_HELPREFRESH_ERROR_STORE'), 500);
}

$options = array_merge(
array(
JHtml::_('select.option', '', JText::_('JOPTION_USE_DEFAULT'))
),
JHelp::createSiteList(JPATH_ADMINISTRATOR . '/help/helpsites.xml')
);

echo json_encode($options);
JFactory::getApplication()->close();
}
}
6 changes: 3 additions & 3 deletions libraries/cms/form/field/helpsite.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ protected function getOptions()
protected function getInput()
{
JHtml::script('system/helpsite.js', false, true);
JFactory::getDocument()->addScriptDeclaration(
'var helpsite_base = "' . addslashes(JUri::root()) . '";'
);

$showDefault = $this->getAttribute('showDefault') === 'false' ? 'false' : 'true';

$html = parent::getInput();
$button = '<button
type="button"
class="btn btn-small"
id="helpsite-refresh"
rel="' . $this->id . '"
showDefault="' . $showDefault . '"
>
<span>' . JText::_('JGLOBAL_HELPREFRESH_BUTTON') . '</span>
</button>';
Expand Down
10 changes: 7 additions & 3 deletions media/system/js/helpsite.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ jQuery(document).ready(function() {
jQuery('#helpsite-refresh').click(function()
{
// Uses global variable helpsite_base for bast uri
var select_id = jQuery(this).attr('rel');
jQuery.getJSON(helpsite_base + 'index.php?option=com_users&task=profile.gethelpsites&format=json', function(data){
var select_id = jQuery(this).attr('rel');
var showDefault = jQuery(this).attr('showDefault');

jQuery.getJSON('index.php?option=com_users&task=profile.gethelpsites&format=json', function(data){
// The response contains the options to use in help site select field
var items = [];

// Build options
jQuery.each(data, function(key, val) {
items.push('<option value="' + val.value + '">' + val.text + '</option>');
if (val.value !== '' || showDefault === 'true') {
items.push('<option value="' + val.value + '">' + val.text + '</option>');
}
});

// Replace current select options. The trigger is needed for Chosen select box enhancer
Expand Down

0 comments on commit a0fbc2d

Please sign in to comment.