From 715d45a2c1b617d451c4dc801cf69c517cad8dec Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 8 Apr 2013 14:06:01 +0000 Subject: [PATCH] Add very basic support for et2 widgets into editor, to at least not destroy templates --- etemplate/inc/class.editor.inc.php | 36 ++++++++++++++++++++++- etemplate/inc/class.etemplate_old.inc.php | 3 ++ etemplate/inc/class.soetemplate.inc.php | 3 ++ etemplate/inc/class.xul_io.inc.php | 2 ++ 4 files changed, 43 insertions(+), 1 deletion(-) diff --git a/etemplate/inc/class.editor.inc.php b/etemplate/inc/class.editor.inc.php index d7f082e226..03fcc99fb2 100644 --- a/etemplate/inc/class.editor.inc.php +++ b/etemplate/inc/class.editor.inc.php @@ -1371,6 +1371,37 @@ class editor { $editor->set_cell_attribute('etemplate.editor.widget.generic','obj',$type_tmpl); } + /* + Not a known type, use a generic attribute thing to at least allow working + with the attributes provided + */ + if(!$this->types[$widget['type']] && !$this->extensions[$widget['type']]) + { + $grid =& $editor->get_widget_by_name('etemplate.editor.widget.generic'); + $grid['type'] = 'grid'; + $grid['name'] = 'cell'; + $grid['data'] = array(array()); + $grid['data'][] = array('A'=>boetemplate::empty_cell('label','',array('label' => 'Type')), 'B' => boetemplate::empty_cell('select','type')); + $attributes = array('type'=>$widget_type,'name'=>''); + if(is_array($widget)) + { + $attributes += $widget; + } + foreach($attributes as $attr_name => $attr_value) + { + if(is_array($attr_value) || in_array($attr_value, array('type','options'))) + { + continue; + } + else + { + $attr = boetemplate::empty_cell('text',$attr_name,array()); + } + $grid['data'][] = array('A' => boetemplate::empty_cell('label','',array('label' => $attr_name)),'B'=>$attr); + //boetemplate::add_child($grid,$attr); + unset($attr); + } + } if ($parent['type'] == 'grid') { $editor->disable_cells('box_menu'); @@ -1382,6 +1413,7 @@ class editor } $preserv = $this->etemplate->as_array()+array( 'path' => $content['path'], + 'type' => $content['type'], 'old_version' => $this->etemplate->version, 'opener' => $content['opener'], 'cell' => $content['cell'], @@ -1392,7 +1424,9 @@ class editor $GLOBALS['egw_info']['flags']['java_script'] = "\n"; $GLOBALS['egw_info']['flags']['app_header'] = lang('Editable Templates - Editor'); $editor->exec('etemplate.editor.widget',$content,array( - 'type' => array_merge(boetemplate::$types,$this->extensions), + 'type' => array_merge(array($widget['type'] => $widget['type'] . ' (?)'), + boetemplate::$types,$this->extensions + ), 'align' => &$this->aligns, 'valign' => &$this->valigns, 'part' => $allowed_parts, diff --git a/etemplate/inc/class.etemplate_old.inc.php b/etemplate/inc/class.etemplate_old.inc.php index 684dc5709c..c9c15e76be 100644 --- a/etemplate/inc/class.etemplate_old.inc.php +++ b/etemplate/inc/class.etemplate_old.inc.php @@ -1719,6 +1719,9 @@ class etemplate_old extends boetemplate )); } break; + case 'split': + // Render this et2 widget as a box + $orient = $cell['orientation']; case 'vbox': case 'hbox': case 'groupbox': diff --git a/etemplate/inc/class.soetemplate.inc.php b/etemplate/inc/class.soetemplate.inc.php index 7f44319d59..e970fb2294 100644 --- a/etemplate/inc/class.soetemplate.inc.php +++ b/etemplate/inc/class.soetemplate.inc.php @@ -78,6 +78,7 @@ class soetemplate 'hbox' => 'box', 'groupbox' => 'box', 'deck' => 'box', + 'split' => 'box', ); /** @@ -242,6 +243,7 @@ class soetemplate case 'groupbox': case 'box': case 'deck': + default: list($n,$options) = explode(',',$parent['size'],2); $parent[++$n] = &$cell; $parent['size'] = $n . ($options ? ','.$options : ''); @@ -1171,6 +1173,7 @@ class soetemplate } switch($widget['type']) { + case 'split': case 'box': case 'vbox': case 'hbox': diff --git a/etemplate/inc/class.xul_io.inc.php b/etemplate/inc/class.xul_io.inc.php index 2169397a56..bad1e09872 100644 --- a/etemplate/inc/class.xul_io.inc.php +++ b/etemplate/inc/class.xul_io.inc.php @@ -271,6 +271,7 @@ class xul_io unset($cell['label']); } // fall-through + case 'split': case 'vbox': case 'hbox': case 'box': @@ -664,6 +665,7 @@ class xul_io unset($menulist_attr); } break; + case 'split': case 'vbox': case 'hbox': case 'deck':