Kaynağa Gözat

modify info

superbee315 5 yıl önce
ebeveyn
işleme
de0d5cda03

+ 38 - 0
application/newhome/controller/Message.php

@@ -0,0 +1,38 @@
+<?php
+namespace app\newhome\controller;
+
+use think\Controller;
+use app\user\model\User;
+use app\user\model\Mail;
+use app\user\model\Notice;
+
+class Message extends Controller {
+	
+	private $userModel, $noticeModel, $mailModel;
+	
+	public function _initialize(){
+		parent::_initialize();
+		
+		$this->userModel = new User();
+		$this->mailModel = new Mail();
+		$this->noticeModel = new Notice();
+	}
+	
+	public function notice()
+	{
+		
+	}
+	
+	public function mail(){
+		$uid = $this->request->post('i', '1907239071686061468');
+		$res = $this->mailModel
+		->where(['is_del'=>0])
+		->where(['users'=>['like', "%{$uid}%"]])
+		->whereOr(['users'=>''])
+		->select();
+		echo '<pre>';
+		print_r(collection($res)->toArray());
+	}
+	
+	
+}

+ 52 - 0
application/user/controller/Notice.php

@@ -37,10 +37,62 @@ class Notice extends Base{
 	}
 	
 	public function create(){
+		$res = $this->noticeModel->where(['is_del'=>0])->order('update_time', 'desc')->select();
 		
+		$dom = new \DOMDocument('1.0', 'utf-8');
+		$filename = 'xml/announce.xml';
+		$dom->formatOutput = true;
+		
+		$announce = $dom->createElement('announce');
+		// 添加版本信息
+		$version = $dom->createElement('version', count($res));
+		$announce->appendChild($version);
+		
+		foreach ($res as $val) {
+			$item = $dom->createElement('item');
+			$id = $dom->createElement('id', $val['id']);
+			$zh_t = $dom->createElement('title', $val['zh_t']);
+			$zh_t->setAttribute('language', 'Chinese');
+			$tw_t = $dom->createElement('title', $val['tw_t']);
+			$tw_t->setAttribute('language', 'ChineseTraditional');
+			$en_t = $dom->createElement('title', $val['en_t']);
+			$en_t->setAttribute('language', 'English');
+			$time = $dom->createElement('date', $val['time']);
+			$content = $dom->createElement('content');
+			
+			$this->fillContent($dom, $content, $val['zh'], 'Chinese');
+			$this->fillContent($dom, $content, $val['tw'], 'ChineseTraditional');
+			$this->fillContent($dom, $content, $val['en'], 'English');
+			
+			$item->appendChild($id);
+			$item->appendChild($zh_t);
+			$item->appendChild($tw_t);
+			$item->appendChild($en_t);
+			$item->appendChild($time);
+			$item->appendChild($content);
+			
+			$announce->appendChild($item);
+		}
+		
+		$dom->appendChild($announce);
+		$dom->save($filename);
 		$this->success('创建xml成功!');
 	}
 	
+	private function fillContent(\DOMDocument &$dom, \DOMElement &$node, string $content, string $type){
+		$info = explode(PHP_EOL, $content);
+		
+		foreach ($info as $val) {
+			$cdata = $dom->createCDATASection($val);
+			$text = $dom->createElement('text');
+			$text->setAttribute('language', $type);
+			$text->appendChild($cdata);
+			
+			$node->appendChild($text);
+		}
+		
+	}
+	
 	public function delete(){
 		$res = $this->noticeModel->where(['id'=>$this->request->get('id')])->update(['is_del'=>1]);
 		

+ 14 - 0
application/user/view/mail/edit.html

@@ -38,6 +38,20 @@
           </div>
           
           <div class="am-form-group">
+            <label for="diamond" class="am-u-sm-3 am-form-label">钻石 / Diamond</label>
+            <div class="am-u-sm-9">
+				<input type="text" id="diamond" name="diamond" value="{$info.diamond}" placeholder="钻石 / Diamond"/>
+            </div>
+          </div>
+          
+          <div class="am-form-group">
+            <label for="coin" class="am-u-sm-3 am-form-label">金币 / Coin</label>
+            <div class="am-u-sm-9">
+				<input type="text" id="coin" name="coin" value="{$info.coin}" placeholder="金币 / Coin"/>
+            </div>
+          </div>
+          
+          <div class="am-form-group">
             <label for="content" class="am-u-sm-3 am-form-label">内容 / Content</label>
             <div class="am-u-sm-9">
             	<textarea id="content" name="content" rows="5" placeholder="内容 / Content">{$info.content}</textarea>

+ 16 - 2
application/user/view/notice/edit.html

@@ -11,9 +11,23 @@
           <form class="am-form am-form-horizontal" method="post" action="save">
           <input type="hidden" value="{$info.id}" name="id" />
             <div class="am-form-group">
-              <label for="title" class="am-u-sm-3 am-form-label">标题 / Title</label>
+              <label for="zh_t" class="am-u-sm-3 am-form-label">中文标题 / Title</label>
               <div class="am-u-sm-9">
-                <input type="text" id="title" name="title" value="{$info.title}" placeholder="标题 / Title">
+                <input type="text" id="zh_t" name="zh_t" value="{$info.zh_t}" placeholder="标题 / Title">
+              </div>
+            </div>
+            
+            <div class="am-form-group">
+              <label for="tw_t" class="am-u-sm-3 am-form-label">台湾标题 / Title</label>
+              <div class="am-u-sm-9">
+                <input type="text" id="tw_t" name="tw_t" value="{$info.tw_t}" placeholder="标题 / Title">
+              </div>
+            </div>
+            
+            <div class="am-form-group">
+              <label for="en_t" class="am-u-sm-3 am-form-label">标题 / Title</label>
+              <div class="am-u-sm-9">
+                <input type="text" id="en_t" name="en_t" value="{$info.en_t}" placeholder="标题 / Title">
               </div>
             </div>
             

+ 1 - 1
application/user/view/notice/index.html

@@ -50,7 +50,7 @@
               	{foreach name="info" key="k" item="v"}
 		              <tr>
 		                <td>{$k+1}</td>
-		                <td>{$v.title}</td>
+		                <td>{$v.zh_t}</td>
 		                <td class="am-hide-sm-only">{$v.create_time}</td>
 		                <td class="am-hide-sm-only">{$v.update_time}</td>
 		                <td>