1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 22:57:14 +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 * News Administration
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $ * $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $
* $Revision: 1.28 $ * $Revision: 1.29 $
* $Date: 2009-01-20 21:29:23 $ * $Date: 2009-01-20 22:37:49 $
* $Author: secretr $ * $Author: secretr $
*/ */
require_once("../class2.php"); require_once("../class2.php");
@@ -1080,8 +1080,8 @@ class admin_newspost
$text .= " $text .= "
<tr> <tr>
<td class='label'>".NWSLAN_22.":</td> <td class='label'>".NWSLAN_22.":</td>
<td class='control'><div class='check-block'> <td class='control'>
".$e107->user_class->vetted_tree("news_userclass", array($e107->user_class,'checkbox'), $_POST['news_class'], "nobody,public,guest,member,admin,classes,language")."</div> ".$frm->uc_checkbox('news_userclass', $_POST['news_class'], 'nobody,public,guest,member,admin,classes,language', 'description=1')."
<div class='field-help'> <div class='field-help'>
".NWSLAN_84." ".NWSLAN_84."
</div> </div>
@@ -1479,13 +1479,13 @@ class admin_newspost
<tr> <tr>
<td class='label'>".LAN_NEWS_51."</td> <td class='label'>".LAN_NEWS_51."</td>
<td class='control'> <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> </td>
</tr> </tr>
<tr> <tr>
<td class='label'>".NWSLAN_106."</td> <td class='label'>".NWSLAN_106."</td>
<td class='control'> <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> </td>
</tr> </tr>
<tr> <tr>

View File

@@ -9,8 +9,8 @@
* Form Handler * Form Handler
* *
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $ * $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
* $Revision: 1.20 $ * $Revision: 1.21 $
* $Date: 2009-01-20 20:46:26 $ * $Date: 2009-01-20 22:37:49 $
* $Author: secretr $ * $Author: secretr $
* *
*/ */
@@ -71,7 +71,7 @@ class e_form
{ {
$this->_tabindex_enabled = $enable_tabindex; $this->_tabindex_enabled = $enable_tabindex;
$e107 = &e107::getInstance(); $e107 = &e107::getInstance();
$this->uc = &$e107->user_class; $this->_uc = &$e107->user_class;
} }
function text($name, $value, $maxlength = 200, $options = array()) 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')); 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()) function radio($name, $value, $checked = false, $options = array())
{ {
$options['checked'] = $checked; //comes as separate argument just for convenience $options['checked'] = $checked; //comes as separate argument just for convenience
@@ -210,11 +241,9 @@ class e_form
return $this->select_open($name, $options)."\n".$this->option_multi($option_array, $selected)."\n".$this->select_close(); return $this->select_open($name, $options)."\n".$this->option_multi($option_array, $selected)."\n".$this->select_close();
} }
//UNDER CONSTRUCTION function uc_select($name, $current_value, $uc_options, $select_options = array(), $opt_options = array())
function uc_select($name, $default, $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).$this->_uc->vetted_tree($name, array($this, '_uc_select_cb'), $current_value, $uc_options, $opt_options).$this->select_close();
return $this->select_open($name, $select_options).$ret.$this->select_close();
} }
// Callback for vetted_tree - Creates the option list for a selection box // Callback for vetted_tree - Creates the option list for a selection box
@@ -239,9 +268,8 @@ class e_form
$prefix = '&nbsp;&nbsp;'.str_repeat('--', $nest_level - 1).'&gt;'; $prefix = '&nbsp;&nbsp;'.str_repeat('--', $nest_level - 1).'&gt;';
$style = ''; $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) function optgroup_open($label, $disabled)
{ {

View File

@@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/userclass_class.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/userclass_class.php,v $
| $Revision: 1.29 $ | $Revision: 1.30 $
| $Date: 2009-01-20 22:22:01 $ | $Date: 2009-01-20 22:37:49 $
| $Author: e107steved $ | $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 $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 $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 = ''; $ret = '';
$nest_level++; $nest_level++;
@@ -491,9 +491,9 @@ class user_class
// Looks like we don't need to differentiate between function and class calls // Looks like we don't need to differentiate between function and class calls
if (isset($perms[$p])) 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; return $ret;
} }
@@ -514,9 +514,9 @@ class user_class
{ {
if (isset($perms[$p])) 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; 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; } .field-help { width: 280px; line-height: 1.4em; padding-top: 3px; color:#333333; font-size: 11px; }
.label-note { font-style: italic; } .label-note { font-style: italic; }
.form-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) */ /* Related JS functionality - .autocheck together with .auto-toggle-area (see admin/image.php) */
.auto-toggle-area { width: 280px; cursor: pointer; } .auto-toggle-area { width: 280px; cursor: pointer; }