Skip to content
Browse files

-Added the ability to 'bump' a news post, so that it jumps to the

 beginning of the list
  • Loading branch information...
1 parent d33dd83 commit d890eb1839d292bf30cd45b074abb2e5cd6c4af9 @Finalfantasykid committed Apr 16, 2012
Showing with 21 additions and 4 deletions.
  1. +18 −2 PenguinCMS/NewsPost.php
  2. +2 −2 PenguinCMS/Page.php
  3. +1 −0 PenguinCMS/install/install.php
View
20 PenguinCMS/NewsPost.php
@@ -14,6 +14,7 @@ class NewsPost{
var $files;
var $filesRows;
var $comments;
+ var $bump;
function NewsPost($row, $isMore){
global $parser, $me, $db, $out;
@@ -34,6 +35,7 @@ function NewsPost($row, $isMore){
WHERE `c_n_id` = '{$this->id}'";
$rows2 = $db->execSQL($sql);
$this->comments = $rows2[0]['count'];
+ $this->bump = $row['bump'];
if ($row['more'] == ""){
$this->more = "";
}
@@ -81,7 +83,9 @@ function insertPost(){
$files[] = $_POST["media_id$i"];
$i++;
}
- $sql = "INSERT INTO `news` (`title`,`name`,`date`,`image`,`text`,`more`,`files`) VALUES('{$parser->stripHTML($_POST['title'])}','{$parser->stripHTML($_POST['name'])}','{$date}','{$_POST['image']}','{$parser->stripHTML($_POST['text'])}','{$parser->stripHTML($_POST['more'])}','".serialize($files)."')";
+
+ $sql = "INSERT INTO `news` (`title`,`name`,`date`,`image`,`text`,`more`,`files`,`bump`) VALUES('{$parser->stripHTML($_POST['title'])}','{$parser->stripHTML($_POST['name'])}','{$date}','{$_POST['image']}','{$parser->stripHTML($_POST['text'])}','{$parser->stripHTML($_POST['more'])}','".serialize($files)."',CURRENT_TIMESTAMP)";
+
$status = $db->execUpdate($sql);
$hooks->processHook(HOOK_AFTER_NEWS_INSERT, array(&$status, &$this));
return $status;
@@ -93,6 +97,10 @@ function updatePost(){
$text = $parser->stripHTML($_POST['text']);
$more = $parser->stripHTML($_POST['more']);
$icon = $_POST['image'];
+ $bump = "'{$this->bump}'";
+ if(isset($_POST['bump'])){
+ $bump = "CURRENT_TIMESTAMP";
+ }
$files = $this->filesRows;
@@ -123,8 +131,10 @@ function updatePost(){
`image` = '$icon',
`text` = '$text',
`more` = '$more',
- `files` = '".serialize($files)."'
+ `files` = '".serialize($files)."',
+ `bump` = {$bump}
WHERE `id` = '{$this->id}'";
+
$status = $db->execUpdate($sql);
$hooks->processHook(HOOK_AFTER_NEWS_UPDATE, array(&$status, &$this));
return $status;
@@ -325,6 +335,11 @@ function removeImage(){
$upload .= "<tr id='i1'><td>Image 1:</td><td><input type='file' name='file1' /></td><td>Image Name:<input type='text' name='fname1' /></td></tr>";
$upload .= "</fieldset></td></tr>";
$upload .= "</table><br /><a class='button' href='javascript:addImage()'>Add Image</a> <a class='button' href='javascript:removeImage()'>Remove Image</a></div><br />";
+
+ $bump = "";
+ if(isset($_GET['edit'])){
+ $bump = "<p class='news_info'><label style='vertical-align:25%;'>Bump?</label><input type='checkbox' name='bump' /></p>";
+ }
$ret =
"<form method='post' action='$action' enctype='multipart/form-data'><div class='block'>
<div class='news_block_icon'>
@@ -337,6 +352,7 @@ function removeImage(){
<label>Date:</label> {$this->date}<br />
<label>Updated By:</label> {$this->reporter}
</p>
+$bump
<label>Icon:</label> <select onchange='document[\"icon\"].src = \"images/icons/\" + options[selectedIndex].value + \".png\";' style='margin-top:2px;' name='image'>";
foreach($icons as $icon){
$selected = "";
View
4 PenguinCMS/Page.php
@@ -41,7 +41,7 @@ function generateHTML(){
FROM `news` n, `news_icons` i
WHERE n.deleted != 'deleted'
AND n.image = i.image
- ORDER BY n.id DESC
+ ORDER BY n.bump DESC, n.id DESC
LIMIT $id, 10";
}
else{
@@ -51,7 +51,7 @@ function generateHTML(){
WHERE n.deleted != 'deleted'
AND n.image = i.image
AND i.name IN ('".implode("','", $activeCategories)."')
- ORDER BY n.id DESC
+ ORDER BY n.bump DESC, n.id DESC
LIMIT $id, 10";
}
$rows = $db->execSQL($sql);
View
1 PenguinCMS/install/install.php
@@ -155,6 +155,7 @@ function showNext(){
`more` longtext NOT NULL,
`comments` int(11) NOT NULL DEFAULT '0',
`files` text NOT NULL,
+ `bump` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`deleted` varchar(32) NOT NULL DEFAULT 'active',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1");

0 comments on commit d890eb1

Please sign in to comment.
Something went wrong with that request. Please try again.