<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#webliberty::Skin.pm (2006/03/26)
#Copyright(C) 2002-2006 Knight, All rights reserved.

package webliberty::Skin;

use strict;
use base qw(webliberty::Basis);

### ã‚³ãƒ³ã‚¹ãƒˆãƒ©ã‚¯ã‚¿
sub new {
	my $class = shift;

	my $self = {
		data =&gt; undef,
		list =&gt; undef
	};
	bless $self, $class;

	return $self;
}

### ã‚¹ã‚­ãƒ³è§£æž
sub parse_skin {
	my $self = shift;
	my $file = shift;

	my $skin_info;

	open(FH, $file) or $self-&gt;error("Read Error : $file");
	while (&lt;FH&gt;) {
		if (/&lt;!--SKIN_(\w+)_START--&gt;/) {
			$skin_info = lc($1);
			push(@{$self-&gt;{list}}, $skin_info);
		} elsif (/&lt;!--SKIN_(\w+)_END--&gt;/) {
			$skin_info = '';
		} elsif ($skin_info) {
			$self-&gt;{data}-&gt;{$skin_info} .= $_;
		} else {
			$self-&gt;{data}-&gt;{_blank} .= $_;
		}
	}
	close(FH);

	return;
}

### ãƒ‡ãƒ¼ã‚¿ç½®æ›
sub replace_skin {
	my $self = shift;
	my %args = @_;

	foreach my $data (keys %{$self-&gt;{data}}) {
		$self-&gt;{data}-&gt;{$data} =~ s/\$/\a/g;

		foreach (keys %args) {
			if (/_START$/ or /_END$/) {
				$self-&gt;{data}-&gt;{$data} =~ s/&lt;!--$_--&gt;/$args{$_}/g;
			} else {
				$self-&gt;{data}-&gt;{$data} =~ s/\a\{$_\}/$args{$_}/g;
			}
		}

		$self-&gt;{data}-&gt;{$data} =~ s/\a/\$/g;
	}

	return;
}

### ã‚¹ã‚­ãƒ³ãƒªã‚¹ãƒˆå–å¾—
sub get_list {
	my $self = shift;

	return @{$self-&gt;{list}};
}

### ãƒ‡ãƒ¼ã‚¿å–å¾—
sub get_data {
	my $self = shift;
	my $info = shift;

	if ($info eq '_all') {
		$self-&gt;{data}-&gt;{_all} .= $self-&gt;{data}-&gt;{_blank};
	}

	return $self-&gt;{data}-&gt;{$info};
}

### ãƒ‡ãƒ¼ã‚¿ç½®æ›å–å¾—
sub get_replace_data {
	my $self = shift;
	my($info, %args) = @_;

	if ($info eq '_all') {
		$self-&gt;{data}-&gt;{_all} .= $self-&gt;{data}-&gt;{_blank};
	}

	my $skin = $self-&gt;{data}-&gt;{$info};

	$skin =~ s/\$/\a/g;

	foreach (keys %args) {
		if (/_START$/ or /_END$/) {
			$skin =~ s/&lt;!--$_--&gt;/$args{$_}/g;
		} else {
			$skin =~ s/\a\{$_\}/$args{$_}/g;
		}
	}

	$skin =~ s/\a/\$/g;

	return $skin;
}

1;
</pre></body></html>