#webliberty::App::Init.pm (2006/03/26)
#Copyright(C) 2002-2006 Knight, All rights reserved.

package webliberty::App::Init;

use strict;

### コンストラクタ
sub new {
	my $class = shift;

	my $self = {
		init   => undef,
		config => undef,
		label  => undef
	};
	bless $self, $class;

	$self->{init}   = $self->_set_init;
	$self->{config} = $self->_set_config;
	$self->{label}  = $self->_set_label;

	return $self;
}

### 初期設定取得
sub get_init {
	my $self = shift;
	my $name = shift;

	my $init;

	if ($name) {
		$init = $self->{init}->{$name};
	} else {
		$init = $self->{init};
	}

	return $init;
}

### 環境設定取得
sub get_config {
	my $self = shift;
	my $name = shift;

	my $config;

	if ($name) {
		$config = $self->{config}->{$name};
	} else {
		$config = $self->{config};
	}

	return $config;
}

### ラベル取得
sub get_label {
	my $self = shift;
	my $name = shift;

	my $label;

	if ($name) {
		$label = $self->{label}->{$name};
	} else {
		$label = $self->{label};
	}

	return $label;
}

### 初期設定
sub _set_init {
	my $self = shift;

	my $init = {
		#基本設定
		script      => 'Web Diary Professional',
		version     => '4.08',
		copyright   => 'Copyright(C) 2002-2006 Knight',
		script_file => './diary.cgi',
		tb_file     => './diary-tb.cgi',
		paint_file  => './diary-paint.cgi',
		html_file   => './index.html',
		parse_size  => 15000,
		jcode_mode  => 0,
		chmod_mode  => 1,
		suexec_mode => 0,

		#ログファイル
		data_dir           => './data/',
		data_config        => 'diary.ini',
		data_user          => 'user.log',
		data_profile       => 'profile.log',
		data_field         => 'field.log',
		data_icon_dir      => 'icon/',
		data_icon          => 'icon.log',
		data_menu          => 'menu.log',
		data_link          => 'link.log',
		data_upfile_dir    => 'upfile/',
		data_upfile_tmp    => 'Temporary.file',
		data_thumbnail_dir => 'thumbnail/',
		data_diary_dir     => 'diary/',
		data_diary_index   => 'index.log',
		data_comt_dir      => 'comment/',
		data_comt_index    => 'index.log',
		data_tb_dir        => 'trackback/',
		data_tb_index      => 'index.log',
		data_ext           => 'log',
		data_lock          => 'diary.lock',

		#スキンファイル
		skin_dir             => './skin/',
		skin_header          => 'header.html',
		skin_footer          => 'footer.html',
		skin_navigation      => 'navigation.html',
		skin_diary           => 'diary.html',
		skin_comment         => 'comment.html',
		skin_complete        => 'complete.html',
		skin_trackback       => 'trackback.html',
		skin_image           => 'image.html',
		skin_icon            => 'icon.html',
		skin_edit            => 'edit.html',
		skin_search          => 'search.html',
		skin_profile         => 'profile.html',
		skin_admin           => 'admin.html',
		skin_admin_work      => 'admin_work.html',
		skin_admin_form      => 'admin_form.html',
		skin_admin_edit      => 'admin_edit.html',
		skin_admin_comment   => 'admin_comment.html',
		skin_admin_trackback => 'admin_trackback.html',
		skin_admin_confirm   => 'admin_confirm.html',
		skin_admin_field     => 'admin_field.html',
		skin_admin_env       => 'admin_env.html',
		skin_admin_icon      => 'admin_icon.html',
		skin_admin_menu      => 'admin_menu.html',
		skin_admin_link      => 'admin_link.html',
		skin_admin_profile   => 'admin_profile.html',
		skin_admin_pwd       => 'admin_pwd.html',
		skin_admin_paint     => 'admin_paint.html',
		skin_admin_build     => 'admin_build.html',
		skin_admin_status    => 'admin_status.html',
		skin_info            => 'info.html',
		skin_error           => 'error.html',

		#アーカイブファイル
		archive_dir => './archives/',
		archive_ext => 'html',

		#JSファイル
		js_title_file => './data/title.js',
		js_text_file  => './data/text.js',

		#ペイント用ファイル
		paint_jar => './spainter.jar',
		res_dir   => './res/',
		paint_dir => 'paint/',
		pch_dir   => 'pch/'
	};

	#祝日 : 特定月日を指定(2桁＋2桁で記述)
	@{$init->{days_holiday}} = ('0102', '0211', '0321', '0429', '0503', '0504', '0505', '0923', '1103', '1123', '1223');

	#祝日 : 何月の第何月曜日か指定
	%{$init->{weeks_holiday}} = ('01'=>'2', '07'=>'3', '09'=>'3', '10'=>'2');

	return $init;
}

### 環境設定
sub _set_config {
	my $self = shift;

	my $config = {
		#基本設定
		site_title        => 'My Diary',
		back_url          => 'http://your.site.addr/index.html',
		mobile_site_title => 'My Diary',
		mobile_back_url   => 'http://your.site.addr/index.html',
		site_description  => '日々の生活を気ままにつづった日記帳。',
		site_url          => '',

		#ログの表示設定
		page_size           => '10',
		list_size           => '5',
		cmtlist_size        => '5',
		tblist_size         => '5',
		mobile_page_size    => '5',
		mobile_cmtlist_size => '5',
		mobile_tblist_size  => '5',

		#投稿画面の表示設定
		use_field => '1',
		use_icon  => '0',
		use_file  => '1',
		use_tburl => '1',

		#投稿記事の初期設定
		default_stat  => '1',
		default_break => '1',
		default_comt  => '0',
		default_tb    => '0',

		#投稿記事の表示設定
		new_days        => '3',
		autolink_mode   => '1',
		quotation_color => '#AAAAAA',

		#ファイルアップロードの設定
		img_maxwidth   => '200',
		thumbnail_mode => '0',

		#コメント投稿制限の設定
		ng_word   => '',
		wait_time => '60',

		#レイアウトの設定
		show_calendar => '1',
		show_field    => '1',
		show_search   => '1',
		show_past     => '1',
		show_menu     => '0',
		show_link     => '0',
		show_profile  => '0',

		#コンテンツリストの設定
		menu_list => '',

		#リンク集の設定
		link_list => '',

		#メール通知の設定
		sendmail_cmt_mode => '0',
		sendmail_tb_mode  => '0',
		sendmail_path     => '/usr/sbin/sendmail',
		sendmail_list     => 'your@mail.addr',
		sendmail_admin    => '',

		#更新PINGの設定
		ping_mode => '0',
		ping_list => 'http://www.blogpeople.net/servlet/weblogUpdates<>http://ping.cocolog-nifty.com/xmlrpc<>http://ping.myblog.jp<>http://blog.goo.ne.jp/XMLRPC<>http://ping.bloggers.jp/rpc/',

		#Cookieの設定
		cookie_id       => 'webdiary',
		cookie_holddays => '90',
		cookie_admin    => 'webdiary_admin',

		#HTMLファイル書き出しの設定
		html_index_mode   => '0',
		html_archive_mode => '0',

		#JSファイル書き出しの設定
		js_title_mode => '0',
		js_title_size => '3',
		js_text_mode  => '0',
		js_text_size  => '5',

		#アクセス制限の設定
		black_list => 'anonymizer.com<>delegate',
		proxy_mode => '1',
		base_url   => ''
	};

	return $config;
}

### ラベル設定
sub _set_label {
	my $self = shift;

	my $label = {
		#パソコンモード用ラベル
		pc_no    => '記事番号',
		pc_id    => '記事ID',
		pc_stat  => '状態',
		pc_break => '改行の変換',
		pc_comt  => 'コメントの受付',
		pc_tb    => 'トラックバックの受付',
		pc_field => '分類',
		pc_date  => '投稿日時',
		pc_name  => '名前',
		pc_subj  => '題名',
		pc_text  => 'メッセージ',
		pc_color => '文字色',
		pc_icon  => 'アイコン',
		pc_file  => 'ファイル',
		pc_host  => 'ホスト',

		pc_pno   => '親記事番号',
		pc_mail  => 'Ｅメール',
		pc_url   => 'ＵＲＬ',
		pc_rank  => '投稿ランク',
		pc_pwd   => '削除キー',

		#携帯モード用ラベル
		mobile_no    => '記事番号',
		mobile_id    => '記事ID',
		mobile_stat  => '状態',
		mobile_break => '改行の変換',
		mobile_comt  => 'ｺﾒﾝﾄの受付',
		mobile_tb    => 'ﾄﾗｯｸﾊﾞｯｸの受付',
		mobile_field => '分類',
		mobile_date  => '投稿日時',
		mobile_name  => '名前',
		mobile_subj  => '題名',
		mobile_text  => 'ﾒｯｾｰｼﾞ',
		mobile_color => '文字色',
		mobile_icon  => 'ｱｲｺﾝ',
		mobile_file  => 'ﾌｧｲﾙ',
		mobile_host  => 'ﾎｽﾄ',

		mobile_pno   => '親記事番号',
		mobile_mail  => 'Eﾒｰﾙ',
		mobile_url   => 'URL',
		mobile_rank  => '投稿ﾗﾝｸ',
		mobile_pwd   => '削除ｷｰ'
	};

	return $label;
}

1;
