[interchange-cvs] interchange - heins modified 5 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Sat May 7 23:50:06 EDT 2005


User:      heins
Date:      2005-05-08 03:50:06 GMT
Modified:  dist/lib/UI ContentEditor.pm Primitive.pm
Modified:  dist/lib/UI/pages/admin content_editor.html
Modified:  dist/standard/products variable.txt
Added:     dist/lib/UI/pages/include page_editor_standard
Log:
* Add abililty to have different page editor styles.

* Added a simpler page editor for the standard catalog. Should probably
  remove the component editor in favor of simple text editing of
  the preamble.

* Still in process -- will be trying out on a real person to see
  if it makes sense.

* Still need easy way to get to overall meta to add page controls easily.

Revision  Changes    Path
2.15      +119 -4    interchange/dist/lib/UI/ContentEditor.pm


rev 2.15, prev_rev 2.14
Index: ContentEditor.pm
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/ContentEditor.pm,v
retrieving revision 2.14
retrieving revision 2.15
diff -u -r2.14 -r2.15
--- ContentEditor.pm	23 Feb 2004 01:55:50 -0000	2.14
+++ ContentEditor.pm	8 May 2005 03:50:05 -0000	2.15
@@ -2,7 +2,7 @@
 #
 # UI::ContentEditor - Interchange page/component edit
 # 
-# $Id: ContentEditor.pm,v 2.14 2004/02/23 01:55:50 racke Exp $
+# $Id: ContentEditor.pm,v 2.15 2005/05/08 03:50:05 mheins Exp $
 #
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -24,7 +24,7 @@
 
 package UI::ContentEditor;
 
-$VERSION = substr(q$Revision: 2.14 $, 10);
+$VERSION = substr(q$Revision: 2.15 $, 10);
 $DEBUG = 0;
 
 use POSIX qw/strftime/;
@@ -70,6 +70,47 @@
 		component => {
 		},
 		);
+my %Extra_options = (
+		standard => {
+				name => 'standard_page_editor',
+				control_fields
+					=> [ qw/page_title page_banner display_class members_only /],
+				control_fields_meta => {
+					page_title => {
+						width => 30,
+						label => errmsg('Page Title'),
+					},
+					page_banner => {
+						width => 30,
+						label => errmsg('Page Banner'),
+					},
+					display_class => {
+						label => errmsg('Display class'),
+						help => errmsg('This overrides the template type with a different display'),
+					},
+					members_only => {
+						label => errmsg('Members only'),
+						help => errmsg('Allows only logged-in users to display the page'),
+						type => 'yesno',
+					},
+				},
+				component_fields => [qw/ output /],
+				component_fields_meta => {
+					output => {
+						label => errmsg('Output location'),
+						help => errmsg('Which section of the page the component should go to'),
+						type => 'select',
+						passed => qq[
+							=default,
+							left=Left,
+							right=Right,
+							top=Top,
+							Bottom=Bottom
+						],
+					},
+				},
+		},
+	);
 my %Template;  # Initialized at bottom of file
 my @All_templates;
 my @All_components;
@@ -1441,6 +1482,40 @@
 	my $order = $cref->{ui_display_order} || [];
 	#return undef unless @$order;
 
+	if( my $extra_opt = $Extra_options{$opt->{editor_style}} ) {
+		my $name = $extra_opt->{name} || 'page_editor';
+		my $ef = $Tag->meta_record('ui_component', $name);
+		$ef ||= $extra_opt->{component_fields};
+		if($ef) {
+			my $eo = $extra_opt->{component_fields_meta} || {};
+			my %seen;
+			for(@$order) {
+				$seen{$_} = 1;
+			}
+			for(@$ef) {
+				next if $seen{$_};
+				push @$order, $_;
+				$cref->{$_} = $Tag->meta_record("ui_component::$_",  $name)
+					or
+				$cref->{$_} = $eo->{$_} ? { %{ $eo->{$_} } } : {};
+			}
+			if($Tag->if_mm('super')) {
+				for(@$order) {
+					my $url = $Tag->area({
+						href => 'admin/meta_editor',
+						form => qq{
+							item_id=${name}::ui_component::$_
+						},
+					});
+					my $anchor = errmsg('meta');
+					my $title = errmsg('Edit meta');
+					$cref->{$_}{label} ||= $_;
+					$cref->{$_}{label} = qq{<a href="$url" title="$title" style="float: right">$anchor</a>$cref->{$_}{label}};
+				}
+			}
+		}
+	}
+
 	for my $f (@$order) {
 #::logDebug("building field $f");
 		$meta->{$f} = { %{ $cref->{$f} || {} } };
@@ -1517,6 +1592,41 @@
 	my $meta = { };
 	my @fields = 'code';
 
+	if( my $extra_opt = $Extra_options{$opt->{editor_style}} ) {
+		my $name = $extra_opt->{name} || 'page_editor';
+		my $ef = $Tag->meta_record('ui_control', $name);
+		$ef ||= $extra_opt->{control_fields};
+		if($ef) {
+			my $eo = $extra_opt->{control_fields_meta} || {};
+			my %seen;
+			for(@$order) {
+				$seen{$_} = 1;
+			}
+			for(@$ef) {
+				next if $seen{$_};
+				push @$order, $_;
+				$pref->{$_} = $Tag->meta_record("ui_control::$_",  $name)
+					or
+				$pref->{$_} = $eo->{$_} ? { %{ $eo->{$_} } } : {};
+			}
+			if($Tag->if_mm('super')) {
+				for(@$order) {
+					my $url = $Tag->area({
+						href => 'admin/meta_editor',
+						form => qq{
+							item_id=${name}::ui_control::$_
+
+						},
+					});
+					my $anchor = errmsg('meta');
+					my $title = errmsg('Edit meta');
+					$pref->{$_}{label} ||= $_;
+					$pref->{$_}{label} = qq{<a href="$url" title="$title" style="float: right">$anchor</a>$pref->{$_}{label}};
+				}
+			}
+		}
+	}
+
 	for my $f (@$order) {
 		$meta->{$f} = { %{ $pref->{$f} } };
 		my $lab = $meta->{$f}{label} || $f;
@@ -2300,9 +2410,9 @@
 	$dest =~ s/^\s+$//;
 	my $record = ref_content($ref, $opt)
 		or return death("publish_page", "bad news");
+	delete_preview_page($ref, $opt);
 	my $text = format_page($ref);
 	$record->{page_text} = $text;
-#::logDebug("header record: " . uneval($record));
 	write_page($record);
 }
 
@@ -2336,12 +2446,17 @@
 	write_component($record);
 }
 
-sub cancel_edit {
+sub delete_preview_page {
 	my ($ref, $opt) = @_;
 	my $dir = preview_dir();
 	if($ref->{ui_name} and -f "$dir/$ref->{ui_name}") {
 		unlink "$dir/$ref->{ui_name}";
 	}
+}
+
+sub cancel_edit {
+	my ($ref, $opt) = @_;
+	delete_preview_page($ref, $opt);
 	my $store = $Vend::Session->{content_edit}
 		or return death('cancel', 'content store not found');
 	$store = $store->{$ref->{ui_type}}



2.24      +3 -2      interchange/dist/lib/UI/Primitive.pm


rev 2.24, prev_rev 2.23
Index: Primitive.pm
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/Primitive.pm,v
retrieving revision 2.23
retrieving revision 2.24
diff -u -r2.23 -r2.24
--- Primitive.pm	25 Jun 2003 16:38:17 -0000	2.23
+++ Primitive.pm	8 May 2005 03:50:05 -0000	2.24
@@ -1,6 +1,6 @@
 # UI::Primitive - Interchange configuration manager primitives
 
-# $Id: Primitive.pm,v 2.23 2003/06/25 16:38:17 mheins Exp $
+# $Id: Primitive.pm,v 2.24 2005/05/08 03:50:05 mheins Exp $
 
 # Copyright (C) 2002-2003 Interchange Development Group
 # Copyright (C) 1998-2002 Red Hat, Inc.
@@ -27,7 +27,7 @@
 
 package UI::Primitive;
 
-$VERSION = substr(q$Revision: 2.23 $, 10);
+$VERSION = substr(q$Revision: 2.24 $, 10);
 
 $DEBUG = 0;
 
@@ -40,6 +40,7 @@
 use File::Find;
 use Exporter;
 use strict;
+no warnings qw(uninitialized numeric);
 use Vend::Util qw/errmsg/;
 $DECODE_CHARS = qq{&[<"\000-\037\177-\377};
 



1.8       +5 -0      interchange/dist/lib/UI/pages/admin/content_editor.html


rev 1.8, prev_rev 1.7
Index: content_editor.html
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/pages/admin/content_editor.html,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- content_editor.html	23 Apr 2005 18:10:07 -0000	1.7
+++ content_editor.html	8 May 2005 03:50:06 -0000	1.8
@@ -113,7 +113,12 @@
 [/elsif]
 [else]
 	[set page_name_click][/set]
+	[if variable PAGE_EDITOR_STYLE]
+		[include include/page_editor___PAGE_EDITOR_STYLE__]
+	[else]
 	[include include/page_editor]
+	[/else]
+	[/if]
 [/else]
 [/if]
 



1.1                  interchange/dist/lib/UI/pages/include/page_editor_standard


rev 1.1, prev_rev 1.0
Index: page_editor_standard
===================================================================
[content-editor name="[cgi ui_name]" ui_page_template="[cgi ui_page_template]" type="page" editor-style=standard]
[pages]

[calcn]
	$page_content = <<'EoPA';
[page-param CONTENT]
EoPA
	$page_preamble = <<'EoPB';
[page-param PREAMBLE]
EoPB
	$page_postamble = <<'EoPC';
[page-param POSTAMBLE]
EoPC
	for(\$page_content, \$page_preamble, \$page_postamble) {
		chop $$_;
	}
	return;
[/calcn]

<script language=JavaScript>
function changed (code, field) {
	var name = "changed_" + code;
	silent_revert();
	var cchanged =  document.getElementById('cchanged');
	if(cchanged != undefined) {
		var lab = field;
		if(lab == '' || lab == undefined)
			lab = code;
		cchanged.innerHTML += '<br><span class=cmessage>Changed ' + lab + '</span>';
	}
	cbox = document.getElementById(name);
	if(cbox != undefined)
		cbox.checked = true;
}

function submitted (code) {
	var name = "changed_" + code;
	silent_revert();
	cbox = document.getElementById(name);
	if(cbox != undefined)
		cbox.checked = false;
	return true;
}

function silent_revert () {
	var sil = document.getElementById('silent_display');
	if(sil != undefined)
		sil.innerHTML = '[L]Page Attributes/Controls[/L]';
	return true;
}

// Don't remove this, called with forms genned by UI::ContentEditor
function silent_submit () {
	var sil = document.getElementById('silent_display');
	if(sil != undefined)
		sil.innerHTML
		= '[L]Page Attributes/Controls[/L] <span class=cmessage>[L]Change saved[/L]</span>';
	return true;
}

function change_alert (code) {
	if(code.length == 0) {
		code = 'a new component';
	}
	var status;
	status = confirm('You have changed ' + code + ". Choosing OK will lose these changes. Are you sure?");
	return status;
}

function check_change () {
	var el;
	silent_revert();
	el = document.getElementById('changed_[page-param ui_name]');
	if(el != undefined && el.checked == true) {
		return change_alert('the page controls');
	}
[components]
	[if-comp-param code]
	el = document.getElementById('changed_[comp-param code]');
	if(el != undefined && el.checked == true) {
		return change_alert('[comp-param code]');
	}
	[else]
	el = document.getElementById('changed_CONTENT');
	if(el != undefined && el.checked == true) {
		return change_alert('the page content');
	}
	[/else]
	[/if-comp-param]
[/components]
	el = document.getElementById('[page-param ui_name]');
	if(el != undefined && el.checked == true) {
		return change_alert('the page controls');
	}
	el = document.getElementById('changed_PREAMBLE');
	if(el != undefined && el.checked == true) {
		return change_alert('the PREAMBLE');
	}
	el = document.getElementById('changed_POSTAMBLE');
	if(el != undefined && el.checked == true) {
		return change_alert('the POSTAMBLE');
	}
	return true;
}

function layback (nam) {
	var el = document.getElementById(nam);

	if(el != undefined) {
		el.style.background = '#CCCCCC';
		el.style.borderStyle = 'dotted';
		el.style.borderWidth = 'thin';
	}
}

function standout (nam) {
	var el = document.getElementById(nam);

	if(el != undefined) {
		el.style.background = '#EEEEEE';
		el.style.borderStyle = 'solid';
		el.style.borderWidth = 'thin';
	}
}

function content_win () {
	window.name = 'mainwindow[scratch window_name]';
	var url = '[area
					href="admin/page_portion"
					form=|
						ui_source_form=content_edit
						ui_source_var=ui_body_text
						page=[page-param ui_name]
					|]';
	window.open(url, undefined, 'scrollbars,location=no,status=no,toolbar=no,resizable,fullsize=no,width=600,height=480');
	return void(0);
}

var visdone = new Array;

</script>

	<form name=overall action="[area @@MV_PAGE@@]" method=POST>
	<input type=hidden name=ui_content_op value="modify">
	<input type=hidden name=ui_name value="[page-param ui_name]">
	<input type=hidden name=ui_type value=page>
	<input type=hidden name=mv_action value="back">
	<table width="98%">
	<tr>
		<td>
			[L]Name[/L]: <b>[page-param ui_name]</b><BR>
			[L]Source[/L]: [page-param ui_source]
		[page-sub foo_sub]
			shift;
			my $item = shift;
			## Set up access to the controls
			for(keys %$item) {
				$control{$_} = $item->{$_};
			}
			return;
		[/page-sub]
		[page-exec foo_sub][/page-exec]
		</td>
		<td id=cchanged
			 style="
			 	overflow: auto;
			">
		</td>
		<td align=right>
			[L]Template[/L]: [display
							name=ui_page_template
							type=select
							default="[page-param ui_page_template]"
							passed="[content-info templates=1]"
							]<br>

[set [L]Publish[/L]]
ui_content_op=publish
mv_nextpage=__UI_BASE__/content
[/set]
[set [L]Cancel[/L]]
ui_content_op=cancel
mv_nextpage=__UI_BASE__/content
[/set]
[set [L]Preview[/L]]
ui_content_op=preview
mv_nextpage=__UI_BASE__/content_preview
[/set]
<input
	style="font-weight: bold"
	type=submit onClick="return check_change()"
	name="mv_click"
	value="[L]Publish[/L]"
> &nbsp;
<input
	type=submit
	onClick="return confirm(
			'This will destroy all edits you have made to this page '
			+ 'since the last Publish operation.\n Are you sure?'
		)"
	name="mv_click"
	value="[L]Cancel[/L]"
> &nbsp;
<input
	type=submit
	name="mv_click"
	value="[L]Preview[/L]"
> &nbsp;
<input
	type=submit
	onClick="return confirm(
			'[L]This may delete components from your configuration.[/L]' +
			'[L]Continue?[/L]'
		)"
	value="[L]Change template[/L]"

			</td>
	</tr>
	</table>

	</form>

[page-calc]
	$page_content = <<'EoPA';
[page-param CONTENT]
EoPA
	$page_preamble = <<'EoPB';
[page-param PREAMBLE]
EoPB
	$page_postamble = <<'EoPC';
[page-param POSTAMBLE]
EoPC
	for(\$page_content, \$page_preamble, \$page_postamble) {
		chop $$_;
	}
	return;
[/page-calc]

[tabbed-display
	ui-style=1
    start-at-index="[cgi start_at_index]"
    panel-shade=f
    panel-width="[either][cgi panel_width][or]100%[/either]"
    tab-width=160
]


[tabbed-panel [L]Content (source edit)[/L]]

		[table-editor
			action=return
			height.ui_body_text="38"
			width.ui_body_text="100%"
			hidden.ui_content_op=modify_body
			hidden.ui_name="[page-param ui_name]"
			hidden.ui_type=page
			form-name=content_edit
			href="silent/ce_modify"
			item_id="CONTENT"
			js_changed=changed
			label.ui_body_text=|&nbsp;&nbsp;&nbsp;Page&nbsp;content|
			mv_nextpage=@@MV_PAGE@@
			nocancel=1
			notable=1
			no_meta=1
			panel-style="padding: 5; vertical-align: top"
			no-table-meta=1
			override.ui_body_text=`$page_content`
			show_reset=1
			table=junk
			table_width="100%"
			top-buttons-rows=1
			ui_data_fields="code ui_body_text"
			ui_hide_key=1
			ui-style=0
			widget.ui_body_text="textarea"
			form-extra=|
				onSubmit="submitted('CONTENT'); return check_change()"
				onReset="submitted('CONTENT')"
			|
		][/table-editor]

[/tabbed-panel]

[tabbed-panel [L]Page Controls[/L]]
		[page-param _editor_table]
[/tabbed-panel]

[tabbed-panel [L]Components[/L]]
<span class=cerror>Warning: changing component refreshes page.</span>
[components]
	[if-comp-param where]
	<div class=titlebox>[L]Component[/L] [comp-param component]</div>
	[comp-param _editor_table]
	[/if-comp-param]
[/components]
[/tabbed-panel]

[tabbed-panel [L]Preamble[/L]]
		[table-editor
			action=return
			height.ui_body_text="10"
			hidden.ui_content_op=modify_body
			hidden.ui_name="[page-param ui_name]"
			hidden.ui_type=page
			href="silent/ce_modify"
			item_id="PREAMBLE"
			js_changed=changed
			label.ui_body_text="&nbsp;&nbsp;&nbsp;Preamble"
			mv_nextpage=@@MV_PAGE@@
			no-table-meta=1
			no_meta=1
			nocancel=1
			notable=1
			override.ui_body_text=`$page_preamble`
			show_reset=1
			table=junk
			table_width="100%"
			ui_data_fields="code ui_body_text"
			ui_hide_key=1
			widget.ui_body_text="textarea"
			width.ui_body_text="100%"
			form-extra=|
				onSubmit="submitted('PREAMBLE'); return check_change()"
				onReset="submitted('PREAMBLE')"
			|
		/]
[/tabbed-panel]

[tabbed-panel [L]Postamble[/L]]
		[table-editor
			action=return
			height.ui_body_text="30"
			width.ui_body_text="100%"
			hidden.ui_content_op=modify_body
			hidden.ui_name="[page-param ui_name]"
			hidden.ui_type=page
			href="silent/ce_modify"
			item_id="POSTAMBLE"
			js_changed=changed
			label.ui_body_text="&nbsp;&nbsp;&nbsp;Postamble"
			mv_nextpage=@@MV_PAGE@@
			nocancel=1
			notable=1
			no_meta=1
			top-buttons=1
			no-table-meta=1
			override.ui_body_text=`$page_postamble`
			show_reset=1
			table=junk
			table_width="100%"
			ui_data_fields="code ui_body_text"
			ui_hide_key=1
			ui-style=0
			widget.ui_body_text="textarea"
			form-extra=|
				onSubmit="submitted('POSTAMBLE'); return check_change()"
				onReset="submitted('POSTAMBLE')"
			|
		][/table-editor]
[/tabbed-panel]
[/tabbed-display]

[/pages]
[/content-editor]
[comment]
<xmp>
[dump content_edit]
</xmp>
[/comment]



1.3       +1 -0      interchange/dist/standard/products/variable.txt


rev 1.3, prev_rev 1.2
Index: variable.txt
===================================================================
RCS file: /var/cvs/interchange/dist/standard/products/variable.txt,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- variable.txt	3 Jun 2004 06:31:20 -0000	1.2
+++ variable.txt	8 May 2005 03:50:06 -0000	1.3
@@ -47,6 +47,7 @@
 MYSQL	__MVC_MYSQL__	Database
 ORDERS_TO	__MVC_MAILORDERTO__	Order
 ORDER_ROUTES	log main copy_user	Order
+PAGE_EDITOR_STYLE	standard	Content Edit
 PGP_KEY		Encryption
 PGSQL	__MVC_PGSQL__	Database
 PHONE	(765) 555-1212	Company








More information about the interchange-cvs mailing list