[interchange-cvs] interchange - heins modified dist/lib/UI/ui.cfg

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Sun Jul 27 03:34:00 EDT 2003


User:      heins
Date:      2003-07-27 06:34:43 GMT
Modified:  dist/lib/UI ui.cfg
Log:
Allow component modification via Mozilla editor.

* If you follow the "show tags" link (i.e. add ui_mozilla_edit=1 to
  the param list), it will output the current component set
  in meta headers:

  <meta name="component" content="1;component;search_box_small">
  <meta name="component" content="2;component;cart_tiny">
  <meta name="component" content="3;component;product_tree">
  <meta name="component" content="4;component;">
  <meta name="component" content="5;component;cross">
  <meta name="component" content="5;banner;Specials">
  <meta name="component" content="5;cols;2">
  <meta name="component" content="5;size;2">
  <meta name="component" content="6;component;random">
  <meta name="component" content="6;banner;See also...">
  <meta name="component" content="6;cols;1">
  <meta name="component" content="6;size;3">
  <meta name="component" content="7;component;">
  <meta name="component" content="8;component;">

  For instance, component 5 above is exactly equivalent to:

  	[control-set]
		[component]cross[/component]
		[banner][L]Specials[/component]
		[cols]2[/cols]
		[size]2[/size]
	[/control-set]

* Also turn on no_locale_parse in ui_mozilla_edit mode, so that
  locale-based information won't be lost.

Revision  Changes    Path
2.12      +60 -0     interchange/dist/lib/UI/ui.cfg


rev 2.12, prev_rev 2.11
Index: ui.cfg
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/ui.cfg,v
retrieving revision 2.11
retrieving revision 2.12
diff -u -r2.11 -r2.12
--- ui.cfg	27 Jul 2003 04:30:54 -0000	2.11
+++ ui.cfg	27 Jul 2003 06:34:43 -0000	2.12
@@ -90,6 +90,7 @@
 EOF
 
 	if($CGI::values{ui_mozilla_edit}) {
+		$::Pragma->{no_locale_parse} = 1;
 		$::Pragma->{init_page} = 'show_tags_for_edit';
 	}
 	return;
@@ -100,6 +101,27 @@
 GlobalSub <<EOS
 sub show_tags_for_edit {
 	my $html = shift;
+
+	my @headers;
+	my $i = 0;
+	while($$html =~ m{\[control-set\](.*?)\[/control-set\]}isg) {
+		$i++;
+		my $data = $1;
+		while($data =~ m{\[(\w+)\](.*?)\[/\1]}sg) {
+			my $parm = $1;
+			my $val = HTML::Entities::encode_entities($2);
+			push @headers, qq{<meta name="component" content="$i;$parm;$val">};
+		}
+	}
+
+	my $meta_string = join "\n", @headers;
+	if($meta_string) {
+		$$html =~ s{(\[(seti?|tmpn?)\s+meta_header\s*\])(.*?\[/\2])}
+					{$1 . $meta_string . "\n" . $3}is
+			or
+		 $$html =~ s{^}{[set meta_header]$meta_string\[/set]\n};
+	}
+
 	$$html =~ s{(<!--+\s*BEGIN\s+CONTENT\s*--+>)}{[strip reparse=0]$1};
 	$$html =~ s{(<!--+\s*END\s+CONTENT\s*--+>)}{$1\[/strip]};
 }
@@ -207,6 +229,44 @@
 
 		$p->parse($content);
 		$header{page_title} = $p->header('title');
+		
+		my @components;
+		my $compcheck = sub {
+			my($hname, $value) = @_;
+#::logDebug("Calling compcheck name=$hname value=$value");
+			return unless lc($hname) eq 'x-meta-component';
+#::logDebug("doing $value");
+			my ($idx, $name, $val) = split /;/, $value, 3;
+			return unless $idx > 0;
+			$components[$idx - 1] ||= [];
+			$val = HTML::Entities::decode_entities($val);
+			my $string = join "",
+							"[$name]",
+							$val,
+							"[/$name]",
+							;
+			push @{$components[$idx - 1]}, $string;
+		};
+
+		$p->header->scan($compcheck);
+
+		if(@components) {
+			my @c;
+			for(my $i = 0; $i < @components; $i++) {
+				my $ref = $components[$i];
+				push @c, '[control-set]';
+				if($ref) {
+					for(@$ref) {
+						push @c, $_;
+					}
+				}
+				push @c, '[/control-set]';
+			}
+			my $cstring = join "\n", @c;
+#::logDebug("Component cstring:\n$cstring");
+			$top =~ s{(\[control\s+reset=1\s*\]).*(\[control\s+reset=1\s*\])}
+			         {$1$cstring$2}si;
+		}
 #::logDebug("header title=$header{page_title} object" . ::uneval($p));
 		$top =~ s{(\[(seti?|tmpn?)\s+(\w+)\s*\])(.*?)(\[/\2\])}
 				{$1 . ($header{$3} || $4) . $5}eg;







More information about the interchange-cvs mailing list