瀏覽代碼

Update to newssystem to allow upload and display of thumbnails.

tags/rls1
kenn408k 6 年之前
父節點
當前提交
f4532eb974
共有 4 個文件被更改,包括 24 次插入6 次删除
  1. 11
    2
      content/addnews.php
  2. 12
    2
      content/editnews.php
  3. 1
    1
      content/news.php
  4. 0
    1
      content/readnews.php

+ 11
- 2
content/addnews.php 查看文件

@@ -8,7 +8,13 @@ $setup['description'] = "Odense Track Administration";
8 8
 Design::header($setup, 100);
9 9
 
10 10
 if (isset($_POST['title'])) {
11
-    Alter::addNews($_SESSION['user'], $_POST['title'], $_POST['textinput']);
11
+    if (isset($_FILES['thumbnail'])) {
12
+        $uploaded = Upload::handleUpload($_FILES['thumbnail']);
13
+         if ($uploaded == false) {
14
+         // Fail!
15
+         }
16
+    }
17
+    Alter::addNews($_SESSION['user'], $_POST['title'], $_POST['textinput'], $uploaded);
12 18
 }
13 19
 ?>
14 20
 
@@ -17,9 +23,12 @@ if (isset($_POST['title'])) {
17 23
     <div class="border"></div>
18 24
     <br />
19 25
     <div class='editorform'>
20
-        <form method="POST" action="">
26
+        <form method="POST" action="" enctype="multipart/form-data">
21 27
             <input type="text" class='editformtitle' required placeholder='Nyhedstitel' name="title" />
22 28
             <br /><br />
29
+            <p>Thumbnail</p>
30
+            <input type="file" class='editformtitle' required name="thumbnail" />
31
+            <br /><br />
23 32
             <textarea name='textinput' class='editor'></textarea>
24 33
             <br />
25 34
             <input type="submit" class='button btn btn-success pull_right' value="Tilføj" />

+ 12
- 2
content/editnews.php 查看文件

@@ -22,7 +22,14 @@ $result = Get::NewsArticle($_GET['id']);
22 22
 
23 23
 
24 24
 if (isset($_POST['title'])) {
25
-    Alter::editNews($_GET['id'], $_POST['title'], $_POST['textinput']);
25
+    if (isset($_FILES['thumbnail'])) {
26
+        $uploaded = Upload::handleUpload($_FILES['thumbnail']);
27
+         if ($uploaded == false) {
28
+         // Fail!
29
+         }
30
+    }
31
+    
32
+    Alter::editNews($_GET['id'], $_POST['title'], $_POST['textinput'], $uploaded);
26 33
 }
27 34
 ?>
28 35
 
@@ -31,9 +38,12 @@ if (isset($_POST['title'])) {
31 38
     <div class="border"></div>
32 39
     <br />
33 40
     <div class='editorform'>
34
-        <form method="POST" action="">
41
+        <form method="POST" action="" enctype="multipart/form-data">
35 42
             <input type="text" class='editformtitle' required placeholder='Nyhedstitel' value="<?php echo $result['title']; ?>" name="title" />
36 43
             <br /><br />
44
+            <p>Thumbnail</p>
45
+            <input type="file" class='editformtitle' name="thumbnail" />
46
+            <br /><br />
37 47
             <textarea name='textinput' class='editor'><?php echo strip_tags($result['content'], '<br><p><b><i><u><img><a><strong><pre><em><span><div><h1><h2><h3><h4><h5><h6><h7><sub><sup><blockquote><code>'); ?></textarea>
38 48
             <br />
39 49
             <input type="submit" class='button btn btn-success pull_right' value="Rediger" />

+ 1
- 1
content/news.php 查看文件

@@ -18,7 +18,7 @@ Design::header($setup, 0);
18 18
     foreach (Get::publicNewsList() as $row) {
19 19
         ?>
20 20
         <div class="newsitem">
21
-            <div class="newsitemimg pull_left"><img src="img/fbanner/track.png" alt="" /></div>
21
+            <div class="newsitemimg pull_left"><img src="<?php echo $row['img']; ?>" alt="" /></div>
22 22
 
23 23
             <div class="newsitemcont pull_left">
24 24
                 <div class="newsitemauthor"><h2><?php echo $row['title']; ?></h2> <p><?php echo date('H:i d/m-Y', $row['time']); ?></p></div>

+ 0
- 1
content/readnews.php 查看文件

@@ -20,7 +20,6 @@ Design::header($setup, 0);
20 20
     <div class="border"></div>
21 21
 
22 22
     <div class="newsbody">
23
-        <img src="<?php echo Config::$sys_url . Config::$file_path . $result['img']; ?>" />
24 23
         <?php echo strip_tags($result['content'], '<br><p><b><i><u><img><a><strong><pre><em><span><div><h1><h2><h3><h4><h5><h6><h7><sub><sup><blockquote><code>'); ?>
25 24
     </div>
26 25
 </div>

Loading…
取消
儲存