Permalink
Browse files

[altsys] add Pref formtype radio, checkbox & group_checkbox

XCL 2.2.2 compat. ref. xoopscube#59
  • Loading branch information...
nao-pon committed Mar 28, 2015
1 parent 3d61f80 commit 207e0c8158f004e07a062b91126a053637646324
@@ -0,0 +1,81 @@
<?php
// $Id: formcheckboxgroup.php,v 1.1 2007/05/15 02:34:42 minahito Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: Kazumi Ono (AKA onokazu) //
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
if (!defined('XOOPS_ROOT_PATH')) exit();
/**
* @package kernel
* @subpackage form
*
* @author Kazumi Ono <onokazu@xoops.org>
* @copyright copyright (c) 2000-2003 XOOPS.org
*/
/**
* Parent
*/
include_once XOOPS_ROOT_PATH."/class/xoopsform/formcheckbox.php";
/**
* A checkbox field with a choice of available groups
*
* @package kernel
* @subpackage form
*
* @author Kazumi Ono <onokazu@xoops.org>
* @copyright copyright (c) 2000-2003 XOOPS.org
*/
class AltsysFormCheckboxGroup extends XoopsFormCheckbox
{
/**
* Constructor
*
* @param string $caption
* @param string $name
* @param bool $include_anon Include group "anonymous"?
* @param mixed $value Pre-selected value (or array of them).
*/
function AltsysFormCheckboxGroup($caption, $name, $include_anon=false, $value=null)
{
$this->XoopsFormCheckbox($caption, $name, $value);
$member_handler =& xoops_gethandler('member');
if (!$include_anon) {
$options = $member_handler->getGroupList(new Criteria('groupid', XOOPS_GROUP_ANONYMOUS, '!='));
} else {
$options = $member_handler->getGroupList();
}
foreach($options as $k => $v) {
$options[$k] = $v . '<br />';
}
$this->addOptionArray($options);
}
}
?>
@@ -86,23 +86,38 @@
}
break;
case 'select':
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
case 'radio':
if ($config[$i]->getVar('conf_formtype') === 'select') {
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
$addBr = '';
} else {
$ele = new XoopsFormRadio($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
$addBr = '<br />';
}
$options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
$opcount = count($options);
for ($j = 0; $j < $opcount; $j++) {
$optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
$optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
$ele->addOption($optval, $optkey);
$ele->addOption($optval, $optkey.$addBr);
}
break;
case 'select_multi':
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true);
case 'checkbox':
if ($config[$i]->getVar('conf_formtype') === 'select_multi') {
$ele = new XoopsFormSelect($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput(), 5, true);
$addBr = '';
} else {
$ele = new XoopsFormCheckBox($title, $config[$i]->getVar('conf_name'), $config[$i]->getConfValueForOutput());
$addBr = '<br />';
}
$options =& $config_handler->getConfigOptions(new Criteria('conf_id', $config[$i]->getVar('conf_id')));
$opcount = count($options);
for ($j = 0; $j < $opcount; $j++) {
$optval = defined($options[$j]->getVar('confop_value')) ? constant($options[$j]->getVar('confop_value')) : $options[$j]->getVar('confop_value');
$optkey = defined($options[$j]->getVar('confop_name')) ? constant($options[$j]->getVar('confop_name')) : $options[$j]->getVar('confop_name');
$ele->addOption($optval, $optkey);
$ele->addOption($optval, $optkey.$addBr);
}
break;
case 'yesno':
@@ -116,6 +131,10 @@
include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';
$ele = new XoopsFormSelectGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput(), 5, true);
break;
case 'group_checkbox':
include_once dirname(__FILE__).'/include/formcheckboxgroup.php';
$ele = new AltsysFormCheckboxGroup($title, $config[$i]->getVar('conf_name'), false, $config[$i]->getConfValueForOutput());
break;
// RMV-NOTIFY: added 'user' and 'user_multi'
case 'user':
include_once XOOPS_ROOT_PATH.'/class/xoopslists.php';

0 comments on commit 207e0c8

Please sign in to comment.