1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-26 17:30:24 +02: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 class usersettings_shortcodes extends e_shortcode
{ {
private $extendedTabs = false;
function sc_username($parm) // This is the 'display name' function sc_username($parm) // This is the 'display name'
{ {
@@ -262,7 +263,7 @@ class usersettings_shortcodes extends e_shortcode
function sc_userextended_all($parm) function sc_userextended_all($parm='')
{ {
$sql = e107::getDb(); $sql = e107::getDb();
$tp = e107::getParser(); $tp = e107::getParser();
@@ -276,28 +277,59 @@ class usersettings_shortcodes extends e_shortcode
$ret=""; $ret="";
if($sql->db_Select_gen($qry)) if($sql->gen($qry))
{ {
$catList = $sql->db_getList(); $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); $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) foreach($catList as $cat)
{ {
cachevars("extendedcat_{$cat['user_extended_struct_id']}", $cat); cachevars("extendedcat_{$cat['user_extended_struct_id']}", $cat);
$ret .= $this->sc_userextended_cat($cat['user_extended_struct_id']); $text = $this->sc_userextended_cat($cat['user_extended_struct_id']);
// $ret .= $tp->parseTemplate("{USEREXTENDED_CAT={$cat['user_extended_struct_id']}}", TRUE, $usersettings_shortcodes); $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; 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])) if(isset($extended_showed['cat'][$parm]))
{ {
return ""; return "";
@@ -312,9 +344,9 @@ class usersettings_shortcodes extends e_shortcode
AND user_extended_struct_write IN (".USERCLASS_LIST.") AND user_extended_struct_write IN (".USERCLASS_LIST.")
AND user_extended_struct_id = ".intval($parm)." 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 AND user_extended_struct_type != 0
ORDER BY user_extended_struct_order ASC ORDER BY user_extended_struct_order ASC
"; ";
if($sql->db_Select_gen($qry)) if($sql->gen($qry))
{ {
$fieldList = $sql->db_getList(); $fieldList = $sql->db_getList();
foreach($fieldList as $field) foreach($fieldList as $field)
{ {
cachevars("extendedfield_{$cat['user_extended_struct_name']}", $field); cachevars("extendedfield_{$cat['user_extended_struct_name']}", $field);
//TODO use $this instead of parseTemplate(); //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']; $catName = $catInfo['user_extended_struct_text'] ? $catInfo['user_extended_struct_text'] : $catInfo['user_extended_struct_name'];
if(defined($catName)) $catName = constant($catName); 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])) if(isset($extended_showed['field'][$parm]))
{ {
return ""; return "";
} }
$sql = e107::getDb();
$tp = e107::getParser();
$ret = ""; $ret = "";
$fInfo = getcachedvars("extendeddata_{$parm}"); $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_write IN (".USERCLASS_LIST.")
AND user_extended_struct_name = '".$tp -> toDB($parm, true)."' 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} {PHOTO_UPLOAD}
{USERCLASSES} {USERCLASSES}
{USEREXTENDED_ALL} {USEREXTENDED_ALL=tabs}
{SIGNATURE=cols=58&rows=4} {SIGNATURE=cols=58&rows=4}
@@ -308,11 +308,16 @@ $USERSETTINGS_TEMPLATE['edit'] = "
</div> </div>
</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>
<item name="location"> <item name="location">
<type>text</type> <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> <applicable>253</applicable>
<read>253</read> <read>253</read>
<write>253</write> <write>253</write>
</item> </item>
<item name="aim"> <item name="aim">
<type>text</type> <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> <applicable>253</applicable>
<read>253</read> <read>253</read>
<write>253</write> <write>253</write>
</item> </item>
<item name="icq"> <item name="icq">
<type>text</type> <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> <applicable>253</applicable>
<read>253</read> <read>253</read>
<write>253</write> <write>253</write>
</item> </item>
<item name="yahoo"> <item name="yahoo">
<type>text</type> <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> <applicable>253</applicable>
<read>253</read> <read>253</read>
<write>253</write> <write>253</write>
</item> </item>
<item name="msn"> <item name="msn">
<type>text</type> <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> <applicable>253</applicable>
<read>253</read> <read>253</read>
<write>253</write> <write>253</write>
</item> </item>
<item name="skype"> <item name="skype">
<type>text</type> <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> <applicable>253</applicable>
<read>253</read> <read>253</read>
<write>253</write> <write>253</write>
@@ -66,7 +66,7 @@
</item> </item>
<item name="homepage"> <item name="homepage">
<type>text</type> <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> <regex>#^[a-z0-9]+://#si</regex>
<applicable>253</applicable> <applicable>253</applicable>
<read>253</read> <read>253</read>

View File

@@ -890,7 +890,7 @@ class e_form
} }
else 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; // $text .= "ValueFormat: ".$dateFormat." Value: ".$value;

View File

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

View File

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