[Mvblog-commits] r729 - trunk/common
mvblog-commits at lists.three-dimensional.net
mvblog-commits at lists.three-dimensional.net
Sun Dec 23 12:26:17 CET 2007
Author: michiel
Date: 2007-12-23 12:26:17 +0100 (Sun, 23 Dec 2007)
New Revision: 729
Modified:
trunk/common/mvblog.php
Log:
make category name/icon on posts a link to the category archive.
Also show category icon when viewing a specific post.
Closes #175
Modified: trunk/common/mvblog.php
===================================================================
--- trunk/common/mvblog.php 2007-12-09 18:00:11 UTC (rev 728)
+++ trunk/common/mvblog.php 2007-12-23 11:26:17 UTC (rev 729)
@@ -193,13 +193,24 @@
*/
public function get_articles($start, $limit, $archive=0, $dossier=0) {
// FB: 20070304: Check key and set a default if not set.
- if (array_key_exists("top", $_REQUEST)) {
+ if (array_key_exists("top", $_REQUEST))
$top = $_REQUEST["top"];
- }
- if (!isset($top) || empty($top)) {
+
+ if (!isset($top) || empty($top))
$top = 1;
- }
+ //article url base
+ if ($this->settings["cleanurl"])
+ $link = "post/%d#READMORE";
+ else
+ $link = "index.php?action=view&id=%d#READMORE";
+
+ //category url base
+ if ($this->settings["cleanurl"])
+ $catlink = "category/%d";
+ else
+ $catlink = "index.php?action=archive_cat&c=%d";
+
$start = $top-1;
$max_time = mktime(0, 0, 0, date("m"), date("d")+1, date("Y"));
@@ -233,21 +244,15 @@
<div class="log_post">
<?php if ($row["aside"] !=1) { ?>
<div class="log_post_head">
- <?php
- if ($this->settings["cleanurl"])
- $link = "post/".$row["id"]."#READMORE";
- else
- $link = "index.php?action=view&id=".$row["id"]."#READMORE";
- ?>
- <h1 class="log_post_h1"><a href="<?php echo $link; ?>"><?php echo htmlspecialchars(stripslashes($row["title"])); ?></a></h1>
+ <h1 class="log_post_h1"><a href="<?php echo sprintf($link, $row["id"]); ?>"><?php echo htmlspecialchars(stripslashes($row["title"])); ?></a></h1>
<h2 class="log_post_h2"><?php echo gettext("category"); ?>:
<?php
$categories = explode(",", $row["categories_ids"]);
foreach ($categories as $v) {
if (array_key_exists($v, $this->categories) && $this->categories[$v]["icon"] && $this->settings["show_cat_icons"])
- echo "<img src=\"images/categories/".$this->categories[$v]["icon"]."\" title=\"".htmlspecialchars($this->categories[$v]["name"])."\" alt=\"".htmlspecialchars($this->categories[$v]["name"])."\" class=\"category_icon\" /> ";
+ echo "<a href=\"".sprintf($catlink, $v)."\"><img src=\"images/categories/".$this->categories[$v]["icon"]."\" title=\"".htmlspecialchars($this->categories[$v]["name"])."\" alt=\"".htmlspecialchars($this->categories[$v]["name"])."\" class=\"category_icon\" /></a> ";
elseif (array_key_exists($v, $this->categories))
- echo htmlspecialchars($this->categories[$v]["name"])." ";
+ echo "<a href=\"".sprintf($catlink, $v)."\">".htmlspecialchars($this->categories[$v]["name"])."</a> ";
}
?>
</h2>
@@ -362,6 +367,12 @@
* @param int $captcha_error if 1 it shows an error
*/
public function show_article($id, $captcha_error = 0) {
+ //category url base
+ if ($this->settings["cleanurl"])
+ $catlink = "category/%d";
+ else
+ $catlink = "index.php?action=archive_cat&c=%d";
+
if ($id == "httperror") {
$row = array(
"title" => $_REQUEST["error"],
@@ -376,6 +387,7 @@
);
$errormode = 1;
} else {
+
$res =& $this->db->query(sprintf("SELECT * FROM articles WHERE id = %d", $id));
if (PEAR::isError($res))
@@ -403,8 +415,10 @@
<?php
$categories = explode(",", $row["categories_ids"]);
foreach ($categories as $v) {
- if (array_key_exists($v, $this->categories))
- echo htmlspecialchars($this->categories[$v]["name"])." ";
+ if (array_key_exists($v, $this->categories) && $this->categories[$v]["icon"] && $this->settings["show_cat_icons"])
+ echo "<a href=\"".sprintf($catlink, $v)."\"><img src=\"images/categories/".$this->categories[$v]["icon"]."\" title=\"".htmlspecialchars($this->categories[$v]["name"])."\" alt=\"".htmlspecialchars($this->categories[$v]["name"])."\" class=\"category_icon\" /></a> ";
+ elseif (array_key_exists($v, $this->categories))
+ echo "<a href=\"".sprintf($catlink, $v)."\">".htmlspecialchars($this->categories[$v]["name"])."</a> ";
}
?>
</h2>
More information about the Mvblog-commits
mailing list