示例#1
0
 /**
  * Displays HTML-form to configure module settings
  * 
  * @return HTML-code
  */
 function admin_configure()
 {
     $arp = JRequest::getVar('arp', array(), '', 'array');
     $jo_db =& JFactory::getDBO();
     $jo_document =& JFactory::getDocument();
     /* Add CSS */
     $jo_document->addStyleSheet(JRoute::_('index.php?option=com_glossword&&format=css&arg[files]=admin&arg[sef_output]=css'));
     /* */
     $str = '';
     if (empty($arp)) {
         /* Load component configuration */
         $query = 'SELECT * FROM #__gw_config ORDER BY `setting_key`';
         $jo_db->setQuery($query);
         $ar_sql = $jo_db->loadAssocList();
         $ar_cfg = array();
         foreach ($ar_sql as $k => $v) {
             $ar_cfg[$v['setting_key']] = $v['setting_value'];
         }
         /* Display HTML-form */
         $str .= HTML_glossword::showform($ar_cfg);
         /* Register tasks */
         JToolBarHelper::save('configure');
     } else {
         /* */
         GlosswordController::user_sync($arp, GW_ID_GROUP_ADMINS);
         GlosswordController::user_sync($arp, GW_ID_GROUP_USERS);
         foreach ($arp as $k => $v) {
             /* Checking trailing slash */
             if ($k == 'path_temp_abs' || $k == 'path_core_abs' || $k == 'server_dir' || $k == 'server_dir_admin') {
                 $v = str_replace("\\", "/", $v);
                 $v = preg_replace("/(\\x2f)\$/", '', $v);
             }
             $query = 'UPDATE #__gw_config' . ' SET setting_value = \'' . mysql_escape_string($v) . '\'' . ' WHERE setting_key = \'' . mysql_escape_string($k) . '\'';
             $jo_db->setQuery($query);
             $jo_db->query();
         }
         $href_index = JRoute::_('index.php?option=com_glossword');
         $str .= JText::_('Settings saved');
         $str .= '. <a href="' . $href_index . '">' . JText::_('Continue to Control Panel') . '</a>.';
     }
     print $str;
 }
/**
 * @version		$Id$
 * @package		Joomla
 * @subpackage	Glossword
 * @copyright	� Dmitry N. Shilnikov, 2007-2010
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant to the
 * GNU General Public License, and as distributed it includes or is derivative
 * of works licensed under the GNU General Public License or other free or open
 * source software licenses. See COPYRIGHT.php for copyright notices and
 * details.
 */
/* no direct access */
defined('_JEXEC') or die('Restricted access');
/* Require the base controller */
require_once JPATH_COMPONENT . DS . 'controller.php';
require_once JApplicationHelper::getPath('admin_html');
define('GW_ID_GROUP_USERS', 3);
define('GW_ID_GROUP_ADMINS', 1);
$controller = new GlosswordController();
$task = JRequest::getVar('task');
JSubMenuHelper::addEntry(JText::_('LJADM0001'), 'index.php?option=com_glossword', true);
JSubMenuHelper::addEntry(JText::_('LJADM0002'), 'index.php?option=com_glossword&task=configure', true);
switch (strtolower($task)) {
    case 'configure':
        GlosswordController::admin_configure();
        break;
    default:
        GlosswordController::admin_cph();
        break;
}