浏览代码

* Change on themes {$postType} from numbers to type string.

Victor De la Rocha 16 年前
父节点
当前提交
3290ea1a8d
共有 2 个文件被更改,包括 95 次插入92 次删除
  1. 21 22
      index.php
  2. 74 70
      themes/tumblr/index.htm

+ 21 - 22
index.php 查看文件

@@ -18,7 +18,7 @@ require_once('entry.php');
18 18
 global $user, $tumble, $conf;
19 19
 
20 20
 $theme = new themes;
21
-        // Our first approach to MVC... ¿our second? visit http://www.flavorphp.com
21
+        // Our first approach to MVC... �our second? visit http://www.flavorphp.com
22 22
 
23 23
         if(isset($_SERVER['PATH_INFO'])) $param_url = explode("/",$_SERVER['PATH_INFO']);
24 24
 
@@ -36,7 +36,7 @@ $theme = new themes;
36 36
         }
37 37
 
38 38
         $theme->set('id_post',$id_post);
39
-	$theme->set('error','');
39
+		$theme->set('error','');
40 40
 
41 41
         if (isset($_GET["page"])) {
42 42
                 $page_num = $_GET["page"];
@@ -61,7 +61,7 @@ $theme = new themes;
61 61
 		$page_title_divisor = " » "; // it should be set in configuration
62 62
 		$page_title_len = 50; // it should be set in configuration
63 63
 		if ($id_post) {
64
-			$register = $tumble->getPost($id_post);			
64
+			$register = $tumble->getPost($id_post);
65 65
 			if (empty($register["title"])) {
66 66
 				if (!empty($register["description"])) {
67 67
 					$page_title_data = trimString($register["description"], $page_title_len);
@@ -70,7 +70,7 @@ $theme = new themes;
70 70
 				}
71 71
 			} else {
72 72
 				$page_title_data = $register["title"];
73
-			}			
73
+			}
74 74
 			if (!empty($page_title_data)) {
75 75
 				$page_title .= $page_title_divisor.stripslashes($page_title_data);
76 76
 			}
@@ -82,6 +82,7 @@ $theme = new themes;
82 82
 		$theme->set('Description',$conf->description);
83 83
 		$theme->set('URL_Tumble',$conf->urlGelato);
84 84
 		$theme->set('Template_name',$conf->template);
85
+		$theme->set('allowComments',$conf->allowComments);
85 86
 
86 87
 		$theme->set('isAuthenticated',$user->isAuthenticated());
87 88
         if($user->isAuthenticated()){
@@ -116,12 +117,11 @@ $theme = new themes;
116 117
                                 $register["title"] = stripslashes($register["title"]);
117 118
                                 $register["description"] = stripslashes($register["description"]);
118 119
 
119
-								$postType = $tumble->getType($register["id_post"]);
120
-
121 120
 								$row['Date_Added'] = $formatedDate;
122 121
 								$row['Permalink'] = $permalink;
123
-								$row['postType'] = $postType;
124
-                                switch ($postType){
122
+								$row['postType'] = type2Text($register["type"]);
123
+
124
+                                switch ($register['type']){
125 125
                                         case "1":
126 126
                                         		$row['Title'] = $register["title"];
127 127
                                         		$row['Body'] = $register["description"];
@@ -216,9 +216,9 @@ $theme = new themes;
216 216
 
217 217
 				$row['Date_Added'] = $formatedDate;
218 218
 				$row['Permalink'] = $permalink;
219
-				$postType = $tumble->getType($register["id_post"]);
220
-				$row['postType'] = $postType;
221
-                switch ($postType) {
219
+				$row['postType'] = type2Text($register["type"]);
220
+
221
+                switch ($register['type']) {
222 222
                         case "1":
223 223
 								$row['Title'] = $register["title"];
224 224
 								$row['Body'] = $register["description"];
@@ -266,16 +266,11 @@ $theme = new themes;
266 266
 								break;
267 267
                 }
268 268
 
269
-				if ($conf->allowComments) {
270
-
271
-					$comment = new comments();
272
-					$rsComments = $comment->getComments($register["id_post"]);
273
-
274 269
 					$user = new user();
275 270
 					$username = $user->getUserByID($register["id_user"]);
276 271
 
277 272
 					$row["User"] = $username["name"];
278
-					
273
+
279 274
 					if (empty($register["title"])) {
280 275
 						if (!empty($register["description"])) {
281 276
 							$postTitle = trimString($register["description"]);
@@ -284,14 +279,15 @@ $theme = new themes;
284 279
 						}
285 280
 					} else {
286 281
 						$postTitle = $register["title"];
287
-					}					
282
+					}
288 283
 
289
-					$row["Post_Title"] = $postTitle;
290
-					$row["Comments_Number"] = $comment->countComments($register["id_post"]);
284
+				$row["Post_Title"] = $postTitle;
291 285
 
292
-					$rows[] = $row;
293
-					$theme->set('rows',$rows);
286
+				$comment = new comments();
287
+				$row["Comments_Number"] = $comment->countComments($register["id_post"]);
294 288
 
289
+				if ($conf->allowComments) {
290
+					$rsComments = $comment->getComments($register["id_post"]);
295 291
 					$comments = array();
296 292
 					while($rowComment = mysql_fetch_assoc($rsComments)) {
297 293
 						$commentAuthor = ($rowComment["web"]=="") ? $rowComment["username"] : "<a href=\"".$rowComment["web"]."\" rel=\"external\">".$rowComment["username"]."</a>";
@@ -314,6 +310,9 @@ $theme = new themes;
314 310
 					$theme->set('Form_Action',$conf->urlGelato."/admin/comments.php");
315 311
 					$theme->set('whois',$whois);
316 312
 				}
313
+
314
+				$rows[] = $row;
315
+				$theme->set('rows',$rows);
317 316
         }
318 317
 
319 318
         $theme->set('URL_Tumble',$conf->urlGelato);

+ 74 - 70
themes/tumblr/index.htm 查看文件

@@ -36,8 +36,8 @@
36 36
 			{block {$rows} as {$row}}
37 37
 				<div class="date">
38 38
 					{$row.Date_Added}
39
-				</div>
40
-				{if {$row.postType}==1}
39
+				</div> {$row.postType}
40
+				{if {$row.postType}=='regular'}
41 41
 					<div class="post">
42 42
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
43 43
 
@@ -46,7 +46,7 @@
46 46
 							{$row.Body}
47 47
 						</div>
48 48
 					</div>
49
-				{elseif {$row.postType}==2}
49
+				{elseif {$row.postType}=='photo'}
50 50
 					<div class="post">
51 51
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
52 52
 						<div class="photo">
@@ -54,7 +54,7 @@
54 54
 							<div class="caption">{$row.Caption}</div>
55 55
 						</div>
56 56
 					</div>
57
-				{elseif {$row.postType}==3}
57
+				{elseif {$row.postType}=='quote'}
58 58
 					<div class="post">
59 59
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
60 60
 						<div class="quote">
@@ -62,7 +62,7 @@
62 62
 							<div class="source">&mdash; {$row.Source}</div>
63 63
 						</div>
64 64
 					</div>
65
-				{elseif {$row.postType}==4}
65
+				{elseif {$row.postType}=='link'}
66 66
 					<div class="post">
67 67
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
68 68
 							<div class="link">
@@ -70,7 +70,7 @@
70 70
 							<div class="description">{$row.Description}</div>
71 71
 						</div>
72 72
 					</div>
73
-				{elseif {$row.postType}==5}
73
+				{elseif {$row.postType}=='conversation'}
74 74
 					<div class="post">
75 75
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
76 76
 						<div class="conversation">
@@ -78,7 +78,7 @@
78 78
 							{$row.Conversation}
79 79
 						</div>
80 80
 					</div>
81
-				{elseif {$row.postType}==6}
81
+				{elseif {$row.postType}=='video'}
82 82
 					<div class="post">
83 83
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
84 84
 						<div class="video">
@@ -86,7 +86,7 @@
86 86
 							<div class="caption">{$row.Caption}</div>
87 87
 						</div>
88 88
 					</div>
89
-				{elseif {$row.postType}==7}
89
+				{elseif {$row.postType}=='mp3'}
90 90
 					<div class="post">
91 91
 						<a href="{$row.Permalink}"><img src="{URL_Tumble}/themes/tumblr/img/link.gif" class="permalink" alt="Permalink"/></a>
92 92
 						<div class="video">
@@ -98,73 +98,77 @@
98 98
 
99 99
 			{if !{$id_post}}
100 100
 				<div class="totalComments">
101
-					<h3>Posted by {$row.User} - <a href="{$row.Permalink}#comments">( {$row.Comments_Number} ) comments</a></h3>
101
+					<h3>Posted by {$row.User} {if {$allowComments}}- <a href="{$row.Permalink}#comments">( {$row.Comments_Number} ) comments{/if}</a></h3>
102 102
 				</div>
103 103
 			{/if}
104 104
 		{/block}
105 105
 
106
-		{if {$id_post}}
107
-			<div class="containerComments">
108
-				<h3 id="comments">{$row.Comments_Number} answers to &#8220;{$row.Post_Title}&#8221;</h3>
109
-				<ol class="commentlist">
110
-					{block {$comments} as {$comment}}
111
-					<li class="alt" id="comment-{$comment.Id_Comment}">
112
-						<cite>
113
-							<a href="#comment-{$comment.Id_Comment}" title="Comment permalink">#</a>&nbsp;&nbsp;
114
-							{$comment.Comment_Author} said:
115
-						</cite>
116
-						<br />
117
-						<span class="timestampComment"> at {$comment.Date}</span><br /><br />
118
-						{$comment.Comment}
119
-						<br /><br />
120
-					</li>
121
-					{/block}
122
-				</ol>
123
-			</div>
124
-
125
-			<div class="containerFormComments">
126
-			<h3 id="respond">Add your comment</h3>
106
+		{if {$id_post}}
107
+			{if {$row.Comments_Number}>0}
108
+				<div class="containerComments">
109
+					<h3 id="comments">{$row.Comments_Number} answers to &#8220;{$row.Post_Title}&#8221;</h3>
110
+					<ol class="commentlist">
111
+						{block {$comments} as {$comment}}
112
+						<li class="alt" id="comment-{$comment.Id_Comment}">
113
+							<cite>
114
+								<a href="#comment-{$comment.Id_Comment}" title="Comment permalink">#</a>&nbsp;&nbsp;
115
+								{$comment.Comment_Author} said:
116
+							</cite>
117
+							<br />
118
+							<span class="timestampComment"> at {$comment.Date}</span><br /><br />
119
+							{$comment.Comment}
120
+							<br /><br />
121
+						</li>
122
+						{/block}
123
+					</ol>
124
+				</div>
125
+			{/if}
126
+
127
+			{if {$allowComments}}
128
+				<div class="containerFormComments">
129
+					<h3 id="respond">Add your comment</h3>
127 130
 
128
-			<form action="{Form_Action}" method="post" name="commentForm" id="commentForm">
129
-				<p>
130
-					<label for="username">
131
-						<small>Name:</small>
132
-					</label>
133
-					<input name="username" id="username" value="{whois.User_Cookie}" size="22" tabindex="1" type="text" />
134
-				</p>
135
-				<p>
136
-					<label for="email">
137
-						<small>E-mail:</small>
138
-					</label>
139
-					<input name="email" id="email" value="{whois.Email_Cookie}" size="22" tabindex="2" type="text" />
140
-				</p>
141
-				<p>
142
-					<label for="web">
143
-						<small>Website:</small>
144
-					</label>
145
-					<input name="web" id="web" value="{whois.Web_Cookie}" size="22" tabindex="3" type="text" />
146
-				</p>
147
-				<p>
148
-					<textarea name="content" id="content" cols="100" rows="10" tabindex="4"></textarea>
149
-				</p>
150
-				<p>
151
-					<span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;">
152
-                    	Some HTML allowed:<br />
153
-                        &nbsp;&nbsp;&nbsp;&nbsp;
154
-                        <code>
155
-                            &lt;blockquote&gt; &lt;code&gt; &lt;em&gt; &lt;strong&gt; &lt;a&gt;
156
-                        </code>    
157
-                	</span>
158
-                </p>
159
-		  		<p>
160
-					<input type="submit" value="Add comment" name="btnAdd" id="btnAdd" tabindex="5" />
161
-				</p>
162
-				<p>
163
-					<input name="id_post" id="id_post" value="{id_post}" type="hidden" />
164
-					<input name="comment_date" id="comment_date" value="{Date_Added}" type="hidden" />
165
-				</p>
166
-			</form>
167
-		</div>
131
+					<form action="{Form_Action}" method="post" name="commentForm" id="commentForm">
132
+						<p>
133
+							<label for="username">
134
+								<small>Name:</small>
135
+							</label>
136
+							<input name="username" id="username" value="{whois.User_Cookie}" size="22" tabindex="1" type="text" />
137
+						</p>
138
+						<p>
139
+							<label for="email">
140
+								<small>E-mail:</small>
141
+							</label>
142
+							<input name="email" id="email" value="{whois.Email_Cookie}" size="22" tabindex="2" type="text" />
143
+						</p>
144
+						<p>
145
+							<label for="web">
146
+								<small>Website:</small>
147
+							</label>
148
+							<input name="web" id="web" value="{whois.Web_Cookie}" size="22" tabindex="3" type="text" />
149
+						</p>
150
+						<p>
151
+							<textarea name="content" id="content" cols="100" rows="10" tabindex="4"></textarea>
152
+						</p>
153
+						<p>
154
+							<span style="color: rgb(136, 136, 136); margin-bottom: 10px; font-size: 10px;">
155
+		                    	Some HTML allowed:<br />
156
+		                        &nbsp;&nbsp;&nbsp;&nbsp;
157
+		                        <code>
158
+		                            &lt;blockquote&gt; &lt;code&gt; &lt;em&gt; &lt;strong&gt; &lt;a&gt;
159
+		                        </code>
160
+		                	</span>
161
+		                </p>
162
+				  		<p>
163
+							<input type="submit" value="Add comment" name="btnAdd" id="btnAdd" tabindex="5" />
164
+						</p>
165
+						<p>
166
+							<input name="id_post" id="id_post" value="{id_post}" type="hidden" />
167
+							<input name="comment_date" id="comment_date" value="{Date_Added}" type="hidden" />
168
+						</p>
169
+					</form>
170
+				</div>
171
+			{/if}
168 172
 		{else}
169 173
 			{pagination}
170 174
 		{/if}