[interchange-cvs] interchange - heins modified dist/lib/UI/pages/admin/menu_editor.html

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Mon May 3 13:38:13 EDT 2004


User:      heins
Date:      2004-05-03 17:38:13 GMT
Modified:  dist/lib/UI/pages/admin menu_editor.html
Log:
* Allow "Create menu from HTML" option to recognize <OPTION value=URL>Anchor
  lists.

Revision  Changes    Path
2.28      +57 -23    interchange/dist/lib/UI/pages/admin/menu_editor.html


rev 2.28, prev_rev 2.27
Index: menu_editor.html
===================================================================
RCS file: /var/cvs/interchange/dist/lib/UI/pages/admin/menu_editor.html,v
retrieving revision 2.27
retrieving revision 2.28
diff -u -r2.27 -r2.28
--- menu_editor.html	14 Feb 2004 14:36:02 -0000	2.27
+++ menu_editor.html	3 May 2004 17:38:13 -0000	2.28
@@ -273,32 +273,66 @@
 
 	if($CGI->{qmenu_html_create} and $CGI->{qmenu_create}) {
 		my $text = $CGI->{qmenu_html_create};
+		my $num_options;
+		my $num_links;
+		$num_options++ while $text =~ m{<option\s+}gi;
+		$num_links++   while $text =~ m{<a\s+}gi;
 		my $start = '0001';
 		my @out = join "\t", @menufields;
-		while($text =~ s{<a(\s+.*?)</a>}{}is) {
-			my $blob = $1;
-			my $desc = '';
-			$blob =~ m{^[^>]*\s+title=(['"]?)(.*?)\1}
-				and $desc = $2;
-			$blob =~ s{^.*?\shref\s*=\s*(["'])?(.*?)\1}{}is
-				or next;
-			my $link = $2;
-			$blob =~ s/.*?>//;
-			1 while $blob =~ s{<.*?>}{};
-			$anchor = $blob;
-			my $sort = $start;
-			$sort =~ s/./x/;
-			my($href, $parms) = split /\?/, $link, 2;
-			my %record = (
-				code => $start++,
-				msort => $sort,
-				page => $href,
-				form => $parms,
-				name => $anchor,
-				description => $desc,
-			);
 
-			push @out, join "\t", @record{@menufields};
+		if($num_options > $num_links) {
+			while( $text =~ m{
+					 <option\s+
+						[^>]*
+						value\s*=\s*"(.*?)"
+						[^>]*
+						>
+						([^<>]*)
+					}ixgs
+				)
+			{
+				my $url = $1;
+				my $anchor = $2;
+				my $sort = $start;
+				$sort =~ s/./x/;
+				my($href, $parms) = split /\?/, $url, 2;
+				my %record = (
+					code => $start++,
+					msort => $sort,
+					page => $href,
+					form => $parms,
+					name => $anchor,
+				);
+				push @out, join "\t", @record{@menufields};
+			}
+
+		}
+		else {
+			while($text =~ s{<a(\s+.*?)</a>}{}is) {
+				my $blob = $1;
+				my $desc = '';
+				$blob =~ m{^[^>]*\s+title=(['"]?)(.*?)\1}
+					and $desc = $2;
+				$blob =~ s{^.*?\shref\s*=\s*(["'])?(.*?)\1}{}is
+					or next;
+				my $link = $2;
+				$blob =~ s/.*?>//;
+				1 while $blob =~ s{<.*?>}{};
+				$anchor = $blob;
+				my $sort = $start;
+				$sort =~ s/./x/;
+				my($href, $parms) = split /\?/, $link, 2;
+				my %record = (
+					code => $start++,
+					msort => $sort,
+					page => $href,
+					form => $parms,
+					name => $anchor,
+					description => $desc,
+				);
+
+				push @out, join "\t", @record{@menufields};
+			}
 		}
 
 		$Scratch->{qmenu_data} = join "\n", @out, '';








More information about the interchange-cvs mailing list