ramazan34
07-08-2007, 18:32:04
http://img186.imageshack.us/img186/2830/eqeqwfz4.jpg (http://imageshack.us)
arkadaşlar bu modülü kullanmak istiyorum ama 23Gün Sonra ile 96Yaşında birleşik.. Bunların 23 Gün Sonra ve 96 Yaşında olarak gözükmesini istiyorum.. kodlardan nasıl yapabiliriz?
Bunlarda modülün .php kodları
<?
//
// Package: CbBirthday 1.1
//
// Copyright (C) 2006 Erik Happaerts
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// 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. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// The "GNU General Public License" (GPL) is available at
// http://www.gnu.org/copyleft/gpl.html.
//
// CbBirthday is free software and parts of it are derived from
// GNU GPL Birthday Reminder (copyright 2004 Helge Brauer)
//
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
global $database;
// System vars
$birthday_table='comprofiler';
$birthday_userid='user_id';
// User vars
$params = mosParseParams( $module->params );
$birthday_field=$params->Field;
$maxbirthdays=$params->Number;
$lang_days=$params->Days;
$lang_year=$params->Year;
$lang_today='<b>'.$params->Today.'</b>';
$daysleft=$params->DaysLeft;
$image=$params->Image;
$displayimage=$params->DisplayImage;
$name=$params->Name;
// Load list of birthdays
$thenextbirthdays=new birthday_list($database,$maxbirthdays,$birthday_fi eld,$birthday_table,$birthday_userid,$daysleft,$na me);
// Create HTML overview of birthdays
$content.=$thenextbirthdays->createHTMLlist($lang_days,$lang_today,$lang_year,$ image,$displayimage,$name);
// CLASSES
// Birthday list
class birthday_list {
var $birthdayArray=null;
function birthday_list($database,$maxbirth,$birthday_field, $birthday_table,$birthday_userid,$daysleft,$name){//constructor
$time_now = time() + (60 * 60 * $mosConfig_offset_user);
$year_now = date(Y,$time_now);
$month_now = date(n,$time_now);
$day_now = date(j,$time_now);
$date_now = "$year_now-$month_now-$day_now";
$query = "SELECT #__users.id,username,name,$birthday_field AS day,(DAYOFYEAR( CONCAT($year_now,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field)) ) - DAYOFYEAR('$date_now')) AS diff FROM #__users "
. "\nLEFT JOIN #__$birthday_table ON #__users.id=#__$birthday_table.$birthday_userid "
. "\nWHERE (DAYOFYEAR(CONCAT($year_now,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field))) > DAYOFYEAR('$date_now')-1)"
.($daysleft ? " AND (DAYOFYEAR( CONCAT($year_now,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field)) ) - DAYOFYEAR('$date_now'))<=$daysleft" : "")
." ORDER BY diff ASC LIMIT $maxbirth";
//echo $query."<br />\n";
$database->setQuery( $query );
$rows = $database->loadObjectList();
$i=0;
foreach ($rows as $row){
if($name==0) {
$this->birthdayArray[$i]=new birthday($row->username,$row->day,$row->id);
} else {
$this->birthdayArray[$i]=new birthday($row->name,$row->day,$row->id);
}
$test=$this->birthdayArray[$i];
$i++;
}
if ($i<$maxbirth){
//when the birthday list isn't full, check wether there are some birthsdays in the nex year
$newlimit=$maxbirth-$i;
$query = "SELECT #__users.id,username,name,$birthday_field AS day,(DAYOFYEAR( CONCAT($year_now+1,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field)) ) + DAYOFYEAR(CONCAT($year_now,'-12-31')) - DAYOFYEAR('$date_now')) AS diff FROM #__users "
. "\nLEFT JOIN #__$birthday_table ON #__users.id=#__$birthday_table.$birthday_userid "
. "\nWHERE (DAYOFYEAR(CONCAT($year_now,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field))) > DAYOFYEAR(CONCAT($year_now+1,'-1-1'))-1)"
.($daysleft ? " AND (DAYOFYEAR( CONCAT($year_now+1,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field)) ) + DAYOFYEAR(CONCAT($year_now,'-12-31')) - DAYOFYEAR('$date_now'))<=$daysleft" : "")
." ORDER BY diff ASC LIMIT $newlimit";
//echo $query."<br />\n";
// initialise the query in the $database connector
// this translates the '#__' prefix into the real database prefix
$database->setQuery( $query );
// retrieve the list of returned records as an array of objects
$rows = $database->loadObjectList();
foreach ($rows as $row){
$existe = false;
for ($j=0; $j<$i; $j++)
if ($this->birthdayArray[$j]->u_name == $row->username)
$existe = true;
if (!$existe) {
$this->birthdayArray[$i]=new birthday($row->username,$row->day,$row->id);
$test=$this->birthdayArray[$i];
$i++;
}
}
}
}
function createHTMLlist($l_days,$l_today,$l_year,$image, $displayimage){
echo "<table cellspacing=0 cellpadding=0 width=\"100%\">";
$i=0;
while($this->birthdayArray[$i]) {
$birthdaypointer=$this->birthdayArray[$i];
if($birthdaypointer->birthday_is_today) {
if($displayimage == 1) {
echo "<tr><td colspan=\"3\" align=\"center\"><img src=\"modules/$image\" alt=\"Image for $birthdaypointer->u_name\" border=\"0\" /></td></tr>";
}
}
echo "<tr><td align=\"right\">".$birthdaypointer->daysleft($l_days,$l_today)."</td><td> - </td><td><a href=\"index.php?option=com_comprofiler&task=userProfile&user=".$birthdaypointer->u_id."\">";
echo $birthdaypointer->u_name;
echo "</a> (".$birthdaypointer->age().$l_year.")</td></tr>";
$i++;
}
echo "</table>";
}
}
//birthday class: each birthday has is an object
class birthday{
var $u_name=null;
var $u_id=null;
var $day=null;
var $DOBArray=null;
var $day_timestamp=null;
var $birthday_is_today=null;
var $TodayDay=null;
var $TodayMonth=null;
var $TodayYear=null;
var $now_timestamp=null;
function birthday($name,$theday,$id){//constructor
$this->u_name=$name;
$this->u_id=$id;
$this->day=$theday;
// $day is in YYYY-MM-DD format
//explode $day to an array for easy processing.
$this->DOBArray = explode("-", $this->day);
$this->TodayDay=date("d");
$this->TodayMonth=date("m");
$this->TodayYear=date("Y");
if($this->DOBArray[0]-1>$this->TodayYear) {
$this->DOBArray[0]=$this->DOBArray[0]-100;
}
$this->now_timestamp=time();
$this->day_timestamp=mktime(0, 0, 0, $this->DOBArray[1], $this->DOBArray[2], $this->TodayYear); //this years birthday
$this->day_timestamp_nextyear=mktime(0, 0, 0, $this->DOBArray[1], $this->DOBArray[2], $this->TodayYear+1); //this years birthday
$this->daysleft();
}
function daysleft($l_days='Tagen',$l_today='heute'){
if (($this->TodayMonth < $this->DOBArray[1]) || (($this->TodayMonth == $this->DOBArray[1]) && ($this->TodayDay < $this->DOBArray[2]))) {
$Xdays=ceil(($this->day_timestamp-$this->now_timestamp)/(3600*24));
return $Xdays.$l_days;
} else {
if((($this->TodayMonth == $this->DOBArray[1]) && ($this->TodayDay == $this->DOBArray[2]))) {
$this->birthday_is_today=1;
return ' '.$l_today;
} else {
//birthday in next year
$Xdays=ceil(($this->day_timestamp_nextyear-$this->now_timestamp)/(3600*24));
return $Xdays.$l_days;
}
}
}
function age() {
// The logic
if ( ($this->TodayMonth>$this->DOBArray[1]) || (($this->TodayMonth==$this->DOBArray[1])&&($this->TodayDay>$this->DOBArray[2])) ) {
$Age = $this->TodayYear - $this->DOBArray[0]+1;
} else {
//age next year
$Age = $this->TodayYear - $this->DOBArray[0];
}
// return the age
return $Age;
}
}
?>
arkadaşlar bu modülü kullanmak istiyorum ama 23Gün Sonra ile 96Yaşında birleşik.. Bunların 23 Gün Sonra ve 96 Yaşında olarak gözükmesini istiyorum.. kodlardan nasıl yapabiliriz?
Bunlarda modülün .php kodları
<?
//
// Package: CbBirthday 1.1
//
// Copyright (C) 2006 Erik Happaerts
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// 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. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// The "GNU General Public License" (GPL) is available at
// http://www.gnu.org/copyleft/gpl.html.
//
// CbBirthday is free software and parts of it are derived from
// GNU GPL Birthday Reminder (copyright 2004 Helge Brauer)
//
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );
global $database;
// System vars
$birthday_table='comprofiler';
$birthday_userid='user_id';
// User vars
$params = mosParseParams( $module->params );
$birthday_field=$params->Field;
$maxbirthdays=$params->Number;
$lang_days=$params->Days;
$lang_year=$params->Year;
$lang_today='<b>'.$params->Today.'</b>';
$daysleft=$params->DaysLeft;
$image=$params->Image;
$displayimage=$params->DisplayImage;
$name=$params->Name;
// Load list of birthdays
$thenextbirthdays=new birthday_list($database,$maxbirthdays,$birthday_fi eld,$birthday_table,$birthday_userid,$daysleft,$na me);
// Create HTML overview of birthdays
$content.=$thenextbirthdays->createHTMLlist($lang_days,$lang_today,$lang_year,$ image,$displayimage,$name);
// CLASSES
// Birthday list
class birthday_list {
var $birthdayArray=null;
function birthday_list($database,$maxbirth,$birthday_field, $birthday_table,$birthday_userid,$daysleft,$name){//constructor
$time_now = time() + (60 * 60 * $mosConfig_offset_user);
$year_now = date(Y,$time_now);
$month_now = date(n,$time_now);
$day_now = date(j,$time_now);
$date_now = "$year_now-$month_now-$day_now";
$query = "SELECT #__users.id,username,name,$birthday_field AS day,(DAYOFYEAR( CONCAT($year_now,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field)) ) - DAYOFYEAR('$date_now')) AS diff FROM #__users "
. "\nLEFT JOIN #__$birthday_table ON #__users.id=#__$birthday_table.$birthday_userid "
. "\nWHERE (DAYOFYEAR(CONCAT($year_now,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field))) > DAYOFYEAR('$date_now')-1)"
.($daysleft ? " AND (DAYOFYEAR( CONCAT($year_now,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field)) ) - DAYOFYEAR('$date_now'))<=$daysleft" : "")
." ORDER BY diff ASC LIMIT $maxbirth";
//echo $query."<br />\n";
$database->setQuery( $query );
$rows = $database->loadObjectList();
$i=0;
foreach ($rows as $row){
if($name==0) {
$this->birthdayArray[$i]=new birthday($row->username,$row->day,$row->id);
} else {
$this->birthdayArray[$i]=new birthday($row->name,$row->day,$row->id);
}
$test=$this->birthdayArray[$i];
$i++;
}
if ($i<$maxbirth){
//when the birthday list isn't full, check wether there are some birthsdays in the nex year
$newlimit=$maxbirth-$i;
$query = "SELECT #__users.id,username,name,$birthday_field AS day,(DAYOFYEAR( CONCAT($year_now+1,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field)) ) + DAYOFYEAR(CONCAT($year_now,'-12-31')) - DAYOFYEAR('$date_now')) AS diff FROM #__users "
. "\nLEFT JOIN #__$birthday_table ON #__users.id=#__$birthday_table.$birthday_userid "
. "\nWHERE (DAYOFYEAR(CONCAT($year_now,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field))) > DAYOFYEAR(CONCAT($year_now+1,'-1-1'))-1)"
.($daysleft ? " AND (DAYOFYEAR( CONCAT($year_now+1,'-',MONTH($birthday_field),'-',DAYOFMONTH($birthday_field)) ) + DAYOFYEAR(CONCAT($year_now,'-12-31')) - DAYOFYEAR('$date_now'))<=$daysleft" : "")
." ORDER BY diff ASC LIMIT $newlimit";
//echo $query."<br />\n";
// initialise the query in the $database connector
// this translates the '#__' prefix into the real database prefix
$database->setQuery( $query );
// retrieve the list of returned records as an array of objects
$rows = $database->loadObjectList();
foreach ($rows as $row){
$existe = false;
for ($j=0; $j<$i; $j++)
if ($this->birthdayArray[$j]->u_name == $row->username)
$existe = true;
if (!$existe) {
$this->birthdayArray[$i]=new birthday($row->username,$row->day,$row->id);
$test=$this->birthdayArray[$i];
$i++;
}
}
}
}
function createHTMLlist($l_days,$l_today,$l_year,$image, $displayimage){
echo "<table cellspacing=0 cellpadding=0 width=\"100%\">";
$i=0;
while($this->birthdayArray[$i]) {
$birthdaypointer=$this->birthdayArray[$i];
if($birthdaypointer->birthday_is_today) {
if($displayimage == 1) {
echo "<tr><td colspan=\"3\" align=\"center\"><img src=\"modules/$image\" alt=\"Image for $birthdaypointer->u_name\" border=\"0\" /></td></tr>";
}
}
echo "<tr><td align=\"right\">".$birthdaypointer->daysleft($l_days,$l_today)."</td><td> - </td><td><a href=\"index.php?option=com_comprofiler&task=userProfile&user=".$birthdaypointer->u_id."\">";
echo $birthdaypointer->u_name;
echo "</a> (".$birthdaypointer->age().$l_year.")</td></tr>";
$i++;
}
echo "</table>";
}
}
//birthday class: each birthday has is an object
class birthday{
var $u_name=null;
var $u_id=null;
var $day=null;
var $DOBArray=null;
var $day_timestamp=null;
var $birthday_is_today=null;
var $TodayDay=null;
var $TodayMonth=null;
var $TodayYear=null;
var $now_timestamp=null;
function birthday($name,$theday,$id){//constructor
$this->u_name=$name;
$this->u_id=$id;
$this->day=$theday;
// $day is in YYYY-MM-DD format
//explode $day to an array for easy processing.
$this->DOBArray = explode("-", $this->day);
$this->TodayDay=date("d");
$this->TodayMonth=date("m");
$this->TodayYear=date("Y");
if($this->DOBArray[0]-1>$this->TodayYear) {
$this->DOBArray[0]=$this->DOBArray[0]-100;
}
$this->now_timestamp=time();
$this->day_timestamp=mktime(0, 0, 0, $this->DOBArray[1], $this->DOBArray[2], $this->TodayYear); //this years birthday
$this->day_timestamp_nextyear=mktime(0, 0, 0, $this->DOBArray[1], $this->DOBArray[2], $this->TodayYear+1); //this years birthday
$this->daysleft();
}
function daysleft($l_days='Tagen',$l_today='heute'){
if (($this->TodayMonth < $this->DOBArray[1]) || (($this->TodayMonth == $this->DOBArray[1]) && ($this->TodayDay < $this->DOBArray[2]))) {
$Xdays=ceil(($this->day_timestamp-$this->now_timestamp)/(3600*24));
return $Xdays.$l_days;
} else {
if((($this->TodayMonth == $this->DOBArray[1]) && ($this->TodayDay == $this->DOBArray[2]))) {
$this->birthday_is_today=1;
return ' '.$l_today;
} else {
//birthday in next year
$Xdays=ceil(($this->day_timestamp_nextyear-$this->now_timestamp)/(3600*24));
return $Xdays.$l_days;
}
}
}
function age() {
// The logic
if ( ($this->TodayMonth>$this->DOBArray[1]) || (($this->TodayMonth==$this->DOBArray[1])&&($this->TodayDay>$this->DOBArray[2])) ) {
$Age = $this->TodayYear - $this->DOBArray[0]+1;
} else {
//age next year
$Age = $this->TodayYear - $this->DOBArray[0];
}
// return the age
return $Age;
}
}
?>