1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-05 14:17:49 +02:00

e_form - full userclass support - select, checkbox lists, newspost updated to use them

This commit is contained in:
secretr
2009-01-20 22:37:49 +00:00
parent 8687136581
commit 4ec4f4fac7
4 changed files with 54 additions and 25 deletions

View File

@@ -9,8 +9,8 @@
* News Administration
*
* $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $
* $Revision: 1.28 $
* $Date: 2009-01-20 21:29:23 $
* $Revision: 1.29 $
* $Date: 2009-01-20 22:37:49 $
* $Author: secretr $
*/
require_once("../class2.php");
@@ -1080,8 +1080,8 @@ class admin_newspost
$text .= "
<tr>
<td class='label'>".NWSLAN_22.":</td>
<td class='control'><div class='check-block'>
".$e107->user_class->vetted_tree("news_userclass", array($e107->user_class,'checkbox'), $_POST['news_class'], "nobody,public,guest,member,admin,classes,language")."</div>
<td class='control'>
".$frm->uc_checkbox('news_userclass', $_POST['news_class'], 'nobody,public,guest,member,admin,classes,language', 'description=1')."
<div class='field-help'>
".NWSLAN_84."
</div>
@@ -1479,13 +1479,13 @@ class admin_newspost
<tr>
<td class='label'>".LAN_NEWS_51."</td>
<td class='control'>
".$frm->uc_select('news_editauthor', $pref['news_editauthor'], 'nobody,main,admin,classes', 'tabindex='.$frm->getNext())."
".$frm->uc_select('news_editauthor', $pref['news_editauthor'], 'nobody,main,admin,classes')."
</td>
</tr>
<tr>
<td class='label'>".NWSLAN_106."</td>
<td class='control'>
".$frm->uc_select('subnews_class', $pref['subnews_class'], 'nobody,public,guest,member,admin,classes', 'tabindex='.$frm->getNext())."
".$frm->uc_select('subnews_class', $pref['subnews_class'], 'nobody,public,guest,member,admin,classes')."
</td>
</tr>
<tr>

View File

@@ -9,8 +9,8 @@
* Form Handler
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
* $Revision: 1.20 $
* $Date: 2009-01-20 20:46:26 $
* $Revision: 1.21 $
* $Date: 2009-01-20 22:37:49 $
* $Author: secretr $
*
*/
@@ -71,7 +71,7 @@ class e_form
{
$this->_tabindex_enabled = $enable_tabindex;
$e107 = &e107::getInstance();
$this->uc = &$e107->user_class;
$this->_uc = &$e107->user_class;
}
function text($name, $value, $maxlength = 200, $options = array())
@@ -162,6 +162,37 @@ class e_form
return $this->checkbox($name, $selector, false, array('id'=>false,'class'=>'checkbox toggle-all'));
}
function uc_checkbox($name, $current_value, $uc_options, $field_options = array())
{
if(!is_array($field_options)) parse_str($field_options, $field_options);
return '
<div class="check-block">
'.$this->_uc->vetted_tree($name, array($this, '_uc_checkbox_cb'), $current_value, $uc_options, $field_options).'
</div>
';
}
function _uc_checkbox_cb($treename, $classnum, $current_value, $nest_level, $field_options)
{
if($classnum == e_UC_BLANK)
return '';
$tmp = explode(',', $current_value);
$class = $style = '';
if($nest_level == 0)
{
$class = " strong";
}
else
{
$style = " style='text-indent:" . (1.2 * $nest_level) . "em'";
}
$descr = varset($field_options['description']) ? ' <span class="smalltext">('.$this->_uc->uc_get_classdescription($classnum).')</span>' : '';
return "<div class='field-spacer{$class}'{$style}>".$this->checkbox($treename.'[]', $classnum, in_array($classnum, $tmp), $field_options).$this->label($this->_uc->uc_get_classname($classnum), $treename.'[]', $classnum).$descr."</div>\n";
}
function radio($name, $value, $checked = false, $options = array())
{
$options['checked'] = $checked; //comes as separate argument just for convenience
@@ -209,12 +240,10 @@ class e_form
{
return $this->select_open($name, $options)."\n".$this->option_multi($option_array, $selected)."\n".$this->select_close();
}
//UNDER CONSTRUCTION
function uc_select($name, $default, $uc_options, $select_options = array(), $opt_options = array())
function uc_select($name, $current_value, $uc_options, $select_options = array(), $opt_options = array())
{
$ret = $this->uc->vetted_tree($name, array($this, '_uc_select_cb'), $default, $uc_options, $opt_options);
return $this->select_open($name, $select_options).$ret.$this->select_close();
return $this->select_open($name, $select_options).$this->_uc->vetted_tree($name, array($this, '_uc_select_cb'), $current_value, $uc_options, $opt_options).$this->select_close();
}
// Callback for vetted_tree - Creates the option list for a selection box
@@ -238,10 +267,9 @@ class e_form
{
$prefix = '&nbsp;&nbsp;'.str_repeat('--', $nest_level - 1).'&gt;';
$style = '';
}
return $this->option($prefix.$this->uc->uc_get_classname($classnum), $classnum, in_array($classnum, $tmp), "style={$style}");
}
return $this->option($prefix.$this->_uc->uc_get_classname($classnum), $classnum, in_array($classnum, $tmp), "style={$style}");
}
//UNDER CONSTRUCTION END
function optgroup_open($label, $disabled)
{

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org).
|
| $Source: /cvs_backup/e107_0.8/e107_handlers/userclass_class.php,v $
| $Revision: 1.29 $
| $Date: 2009-01-20 22:22:01 $
| $Author: e107steved $
| $Revision: 1.30 $
| $Date: 2009-01-20 22:37:49 $
| $Author: secretr $
+----------------------------------------------------------------------------+
*/
@@ -482,7 +482,7 @@ class user_class
$current_value is a single class number for single-select dropdown; comma separated array of class numbers for checkbox list or multi-select
$optlist works the same as for other class displays
*/
function vetted_sub_tree($treename, $callback,$listnum,$nest_level,$current_value, $perms)
function vetted_sub_tree($treename, $callback,$listnum,$nest_level,$current_value, $perms, $opt_options)
{
$ret = '';
$nest_level++;
@@ -491,9 +491,9 @@ class user_class
// Looks like we don't need to differentiate between function and class calls
if (isset($perms[$p]))
{
$ret .= call_user_func($callback,$treename, $p,$current_value,$nest_level);
$ret .= call_user_func($callback,$treename, $p,$current_value,$nest_level, $opt_options);
}
$ret .= $this->vetted_sub_tree($treename, $callback,$p,$nest_level,$current_value, $perms);
$ret .= $this->vetted_sub_tree($treename, $callback,$p,$nest_level,$current_value, $perms, $opt_options);
}
return $ret;
}
@@ -514,9 +514,9 @@ class user_class
{
if (isset($perms[$p]))
{
$ret .= call_user_func($callback,$treename, $p,$current_value,0);
$ret .= call_user_func($callback,$treename, $p,$current_value,0, $opt_options);
}
$ret .= $this->vetted_sub_tree($treename, $callback,$p,0, $current_value, $perms. $opt_options);
$ret .= $this->vetted_sub_tree($treename, $callback,$p,0, $current_value, $perms, $opt_options);
}
return $ret;
}

View File

@@ -147,6 +147,7 @@ label { cursor: pointer; }
.field-help { width: 280px; line-height: 1.4em; padding-top: 3px; color:#333333; font-size: 11px; }
.label-note { font-style: italic; }
.form-note { font-style: italic; }
.field-spacer.strong { font-weight: bold }
/* Related JS functionality - .autocheck together with .auto-toggle-area (see admin/image.php) */
.auto-toggle-area { width: 280px; cursor: pointer; }