HtmlTemplateFramework
[
class tree: HtmlTemplateFramework
] [
index: HtmlTemplateFramework
] [
all elements
]
Packages:
HtmlTemplateFramework
Source for file htf_com_conf.phl
Documentation is available at
htf_com_conf.phl
<?php
/**
* htf_com_conf.phl
*
* htf環境設定情報を保有するクラス
*
*
@package
HtmlTemplateFramework
*
@subpackage
common
*
@access
public
*
@author
Yamauchi Shogo <htf@as-prj.com>
*
@version
$Id: htf_com_conf.phl ,v 1.0 $;
***/
require_once
(
"htf_com_define.inc"
)
;
//共通定数
require_once
(
"htf_com_func.inc"
)
;
//共通関数
/**
* htf環境設定情報を保有するクラス
*
* コンストラクタに指定されたファイル名をサーチ・読み込みを行い、htfの環境設定情報の
* 各設定値を保有します。指定したファイル名は、以下の順序でサーチされます。<br>
* (1)現在の実行ディレクトリ<br>
* (2)実行ディレクトリから上位(ドキュメントルート・またはルートディレクトリまで)<br>
* (3)PHPに設定されたインクルードディレクトリ<br>
* 指定したファイルがみつからなかった場合には、初期値が設定されます。<br>
* <br>
* また、内部エンコード判別(internal_encoding_distinct)がonになっている場合や
* エンコード指定(internal_encoding_encode)が指定されていない場合には、
* PHPの設定値(mb_internal_encodingやmg_language)を参照して内部エンコード判別を行い、
* internal_encoding_encodeを設定します。(EUC-JPもしくはUTF-8のどちらかになります。)
*
*
@access
public
*
@author
Yamauchi Shogo <htf@as-prj.com>
***/
class
htf_com_conf
{
/**
* htmlタグ・エレメントの大文字小文字出力設定値。
* 'lower'(小文字・デフォルト)もしくは'upper'(大文字)を設定します。
*
@access
public
*
@var
string
*/
var
$itemcase_element
;
//htmlタグ・エレメントの大文字・小文字設定
/**
* htmlタグ・属性の大文字小文字出力設定値。
* 'lower'(小文字・デフォルト)もしくは'upper'(大文字)を設定します。
*
@access
public
*
@var
string
*/
var
$itemcase_attribute
;
//htmlタグ・属性の大文字・小文字設定
/**
* htfの内部エンコーディング判別方法設定値。
* 'off'(判別を行わない・デフォルト)もしくは'on'(判別を行う)を設定します。
*
@access
public
*
@var
string
*/
var
$internal_encoding_distinct
;
//内部エンコーディング判定方法
/**
* htfの内部エンコーディング文字列。
* 'EUC-JP'もしくは'UTF-8'を設定します(デフォルトは空文字で、htfではUTF-8と評価される)。
*
@access
public
*
@var
string
*/
var
$internal_encoding_encode
;
//内部エンコーディング文字列
/**
* htfで管理するイメージ格納パス(デフォルトは空文字)。
* ex)/htf/sample/images
*
@access
public
*
@var
string
*/
var
$imagepath
;
//イメージ格納パス
/**
* htfで管理するCSSファイル格納パス(デフォルトは空文字)。
* ex)/htf/sample/css
*
@access
public
*
@var
string
*/
var
$csspath
;
//CSS格納パス
/**
* htfで管理するJavaScriptファイル格納パス(デフォルトは空文字)。
* ex)/htf/sample/js
*
@access
public
*
@var
string
*/
var
$jspath
;
//JavaScript格納パス
/**
* htfで管理するルートパス(デフォルトは空文字)。
* ex)/htf/sample
*
@access
public
*
@var
string
*/
var
$rootpath
;
//ルートパス
/**
* 引数のxmlファイル名をサーチし、環境設定情報を取得します。
*
*
@access
public
*
@param
string
$strfname
環境設定ファイル名(初期値は'htfconf.xml')
*
@return
void
***/
function
htf_com_conf
(
$strfname
=
HTF_CONF_FNAME
)
{
//プロパティ初期化
$this
->
itemcase_element
=
HTF_CASE_LOWER
;
//初期値は小文字(エレメント)
$this
->
itemcase_attribute
=
HTF_CASE_LOWER
;
//初期値は小文字(属性)
$this
->
internal_encoding_distinct
=
HTF_CONF_OFF
;
//初期値は判別オフ(内部エンコード判別)
$this
->
internal_encoding_encode
=
""
;
//初期値はなし(このままなら自動判別へ)
$this
->
imagepath
=
""
;
//初期値はなし
$this
->
csspath
=
""
;
//初期値はなし
$this
->
jspath
=
""
;
//初期値はなし
$this
->
rootpath
=
""
;
//初期値はなし
//htfconf.xmlのDOMオブジェクト&ルート取得
$strxmlpath
=
htf_get_filepath
(
realpath
(
'.'
)
,
$strfname
)
;
if
(
!
htf_is_existsval
(
$strxmlpath
))
{
//見つからなかったらインクルードパスをサーチ
$strxmlpath
=
htf_get_fileincludepath
(
$strfname
)
;
if
(
!
htf_is_existsval
(
$strxmlpath
))
{
return
;
}
}
$this
->
objdom
=
domxml_open_file
(
$strxmlpath
)
;
$objroot
=
$this
->
objdom
->
document_element
(
)
;
//設定情報取得
$this
->
set_confvalue
(
$objroot
)
;
//内部エンコード判別(自動判別指定の場合・指定エンコードが存在しない場合)
if
(
htf_comp_property
(
$this
->
internal_encoding_distinct
,
HTF_CONF_ON
)
||
$this
->
internal_encoding_encode
==
""
)
{
$this
->
judge_internal_encoding
(
)
;
}
return
;
}
/**
* 設定値取得
*
* 引数のDOMルートオブジェクトから、設定値を取得します。
*
*
@access
private
*
@param
DomElement
$objroot
htfconf.xmlのルート要素
*
@return
void
***/
function
set_confvalue
(
$objroot
=
NULL
)
{
//配下の子ノード取得
if
(
!
is_null
(
$objroot
))
{
$arrcnode
=
$objroot
->
child_nodes
(
)
;
}
else
{
return
;
}
//特定要素のアトリビュート取得
for
(
$i
=
0
;
$i
<
count
(
$arrcnode
)
;
$i
++
)
{
if
(
$arrcnode
[
$i
]
->
node_type
(
)
!=
XML_TEXT_NODE
)
{
if
(
htf_comp_xmlelementname
(
$arrcnode
[
$i
]
->
node_name
(
)
,
HTF_CONF_XML_ITEMCASE
))
{
//itemcase要素
$arr_ic_attr
=
$arrcnode
[
$i
]
->
attributes
(
)
;
for
(
$j
=
0
;
$j
<
count
(
$arr_ic_attr
)
;
$j
++
)
{
if
(
htf_comp_xmlattrname
(
$arr_ic_attr
[
$j
]
->
name
,
HTF_ATTR_ITEMCASE_ELEMENT
))
{
//itemcase_element属性
$this
->
itemcase_element
=
$arr_ic_attr
[
$j
]
->
value
;
}
else
if
(
htf_comp_xmlattrname
(
$arr_ic_attr
[
$j
]
->
name
,
HTF_ATTR_ITEMCASE_ATTRIBUTE
))
{
//itemcase_attribute属性
$this
->
itemcase_attribute
=
$arr_ic_attr
[
$j
]
->
value
;
}
}
}
else
if
(
htf_comp_xmlelementname
(
$arrcnode
[
$i
]
->
node_name
(
)
,
HTF_CONF_XML_INTERNAL_ENCODING
))
{
//internal_encoding要素
$arr_ie_attr
=
$arrcnode
[
$i
]
->
attributes
(
)
;
for
(
$j
=
0
;
$j
<
count
(
$arr_ie_attr
)
;
$j
++
)
{
if
(
htf_comp_xmlattrname
(
$arr_ie_attr
[
$j
]
->
name
,
HTF_ATTR_INTERNAL_ENCODING_DISTINCT
))
{
//internal_encoding_distinct属性
$this
->
internal_encoding_distinct
=
$arr_ie_attr
[
$j
]
->
value
;
}
else
if
(
htf_comp_xmlattrname
(
$arr_ie_attr
[
$j
]
->
name
,
HTF_ATTR_INTERNAL_ENCODING_ENCODE
))
{
//internal_encoding_encode属性
$this
->
internal_encoding_encode
=
$arr_ie_attr
[
$j
]
->
value
;
}
}
}
else
if
(
htf_comp_xmlelementname
(
$arrcnode
[
$i
]
->
node_name
(
)
,
HTF_CONF_XML_IMAGEPATH
))
{
//imagepath要素
$arr_ie_attr
=
$arrcnode
[
$i
]
->
attributes
(
)
;
for
(
$j
=
0
;
$j
<
count
(
$arr_ie_attr
)
;
$j
++
)
{
if
(
htf_comp_xmlattrname
(
$arr_ie_attr
[
$j
]
->
name
,
HTF_ATTR_IMAGEPATH_PATH
))
{
//imagepath属性
$this
->
imagepath
=
$arr_ie_attr
[
$j
]
->
value
;
}
}
}
else
if
(
htf_comp_xmlelementname
(
$arrcnode
[
$i
]
->
node_name
(
)
,
HTF_CONF_XML_CSSPATH
))
{
//csspath要素
$arr_ie_attr
=
$arrcnode
[
$i
]
->
attributes
(
)
;
for
(
$j
=
0
;
$j
<
count
(
$arr_ie_attr
)
;
$j
++
)
{
if
(
htf_comp_xmlattrname
(
$arr_ie_attr
[
$j
]
->
name
,
HTF_ATTR_CSSPATH_PATH
))
{
//csspath属性
$this
->
csspath
=
$arr_ie_attr
[
$j
]
->
value
;
}
}
}
else
if
(
htf_comp_xmlelementname
(
$arrcnode
[
$i
]
->
node_name
(
)
,
HTF_CONF_XML_JSPATH
))
{
//jspath要素
$arr_ie_attr
=
$arrcnode
[
$i
]
->
attributes
(
)
;
for
(
$j
=
0
;
$j
<
count
(
$arr_ie_attr
)
;
$j
++
)
{
if
(
htf_comp_xmlattrname
(
$arr_ie_attr
[
$j
]
->
name
,
HTF_ATTR_JSPATH_PATH
))
{
//jspath属性
$this
->
jspath
=
$arr_ie_attr
[
$j
]
->
value
;
}
}
}
else
if
(
htf_comp_xmlelementname
(
$arrcnode
[
$i
]
->
node_name
(
)
,
HTF_CONF_XML_ROOTPATH
))
{
//rootpath要素
$arr_ie_attr
=
$arrcnode
[
$i
]
->
attributes
(
)
;
for
(
$j
=
0
;
$j
<
count
(
$arr_ie_attr
)
;
$j
++
)
{
if
(
htf_comp_xmlattrname
(
$arr_ie_attr
[
$j
]
->
name
,
HTF_ATTR_ROOTPATH_PATH
))
{
//rootpath属性
$this
->
rootpath
=
$arr_ie_attr
[
$j
]
->
value
;
}
}
}
}
}
return
;
}
/**
* 内部エンコード判別
*
* 現在のPHP上の設定値から、使用する内部エンコードを判別し、設定します。
*
*
@access
private
*
@return
String
***/
function
judge_internal_encoding
(
)
{
if
(
!
strcasecmp
(
mb_internal_encoding
(
)
,
HTF_ENCODE_EUC
))
{
//mbstring.internal_encodingがEUC-JPの場合
$this
->
internal_encoding_encode
=
HTF_ENCODE_EUC
;
}
else
if
(
!
strcasecmp
(
mb_internal_encoding
(
)
,
HTF_ENCODE_UTF8
))
{
//mbstring.internal_encodingがUTF-8の場合
$this
->
internal_encoding_encode
=
HTF_ENCODE_UTF8
;
}
else
if
(
!
strcasecmp
(
mb_language
(
)
,
'Japanese'
))
{
//mbstring.languageがjapaneseの場合
$this
->
internal_encoding_encode
=
HTF_ENCODE_EUC
;
}
else
if
(
!
strcasecmp
(
mb_language
(
)
,
'ja'
))
{
//mbstring.languageがjaの場合
$this
->
internal_encoding_encode
=
HTF_ENCODE_EUC
;
}
else
if
(
!
strcasecmp
(
mb_language
(
)
,
'uni'
))
{
//mbstring.languageがuniの場合
$this
->
internal_encoding_encode
=
HTF_ENCODE_UTF8
;
}
else
if
(
!
strcasecmp
(
mb_language
(
)
,
'neutral'
))
{
//mbstring.languageがneutralの場合
$this
->
internal_encoding_encode
=
HTF_ENCODE_UTF8
;
}
else
{
//それ以外の場合はUTF-8
$this
->
internal_encoding_encode
=
HTF_ENCODE_UTF8
;
}
return
;
}
}
?>
Documentation generated on Tue, 19 Sep 2006 06:20:29 +0900 by
phpDocumentor 1.3.0