mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Merge pull request #1451 from lonalore/master
Inline support for expandit behavior. Use Ajax API to avoid page-reload on user extended form.
This commit is contained in:
@@ -9,25 +9,145 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
require_once('../class2.php');
|
require_once('../class2.php');
|
||||||
|
|
||||||
if (!getperms('4'))
|
if (!getperms('4'))
|
||||||
{
|
{
|
||||||
e107::redirect('admin');
|
e107::redirect('admin');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
if (isset($_POST['cancel']))
|
|
||||||
{
|
|
||||||
header('location:'.e_SELF);
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
if (isset($_POST['cancel_cat']))
|
|
||||||
{
|
|
||||||
header("location:".e_SELF."?cat");
|
|
||||||
exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
include_lan(e_LANGUAGEDIR . e_LANGUAGE . '/admin/lan_' . e_PAGE);
|
include_lan(e_LANGUAGEDIR . e_LANGUAGE . '/admin/lan_' . e_PAGE);
|
||||||
|
|
||||||
|
if(varset($_GET['mode']) == "ajax")
|
||||||
|
{
|
||||||
|
// Construct action string.
|
||||||
|
$action = varset($_GET['mode']) . '/' . varset($_GET['action']);
|
||||||
|
|
||||||
|
switch($action)
|
||||||
|
{
|
||||||
|
case 'ajax/changeTable':
|
||||||
|
$tableName = varset($_POST['table_db'], null);
|
||||||
|
|
||||||
|
if($tableName)
|
||||||
|
{
|
||||||
|
$sql = e107::getDb();
|
||||||
|
|
||||||
|
$sub_action = '';
|
||||||
|
|
||||||
|
if(e_QUERY)
|
||||||
|
{
|
||||||
|
$tmp = explode(".", e_QUERY);
|
||||||
|
$action = $tmp[0];
|
||||||
|
$sub_action = varset($tmp[1], '');
|
||||||
|
$id = varset($tmp[2], 0);
|
||||||
|
unset($tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($sql->select('user_extended_struct', '*', "user_extended_struct_id = '{$sub_action}'"))
|
||||||
|
{
|
||||||
|
$current = $sql->fetch();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$current = 'new';
|
||||||
|
}
|
||||||
|
|
||||||
|
$currVal = $current['user_extended_struct_values'];
|
||||||
|
$curVals = explode(",", varset($currVal));
|
||||||
|
|
||||||
|
// Ajax URL for "Table" dropdown.
|
||||||
|
$ajaxGetTableSrc = e_SELF . '?mode=ajax&action=changeTable';
|
||||||
|
|
||||||
|
$text = "<table style='width:70%;margin-left:0;'><tr><td>";
|
||||||
|
$text .= EXTLAN_62 . "</td><td style='70%'>\n";
|
||||||
|
$text .= "<select name='table_db' style='width:99%' class='tbox e-ajax' data-src='{$ajaxGetTableSrc}'>";
|
||||||
|
$text .= "<option value='' class='caption'>" . EXTLAN_61 . "</option>";
|
||||||
|
$result = e107::getDb()->tables();
|
||||||
|
foreach($result as $row2)
|
||||||
|
{
|
||||||
|
$fld = $row2;
|
||||||
|
$selected = (varset($_POST['table_db'], '') == $fld || $curVals[0] == $fld) ? " selected='selected'" : "";
|
||||||
|
$text .= "<option value=\"" . $fld . "\" $selected>" . $fld . "</option>\n";
|
||||||
|
}
|
||||||
|
$text .= "</select></td></tr>";
|
||||||
|
|
||||||
|
if($_POST['table_db'] || $curVals[0])
|
||||||
|
{
|
||||||
|
// Field ID.
|
||||||
|
$text .= "<tr><td>" . EXTLAN_63 . "</td><td>";
|
||||||
|
$text .= "<select style='width:99%' class='tbox e-select' name='field_id'>";
|
||||||
|
$text .= "<option value='' class='caption'>" . EXTLAN_61 . "</option>";
|
||||||
|
$table_list = ($_POST['table_db']) ? $_POST['table_db'] : $curVals[0];
|
||||||
|
if($sql->gen("DESCRIBE " . MPREFIX . "{$table_list}"))
|
||||||
|
{
|
||||||
|
while($row3 = $sql->fetch())
|
||||||
|
{
|
||||||
|
$field_name = $row3['Field'];
|
||||||
|
$selected = ($curVals[1] == $field_name) ? " selected='selected' " : "";
|
||||||
|
$text .= "<option value=\"$field_name\" $selected>" . $field_name . "</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$text .= "</select></td></tr><tr><td>";
|
||||||
|
|
||||||
|
// Display Value.
|
||||||
|
$text .= EXTLAN_64 . "</td><td>";
|
||||||
|
$text .= "<select style='width:99%' class='tbox e-select' name='field_value'>";
|
||||||
|
$text .= "<option value='' class='caption'>" . EXTLAN_61 . "</option>";
|
||||||
|
$table_list = ($_POST['table_db']) ? $_POST['table_db'] : $curVals[0];
|
||||||
|
if($sql->gen("DESCRIBE " . MPREFIX . "{$table_list}"))
|
||||||
|
{
|
||||||
|
while($row3 = $sql->fetch())
|
||||||
|
{
|
||||||
|
$field_name = $row3['Field'];
|
||||||
|
$selected = ($curVals[2] == $field_name) ? " selected='selected' " : "";
|
||||||
|
$text .= "<option value=\"$field_name\" $selected>" . $field_name . "</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$text .= "</select></td></tr><tr><td>";
|
||||||
|
|
||||||
|
// Order.
|
||||||
|
$text .= LAN_ORDER . "</td><td>";
|
||||||
|
$text .= "<select style='width:99%' class='tbox e-select' name='field_order'>";
|
||||||
|
$text .= "<option value='' class='caption'>" . EXTLAN_61 . "</option>";
|
||||||
|
$table_list = ($_POST['table_db']) ? $_POST['table_db'] : $curVals[0];
|
||||||
|
if($sql->gen("DESCRIBE " . MPREFIX . "{$table_list}"))
|
||||||
|
{
|
||||||
|
while($row3 = $sql->fetch())
|
||||||
|
{
|
||||||
|
$field_name = $row3['Field'];
|
||||||
|
$selected = ($curVals[3] == $field_name) ? " selected='selected' " : "";
|
||||||
|
$text .= "<option value=\"$field_name\" $selected>" . $field_name . "</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$text .= "</select></td></tr>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= "</table>";
|
||||||
|
|
||||||
|
|
||||||
|
$ajax = e107::getAjax();
|
||||||
|
$commands = array();
|
||||||
|
$commands[] = $ajax->commandInsert('#db_mode', 'html', $text);
|
||||||
|
$ajax->response($commands);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['cancel']))
|
||||||
|
{
|
||||||
|
header('location:'.e_SELF);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($_POST['cancel_cat']))
|
||||||
|
{
|
||||||
|
header("location:".e_SELF."?cat");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
function js()
|
function js()
|
||||||
{
|
{
|
||||||
@@ -69,14 +189,11 @@ if (isset($_POST['cancel_cat']))
|
|||||||
}
|
}
|
||||||
// ]]>
|
// ]]>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
";
|
";
|
||||||
|
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
e107::js('inline', js());
|
e107::js('inline', js());
|
||||||
|
|
||||||
|
|
||||||
@@ -630,12 +747,16 @@ if(E107_DEBUG_LEVEL > 0 )
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$db_hide = ($current['user_extended_struct_type'] == 4) ? "visible" : "none";
|
$db_hide = ($current['user_extended_struct_type'] == 4) ? "block" : "none";
|
||||||
|
|
||||||
$text .= "<div id='db_mode' style='display:$db_hide'>\n";
|
// Ajax URL for "Table" dropdown.
|
||||||
$text .= "<table style='width:70%;margin-left:0px'><tr><td>";
|
$ajaxGetTableSrc = e_SELF . '?mode=ajax&action=changeTable';
|
||||||
$text .= EXTLAN_62."</td><td style='70%'><select style='width:99%' class='tbox e-select' name='table_db' onchange=\"this.form.submit()\" >
|
|
||||||
<option value='' class='caption'>".EXTLAN_61."</option>\n";
|
$text .= "<div id='db_mode' style='display:{$db_hide}'>";
|
||||||
|
$text .= "<table style='width:70%;margin-left:0;'><tr><td>";
|
||||||
|
$text .= EXTLAN_62 . "</td><td style='70%'>";
|
||||||
|
$text .= "<select name='table_db' style='width:99%' class='tbox e-ajax' data-src='{$ajaxGetTableSrc}'>";
|
||||||
|
$text .= "<option value='' class='caption'>" . EXTLAN_61 . "</option>";
|
||||||
|
|
||||||
$result = e107::getDb()->tables();
|
$result = e107::getDb()->tables();
|
||||||
|
|
||||||
@@ -1469,12 +1590,16 @@ class users_ext
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
$db_hide = ($current['user_extended_struct_type'] == 4) ? "visible" : "none";
|
$db_hide = ($current['user_extended_struct_type'] == 4) ? "block" : "none";
|
||||||
|
|
||||||
$text .= "<div id='db_mode' style='display:$db_hide'>\n";
|
// Ajax URL for "Table" dropdown.
|
||||||
$text .= "<table style='width:70%;margin-left:0px'><tr><td>";
|
$ajaxGetTableSrc = e_SELF . '?mode=ajax&action=changeTable';
|
||||||
$text .= EXTLAN_62."</td><td style='70%'><select style='width:99%' class='tbox e-select' name='table_db' onchange=\"this.form.submit()\" >
|
|
||||||
<option value='' class='caption'>".EXTLAN_61."</option>\n";
|
$text .= "<div id='db_mode' style='display:{$db_hide}'>";
|
||||||
|
$text .= "<table style='width:70%;margin-left:0;'><tr><td>";
|
||||||
|
$text .= EXTLAN_62 . "</td><td style='70%'>";
|
||||||
|
$text .= "<select name='table_db' style='width:99%' class='tbox e-ajax' data-src='{$ajaxGetTableSrc}'>";
|
||||||
|
$text .= "<option value='' class='caption'>" . EXTLAN_61 . "</option>";
|
||||||
|
|
||||||
|
|
||||||
$result = e107::getDb()->tables();
|
$result = e107::getDb()->tables();
|
||||||
|
@@ -3603,7 +3603,7 @@ class e_form
|
|||||||
$ttl = $expand."<button class='btn btn-default btn-xs btn-mini pull-right' {$dataAttr}>" . LAN_MORE . "</button>";
|
$ttl = $expand."<button class='btn btn-default btn-xs btn-mini pull-right' {$dataAttr}>" . LAN_MORE . "</button>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$expands = '<a href="#'.$elid.'-expand" class="e-show-if-js e-expandit">'.defset($ttl, $ttl)."</a>";
|
$expands = '<a href="#'.$elid.'-expand" class="e-show-if-js e-expandit e-expandit-inline">'.defset($ttl, $ttl)."</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldval = $value;
|
$oldval = $value;
|
||||||
|
@@ -233,9 +233,16 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
|||||||
$(href).slideToggle('slow', function ()
|
$(href).slideToggle('slow', function ()
|
||||||
{
|
{
|
||||||
if($(this).is(':visible'))
|
if($(this).is(':visible'))
|
||||||
|
{
|
||||||
|
if($this.hasClass('e-expandit-inline'))
|
||||||
|
{
|
||||||
|
$(this).css('display', 'initial');
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
$(this).css('display', 'block'); //XXX 'initial' broke the default behavior.
|
$(this).css('display', 'block'); //XXX 'initial' broke the default behavior.
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -402,13 +409,13 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
|||||||
options.target = "#" + options.target;
|
options.target = "#" + options.target;
|
||||||
}
|
}
|
||||||
|
|
||||||
var form = $element.closest("form").attr('id');
|
var form = $element.closest("form");
|
||||||
var data = $('#' + form).serialize();
|
var data = form.serialize() || '';
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: options.type || 'POST',
|
type: options.type || 'POST',
|
||||||
url: options.url,
|
url: options.url,
|
||||||
data: data || '',
|
data: data,
|
||||||
complete: function ()
|
complete: function ()
|
||||||
{
|
{
|
||||||
if($loadingImage)
|
if($loadingImage)
|
||||||
|
Reference in New Issue
Block a user