论坛首页 编程语言技术论坛

今天没有带U盘,把代码拷到网上再回家贴

浏览 1299 次
该帖已经被评为隐藏帖
作者 正文
   发表时间:2009-03-11   最后修改:2009-03-24
PHP
<?php
//BeijingExtreme Project - Custom code !

//开启根目录设置,这个文件是所有页面都必须加载的
if(!isset($GLOBALS['root_path']))
{
	$GLOBALS['root_path'] = dirname(__FILE__) . "/../" ;
}
if(!isset($GLOBALS['is_debug']))
{
	$GLOBALS['is_debug'] = false ;
}


if(!isset($GLOBALS['root_path']))
{
	$GLOBALS['root_path'] = dirname(__FILE__) . "/../" ;
}
if(!isset($GLOBALS['root_path']))
{
	$GLOBALS['root_path'] = dirname(__FILE__) . "/../" ;
}
if(!isset($GLOBALS['root_path']))
{
	$GLOBALS['root_path'] = dirname(__FILE__) . "/../" ;
}

/**
 * 常用的辅助代码库
 *
 */
class BJExtremeCommon {
	function dump($vars)
	{
	    echo "<pre>\n" . print_r($vars, true) . "\n</pre>\n";
	}
	
	
	/**
	 * 加载项目的内部文件 , 第二个参数为false,则返回
	 *
	 * @param String $path
	 * @return bool
	 */
	public function loadInterFile($path)
	{
		if (is_file("{$GLOBALS['root_path']}{$path}")){
			include ("{$GLOBALS['root_path']}/{$path}");
			return true ;
		}
		return false ;
	}
	
	function getInterFileContents($path) {
		if (is_file("{$GLOBALS['root_path']}{$path}")){
	        ob_start();
	        include ("{$GLOBALS['root_path']}/{$path}");
	        $contents = ob_get_contents();
	        ob_end_clean();
	        return $contents;
	    }
	    return false;
	}
	
	
	/**
	 * 嵌入HTML代码段 -- 这个路径必须是相对于root_path的相对路径
	 * 且路径前面不要带上 "/" 字符*
	 * @param String $path
	 */
	public function incHtmlPage($path){
		return $this->loadInterFile($path) ;
	}
	
	public function loadJSFile($path){
		echo "<script src='$path' type='text/javascript'></script>\n";
	}
	
	public function loadCSSFile($path){
		echo "<link href='$path' rel='stylesheet' type='text/css'> \n";
	}
	
	/**
	 * 启用指定的JS调试实现
	 *
	 * @param int $debugImpl
	 * @return bool
	 */
	public function loadJSDebug($debugImpl = 0){
		if($debugImpl == 0) 
			return $this->loadJSFile("js/debug/nitobibug/compressed.js") ;
		return NULL ;			
	}
	/**
	 * 加载Jquery1.7框架
	 * @return bool
	 */
	public function loadJqueryFramework(){
		$this->loadJSFile("js/jquery/jq-1.3.2.min.js") ;
	}
	public function loadJqueryUI(){
		$this->loadJSFile("js/jquery/jqui-1.7.min.js");
		$this->loadCSSFile('css/smoothness/jqui-1.7.css');
	}
	
	/**
	 * 生成指定XPath路径下的 DashboardGroup 样板
	 *
	 * @param String $key
	 */
	public function buildDashboardGroup($key) {
		$dashboardArr = $this->getDashboardGroup($key);
		$dashboardTemplate = $this->getInterFileContents('tpl/inc/mdintro.html') ;
		if (is_array($dashboardArr)){
			
			$tdArray = array();
			foreach ($dashboardArr as $dashboard){
				$dTmp = str_ireplace("#title#",$dashboard['title'],$dashboardTemplate) ;
				$dTmp = str_ireplace("#description#",$dashboard['description'],$dTmp) ;
				$dTmp = str_ireplace("#golink#",$dashboard['golink'],$dTmp) ;
				$tdArray[] = $dTmp ;
			}
			echo $this->getHtmlTableFromTdArray('dashboard',$tdArray,2);
		}
	}
	
	/**
	 * 加载 Dashboard内容数组 并返回
	 * 此处仅仅实现从XML文件中获取样板信息
	 * 
	 * @param String $key
	 * @return array
	 */
	protected function getDashboardGroup($key='/'){
		$dashboardArr = NULL ;$key=trim($key);
		if (!empty($key))
		{
			$dashboardXMLPath = 'tpl/inc/dashboard/' ;
			$dashboardArr = $this->getDashboardArrayFromXML( $dashboardXMLPath . 'root-dashboard.xml') ;
			if ($key == '/'){
				return $dashboardArr ;
			} 
			else if (array_key_exists($key,$dashboardArr)) {
				return $this->getDashboardArrayFromXML( $dashboardXMLPath . $dashboardArr[$key]['suburl']) ;
			}
		}
		return $dashboardArr ;	
	}
	/**
	 * 从XML文件中获取Dashboard内容 的具体实现
	 *
	 * @param String $file
	 * @return array
	 */
	private function getDashboardArrayFromXML($file){
		$xmlobj = simplexml_load_file($file);
		$dashboardArr = array() ;
		foreach ($xmlobj->children() as $dashboard)
		{
			$dashboardArr["{$dashboard['name']}"] = array(
				'title' => $dashboard->title .'' ,
				'description' => $dashboard->description  .'',
				'golink' => $dashboard->golink .'' ,
				'suburl' => "{$dashboard['suburl']}"
			);
		}
		return $dashboardArr ;
	}
	
	private function getHtmlTableFromTdArray($tableID,$tdArray,$colnum){
		$table = "<table id='{$tableID}'>" ;
		if($colnum < 1) $colnum = 2 ;	
		$tr_str = ""  ; $td_str = "\n" ; $ii= 1 ;
		$i = 0 ; 
		foreach ($tdArray as $td){
			$td_str .= $td ;
			if ($ii == $colnum){
				$tr_str .= "<tr>{$td_str}</tr>" ;
				$ii = 0 ;$td_str = "\n" ;
			}
			if ($i == count($tdArray)-1)
				$tr_str .= "<tr>{$td_str}</tr>" ;
			$i ++ ;	$ii ++ ;			
		}
		$table .= $tr_str . '</table>';
		return $table ;
	}
	
	
	/**
	 * 嵌入 新浪编辑器对象
	 *
	 * @param String $name
	 * @param int $width
	 * @param int $height
	 */
	public function incSinaEditor($input_name='content',$inputvalue='',$width='700',$height='460',$scroll='No'){
		$sinaEditorTemplate = $this->getInterFileContents('tpl/inc/sinaeditor.html') ;
		$sinaEditorTemplate = str_ireplace("#input_name#",$input_name,$sinaEditorTemplate) ;
		//先将传入的值的' 符号置换为" , 因为模板中value用的是''
//		$input_value = str_ireplace("'",'"',$input_value) ;
		$input_value = htmlspecialchars($input_value) ;
		$sinaEditorTemplate = str_ireplace("#input_value#",$input_value,$sinaEditorTemplate) ;
		
		$sinaEditorTemplate = str_ireplace("#width#",$width,$sinaEditorTemplate) ;
		$sinaEditorTemplate = str_ireplace("#height#",$height,$sinaEditorTemplate) ;
		$sinaEditorTemplate = str_ireplace("#scroll#",$scroll,$sinaEditorTemplate) ;
		echo $sinaEditorTemplate ;
	}
}

?>

 

 

<div id='layout'>
	
	<div id='leftline'></div>

	<div id='interline'>
		<div id='extraop'>额外的信息区域,暂备</div>
		
		<div id='header'>
			<span id='logo'></span>
			<ul id='nav-pageguide'>
				<li t="首页"><span id='page-home'>главная</span> <span class='spe-char'> - </span></li>
				<li t="收藏本站"><span id='page-addfav'>добавить в избранное</span><span class='spe-char'> - </span></li>
				<li t='设为主页'><span id='page-sethome'>cделать стартовой</span><span class='spe-char'> - </span></li>
				<li t='关于我们'><span id='page-aboutus'>о компании</span></li>
			</ul>
			<span id='swftitle'>
				<embed src="swf/top_title.swf" quality="high" type="application/x-shockwave-flash" width="450" height="50"/>
			</span>
		</div>
		
		<div id='nav-topimg'>
		    <div class='img-border'></div>
		    <div id='top-img' title="准备替换的topImg图"></div>
		    <div class='img-border'></div>
		</div>
		
		<div id='nav-mod'>
			<ul id='nav-modguidebar'>
				<li t='首页'><span id='homemod'>главная</span><span class='spe-char'> &gt; </span></li>
				<li t='父模块链接'><span id='fathermod'>путешествия</span><span class='spe-char'> &gt; </span></li>
				<li t='当前模块'><span id='curmod'>тибет</span></li>
				<li t='选中的action'><span id='curact'>Географическая справка</span></li>
			</ul>
		</div>
		
		<div id='contenter' t='内容区域'>
		
			<div id='action-menu'></div>
			<div id='action-top'>
				<span id='action-title' title="菜单标题">
					
				</span>
				<span id='action-rimg' title="右边的小图片"></span>
			</div>
			<div id='action-content'></div>
		</div>
		
		<div id='footer'>
			<p id='copyright'>Copyright &copy; 2006 Beijing Extreme Club. All Rights Reserved</p>
		</div>
		
	</div>
	
	<div id='rightline'></div>
</div>

 

   发表时间:2009-03-17  

<?php
FLEA::loadFile('Serv_Common.php',true);

/**
 * 模块管理逻辑层 -- 在这里验证 数据
 * 正确的数据就入库,错误的返回
 *
 */
class Serv_ModuleManage  extends Serv_Common{
	
	protected $__DOC__ = '模块种类和标签的管理,涉及module_catalog和keydirctory数据表' ;
	
	function __construct(){
		parent::__construct(); //子类中定义了构造器,将不会自动执行父类的构造器
		$this->setDataAccessObjects(array(
			'module_catalog' => 'ModuleCatalogTable',
			'keydirctory' => 'KeyDirctoryTable'
		));		
	}
	
	
	/**
	 * 验证数据的完整性,客户端做了验证,服务器端同样要做验证	 
	 * 
	 * @param mixed $data
	 * @return bool
	 */
	protected function verify($data){
		
		if (empty($data))
			return false ; //空数据返回验证失败
		
		$rules = array(
			array('notEmpty' => false)
			
		);
		
		$this->getLog()->log($data ,'warning',"数据验证操作");
		//dump( $this->verifyHelper->checkAll($data,$rules) );
		$this->setErrorInfo(array(
			'module_name' => '模块名称不能为null'
		));
		
		return true ;
	} 
	
	/**
	 * 添加 模块操作
	 *
	 * @param mixed $data
	 * @return bool
	 */
	public function add($data){
		if ($this->verify($data)){
			//入库操作 -- 对于模块之类表添加操作要求验证模块名称是否存在
			$this->dataAccessObject = & new ModuleCatalogTable();
			$catalog = array('name'=>$data['module_name']) ;	
			__TRY();
			$catalogID = $this->getDataAccessObject('module_catalog')->create($catalog);	
			$ex = __CATCH();
			if (__IS_EXCEPTION($ex)) {
				$this->getLog()->log($ex->getMessage() ,'warning',"数据验证操作");
				return false ;
			}
			
			if ($catalogID == false)
			{
				$this->setErrorInfo(array(
					'module_name' => '模块名称已存在'
				));
				return false ;
			}
			
			$keyDirctory = array(
				array('mid' => $catalogID ,'lang' => 'english' ,'text' => $data['module_english_text']) ,
				array('mid' => $catalogID ,'lang' => 'ru' ,'text' => $data['module_ru_text']) ,
				array('mid' => $catalogID ,'lang' => 'zh-cn' ,'text' => $data['module_zh-cn_text'])
			);
			
			$this->getDataAccessObject('keydirctory')->createRowset($keyDirctory);
			return true ;
		}
		return false ;
	}
}
?>

0 请登录后投票
论坛首页 编程语言技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics