gusucode.com > 同城苏州黄页系统php源码程序 > lib/system_parameter.class.php

    <?
if( !class_exists('detailPge') )
	include_once($root_path."lib/detailPge.class.php");
if( !class_exists('Query') )
	include_once($root_path."lib/Query.class.php");

$events = array(
	'EVENT_BEFORE_QUERY',						// 查询数据库以前
	'EVENT_BEFORE_SAVEKEY',						// 保存一条记录以前
	'EVENT_AFTER_GETKEY',						// 查询到一条记录以后
);
register_event($events);

class system_parameter extends detailPge
{

	var $groups = array();
	var $query_obj ;


	function system_parameter( $dbtable='system_parameters' )
	{
		$this->dbtable = $dbtable ;
		$this->query_obj = & new Query( $this->dbtable );

		$this->query_obj->noLimit = true ;
		$this->query_obj->setGroupLogic() ;
		$this->query_obj->primaryKey = 'key' ;
		$this->query_obj->set_order( array( 'group', 'order' ) ) ;

		$this->act = 'update' ;
		$this->detailPge() ;

	}

	function load_sys_value()
	{
		foreach( $this->fields as $key=>$item )
			$this->query_obj->directCondition( array('key'=>$key) );

		$this->_touch_user_event( EVENT_BEFORE_QUERY );
		$this->query_cnt
			= $this->query_obj->get_result( $this->query_list );

		foreach ($this->query_list as $idx=>$theRecord)
		{
			$theRecord['group'] = preg_replace( "/^\d+\|/", '', $theRecord['group'] ) ;

			$this->_touch_user_event( EVENT_AFTER_GETKEY, &$theRecord );

			$this->fields[ $theRecord['key'] ]->value = $theRecord['value'] ;
			$this->fields[ $theRecord['key'] ]->caption = $theRecord['caption'] ;
			$this->fields[ $theRecord['key'] ]->comment = $theRecord['comment'] ;
			$this->groups[ $theRecord['group'] ][] =& $theRecord['key'] ;
		}

	}


	function save_sys_value()
	{
		$succ = true ;
		foreach ($this->fields as $key=>$fld)
		{
			$this->_touch_user_event( EVENT_BEFORE_SAVEKEY, &$key, &$this->fields[$key]->value );

			if( !setSystem( $key, $this->fields[$key]->value ) )
			{
				$this->bad( "保存栏位{$key}时发生错误:".mysql_error() );
				$succ = false ;
			}
		}

		return $succ ;

	}

	function show_comment( $fldName )
	{
		return $this->fields[ $fldName ]->comment ;
	}
}
?>