ParseVariables Yes

ifdef @UI_BASE
Variable UI_BASE @@UI_BASE@@
endif

ifndef UI_BASE
Variable UI_BASE admin
endif

ifdef @LockType ne 'none'
Variable UI_LOCKING 1
endif

Variable INTERCHANGE_EMAIL interchange@icdevgroup.org
Variable INTERCHANGE_URL http://www.icdevgroup.org/

ifdef @UI
Variable UI_ABOUT_LOGIN_URL http://www.icdevgroup.org/
Variable UI_ABOUT_NORMAL_URL http://www.icdevgroup.org/
Variable UI_ACCESS_TABLE   access
Variable UI_BOTTOMIMG      poweredby.gif
Variable UI_HELP_HEIGHT    480
Variable UI_HELP_WIDTH     650
Variable UI_LEFT_WIDTH     150
Variable UI_SHIPPED_STATUS shipped
Variable UI_MAIN_WIDTH     600
Variable UI_META_TABLE     mv_metadata
Variable UI_PRODUCT_DIR    products
Variable UI_PAGE_DIR       pages
Variable UI_OVERALL_WIDTH  750
Variable UI_P_ALINK        #CC3333
Variable UI_P_BG           #FFFFFF
Variable UI_P_LINK         #CC3333
Variable UI_P_VLINK        #FF3333
Variable UI_RIGHT_WIDTH    450
Variable UI_SZ_LIST_CUSTOMER 50
Variable UI_SZ_LIST_ORDER    50
Variable UI_T_BG           beige
Variable UI_T_PROPERTIES   cellpadding=3 cellspacing=0 width=90% border=0
Variable UI_T_ROW_EVEN     #EEEEEE
Variable UI_T_ROW_ODD      #FFFFFF
Variable UI_TOP_BG		   #CC0000

Variable UI_ITEM_TABLES    products pricing inventory merchandising options:sku

Database ichelp ichelp.txt  TAB
Database ichelp PRELOAD     lib/UI/ichelp.txt
Database ichelp PRELOAD_EMPTY_ONLY 1
Database ichelp HIDE_EDIT   1
Database ichelp AUTO_EXPORT __UI_LOCKING__

endif

ParseVariables No

## Deprecated, could be removed in IC 5.2
Variable  MV_DEFAULT_SEARCH_FILE  products
Variable  MV_DEFAULT_SEARCH_TABLE products

Sub <<EOR
sub bar_link {
	my $base = shift || 'cat';
	my $extra;
	$base =~ s/(\W.*)//s
		and $extra = $1;
	my $ref = shift;
	my $code = $ref->[0];

	my $record =  tag_data($base, 'n/a', $code, { hash => 1 });
	return $ref->[0] unless $record;

	my $url;
	my $anchor;
	my $highlight;
	my $first;
	my $expand;

	LINK: {
		if($record->{link_type} eq 'external') {
			$first = $record->{url};
			$first =~ s/\s+$//;
			$first =~ s/^\s+//;
			$url = $first;
		}
		elsif	($record->{link_type} eq 'internal') {
			my ($page, $form) = split /\s+/, $record->{url}, 2;
			my $current = $Tag->var('MV_PAGE', 1);
            $highlight = 1 if   $page eq $current
                                    or
                                $page eq $CGI->{ui_explode};
			$url = $Tag->area( { href => $page, form => $form });
		}
		elsif	($record->{link_type} eq 'simple') {
			my (@items) = split /\s*[\n,]\s*/, $record->{selector};
			my @out;
			my $fi = $record->{tab};
			my $sp = $record->{page};
			my %options = (
				href => 'scan',
			);
			push @out, "fi=$fi" if $fi;
			push @out, "sp=$sp" if $sp;
			push @out, "st=db";
			if(! @items) {
				push @out, "ra=yes";
				$options{arg} = join "\n", @out;
				$url = $Tag->area(\%options);
				last LINK;
			}
			push @out, "co=yes";
			for(@items) {
				my ($col, $string) = split /\s*=\s*/;
				push @out, "sf=$col";
				push @out, "se=$string";
				push @out, "op=eq";
			}
			push @out, $record->{search}
				if $record->{search} =~ /^\s*\w\w=/;

			push @out, qq{va=banner_image=$record->{banner_image}} if ($record->{banner_image});
			push @out, qq{va=banner_text=$record->{banner_text}} if ($record->{banner_text});
			$options{arg} = join "\n", @out;
			$url = $Tag->area(\%options);
		}
		elsif	($record->{link_type} eq 'complex') {
			$record->{search} =~ s/[\r\n+]/\n/g;
			$record->{search} .= qq{\nva=banner_text=$record->{banner_text}} if ($record->{banner_text});
			$record->{search} .= qq{\nva=banner_image=$record->{banner_image}} if ($record->{banner_image});
			$url = $Tag->area('scan', $record->{search});
		}
		else {
			$url = "";
		}
	}

	ANCHOR: {
		my $display_text = $record->{banner_text} || $record->{name};
		$display_text =~ s/"/&quot;/g;
		if($record->{display_type} eq 'url') {
			$anchor = "";
		}
		elsif ($record->{display_type} eq 'name') {
			$anchor = $display_text;
		}
		elsif ($record->{display_type} eq 'icon') {
			$anchor = qq{<img src="$record->{image}" alt="$display_text"};
			$anchor .= " $record->{image_prop}"
				if $record->{image_prop};
			$anchor .= '>';
			$anchor .= $display_text;
		}
		elsif ($record->{display_type} eq 'image') {
			$anchor = qq{<img src="$record->{image}" alt="$display_text"};
			$anchor .= " $record->{image_prop}"
				if $record->{image_prop};
			$anchor .= '>';
		}
		else {
			$anchor = $display_text;
		}
	}
	return $url if ! $anchor;
	return $anchor if ! $url;
	EXPAND: {
		if ($url =~ /\?/) {
			$expand = "&expand=$code";
		}
		else {
			$expand = "?expand=$code";
		}
	}		
	my $tmpl = $record->{link_template}
			 || $extra
			 || $Variable->{BAR_LINK_TEMPLATE}
			 || q{<A HREF="$URL$" class=barlink>$ANCHOR$</A>};
	$record->{ANCHOR} = $anchor;
	$record->{EXPAND} = $expand;
	$record->{URL} = $url;
	$tmpl =~ s!{HIGHLIGHT}(.*?){/HIGHLIGHT}! $highlight ? $1 : '' !gise;
	$tmpl =~ s/\$(\w+)\$/$record->{$1}/g;
	return $tmpl;
}
EOR
