Skip to content

Commit

Permalink
# more template changes. added feed.php script.
Browse files Browse the repository at this point in the history
  • Loading branch information
brian committed Aug 8, 2006
1 parent 646564a commit 4908808
Show file tree
Hide file tree
Showing 44 changed files with 1,211 additions and 899 deletions.
14 changes: 10 additions & 4 deletions common.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
//right after loading the settings from the database
phorum_hook( "common_pre", "" );

include_once( "./include/cache.php" );
include_once( "./include/cache_memcached.php" );

// stick some stuff from the settings into the DATA member
$PHORUM["DATA"]["TITLE"] = ( isset( $PHORUM["title"] ) ) ? $PHORUM["title"] : "";
Expand Down Expand Up @@ -586,7 +586,7 @@ function phorum_get_url()
$page = "report";
$add_forum_id = true;
break;
case PHORUM_RSS_URL:
case PHORUM_FEED_URL:
switch(phorum_page){
case "list":
$add_forum_id = true;
Expand All @@ -597,7 +597,7 @@ function phorum_get_url()
array_push($argv, $thread_id);
break;
}
$page = "rss";
$page = "feed";
break;
// this is for adding own generic urls
case PHORUM_CUSTOM_URL:
Expand Down Expand Up @@ -737,7 +737,13 @@ function phorum_build_common_urls()
// RSS-Url only makes sense on a couple of pages
if(isset($PHORUM['use_rss']) && $PHORUM['use_rss']
&& (phorum_page=="index" || phorum_page=="list" || phorum_page=="read")){
$GLOBALS["PHORUM"]["DATA"]["URL"]["RSS"] = phorum_get_url( PHORUM_RSS_URL );
if($PHORUM["default_feed"]=="RSS"){
$GLOBALS["PHORUM"]["DATA"]["URL"]["FEED"] = phorum_get_url( PHORUM_FEED_URL, "type=rss" );
$GLOBALS["PHORUM"]["DATA"]["FEED"] = $PHORUM["DATA"]["LANG"]["RSS"];
} else {
$GLOBALS["PHORUM"]["DATA"]["URL"]["FEED"] = phorum_get_url( PHORUM_FEED_URL, "type=atom" );
$GLOBALS["PHORUM"]["DATA"]["FEED"] = $PHORUM["DATA"]["LANG"]["ATOM"];
}
}

$index_id=-1;
Expand Down
132 changes: 132 additions & 0 deletions feed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
<?php

////////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006 Phorum Development Team //
// http://www.phorum.org //
// //
// This program is free software. You can redistribute it and/or modify //
// it under the terms of either the current Phorum License (viewable at //
// phorum.org) or the Phorum License that was distributed with this file //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY, without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. //
// //
// You should have received a copy of the Phorum License //
// along with this program. //
// //
////////////////////////////////////////////////////////////////////////////////

define("phorum_page", "feed");

include_once("./common.php");
include_once("./include/format_functions.php");
include_once("./include/feed_functions.php");

// somehow we got to a folder
if(!empty($PHORUM["folder_flag"])){
exit();
}

// get forums this user can read if no forum_id passed
if(empty($PHORUM["forum_id"])){
$forums = phorum_db_get_forums();
} else {
// its cheap to copy this even though there is more than needed in it
$forums[$PHORUM["forum_id"]] = $PHORUM;
}

// checking read-permissions
if(empty($forums) || !phorum_check_read_common()) {
return;
}

// grab the data from cache if we can
// $cache = phorum_cache_get("feed", $_SERVER["REQUEST_URI"]);

if(!empty($cache)){

// extract the two members from cache
list($data, $content_type) = $cache;

} else {

// if it wasn't in cache, we need to make it

// init array
$messages = array();

// check if this is a thread subscription
$thread = (isset($PHORUM["args"][1])) ? (int)$PHORUM["args"][1] : 0;

// check if we are getting replies
$no_replies = (empty($PHORUM["args"]["replies"])) ? true : false;

// check the feed type
$feed_type = (empty($PHORUM["args"]["type"])) ? "rss" : $PHORUM["args"]["type"];

// generate list of forum ids to grab data for
$forum_ids = array_keys($forums);

// get messages
$messages = phorum_db_get_recent_messages(30, $forum_ids, $thread, $no_replies);

// remove users from messages array
unset($messages["users"]);

// run read hooks to get everything formatted
$messages = phorum_hook("read", $messages);
$messages = phorum_format_messages($messages);

// set up the feed specifics based on the info we are getting
if($thread && $PHORUM["forum_id"]){
$feed_url = phorum_get_url(PHORUM_FOREIGN_READ_URL, $PHORUM["forum_id"], $thread, $thread);
$feed_title = $message[$thread]["subject"];
$feed_description = strip_tags($message[$thread]["body"]);
} elseif($PHORUM["forum_id"]){
$feed_url = phorum_get_url(PHORUM_LIST_URL);
$feed_title = $PHORUM["DATA"]["TITLE"]." - ".$PHORUM["DATA"]["NAME"];
$feed_description = strip_tags($PHORUM["DATA"]["DESCRIPTION"]);
} else {
$feed_url = phorum_get_url(PHORUM_INDEX_URL);
$feed_name = $PHORUM["DATA"]["TITLE"];
$feed_description = (!empty($PHORUM["description"])) ? $PHORUM["description"] : "";
}


switch($feed_type) {

case "html":
$data = phorum_feed_make_html($messages, $forums, $feed_url, $feed_title, $feed_description);
$content_type = "text/html";
break;

case "js":
$data = phorum_feed_make_js($messages, $forums, $feed_url, $feed_title, $feed_description);
$content_type = "text/javascript";
break;

case "atom":
$data = phorum_feed_make_atom($messages, $forums, $feed_url, $feed_title, $feed_description);
$content_type = "application/xml";
break;

default:
$data = phorum_feed_make_rss($messages, $forums, $feed_url, $feed_title, $feed_description);
$content_type = "application/xml";
break;

}

// stick the xml in cache for 5 minutes for future use
phorum_cache_put("feed", $_SERVER["REQUEST_URI"], array($data, $content_type, 600));

}

// output the proper header and the data
header("Content-type: $content_type;");
echo $data;


?>
4 changes: 3 additions & 1 deletion include/admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,9 @@

$row=$frm->addrow( "Phorum Head Tags", $frm->textarea( "head_tags", $PHORUM["head_tags"], 30, 5, "style='width: 100%'" ) );

$row=$frm->addrow( "Show and allow RSS-links", $frm->select_tag( "use_rss", array( "No", "Yes" ), $PHORUM["use_rss"] ) );
$row=$frm->addrow( "Show and allow feed links", $frm->select_tag( "use_rss", array( "No", "Yes" ), $PHORUM["use_rss"] ) );

$row=$frm->addrow( "Default feed type", $frm->select_tag( "default_feed", array( "rss"=>"RSS", "atom"=>"Atom" ), $PHORUM["default_feed"] ) );

$frm->addbreak( "File/Path Settings" );

Expand Down
2 changes: 1 addition & 1 deletion include/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@
define("PHORUM_FOLLOW_ACTION_URL", $i++);
define("PHORUM_PREPOST_URL", $i++);
define("PHORUM_REPORT_URL", $i++);
define("PHORUM_RSS_URL", $i++);
define("PHORUM_FEED_URL", $i++);
define("PHORUM_CUSTOM_URL", $i++);
define("PHORUM_BASE_URL", $i++);

Expand Down
Loading

0 comments on commit 4908808

Please sign in to comment.