[
Class Tree: teeple
] [
Index: teeple
] [
All elements
]
teeple
teeple
·
Packages:
teeple
teeple-converter
teeple-filter
teeple-validator
Source for file Util.php
Documentation is available at
Util.php
<?php
/**
* Teeple2 - PHP5 Web Application Framework inspired by Seasar2
*
* PHP versions 5
*
* LICENSE: This source file is subject to version 3.0 of the PHP license
* that is available through the world-wide-web at the following URI:
* http://www.php.net/license/3_0.txt. If you did not receive a copy of
* the PHP License and are unable to obtain it through the web, please
* send a note to license@php.net so we can mail you a copy immediately.
*
*
@package
teeple
*
@author
Mitsutaka Sato <miztaka@gmail.com>
*
@license
http://www.php.net/license/3_0.txt PHP License 3.0
*/
/**
* Util繧ッ繝ゥ繧ケ縺ァ縺吶�
*
*
@package
teeple
*/
class
Teeple_Util
{
/**
* ini繝輔ぃ繧、繝ォ繧定ェュ霎シ縺ソ縺セ縺吶�
*
*
@param
string
$configfile
ini繝輔ぃ繧、繝ォ縺ョ繝代せ
*
@return
array
*/
public
static
function
readIniFile
(
$configfile
)
{
if
(
!
file_exists
(
$configfile
))
{
$this
->
log
->
info
(
"
Filter縺ョ險ュ螳壹ヵ繧。繧、繝ォ縺悟ュ伜惠縺励∪縺帙s縲�(
$configfile
)
"
)
;
return
NULL
;
}
$config
=
parse_ini_file
(
$configfile
,
true
)
;
if
(
!
is_array
(
$config
))
{
$this
->
log
->
error
(
"
Filter縺ョ險ュ螳壹ヵ繧。繧、繝ォ縺ォ隱、繧翫′縺ゅj縺セ縺吶�(
$configfile
)
"
)
;
return
NULL
;
}
if
(
CONFIG_CODE
!=
INTERNAL_CODE
)
{
mb_convert_variables
(
INTERNAL_CODE
,
CONFIG_CODE
,
$config
)
;
}
return
$config
;
}
/**
* 繝上う繝輔Φ蛹コ蛻�j縺ァCapitalize縺輔l縺溘け繝ゥ繧ケ蜷阪r蜿門セ励@縺セ縺吶�
*
*
@param
string
$name
繧ッ繝ゥ繧ケ蜷�
*
@return
string
*/
public
static
function
capitalizedClassName
(
$name
)
{
$pathList
=
explode
(
"_"
,
$name
)
;
$ucPathList
=
array_map
(
'ucfirst'
,
$pathList
)
;
return
join
(
"_"
,
$ucPathList
)
;
}
/**
* 蛟、縺檎ゥコ逋ス縺九←縺�°繧偵メ繧ァ繝�け縺励∪縺吶�
*
*
@param
mixed
$value
*
@param
boolean
$trim
*
@return
boolean
*/
public
static
function
isBlank
(
$value
,
$trim
=
TRUE
)
{
if
(
is_array
(
$value
))
{
return
(
count
(
$value
)
==
0
)
;
}
if
(
$trim
)
{
$value
=
trim
(
$value
)
;
}
return
(
$value
===
NULL
||
$value
===
""
)
;
}
/**
* 繧ィ繝ゥ繝シ繝。繝�そ繝シ繧ク縺ォ繝代Λ繝。繝シ繧ソ繧貞沂繧∬セシ繧薙〒霑斐@縺セ縺吶�
*
*
@param
string
$msg
*
@param
array
$param
*
@return
string
*/
public
static
function
formatErrorMessage
(
$msg
,
&
$param
)
{
foreach
(
$param
as
$i
=>
$arg
)
{
$msg
=
str_replace
(
"{"
.
$i
.
"}"
,
$arg
,
$msg
)
;
}
return
$msg
;
}
/**
* 繧ッ繝ゥ繧ケ繝輔ぃ繧、繝ォ繧段nclude縺励∪縺吶�
*
*
@param
string
$name
*
@return
boolean
*/
public
static
function
includeClassFile
(
$name
)
{
$pathList
=
explode
(
'_'
,
$name
)
;
$path
=
""
;
for
(
$i
=
0
;
$i
<
count
(
$pathList
)
;
$i
++
)
{
if
(
$i
!=
count
(
$pathList
)
-
1
)
{
$path
.=
strtolower
(
$pathList
[
$i
]
)
;
$path
.=
'/'
;
}
else
{
$path
.=
$pathList
[
$i
]
;
}
}
$path
.=
".php"
;
$result
=
@
include_once
$path
;
if
(
$result
!==
FALSE
)
{
return
TRUE
;
}
$path
=
implode
(
'/'
,
$pathList
)
.
".php"
;
$result
=
@
include_once
$path
;
return
$result
===
FALSE
?
FALSE
:
TRUE
;
}
/**
* 繧ェ繝悶ず繧ァ繧ッ繝医∪縺溘�驟榊�縺九i謖�ョ壹&繧後◆蜷榊燕縺ョ繝励Ο繝代ユ繧」繧貞叙繧雁�縺励∪縺吶�
*
*
@param
mixed
$obj
*
@param
string
$fieldName
*
@return
mixed
*/
public
static
function
getProperty
(
$obj
,
$fieldName
)
{
if
(
is_object
(
$obj
))
{
return
$obj
->
$fieldName
;
}
if
(
is_array
(
$obj
))
{
return
isset
(
$obj
[
$fieldName
]
)
?
$obj
[
$fieldName
]
:
NULL
;
}
return
$obj
;
}
/**
* 繧ェ繝悶ず繧ァ繧ッ繝医∪縺溘�驟榊�縺ォ謖�ョ壹&繧後◆蜷榊燕縺ョ繝励Ο繝代ユ繧」繧偵そ繝�ヨ縺励∪縺吶�
*
*
@param
mixed
$obj
*
@param
string
$fieldName
*
@param
mixed
$value
*/
public
static
function
setProperty
(
&
$obj
,
$fieldName
,
$value
)
{
if
(
is_object
(
$obj
))
{
$obj
->
$fieldName
=
$value
;
}
if
(
is_array
(
$obj
))
{
$obj
[
$fieldName
]
=
$value
;
}
return
;
}
/**
* 繧ェ繝悶ず繧ァ繧ッ繝医∪縺溘�驟榊�縺ォ繧サ繝�ヨ縺輔l縺ヲ縺�k繝励Ο繝代ユ繧」縺ョ蜷榊燕繧偵☆縺ケ縺ヲ蜿門セ励@縺セ縺吶�
*
*
@param
mixed
$obj
*
@return
array
*/
public
static
function
getPropertyNames
(
$obj
)
{
if
(
is_object
(
$obj
))
{
return
array_keys
(
get_object_vars
(
$obj
))
;
}
if
(
is_array
(
$obj
))
{
return
array_keys
(
$obj
)
;
}
return
array
(
)
;
}
}
?>
Documentation generated on Mon, 26 Apr 2010 09:00:03 +0900 by
phpDocumentor 1.4.3