本文整理汇总了PHP中getClassProperties函数的典型用法代码示例。如果您正苦于以下问题:PHP getClassProperties函数的具体用法?PHP getClassProperties怎么用?PHP getClassProperties使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getClassProperties函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_pref_get
/**
* return the user's preferences in a UserPreferences object
* @param int $p_user_id
* @param int $p_project_id
* @return UserPreferences
*/
function user_pref_get( $p_user_id, $p_project_id = ALL_PROJECTS ) {
static $t_vars;
global $g_cache_current_user_pref;
if ( isset( $g_cache_current_user_pref[(int)$p_project_id] ) &&
auth_is_user_authenticated() &&
auth_get_current_user_id() == $p_user_id ) {
return $g_cache_current_user_pref[(int)$p_project_id];
}
$t_prefs = new UserPreferences( $p_user_id, $p_project_id );
$row = user_pref_cache_row( $p_user_id, $p_project_id, false );
# If the user has no preferences for the given project
if( false === $row ) {
if( ALL_PROJECTS != $p_project_id ) {
# Try to get the prefs for ALL_PROJECTS (the defaults)
$row = user_pref_cache_row( $p_user_id, ALL_PROJECTS, false );
}
# If $row is still false (the user doesn't have default preferences)
if( false === $row ) {
# We use an empty array
$row = array();
}
}
if ($t_vars == null ) {
$t_vars = getClassProperties( 'UserPreferences', 'protected');
}
$t_row_keys = array_keys( $row );
# Check each variable in the class
foreach( $t_vars as $var => $val ) {
# If we got a field from the DB with the same name
if( in_array( $var, $t_row_keys, true ) ) {
# Store that value in the object
$t_prefs->$var = $row[$var];
}
}
if ( auth_is_user_authenticated() && auth_get_current_user_id() == $p_user_id ) {
$g_cache_current_user_pref[ (int)$p_project_id ] = $t_prefs;
}
return $t_prefs;
}
示例2: config_get
$t_bugnote_link = config_get('bugnote_link_tag');
$writer = new XMLWriter();
$writer->openURI('php://output');
$writer->setIndent(true);
$writer->setIndentString(' ');
$writer->startDocument('1.0', 'UTF-8');
$writer->startElement('mantis');
$writer->writeAttribute('version', $t_version);
$writer->writeAttribute('urlbase', $t_url);
$writer->writeAttribute('issuelink', $t_bug_link);
$writer->writeAttribute('notelink', $t_bugnote_link);
$writer->writeAttribute('format', '1');
# Ignored fields, these will be skipped
$t_ignore = array('_stats', 'bug_text_id');
/* properties that we want to export are 'protected' */
$t_columns = array_keys(getClassProperties('BugData', 'protected'));
# export the rows
foreach ($t_result as $t_row) {
$writer->startElement('issue');
foreach ($t_columns as $t_element) {
$t_value = $t_row->{$t_element};
if (empty($t_value)) {
continue;
}
if (in_array($t_element, $t_ignore)) {
continue;
}
switch ($t_element) {
case 'reporter_id':
case 'handler_id':
$t_element_name = substr($t_element, 0, -3);
示例3: getClassProperties
/**
* return array of class properties (via reflection api)
* @param string $p_classname Class name.
* @param string $p_type Property type - public/private/protected/static.
* @param boolean $p_return_object Whether to return array of property objects.
* @param boolean $p_include_parent Whether to include properties of parent classes.
* @return array
* @access public
*/
function getClassProperties($p_classname, $p_type = 'public', $p_return_object = false, $p_include_parent = false)
{
$t_ref = new ReflectionClass($p_classname);
$t_props = $t_ref->getProperties();
$t_props_arr = array();
foreach ($t_props as $t_prop) {
$t_name = $t_prop->getName();
if ($t_prop->isPublic() and stripos($p_type, 'public') === false) {
continue;
}
if ($t_prop->isPrivate() and stripos($p_type, 'private') === false) {
continue;
}
if ($t_prop->isProtected() and stripos($p_type, 'protected') === false) {
continue;
}
if ($t_prop->isStatic() and stripos($p_type, 'static') === false) {
continue;
}
if ($p_return_object) {
$t_props_arr[$t_name] = $t_prop;
} else {
$t_props_arr[$t_name] = true;
}
}
if ($p_include_parent) {
if ($t_parentclass = $t_ref->getParentClass()) {
$t_parent_props_arr = getClassProperties($t_parentclass->getName());
if (count($t_parent_props_arr) > 0) {
$t_props_arr = array_merge($t_parent_props_arr, $t_props_arr);
}
}
}
return $t_props_arr;
}
示例4: getClassProperties
function getClassProperties($className, $types = 'public', $return_object = false, $include_parent = false)
{
$ref = new ReflectionClass($className);
$props = $ref->getProperties();
$props_arr = array();
foreach ($props as $prop) {
$f = $prop->getName();
if ($prop->isPublic() and stripos($types, 'public') === FALSE) {
continue;
}
if ($prop->isPrivate() and stripos($types, 'private') === FALSE) {
continue;
}
if ($prop->isProtected() and stripos($types, 'protected') === FALSE) {
continue;
}
if ($prop->isStatic() and stripos($types, 'static') === FALSE) {
continue;
}
if ($return_object) {
$props_arr[$f] = $prop;
} else {
$props_arr[$f] = true;
}
}
if ($include_parent) {
if ($parentClass = $ref->getParentClass()) {
$parent_props_arr = getClassProperties($parentClass->getName());
//RECURSION
if (count($parent_props_arr) > 0) {
$props_arr = array_merge($parent_props_arr, $props_arr);
}
}
}
return $props_arr;
}
示例5: bugnote_get_field
/**
* Get a field for the given bugnote
* @param integer $p_bugnote_id A bugnote identifier.
* @param string $p_field_name Field name to retrieve.
* @return string field value
* @access public
*/
function bugnote_get_field($p_bugnote_id, $p_field_name)
{
static $s_vars;
global $g_cache_bugnote;
if (isset($g_cache_bugnote[(int) $p_bugnote_id])) {
return $g_cache_bugnote[(int) $p_bugnote_id]->{$p_field_name};
}
if ($s_vars == null) {
$s_vars = getClassProperties('BugnoteData', 'public');
}
if (!array_key_exists($p_field_name, $s_vars)) {
error_parameters($p_field_name);
trigger_error(ERROR_DB_FIELD_NOT_FOUND, WARNING);
}
$t_query = 'SELECT ' . $p_field_name . ' FROM {bugnote} WHERE id=' . db_param();
$t_result = db_query($t_query, array($p_bugnote_id), 1);
return db_result($t_result);
}
示例6: bugnote_get_field
/**
* Get a field for the given bugnote
* @param int $p_bugnote_id bugnote id
* @param string $p_field_name field name
* @return string field value
* @access public
*/
function bugnote_get_field($p_bugnote_id, $p_field_name)
{
static $t_vars;
global $g_cache_bugnote;
if (isset($g_cache_bugnote[(int) $p_bugnote_id])) {
return $g_cache_bugnote[(int) $p_bugnote_id]->{$p_field_name};
}
if ($t_vars == null) {
$t_vars = getClassProperties('BugnoteData', 'public');
}
if (!array_key_exists($p_field_name, $t_vars)) {
error_parameters($p_field_name);
trigger_error(ERROR_DB_FIELD_NOT_FOUND, WARNING);
}
$t_bugnote_table = db_get_table('bugnote');
$query = "SELECT {$p_field_name}\n\t\t \tFROM {$t_bugnote_table}\n\t\t \tWHERE id=" . db_param();
$result = db_query_bound($query, array($p_bugnote_id), 1);
return db_result($result);
}