1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00

Fixes #592 Missing User-extended fields when using Bootstrap with usersettings page.

Closes #539 Tabs view of user-extended categories when using Bootstrap.
Added missing css classes to extended-fields.
This commit is contained in:
Cameron 2014-10-05 00:21:58 -07:00
parent 6c9680d3c0
commit abeb140fe6
6 changed files with 94 additions and 42 deletions

View File

@ -17,6 +17,7 @@ if (!defined('e107_INIT')) { exit; }
class usersettings_shortcodes extends e_shortcode
{
private $extendedTabs = false;
function sc_username($parm) // This is the 'display name'
{
@ -262,8 +263,8 @@ class usersettings_shortcodes extends e_shortcode
function sc_userextended_all($parm)
{
function sc_userextended_all($parm='')
{
$sql = e107::getDb();
$tp = e107::getParser();
@ -276,28 +277,59 @@ class usersettings_shortcodes extends e_shortcode
$ret="";
if($sql->db_Select_gen($qry))
if($sql->gen($qry))
{
$catList = $sql->db_getList();
}
else
{
e107::getMessage()->addDebug("No extended fields found");
}
$catList[] = array("user_extended_struct_id" => 0, "user_extended_struct_name" => LAN_USET_7);
$tabs = array();
if($parm == 'tabs')
{
$this->extendedTabs = true;
}
foreach($catList as $cat)
{
cachevars("extendedcat_{$cat['user_extended_struct_id']}", $cat);
$ret .= $this->sc_userextended_cat($cat['user_extended_struct_id']);
// $ret .= $tp->parseTemplate("{USEREXTENDED_CAT={$cat['user_extended_struct_id']}}", TRUE, $usersettings_shortcodes);
$text = $this->sc_userextended_cat($cat['user_extended_struct_id']);
$ret .= $text;
$catName = vartrue($cat['user_extended_struct_text'], $cat['user_extended_struct_name']);
$tabs[] = array('caption'=>$catName, 'text'=>$text);
}
if($parm == 'tabs' && deftrue('BOOTSTRAP'))
{
return e107::getForm()->tabs($tabs);
}
return $ret;
}
function sc_userextended_cat($parm)
function sc_userextended_cat($parm='')
{
global $sql, $tp, $usersettings_shortcodes, $USER_EXTENDED_CAT, $extended_showed;
global $usersettings_shortcodes, $USER_EXTENDED_CAT, $extended_showed;
if(deftrue('BOOTSTRAP'))
{
$USER_EXTENDED_CAT = e107::getCoreTemplate('usersettings','extended-category');
}
$sql = e107::getDb();
$tp = e107::getParser();
if(isset($extended_showed['cat'][$parm]))
{
return "";
@ -312,9 +344,9 @@ class usersettings_shortcodes extends e_shortcode
AND user_extended_struct_write IN (".USERCLASS_LIST.")
AND user_extended_struct_id = ".intval($parm)."
";
if($sql->db_Select_gen($qry))
if($sql->gen($qry))
{
$catInfo = $sql->db_Fetch();
$catInfo = $sql->fetch();
}
}
@ -328,19 +360,20 @@ class usersettings_shortcodes extends e_shortcode
AND user_extended_struct_type != 0
ORDER BY user_extended_struct_order ASC
";
if($sql->db_Select_gen($qry))
if($sql->gen($qry))
{
$fieldList = $sql->db_getList();
foreach($fieldList as $field)
{
cachevars("extendedfield_{$cat['user_extended_struct_name']}", $field);
//TODO use $this instead of parseTemplate();
$ret .= $tp->parseTemplate("{USEREXTENDED_FIELD={$field['user_extended_struct_name']}}", TRUE, $usersettings_shortcodes);
$ret .= $this->sc_userextended_field($field['user_extended_struct_name']);
// $ret .= $tp->parseTemplate("{USEREXTENDED_FIELD={$field['user_extended_struct_name']}}", TRUE, $usersettings_shortcodes);
}
}
}
if($ret)
if($ret && $this->extendedTabs == false)
{
$catName = $catInfo['user_extended_struct_text'] ? $catInfo['user_extended_struct_text'] : $catInfo['user_extended_struct_name'];
if(defined($catName)) $catName = constant($catName);
@ -353,13 +386,25 @@ class usersettings_shortcodes extends e_shortcode
function sc_userextended_field($parm)
function sc_userextended_field($parm='')
{
global $sql, $tp, $usersettings_shortcodes, $extended_showed, $ue, $USEREXTENDED_FIELD, $REQUIRED_FIELD;
global $usersettings_shortcodes, $extended_showed, $ue, $USEREXTENDED_FIELD, $REQUIRED_FIELD;
if(deftrue('BOOTSTRAP'))
{
$USEREXTENDED_FIELD = e107::getCoreTemplate('usersettings','extended-field');
}
if(isset($extended_showed['field'][$parm]))
{
return "";
}
$sql = e107::getDb();
$tp = e107::getParser();
$ret = "";
$fInfo = getcachedvars("extendeddata_{$parm}");
@ -371,9 +416,9 @@ class usersettings_shortcodes extends e_shortcode
AND user_extended_struct_write IN (".USERCLASS_LIST.")
AND user_extended_struct_name = '".$tp -> toDB($parm, true)."'
";
if($sql->db_Select_gen($qry))
if($sql->gen($qry))
{
$fInfo = $sql->db_Fetch();
$fInfo = $sql->fetch();
}
}

View File

@ -295,7 +295,7 @@ $USERSETTINGS_TEMPLATE['edit'] = "
{PHOTO_UPLOAD}
{USERCLASSES}
{USEREXTENDED_ALL}
{USEREXTENDED_ALL=tabs}
{SIGNATURE=cols=58&rows=4}
@ -308,11 +308,16 @@ $USERSETTINGS_TEMPLATE['edit'] = "
</div>
</div>
";
$USERSETTINGS_TEMPLATE['extended-category'] = "<h3>{CATNAME}</h3>";
$USERSETTINGS_TEMPLATE['extended-field'] = "<div class='form-group'>
<label class='col-sm-3 control-label'>{FIELDNAME}</label>
<div class='col-sm-9'>
{FIELDVAL} {HIDEFIELD}
</div>
</div>
";

View File

@ -17,42 +17,42 @@
</item>
<item name="location">
<type>text</type>
<include_text>class='tbox' size='40' maxlength='254'</include_text>
<include_text>class='form-control tbox' size='40' maxlength='254'</include_text>
<applicable>253</applicable>
<read>253</read>
<write>253</write>
</item>
<item name="aim">
<type>text</type>
<include_text>class='tbox' size='40' maxlength='254'</include_text>
<include_text>class='form-control tbox' size='40' maxlength='254'</include_text>
<applicable>253</applicable>
<read>253</read>
<write>253</write>
</item>
<item name="icq">
<type>text</type>
<include_text>class='tbox' size='40' maxlength='254'</include_text>
<include_text>class='form-control tbox' size='40' maxlength='254'</include_text>
<applicable>253</applicable>
<read>253</read>
<write>253</write>
</item>
<item name="yahoo">
<type>text</type>
<include_text>class='tbox' size='40' maxlength='254'</include_text>
<include_text>class='form-control tbox' size='40' maxlength='254'</include_text>
<applicable>253</applicable>
<read>253</read>
<write>253</write>
</item>
<item name="msn">
<type>text</type>
<include_text>class='tbox' size='40' maxlength='254'</include_text>
<include_text>class='form-control tbox' size='40' maxlength='254'</include_text>
<applicable>253</applicable>
<read>253</read>
<write>253</write>
</item>
<item name="skype">
<type>text</type>
<include_text>class='tbox' size='40' maxlength='254'</include_text>
<include_text>class='form-control tbox' size='40' maxlength='254'</include_text>
<applicable>253</applicable>
<read>253</read>
<write>253</write>
@ -66,7 +66,7 @@
</item>
<item name="homepage">
<type>text</type>
<include_text>class='tbox' size='40' maxlength='254'</include_text>
<include_text>class='form-control tbox' size='40' maxlength='254'</include_text>
<regex>#^[a-z0-9]+://#si</regex>
<applicable>253</applicable>
<read>253</read>

View File

@ -890,7 +890,7 @@ class e_form
}
else
{
$text .= "<input class='{$class} input-".$xsize."' type='text' size='{$size}' name='{$name}' id='{$id}' value='{$value}' data-date-format='{$dformat}' data-date-ampm='{$ampm}' data-date-language='".e_LAN."' data-date-firstday='{$firstDay}' {$required} />";
$text .= "<input class='{$class} input-".$xsize." form-control' type='text' size='{$size}' name='{$name}' id='{$id}' value='{$value}' data-date-format='{$dformat}' data-date-ampm='{$ampm}' data-date-language='".e_LAN."' data-date-firstday='{$firstDay}' {$required} />";
}
// $text .= "ValueFormat: ".$dateFormat." Value: ".$value;

View File

@ -675,10 +675,11 @@ class e107_user_extended
$regex = $tp->toText($parms[1]);
$regexfail = $tp->toText($parms[2]);
$fname = "ue[user_".$struct['user_extended_struct_name']."]";
$required = vartrue($struct['user_extended_struct_required']) ? "required" : "";
if(strpos($include, 'class') === FALSE)
{
$include .= " class='tbox' ";
$include .= " class='form-control tbox' ";
}
@ -686,7 +687,8 @@ class e107_user_extended
{
case EUF_TEXT : //textbox
case EUF_INTEGER : //integer
$ret = "<input name='{$fname}' value='{$curval}' {$include} />";
$ret = "<input name='{$fname}' value='{$curval}' {$include} {$required} />";
return $ret;
break;
@ -715,12 +717,12 @@ class e107_user_extended
if(deftrue('BOOTSTRAP'))
{
$ret .= $frm->radio($fname,$val,($curval == $val),array('label'=>$label));
$ret .= $frm->radio($fname,$val,($curval == $val),array('label'=>$label, 'required'=> $struct['user_extended_struct_required']));
}
else
{
$chk = ($curval == $val)? " checked='checked' " : "";
$ret .= "<input {$include} type='radio' name='{$fname}' value='{$val}' {$chk} /> {$label}";
$ret .= "<input {$include} type='radio' name='{$fname}' value='{$val}' {$chk} {$required} /> {$label}";
}
}
@ -751,7 +753,7 @@ class e107_user_extended
if(deftrue('BOOTSTRAP'))
{
$ret .= $frm->checkbox($fname,$val,($curval == $val),array('label'=>$label));
$ret .= $frm->checkbox($fname,$val,($curval == $val),array('label'=>$label, 'required'=> $struct['user_extended_struct_required']));
}
else
{
@ -764,7 +766,7 @@ class e107_user_extended
break;
case EUF_DROPDOWN : //dropdown
$ret = "<select {$include} name='{$fname}'>\n";
$ret = "<select {$include} name='{$fname}' {$required} >\n";
$ret .= "<option value=''>&nbsp;</option>\n"; // ensures that the user chose it.
foreach($choices as $choice)
{
@ -788,7 +790,7 @@ class e107_user_extended
if (!method_exists($className, 'getValue')) return '???-???';
$temp->pointerReset();
$ret = "<select {$include} name='{$fname}'>\n";
$ret = "<select {$include} name='{$fname}' {$required} >\n";
$ret .= "<option value=''>&nbsp;</option>\n"; // ensures that the user chooses it.
while (FALSE !== ($row = $temp->getValue(0, 'next')))
{
@ -808,7 +810,7 @@ class e107_user_extended
if($sql->db_Select($tp -> toDB($choices[0], true), $tp -> toDB($choices[1], true).",".$tp -> toDB($choices[2], true), "1 $order")){
$choiceList = $sql->db_getList('ALL',FALSE);
$ret = "<select {$include} name='{$fname}' >\n";
$ret = "<select {$include} name='{$fname}' {$required} >\n";
$ret .= "<option value=''>&nbsp;</option>\n"; // ensures that the user chose it.
foreach($choiceList as $cArray)
{
@ -825,7 +827,7 @@ class e107_user_extended
break;
case EUF_TEXTAREA : //textarea
return "<textarea {$include} name='{$fname}' >{$curval}</textarea>";
return "<textarea {$include} name='{$fname}' {$required} >{$curval}</textarea>";
break;
case EUF_DATE : //date
@ -839,11 +841,10 @@ class e107_user_extended
break;
case EUF_LANGUAGE : // language
require_once(e_HANDLER."file_class.php");
$fl = new e_file;
$lanlist = $fl->get_dirs(e_LANGUAGEDIR);
$lanlist = e107::getLanguage()->installed();
sort($lanlist);
$ret = "<select {$include} name='{$fname}'>\n";
$ret = "<select {$include} name='{$fname}' {$required} >\n";
$ret .= "<option value=''>&nbsp;</option>\n"; // ensures that the user chose it.
foreach($lanlist as $choice)
{
@ -852,6 +853,7 @@ class e107_user_extended
$ret .= "<option value='{$choice}' {$sel}>{$choice}</option>\n";
}
$ret .= "</select>\n";
break;
}

View File

@ -112,7 +112,7 @@ img.featurebox { border-radius: 5px }
.btn-featurebox, .btn-cpage { margin-top:10px }
.tab-pane { padding-top:15px }
/* CUSTOM Responsive Styles */