ホームページ  >  記事  >  バックエンド開発  >  例 (Smarty+FCKeditor ニュース システム)_PHP チュートリアル

例 (Smarty+FCKeditor ニュース システム)_PHP チュートリアル

WBOY
WBOYオリジナル
2016-07-21 15:58:55714ブラウズ

以下はメインファイルのindex.phpの内容です:

コードをコピーします コードは次のとおりです:

require('./global.php'); /smarty/libs/Smarty.class.php');
require('./mysql.php');
$action=$_REQUEST['アクション'] ;
//FCK を呼び出す関数を定義する
function editor($input_name, $input_value)
{
$editor = new FCKeditor($input_name);
$editor->BasePath = " /";//エディターのパスを指定します

$editor->ToolbarSet = "Default";//エディターのツールバーには Basic (基本ツール) と Default (すべてのツール) の選択があります
$editor->Width = "100 %";
$editor->Height = "320";
$editor->Value = $input_value;
$editor->Config['AutoDetectLanguage'] = true ;
$editor->Config [' DefaultLanguage'] = 'en' ;//言語
$FCKeditor = $editor->CreateHtml();

$smarty->assign("editor", $FCKeditor);//指定領域
}

switch ($action){

case 'addnewsview':

$smarty= new Smarty();
$smarty->template_dir = './template'
$smarty-> ;compile_dir = './smarty /templates_c ';
$smarty->assign('page_title','New News'); $smarty-> // テキスト ドメイン名をコンテンツとして定義します。 addnewsのQUEST['content']以下
$smarty->display('addnews.htm'); :
$title=$_REQUEST['title'];

if( 空 ($ タイトル) || 空 ($ コンテンツ) {
エコー ",記入してください!
}else{ ,'$title','$content',NOW()) "; $db->";
}
break;

case 'editnewsview':
$smarty= new Smarty();
$ Smarty->template_dir = './template';
$smarty->compile_dir = './smarty/templates_c';
$smarty->assign('page_title','修正新闻');
$スマート- >assign('actionvalue','addnews');
$id=$_REQUEST['id'];

$query="select * from news where id=$id";
$db=new mysql() ;
$result = $db->query_exec($query);
$rs = $result->

$smarty->assign('title',$rs['title']) ;
//$smarty->assign('content',$rs['content']);
$smarty->assign('actionvalue','editnews');
$smarty->assign(' id',$rs['id']);
edi​​tor('content',$rs['content']);
$smarty->display('addnews.htm');

case ' editnews':
$title=$_REQUEST['title'];
$content=$_REQUEST['content'];
$id=$_REQUEST['id']; 

$button=$_REQUEST['送信']; 
$db=new mysql(); 
if ($button=='提交'){
$sql="更新ニュースセットtitle='$title',content='$content',date=NOW() where id=$id"; 
$db->query_exec($sql); 
echo "操作成功!"; 
}
休憩; 

case 'delnews':
$db=new mysql(); 
if ($checkbox!="" or count($checkbox)!=0) {
for ($i=0;$i $db->query _exec(" delete from ニュース where id='$checkbox[$i]'"); 
}
}
echo 「操作成功!"; 
break; 

default: 
        $smarty= new Smarty(); 
        $smarty->template_dir = './template'; 
        $smarty->compile_dir = './smarty/templates_c'; 
        $smarty->assign('page_title','新闻管理'); 
        $smarty->assign('actionvalue','delnews'); 

        $query="select * from news"; 
        $db=new mysql(); 
        $result = $db->query_exec($query); 

        while ($rs = $result-> fetch_assoc()) { 
                $array[]= array("id"=>$rs['id'], "title"=>$rs['title'],"date"=>$rs['date']);  
                $smarty->assign('news',$array); 
        } 

        $smarty->display('index.htm'); 


?> 

以下是模板文件index.htm的内容 
nbsp;HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
 
 
 
{$page_title} 

 

 

新闻管理

 

 
 
   
     
     
   
   
     
   
系统管理
 
       
         
           
           
           
         
                {section name=news loop=$news}  
         
           
           
           
         
                {/section} 
      
标题日期选择
{$news[news].title}{$news[news].date}
 
      

 
         
       
          

 
    
 
 

 

 
 
 

以下是添加新闻的模板文件addnews.htm 
nbsp;HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
 
 
 
 
{$page_title} 
 

 

新闻管理登陆 

 

 
 
   
     
 
 
 
 
 
表> 
 
 

注:データ库すでに付属品の面にあり、先新建一名は新しいデータ库、再ハンドル表导入
本系统用户名:admin 密码:admin
打包下ダウンロード
例 (Smarty+FCKeditor ニュース システム)_PHP チュートリアル下にあるこの文書

www.bkjia.comtru​​ehttp://www.bkjia.com/PHPjc/317500.html技術記事以下は主文件index.php の内容です: 复制代码 代码如下: metahttp-equiv="Content-Type"content="text/html;charset=utf-8" ?php require('./global.php'); require('./smarty/libs/...
系统管理
 

标题
 

 

内容:

 

{$editor}

 

 
  
 
  

 
 

新規追加
声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。