Monday, August 25, 2008

News Followed by date in Runcms

calender
<script>
var ns6=document.getElementById&&!document.all;
var ie4=document.all;

var Selected_Month;
var Selected_Year;
var Current_Date = new Date();
var compare_Date = new Date();
var Current_Month = Current_Date.getMonth();

var Days_in_Month = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
var Month_Label = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

var Current_Year = Current_Date.getYear();
if (Current_Year < 1000)
Current_Year+=1900;


var Today = Current_Date.getDate();

function Header(Year, Month) {

if (Month == 1) {
Days_in_Month[1] = ((Year % 400 == 0) || ((Year % 4 == 0) && (Year % 100 !=0))) ? 29 : 28;
}
var Header_String = Month_Label[Month] + ' ' + Year;
return Header_String;
}


function selectDate(mo, day, yr)
{
//alert(mo+day+yr);
date =yr;
if(mo < 10)
{
date += '0'+mo;
}
else
{
date += ''+mo;
}
if(day < 10)
{
date += '0'+day ;
}
else
{
date += ''+day ;
}
//alert(date);
window.location= '{X_SITEURL}/modules/news/day_archive.php?date='+date;

//return false;
}


function Make_Calendar(Year, Month) {
var First_Date = new Date(Year, Month, 1);
var Heading = Header(Year, Month);
var First_Day = First_Date.getDay() + 1;
if (((Days_in_Month[Month] == 31) && (First_Day >= 6)) ||
((Days_in_Month[Month] == 30) && (First_Day == 7))) {
var Rows = 6;
}
else if ((Days_in_Month[Month] == 28) && (First_Day == 1)) {
var Rows = 4;
}
else {
var Rows = 5;
}

var HTML_String = '<div align="left"><table border="1" id="table1" bordercolor="#7B9EBD" cellspacing="0" cellpadding="2"><tr><td align="center">';
HTML_String += '<table border="1" width="160" celpadding="0" cellspacing="0" bordercolorlight="#E0E0E0" bordercolordark="#E0E0E0"><tr>';
HTML_String += '<td width="18" align="right"><b><a style="cursor:hand" onClick="Skip(\'-\')">';
HTML_String += '<font face="Courier" size="2" color="#6C7EAA"><span style="text-decoration: none"><<</span></font></a></b></td>';
HTML_String += '<td width="110" align="center"><b><font face="Arial" size="2">'+ Heading +'</font></b></td>';
HTML_String += '<td width="4" align="left"><b><a style="cursor:hand" onClick="Skip(\'+\')"> <font face="Courier" size="2" color="#6C7EAA">';
HTML_String += '<span style="text-decoration: none">>></span></font></a></b></td></tr></table>';
HTML_String += '<table border="0" width="0" bordercolorlight="#C0C0C0" bordercolordark="#808080" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0">';
HTML_String += '<td width="100%"><table border="1" width="160" bordercolorlight="#E0E0E0" bordercolordark="#E0E0E0" style="border-collapse: collapse" bordercolor="#000000" cellpadding="0" cellspacing="0" bgcolor="#EEEEEE">';
HTML_String += '<tr><td width="20" align="center" nowrap bordercolor="#666666" bgcolor="#F7F9FB" bordercolorlight="#E0E0E0" bordercolordark="#E0E0E0">';
HTML_String += '<font color="#666666" face="Verdana" size="2">Su</font></td>';
HTML_String += '<td width="20" align="center" nowrap bordercolor="#666666" bgcolor="#F7F9FB" bordercolorlight="#E0E0E0" bordercolordark="#E0E0E0">';
HTML_String += '<font color="#666666" face="Verdana" size="2">Mo</font></td>';
HTML_String += '<td width="20" align="center" nowrap bordercolor="#666666" bgcolor="#F7F9FB" bordercolorlight="#E0E0E0" bordercolordark="#E0E0E0">';
HTML_String += '<font color="#666666" face="Verdana" size="2">Tu</font></td>';
HTML_String += '<td width="20" align="center" nowrap bordercolor="#666666" bgcolor="#F7F9FB" bordercolorlight="#E0E0E0" bordercolordark="#E0E0E0">';
HTML_String += '<font face="Verdana" size="2" color="#666666">We</font></td>';
HTML_String += '<td width="20" align="center" nowrap bordercolor="#666666" bgcolor="#F7F9FB" bordercolorlight="#E0E0E0" bordercolordark="#E0E0E0">';
HTML_String += '<font color="#666666" face="Verdana" size="2">Th</font></td>';
HTML_String += '<td width="20" align="center" nowrap bordercolor="#666666" bgcolor="#F7F9FB" bordercolorlight="#E0E0E0" bordercolordark="#E0E0E0">';
HTML_String += '<font color="#666666" face="Verdana" size="2">Fr</font></td>';
HTML_String += '<td width="20" align="center" nowrap bordercolor="#666666" bgcolor="#F7F9FB" bordercolorlight="#E0E0E0" bordercolordark="#E0E0E0">';
HTML_String += '<font color="#666666" face="Verdana" size="2">Sa</font></td></tr>';


var Day_Counter = 1;
var Loop_Counter = 1;
for (var j = 1; j <= Rows; j++) {
HTML_String += '<tr ALIGN="left" VALIGN="top">';
for (var i = 1; i < 8; i++) {
if ((Loop_Counter >= First_Day) && (Day_Counter <= Days_in_Month[Month])) {
//= new Date();
compare_Date.setDate(Day_Counter);
compare_Date.setMonth(Month );
compare_Date.setFullYear(Year );

if(Current_Date > compare_Date)
{
HTML_String += ' <td bgcolor ="#ffffff" width="10" align="center" height="10" valign="top">';
HTML_String += '<a href=javascript: onclick="selectDate(\''+(Month+1) +'\',\''+Day_Counter+'\',\''+Year+'\')" style="cursor:hand;text-decoration: none;">';
HTML_String += '<font color="003DB8" face="Verdana" size="2">' + Day_Counter + '</font></a></font></td>';


}
else
{
if((Day_Counter == Today) && (Year == Current_Year) && (Month == Current_Month))
{
//alert(Current_Date)
HTML_String += ' <td bgcolor ="#6C7EAA" width="10" align="center" height="10" valign="top">';
HTML_String += '<a href="#" onclick="selectDate(\''+(Month+1) +'\',\''+Day_Counter+'\',\''+Year+'\')" style="cursor:hand;text-decoration: none;">';
HTML_String += '<font color="#ffffff" face="Verdana" size="2">' + Day_Counter + '</font></a></font></td>';


}
else
{
HTML_String += '<td bgcolor ="#ffffff" width="10" align="center" height="10" valign="top"><font color="#808080" face="Verdana" size="2">' + Day_Counter + '</font></a></td>';
}
}
/*if ((Day_Counter == Today) && (Year == Current_Year) && (Month == Current_Month)) {

}
else {

}*/
Day_Counter++;
}
else {
HTML_String += '<td BORDERCOLOR="C0C0C0"> </td>';
}
Loop_Counter++;
}
HTML_String += '</tr>';
}
HTML_String += '</table></td></tr></table>';
cross_el=ns6? document.getElementById("Calendar") : document.all.Calendar;
cross_el.innerHTML = HTML_String;
}


function Check_Nums() {
if ((event.keyCode < 48) || (event.keyCode > 57)) {
return false;
}
}



function On_Year() {
var Year = document.when.year.value;
if (Year.length == 4) {
Selected_Month = document.when.month.selectedIndex;
Selected_Year = Year;
Make_Calendar(Selected_Year, Selected_Month);
}
}

function On_Month() {
var Year = document.when.year.value;
if (Year.length == 4) {
Selected_Month = document.when.month.selectedIndex;
Selected_Year = Year;
Make_Calendar(Selected_Year, Selected_Month);
}
else {
alert('Please enter a valid year.');
document.when.year.focus();
}
}


function Defaults() {
if (!ie4&&!ns6)
return
var Mid_Screen = Math.round(document.body.clientWidth / 2);
//document.when.month.selectedIndex = Current_Month;
//document.when.year.value = Current_Year;
Selected_Month = Current_Month;
Selected_Year = Current_Year;
Make_Calendar(Current_Year, Current_Month);
}


function Skip(Direction) {
if (Direction == '+') {
if (Selected_Month == 11) {
Selected_Month = 0;
Selected_Year++;
}
else {
Selected_Month++;
}
}
else {
if (Selected_Month == 0) {
Selected_Month = 11;
Selected_Year--;
}
else {
Selected_Month--;
}
}
Make_Calendar(Selected_Year, Selected_Month);
//document.when.month.selectedIndex = Selected_Month;
//document.when.year.value = Selected_Year;
}

function onload_activities()
{
Defaults();

}
window.onload = onload_activities;
/*Ends Calendar*/

</script>


<table id="table1" style="border-collapse: collapse;" width="154" border="1" bordercolor="#c0c0c0">
<tbody><tr>
<td valign="top">
<div id="Calendar" align="left">

</div></td>
</tr>
</tbody></table>
-----------------------------------------------------------------------------------
day_archive.php
<?
include_once("header.php");

$count = 0;

$lastyear = "0000";
$lastmonth = "00";

$date = $_REQUEST['date'];

$fromyear = (int)substr($date,0,4);
$frommonth = (int)substr($date,4,2);
$fromdate= (int)substr($date,6,2);
#echo $fromyear."/".$frommonth."/".$fromdate;

$current_title = _NW_NEWSARCHIVES;


if($fromyear)
{
$current_month = rc_cal_month_get_by_number($frommonth).", $fromyear";
$current_title = " $fromdate,$current_month : "._NW_NEWSARCHIVES;
}


$meta['title'] = "$current_title : ".$meta['title'];

include_once(XOOPS_ROOT_PATH."/header.php");
include_once(NEWS_ROOT."/class/class.newsstory.php");


$useroffset = "0";
if ($xoopsUser)
{
$timezone = $xoopsUser->timezone();
if (isset($timezone))
{
$useroffset = $xoopsUser->timezone();
}
else
{
$useroffset = $xoopsConfig['default_TZ'];
}
}

OpenTable();





echo "<style>#months li{ list-style-image: url(".get_module_url("images/size.gif").")}</style><h1>";

if($frommonth)
echo _NW_NEWSARCHIVES." $fromdate, $current_month";
else
echo _NW_NEWSARCHIVES;

echo "</h1>";
/*
$result=$db->query("SELECT published FROM ".NEWS_STORIES_TBL." WHERE published>0 AND published<=".time()." ORDER BY published DESC");
if (!$result)
{
echo $db->errno(). ": ".$db->error(). "<br />";
CloseTable();
include_once(XOOPS_ROOT_PATH."/footer.php");
exit();
}
else
{
echo "<ul id='months'>";
while (list($time) = $db->fetch_row($result))
{
$datetime[1] = date("Y", $time);
$datetime[2] = date("m", $time);
if (($lastyear != $datetime[1]) || ($lastmonth != $datetime[2]))
{
$lastyear = $datetime[1];
$lastmonth = $datetime[2];
echo "<li><a href='".news_url_archive($lastyear,$lastmonth)."'>".
rc_cal_month_get_by_number($lastmonth).", $lastyear</a></li>";
}
}
}

echo "</ul>";*/

if ($fromyear)
{
echo "<table border='0' cellspacing='1' cellpadding='2' width='100%' class='bg4'>";
echo "<tr><th>"._NW_TOPICC."</th><th>"._NW_ARTICLES."</th>
<th>"._NW_ACTIONS."</th>
<th>"._NW_VIEWS."</th>
<th>"._NW_COMMENTS."</th>
<th>"._NW_DATE."</th></tr>";

// must adjust the selected time to server timestamp
$timeoffset = $useroffset - $xoopsConfig['server_TZ'];
// $monthstart = mktime(0-$timeoffset,0,0,$frommonth,1,$fromyear);
// $monthend = mktime(23-$timeoffset,59,59,$frommonth+1,0,$fromyear);
// $monthend = ($monthend > time()) ? time() : $monthend;
$day_start= mktime (0 ,0,1, $frommonth ,$fromdate ,$fromyear );
$day_end=mktime (23 ,59,59, $frommonth ,$fromdate ,$fromyear );

$sql = "SELECT a.*, b.topic_id, b.topic_title FROM ".NEWS_STORIES_TBL." a LEFT JOIN ".NEWS_TOPICS_TBL." b
ON a.topicid =b.topic_id WHERE a.published > $day_start and a.published < $day_end ORDER by a.published DESC";
//echo $sql;
$result = $db->query($sql);

$bg = "bg2";

while ($myrow = $db->fetch_array($result))
{
$article = new NewsStory($myrow);
$printP = "<a href='".get_module_url("print.php?storyid=".$article->storyid())."' target='_blank'><img
src='".get_module_url("images/print.gif")."' border='0' alt='"._NW_PRINTERFRIENDLY."' width='15' height='11' /></a> ";

$sendF = "<a target='_top' href='mailto:?subject=".rawurlencode(sprintf(_NW_INTARTICLE, $meta['title']))."&body=".
rawurlencode(sprintf(_NW_INTARTFOUND, $meta['title'])).":\r\n".$article->get_url()."'><img src='".get_module_url("images/friend.gif")."' border='0' alt='"._NW_SENDSTORY."' width='15' height='11' /></a>";

$bg = ( ($bg=="bg2") ? "bg1": "bg2");

echo "<tr class='$bg'><td>".$article->textlink()."</td><td>".$article->show_title()."</td>
<td class='center'>$printP $sendF</td>
<td class='center'><small>".$article->counter()."</small></td>
<td class='center'><small>".(int)$myrow['comments']."</small></td>
<td><small>".formatTimestamp($article->published(), "s", $useroffset)."</small></td>
</tr>";
$count ++;
}
echo "</table><small>";
printf(_NW_THEREAREINTOTAL, $count);
echo "</small>";
}

CloseTable();
include_once(XOOPS_ROOT_PATH."/footer.php");




function news_url_archive($y,$m)
{
global $newsConfig;
return ($newsConfig['mod_rewrite']) ? "archive$y$m.html" : "archive.php?date=$y$m";
}
?>

how to add fav icon for your website

<link type="image/x-icon" href="url-to-favicon.ico" rel="shortcut icon"/>
<link type="image/x-icon" href="url-to-favicon.ico" rel="icon"/>

Sunday, August 17, 2008

latest 10 news article in runcms

----function defenition---
function b_t()
{
global $db, $myts;

include_once(XOOPS_ROOT_PATH."/modules/news/cfg.php");

$block = array();


// $result = $db->query("SELECT storyid, title FROM ".$db->prefix("stories")." WHERE (published > ".$tdate." AND published < ".time().") ORDER BY counter DESC", 1, 0);
$result = $db->query("SELECT `storyid`, `title` FROM ".$db->prefix("stories")." WHERE `published`!=0 order by `storyid` desc LIMIT 10");
$block['content']="<ol>";
while( $arr=$db->fetch_array($result))
{
$block['content'].="<li><a href='".news_url_story($arr["storyid"])."'>". $arr["title"]."</a></li>";
}
$block['content'].= "</ol>";
$block['title'] = _MB_NEWS_TITLE10;

//$block['content'] = news_url_story($id, $title="", 0);
/* $block['content']="<ol>";
foreach($arr as $ar)
{
$block['content'].="<li>".$ar["storyid"]."</li>";
}
$block['content'].= "</ol>";*/


return $block;
}
--xoops version.php
$modversion['blocks']["some_no"]['file'] = 'file_name.php';
$modversion['blocks']["some_no"]['name'] = _MI_NEWS_BNAME10;
$modversion['blocks']["some_no"]['description'] = 'Shows news topics';
$modversion['blocks']["some_no"]['show_func'] = 'b_t';

Sunday, August 10, 2008

add a simple page in runcms

include_once("./mainfile.php");
include_once(XOOPS_ROOT_PATH."/header.php");
-- Contents -----
include_once("footer.php");