HtmlTemplateFramework
[
class tree: HtmlTemplateFramework
] [
index: HtmlTemplateFramework
] [
all elements
]
Packages:
HtmlTemplateFramework
Source for file htf_frm_frameconfig.phl
Documentation is available at
htf_frm_frameconfig.phl
<?php
/**
* htf_frm_frameconfigクラス
*
* 作成するhtfフレーム全体の情報を管理するクラス
*
*
@package
HtmlTemplateFramework
*
@subpackage
frame
*
@access
public
*
@author
Yamauchi Shogo <htf@as-prj.com>
*
@version
$Id: htf_frm_htmlconfig.phl ,v 1.0 $
***/
require_once
(
"htf_com_initialize.inc"
)
;
//共通初期処理
require_once
(
"htf_tag_element.phl"
)
;
//タグオブジェクト
require_once
(
"htf_frm_getcss.phl"
)
;
//CSS取得
require_once
(
"htf_frm_headconfig.phl"
)
;
//ヘッダ
require_once
(
"htf_frm_bodyconfig.phl"
)
;
//ボディ
/**
* 作成するhtfフレーム全体の情報を保持するクラス。
*
* コンストラクタに引数で渡されるframeconfig要素のDOMノードを参照し、
* htfフレーム全体の情報を保持します。<br>
* <br>
* 保持する内容は、htfフレーム定義xmlファイルのルート要素(frameconfig)に記述される
* 属性と、配下の子要素の情報(headconfig要素/bodyconfig要素)の内容です。
* headconfig要素・bodyconfig要素が存在しない場合には、初期値で各保有インスタンスを生成します。<br>
* <br>
* また、HTMLタグを構成する際には、子要素のCSS記述のheadタグへの設定や、
* CSS設定ファイルをサーチして、使用するCSSファイルの決定・headタグへの設定も行います。
*
*
@access
public
*
@author
Yamauchi Shogo <htf@as-prj.com>
***/
class
htf_frm_frameconfig
{
/**
* 言語
*
* コンストラクタで渡されたframeconfig要素のlang属性に指定された値を保有します。
* 初期値は'ja'で、htmlタグのlang属性として設定されます。
*
*
@access
public
*
@var
string
*/
var
$lang
;
/**
* 文書型
*
* コンストラクタでframeconfig要素のdoctype属性に指定された値を保有します。
* 初期値は'HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"'で、文書のDOCTYPE宣言に使用されます。
*
*
@access
public
*
@var
string
*/
var
$doctype
;
/**
* CSSのOS/ブラウザ判別属性
*
* コンストラクタでframeconfig要素のbrowser_distinct_css属性に指定された値を保有します。
* 初期値は'off'で、この場合はOS/ブラウザ判別によるCSSの判別は行いません。判別する場合には、
* 'on'を設定します。
*
*
@access
public
*
@var
string
*/
var
$browser_distinct_css
;
/**
* headconfig
*
* frameconfig要素の子要素のheadconfig要素の内容を保持します。
*
*
@access
public
*
@var
htf_frm_headconfig
*/
var
$headconfig
;
/**
* bodyconfig
*
* frameconfig要素の子要素のbodyconfig要素の内容を保持します。
*
*
@access
public
*
@var
htf_frm_bodyconfig
*/
var
$bodyconfig
;
/**
* htfフレームで管理するイメージ格納パス(デフォルトは空文字)。
* ex)/htf/sample/images
*
@access
public
*
@var
string
*/
var
$imagepath
;
/**
* htfフレームで管理するCSSファイル格納パス(デフォルトは空文字)。
* ex)/htf/sample/css
*
@access
public
*
@var
string
*/
var
$csspath
;
/**
* htfフレームで管理するJavaScriptファイル格納パス(デフォルトは空文字)。
* ex)/htf/sample/js
*
@access
public
*
@var
string
*/
var
$jspath
;
/**
* htfフレームで管理するルートパス(デフォルトは空文字)。
* ex)/htf/sample
*
@access
public
*
@var
string
*/
var
$rootpath
;
/**
* 引数のDOMノードから、htf_frm_frameconfigクラスのインスタンスを生成します。
* 各属性値や子要素が存在しない場合には、初期値で生成します。
*
*
@param
object
$objnode
frameconfigのDOMノード
*
@return
void
***/
function
htf_frm_frameconfig
(
$objnode
=
NULL
)
{
//属性配列・ノード配列取得
if
(
!
is_null
(
$objnode
))
{
$arrattr
=
$objnode
->
attributes
(
)
;
$arrnodes
=
$objnode
->
child_nodes
(
)
;
}
else
{
$arrattr
=
array
(
)
;
$arrnodes
=
array
(
)
;
}
//プロパティ初期化
$this
->
initialize_property
(
)
;
//各プロパティ上書き
$this
->
override_property
(
$arrattr
)
;
//bodyconfig配下の子ノード取得
$this
->
get_childnodes
(
$arrnodes
)
;
//pageconfigが生成されない場合は初期値で生成
$this
->
initialize_nullnodes
(
)
;
}
/**
* htfフレーム全体のHTMLタグを文字列として取得します。
*
* ただし、配下のページエリアのタイプがinclude指定の場合には、その部分はincludeを記述したphpスクリプト文字列となります。
*
*
@access
public
*
@return
string
***/
function
get_htmltag
(
)
{
//htmlタグ作成
$htmltag
=
$this
->
make_htmltag
(
)
;
//DOCTYPE設定
if
(
htf_is_existsval
(
$this
->
doctype
))
{
$strret
=
htf_add_cr
(
'<!DOCTYPE '
.
$this
->
doctype
.
'>'
)
;
}
$strret
.=
$htmltag
->
get_htmltag
(
)
;
return
$strret
;
}
/**
* htfフレーム全体のHTMLタグを出力します。
*
*
@access
public
*
@return
void
***/
function
print_htmltag
(
)
{
//htmlタグ作成
$htmltag
=
$this
->
make_htmltag
(
)
;
//DOCTYPE設定
if
(
htf_is_existsval
(
$this
->
doctype
))
{
print
(
htf_add_cr
(
'<!DOCTYPE '
.
$this
->
doctype
.
'>'
))
;
}
$htmltag
->
print_htmltag
(
)
;
return
;
}
/**
* 出力するタグオブジェクトを生成します。
*
*
@access
private
*
@return
htf_tag_element
***/
function
make_htmltag
(
)
{
//htmlオブジェクト生成
$htmlobj
=
new
htf_tag_element
(
"html"
,
TRUE
,
HTF_ITEMCASE_ELEMENT
)
;
//CSS文字列取得&ヘッダ設定
$strcss
=
$this
->
bodyconfig
->
get_cssformat
(
)
;
$this
->
headconfig
->
cssstr
.=
$strcss
;
//カスタムCSS取得&ヘッダ設定
$strcssfname
=
$this
->
get_cssfname
(
HTF_CSS_FNAME
)
;
$this
->
headconfig
->
cssfilename
=
$strcssfname
;
//lang設定
if
(
htf_is_existsval
(
$this
->
lang
))
{
$htmlobj
->
add_attribute
(
'lang'
,
$this
->
lang
,
HTF_ITEMCASE_ATTRIUTE
)
;
}
//head設定
$ret
=
$htmlobj
->
add_content
(
$this
->
headconfig
)
;
//body設定
$htmlobj
->
add_content
(
$this
->
bodyconfig
)
;
return
$htmlobj
;
}
/**
* 各種プロパティを初期化します。
*
*
@access
private
*
@return
void
***/
function
initialize_property
(
)
{
//プロパティ初期化
$this
->
lang
=
HTF_LANG_JA
;
$this
->
doctype
=
HTF_HTML401TRANSITIONAL
;
$this
->
browser_distinct_css
=
HTF_CONF_OFF
;
$this
->
headconfig
=
NULL
;
$this
->
bodyconfig
=
NULL
;
$this
->
imagepath
=
""
;
$this
->
csspath
=
""
;
$this
->
jspath
=
""
;
$this
->
rootpath
=
""
;
}
/**
* 各種プロパティを引数の属性内容によって上書きします。
*
*
@param
array
$arrattr
属性情報(htf_tag_attribute)配列
*
@access
private
*
@return
void
***/
function
override_property
(
$arrattr
)
{
//各プロパティ取得
for
(
$i
=
0
;
$i
<
count
(
$arrattr
)
;
$i
++
)
{
if
(
htf_comp_xmlattrname
(
HTF_ATTR_HTMLCONFIG_DOCTYPE
,
$arrattr
[
$i
]
->
name
))
{
//doctype属性
$this
->
doctype
=
htf_get_encoded_attr
(
$arrattr
[
$i
]
->
value
)
;
}
else
if
(
htf_comp_xmlattrname
(
HTF_ATTR_HTMLCONFIG_LANG
,
$arrattr
[
$i
]
->
name
))
{
//lang属性
$this
->
lang
=
htf_get_encoded_attr
(
$arrattr
[
$i
]
->
value
)
;
}
else
if
(
htf_comp_xmlattrname
(
HTF_ATTR_HTMLCONFIG_BROWSER_DISTINCT_CSS
,
$arrattr
[
$i
]
->
name
))
{
//browser_distinct_css属性
$this
->
browser_distinct_css
=
htf_get_encoded_attr
(
$arrattr
[
$i
]
->
value
)
;
}
else
if
(
htf_comp_xmlattrname
(
HTF_ATTR_HTMLCONFIG_IMAGEPATH
,
$arrattr
[
$i
]
->
name
))
{
//imagepath属性
$this
->
imagepath
=
htf_get_encoded_attr
(
$arrattr
[
$i
]
->
value
)
;
}
else
if
(
htf_comp_xmlattrname
(
HTF_ATTR_HTMLCONFIG_CSSPATH
,
$arrattr
[
$i
]
->
name
))
{
//csspath属性
$this
->
csspath
=
htf_get_encoded_attr
(
$arrattr
[
$i
]
->
value
)
;
}
else
if
(
htf_comp_xmlattrname
(
HTF_ATTR_HTMLCONFIG_JSPATH
,
$arrattr
[
$i
]
->
name
))
{
//jspath属性
$this
->
jspath
=
htf_get_encoded_attr
(
$arrattr
[
$i
]
->
value
)
;
}
else
if
(
htf_comp_xmlattrname
(
HTF_ATTR_HTMLCONFIG_ROOTPATH
,
$arrattr
[
$i
]
->
name
))
{
//rootpath属性
$this
->
rootpath
=
htf_get_encoded_attr
(
$arrattr
[
$i
]
->
value
)
;
}
}
return
;
}
/**
* 引数のノード情報から子要素オブジェクトを生成する。
*
*
@param
array
$arrcnode
子ノード配列配列
*
@access
private
*
@return
void
***/
function
get_childnodes
(
$arrcnode
)
{
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_HEADCONFIG
))
{
//headconfig
$this
->
headconfig
=
new
htf_frm_headconfig
(
$arrcnode
[
$i
]
)
;
}
else
if
(
htf_comp_xmlelementname
(
$arrcnode
[
$i
]
->
node_name
(
)
,
HTF_CONF_XML_BODYCONFIG
))
{
//bodyconfig
$this
->
bodyconfig
=
new
htf_frm_bodyconfig
(
$arrcnode
[
$i
]
)
;
}
}
}
return
;
}
/**
* 存在しない要素について、子要素を初期値で生成する。
*
*
@access
private
*
@return
void
***/
function
initialize_nullnodes
(
)
{
if
(
is_null
(
$this
->
headconfig
))
{
$this
->
headconfig
=
new
htf_frm_headconfig
(
)
;
}
if
(
is_null
(
$this
->
bodyconfig
))
{
$this
->
bodyconfig
=
new
htf_frm_bodyconfig
(
)
;
}
return
;
}
/**
* 引数のCSS定義xmlファイルをサーチして、使用するCSSファイルを返します。
*
*
@param
string
$strxml
CSS定義xmlファイル名(cssdef.xml)
*
@access
private
*
@return
void
***/
function
get_cssfname
(
$strxml
)
{
//css定義xmlファイルパス取得
//カレントから上位ディレクトリをサーチ
$strfpath
=
htf_get_filepath
(
realpath
(
'.'
)
,
$strxml
)
;
if
(
!
htf_is_existsval
(
$strfpath
))
{
//見つからなかったらインクルードパスをサーチ
$strfpath
=
htf_get_fileincludepath
(
$strxml
)
;
}
//css定義xmlファイルが見当たらない場合は空文字を返して終了
if
(
!
htf_is_existsval
(
$strfpath
))
{
return
""
;
}
//使用するCSSファイルを判別
$objgetcss
=
new
htf_frm_getcss
(
$strfpath
,
$_SERVER
[
'HTTP_USER_AGENT'
]
,
$this
->
browser_distinct_css
)
;
$strcsspath
=
$objgetcss
->
cssname
;
return
$strcsspath
;
}
/**
* 配下の子ノードに記載されているhtfフレーム置換タグを置換します。
*
*
@access
public
*
@return
void
***/
function
replace_defintag_childnodes
(
)
{
//bodyconfig->bgimage
if
(
!
is_null
(
$his
->
bodyconfig
))
{
$this
->
bodyconfig
->
bgimage
=
$this
->
replace_definetag
(
$this
->
bodyconfig
->
bgimage
)
;
//bodyconfig->pageconfig->bgimage
if
(
!
is_null
(
$this
->
bodyconfig
->
pageconfig
))
{
$this
->
bodyconfig
->
pageconfig
->
bgimage
=
$this
->
replace_definetag
(
$this
->
bodyconfig
->
pageconfig
->
bgimage
)
;
//bodyconfig->pageconfig->pageheader->bgimage
if
(
is_null
(
$this
->
bodyconfig
->
pageconfig
->
pageheader
))
{
$this
->
bodyconfig
->
pageconfig
->
pageheader
->
bgimage
=
$this
->
replace_definetag
(
$this
->
bodyconfig
->
pageconfig
->
pageheader
->
bgimage
)
;
}
//bodyconfig->pageconfig->indexbar->bgimage
if
(
is_null
(
$this
->
bodyconfig
->
pageconfig
->
indexbar
))
{
$this
->
bodyconfig
->
pageconfig
->
indexbar
->
bgimage
=
$this
->
replace_definetag
(
$this
->
bodyconfig
->
pageconfig
->
indexbar
->
bgimage
)
;
}
//bodyconfig->pageconfig->leftarea->bgimage
if
(
is_null
(
$this
->
bodyconfig
->
pageconfig
->
leftarea
))
{
$this
->
bodyconfig
->
pageconfig
->
leftarea
->
bgimage
=
$this
->
replace_definetag
(
$this
->
bodyconfig
->
pageconfig
->
leftarea
->
bgimage
)
;
}
//bodyconfig->pageconfig->contentarea->bgimage
if
(
is_null
(
$this
->
bodyconfig
->
pageconfig
->
contentarea
))
{
$this
->
bodyconfig
->
pageconfig
->
contentarea
->
bgimage
=
$this
->
replace_definetag
(
$this
->
bodyconfig
->
pageconfig
->
contentarea
->
bgimage
)
;
}
//bodyconfig->pageconfig->rightarea->bgimage
if
(
is_null
(
$this
->
bodyconfig
->
pageconfig
->
rightarea
))
{
$this
->
bodyconfig
->
pageconfig
->
rightarea
->
bgimage
=
$this
->
replace_definetag
(
$this
->
bodyconfig
->
pageconfig
->
rightarea
->
bgimage
)
;
}
//bodyconfig->pageconfig->pagefooter->bgimage
if
(
is_null
(
$this
->
bodyconfig
->
pageconfig
->
pagefooter
))
{
$this
->
bodyconfig
->
pageconfig
->
pagefooter
->
bgimage
=
$this
->
replace_definetag
(
$this
->
bodyconfig
->
pageconfig
->
pagefooter
->
bgimage
)
;
}
}
}
//headconfig->cssfilename
if
(
!
is_null
(
$this
->
headconfig
))
{
$this
->
headconfig
->
cssfilename
=
$this
->
replace_definetag
(
$this
->
headconfig
->
cssfilename
)
;
}
return
;
}
/**
* htfフレームで設定された各種パス情報(イメージパス・CSSパス・JavaScriptパス・ルートパス)
* で引数内の置換タグを変換します。置換タグ定義は次の通り。
* %FRAME_IMAGEPATH%→イメージパス %FRAME_CSSPATH%→CSSパス %FRAME_JSPATH%→JavaScriptパス %FRAME_ROOTPATH%→ルートパス
*
*
@access
public
*
@param
string
$srcstr
*
@return
string
***/
function
replace_definetag
(
$srcstr
)
{
$repstr1st
=
str_replace
(
HTF_REPLACE_FRAME_IMAGEPATH
,
$this
->
imagepath
,
$srcstr
)
;
$repstr2nd
=
str_replace
(
HTF_REPLACE_FRAME_CSSPATH
,
$this
->
csspath
,
$repstr1st
)
;
$repstr3rd
=
str_replace
(
HTF_REPLACE_FRAME_JSPATH
,
$this
->
jspath
,
$repstr2nd
)
;
$repstr4th
=
str_replace
(
HTF_REPLACE_FRAME_ROOTPATH
,
$this
->
rootpath
,
$repstr3rd
)
;
return
$repstr4th
;
}
}
?>
Documentation generated on Tue, 19 Sep 2006 06:20:52 +0900 by
phpDocumentor 1.3.0