mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Admin-UI Inline editing for dropdown
This commit is contained in:
@@ -283,11 +283,11 @@ class page_admin_ui extends e_admin_ui
|
||||
protected $fields = array(
|
||||
'checkboxes' => array('title'=> '', 'type' => null, 'width' =>'5%', 'forced'=> TRUE, 'thclass'=>'center', 'class'=>'center'),
|
||||
'page_id' => array('title'=> 'ID', 'width'=>'5%', 'forced'=> TRUE),
|
||||
'page_chapter' => array('title'=> 'Book/Chapter', 'type' => 'dropdown', 'width' => '20%', 'filter' => true, 'batch'=>true),
|
||||
'page_chapter' => array('title'=> 'Book/Chapter', 'type' => 'dropdown', 'width' => '20%', 'filter' => true, 'batch'=>true, 'inline'=>true),
|
||||
'page_title' => array('title'=> LAN_TITLE, 'type' => 'text', 'width'=>'25%','readParms'=>'link={e_BASE}page.php?[id]&dialog=1'),
|
||||
'page_theme' => array('title'=> CUSLAN_2, 'type' => 'text', 'width' => 'auto','nolist'=>true),
|
||||
|
||||
'page_template' => array('title'=> 'Template', 'type' => 'text', 'width' => 'auto','filter' => true, 'batch'=>true),
|
||||
'page_template' => array('title'=> 'Template', 'type' => 'dropdown', 'width' => 'auto','filter' => true, 'batch'=>true, 'inline'=>true, 'writeParms'=>''),
|
||||
'page_author' => array('title'=> LAN_AUTHOR, 'type' => 'user', 'width' => 'auto', 'thclass' => 'left'),
|
||||
'page_datestamp' => array('title'=> LAN_DATE, 'type' => 'datestamp', 'width' => 'auto'),
|
||||
'page_class' => array('title'=> LAN_USERCLASS, 'type' => 'userclass', 'width' => 'auto', 'filter' => true, 'batch' => true),
|
||||
@@ -305,6 +305,7 @@ class page_admin_ui extends e_admin_ui
|
||||
|
||||
protected $books = array();
|
||||
protected $cats = array();
|
||||
protected $templates = array();
|
||||
|
||||
function init()
|
||||
{
|
||||
@@ -327,7 +328,8 @@ class page_admin_ui extends e_admin_ui
|
||||
}
|
||||
|
||||
|
||||
|
||||
$this->templates = e107::getLayouts('', 'page', 'front', '', false, false);
|
||||
$this->fields['page_template']['writeParms'] = $this->templates;
|
||||
|
||||
|
||||
$sql = e107::getDb();
|
||||
@@ -529,13 +531,13 @@ class page_admin_ui extends e_admin_ui
|
||||
|
||||
|
||||
// fixed - last parameter (allinfo) should be false as getLayout method is returning non-usable formatted array
|
||||
$templates = e107::getLayouts('', 'page', 'front', '', false, false);
|
||||
|
||||
// $templates['menu'] = "Sidebar"; // ie. a MENU item. //TODO
|
||||
|
||||
$text .= "
|
||||
<tr>
|
||||
<td>Template</td>
|
||||
<td>". $frm->selectbox('page_template',$templates,$row['page_template']) ."</td>
|
||||
<td>". $frm->selectbox('page_template',$this->templates,$row['page_template']) ."</td>
|
||||
</tr>
|
||||
";
|
||||
|
||||
|
@@ -4143,12 +4143,14 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
*/
|
||||
public function InlineAjaxPage()
|
||||
{
|
||||
$this->logajax('Field not found');
|
||||
$protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
|
||||
if(!vartrue($_POST['name']) || !vartrue($this->fields[$_POST['name']]))
|
||||
{
|
||||
header($protocol.': 404 Not Found', true, 404);
|
||||
header("Status: 404 Not Found", true, 404);
|
||||
echo 'Field not found'; // FIXME lan
|
||||
$this->logajax('Field not found');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4163,9 +4165,11 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
header($protocol.': 403 Forbidden', true, 403);
|
||||
header("Status: 403 Forbidden", true, 403);
|
||||
echo 'Forbidden'; // FIXME lan
|
||||
$this->logajax("Forbidden");
|
||||
return;
|
||||
}
|
||||
|
||||
$this->logajax("OK?");
|
||||
$model = $this->getModel()->load($this->getId());
|
||||
|
||||
$res = $model->setPostedData($_name, $_value, false)
|
||||
@@ -4176,6 +4180,7 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
// using 400
|
||||
header($protocol.': 400 Bad Request', true, 400);
|
||||
header("Status: 400 Bad Request", true, 400);
|
||||
$this->logajax("Bad Request");
|
||||
// DEBUG e107::getMessage()->addError('Error test.', $model->getMessageStackName())->addError('Another error test.', $model->getMessageStackName());
|
||||
$message = e107::getMessage()->get('error', $model->getMessageStackName(), true);
|
||||
if(!empty($message)) echo implode(' ', $message);
|
||||
@@ -4183,6 +4188,17 @@ class e_admin_ui extends e_admin_controller_ui
|
||||
}
|
||||
}
|
||||
|
||||
// Temporary - but useful. :-)
|
||||
public function logajax($message)
|
||||
{
|
||||
$message = date('r')."\n".$message."\n";
|
||||
$message .= print_r($_POST,true);
|
||||
$message .= print_r($_GET,true);
|
||||
$message .= "---------------";
|
||||
|
||||
file_put_contents(e_LOG.'uiAjaxResponseInline.log', $message."\n\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Drag-n-Drop sort action
|
||||
|
@@ -1846,6 +1846,8 @@ class e_form
|
||||
$parms = $attributes['readParms'];
|
||||
}
|
||||
|
||||
if(vartrue($attributes['inline'])) $parms['editable'] = true; // attribute alias
|
||||
|
||||
$tp = e107::getParser();
|
||||
switch($field) // special fields
|
||||
{
|
||||
@@ -1934,7 +1936,7 @@ class e_form
|
||||
else $value = number_format($value, $parms['decimals'], vartrue($parms['point'], '.'), vartrue($parms['sep'], ' '));
|
||||
}
|
||||
|
||||
if(vartrue($attributes['inline'])) $parms['editable'] = true;
|
||||
|
||||
if(!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) // avoid bad markup, better solution coming up
|
||||
{
|
||||
$mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));
|
||||
@@ -1973,17 +1975,19 @@ class e_form
|
||||
case 'comma':
|
||||
case 'dropdown':
|
||||
// XXX - should we use readParams at all here? see writeParms check below
|
||||
|
||||
|
||||
if($parms && is_array($parms)) // FIXME - add support for multi-level arrays (option groups)
|
||||
{
|
||||
$value = vartrue($parms['pre']).vartrue($parms[$value]).vartrue($parms['post']);
|
||||
break;
|
||||
//FIXME return no value at all when 'editable=1' is a readParm. See FAQs templates.
|
||||
// $value = vartrue($parms['pre']).vartrue($parms[$value]).vartrue($parms['post']);
|
||||
// break;
|
||||
}
|
||||
|
||||
|
||||
// NEW - multiple (array values) support
|
||||
// FIXME - add support for multi-level arrays (option groups)
|
||||
if(!is_array($attributes['writeParms'])) parse_str($attributes['writeParms'], $attributes['writeParms']);
|
||||
$wparms = $attributes['writeParms'];
|
||||
|
||||
if(!is_array(varset($wparms['__options']))) parse_str($wparms['__options'], $wparms['__options']);
|
||||
|
||||
$opts = $wparms['__options'];
|
||||
@@ -2005,8 +2009,17 @@ class e_form
|
||||
if(isset($wparms[$value])) $ret = $wparms[$value];
|
||||
$value = $ret;
|
||||
}
|
||||
|
||||
$value = ($value ? vartrue($parms['pre']).defset($value, $value).vartrue($parms['post']) : '');
|
||||
|
||||
// Inline Editing. //FIXME - doesn't save data
|
||||
if(!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) // avoid bad markup, better solution coming up
|
||||
{
|
||||
$mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));
|
||||
$source = str_replace('"',"'",json_encode($wparms));
|
||||
$value = "<a class='e-tip e-editable' data-name='".$field."' data-source=\"".$source."\" title=\"".LAN_EDIT." ".$attributes['title']."\" data-type='select' data-pk='".$id."' data-url='".e_SELF."?mode=&action=inline&id={$id}&ajax_used=1' href='#'>".$value."</a>";
|
||||
}
|
||||
|
||||
// return ;
|
||||
break;
|
||||
|
||||
@@ -2022,8 +2035,6 @@ class e_form
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
// attribute alias
|
||||
if(vartrue($attributes['inline'])) $parms['editable'] = true;
|
||||
|
||||
if(vartrue($parms['truncate']))
|
||||
{
|
||||
@@ -2048,9 +2059,8 @@ class e_form
|
||||
if(!vartrue($attributes['noedit']) && vartrue($parms['editable']) && !vartrue($parms['link'])) // avoid bad markup, better solution coming up
|
||||
{
|
||||
$mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], ''));
|
||||
$value = "<a class='e-tip e-editable' data-name='".$field."' title=\"".LAN_EDIT." ".$attributes['title']."\" data-type='text' data-pk='".$id."' data-url='".e_SELF."?mode={$mode}&action=inline&id={$id}&ajax_used=1' href='#'>".$value."</a>";
|
||||
$value = "<a class='e-tip e-editable' data-name='".$field."' title=\"".LAN_EDIT." ".$attributes['title']."\" data-type='text' data-pk='".$id."' data-url='".e_SELF."?mode={$mode}&action=inline&id={$id}&ajax_used=1' href='#'>".$value."</a>";
|
||||
}
|
||||
|
||||
|
||||
$value = vartrue($parms['pre']).$value.vartrue($parms['post']);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user