Bywalec
Postów: 915 Pomógł: 41
Data rejestracji: 12.03.2006 07:28
|
przyblize jak by mialo wygladac przykladowe rozwiazanie wlodka (pozniej podaje wlasne)
tworzymy pierwsza linie z wykozystaniem funkcji array() a w niej umieszczamy kolejno w nawiasach po przecinku liczby miesiaca czyli (podam przyklad na 6 miesiacach) $miesiac_w_cyfrach = array("01", "02", "03", "04", "05", "06");
teraz kolejna linijka powinna zawierac nazwy miesiecy (wszystko podobnie jak w linijce powyzej tylko ze nie wpisujemy liczby a nazwy miesiaca) $miesiac_w_nazwach = array("styczen", "luty", "marzec", "kwiecien", "maj", "czerwiec");
no i spoks teraz potrzebyjemy zamienic nasza date a robimy to tak $czas_do zamiany = "tu wpisujemy funkcje tworzaca nam czas ( w tym przypadku podawany w formie od 01 do 12";
$czas_do zamiany = str_replace($miesiac_w_cyfrach, $miesiac_w_nazwach, $czas_do zamiany);
no i tak by wygladalo zastosowanie array i str_replace ale po co jak mozna w pliku zmienic funkcje ktora to generuje nam te nazy mieciecy....
TERAZ PODAM MOJE ROZWIAZANIE
wejdz w plik news_archiwe.php i usun calosc zaraz po tym wklej tam ten kod (pogrubieniem zaznaczylem zmiany w kodzie)<?
/*--------------------------------------------+
| PHP-Fusion 6 - Content Management System |
|---------------------------------------------|
| author: Nick Jones (Digitanium) © 2002-2005 |
| web: http://www.php-fusion.co.uk |
| email: |
|---------------------------------------------|
| Released under the terms and conditions of |
| the GNU General Public License (Version 2) |
+--------------------------------------------*/
include "../../maincore.php";
include BASEDIR."subheader.php";
include BASEDIR."side_left.php";
if (file_exists(INFUSIONS."news_archive/locale/".$settings['locale'].".php")) {
include INFUSIONS."news_archive/locale/".$settings['locale'].".php";
} else {
include INFUSIONS."news_archive/locale/English.php";
}
$nas = dbarray(dbquery("SELECT * FROM ".DB_PREFIX."nas"));
$newsorder = $nas[news_order];
$numofnews = $nas[numofnews];
if ($nas[listexp] == 1){
$listexp = "AND (news_end='0'||news_end>=".time().")";
} else {
$listexp = "";
}
function listnews($var){
global $rows, $fusion_prefix, $rowstart, $listexp, $numofnews, $year, $month, $day, $PHP_SELF;
if ($rows !=0) {
echo "<br /><table align='center' cellspacing='0' cellpadding='0' border='0' width='100%' class='tbl-border'>
<tr>
<td>";
echo "<table align='center' cellpadding='0' cellspacing='1' width='100%' border='0'>";
echo "<tr><td align='center' width='50%' class='tbl2'><b>".$locale['NA_011']."</b></td><td align='center' class='tbl2'><b>".$locale['NA_012']."</b></td>
<td align='center' class='tbl2'><b>".$locale['NA_013']."</b></td><td align='center' class='tbl2'><b>".$locale['NA_002']."</b></td></tr>";
for ($i=$rowstart;$var[$i];$i++) {
$result2 = dbquery(
"SELECT tn.*, tu.user_id,user_name
FROM ".DB_PREFIX."news tn
LEFT JOIN ".DB_PREFIX."users tu ON tn.news_name=tu.user_id
WHERE news_id=$var[$i] AND (news_start='0'||news_start<=".time().") $listexp
GROUP BY news_id ORDER BY news_datestamp ASC"
);
$data = dbarray($result2);
echo "<tr><td align='left' width='50%' class='tbl1'><a href='".BASEDIR."news.php?readmore=$var[$i]'>".$data['news_subject']."</a></td>
<td align='center' class='tbl2'><a href='".BASEDIR."profile.php?lookup=".$data['user_id']."'>".$data['user_name']."</a></td>
<td align='center' class='tbl1'>".date('d.m.Y', $data[news_datestamp])."</td>
<td align='center' class='tbl2'>".$data['news_reads']."</td></tr>";
if ($i == $rowstart + ($numofnews - 1)) {
break;
}
}
echo "</table></td></tr></table>";
} else {
echo "<center><br />".$locale['NA_014']."<br /><br /></center>\n";
}
}
opentable($locale['NA_001']);
$splityears = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp ASC");
if (dbrows($result)!=0) {
while ($date = dbarray($result)){
$allyears = date('Y', $date[news_datestamp]);
array_push($splityears, $allyears);
}
$yearsnum = array_count_values($splityears);
$years = array_unique($splityears);
$years = array_merge($years);
echo ". <a href='news_archive.php?listtype=last&pre=3'>".$locale['NA_005']."</a><br />";
echo ". <a href='news_archive.php?listtype=last&pre=7'>".$locale['NA_006']."</a><br />";
echo ". <a href='news_archive.php?listtype=last&pre=30'>".$locale['NA_008']."</a><br />";
echo "<hr>";
for ($i=0;$years[$i];$i++) {
echo ". <a href='news_archive.php?year=$years[$i]'>$years[$i]</a> (".$yearsnum[$years[$i]].")<br />";
}
closetable();
if ($listtype == "last") {
tablebreak();
opentable($locale['NA_010']);
$newslastweek = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp $newsorder");
if (!$rowstart) $rowstart = 0;
if (!$pre) $pre = 7;
$weektime = mktime(0, 0, 0, date("m") , date("d")-$pre, date("Y"));
while ($date = dbarray($result)){
$newstime = $date[news_datestamp];
if ($newstime >= $weektime){
$newsid = $date[news_id];
array_push($newslastweek, $newsid);
}
}
$rows = count($newslastweek);
listnews($newslastweek);
echo "<br /><div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,$numofnews,$rows,3,"$PHP_SELF?listtype=last&pre=$pre&")."\n</div>\n";
closetable();
} elseif (isset($year)) {
tablebreak();
opentable($year);
$splitmonths = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp ASC");
while ($date = dbarray($result)){
$allyears = date('Y', $date[news_datestamp]);
if ($allyears == $year){
[b]//$allmonths = date('F', $date[news_datestamp]);
$allmonths = showdate('%B', $date[news_datestamp]);[/b]
array_push($splitmonths, $allmonths);
}
}
$monthsnum = array_count_values($splitmonths);
$months = array_unique($splitmonths);
$months = array_merge($months);
$rows = count($months);
if ($rows !=0) {
for ($i=0;$months[$i];$i++) {
echo ". <a href='news_archive.php?year=$year&month=$months[$i]'>$months[$i]</a> (".$monthsnum[$months[$i]].") - (<a href='news_archive.php?listtype=bymonth&year=$year&month=$months[$i]'>".$locale['NA_004']."</a>)<br />";
}
} else {
echo "<center><br />".$locale['NA_015']."<br /><br /></center>\n";
}
closetable();
if ($listtype == "bymonth") {
tablebreak();
opentable($month);
$newsbymonth = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp $newsorder");
if (!$rowstart) $rowstart = 0;
while ($date = dbarray($result)){
$allyears = date('Y', $date[news_datestamp]);
[b]//$allmonths = date('F', $date[news_datestamp]);
$allmonths = showdate('%B', $date[news_datestamp]);[/b]
if ($allmonths == $month && $allyears == $year){
$newsid = $date[news_id];
array_push($newsbymonth, $newsid);
}
}
$rows = count($newsbymonth);
listnews($newsbymonth);
echo "<br /><div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,$numofnews,$rows,3,"$PHP_SELF?listtype=bymonth&year=$year&month=$month&")."\n</div>\n";
closetable();
} elseif (isset($month)) {
tablebreak();
opentable($month);
$splitdays = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp ASC");
while ($date = dbarray($result)){
$allyears = date('Y', $date[news_datestamp]);
[b]$allmonths = showdate('%B', $date[news_datestamp]);
//$allmonths = date('F', $date[news_datestamp]);[/b]
if ($allmonths == $month && $allyears == $year){
$alldays = date('d', $date[news_datestamp]);
array_push($splitdays, $alldays);
}
}
$daysnum = array_count_values($splitdays);
$days = array_unique($splitdays);
$days = array_merge($days);
$rows = count($days);
if ($rows !=0) {
for ($i=0;$days[$i];$i++) {
if ( $days[$i] == 1 or $days[$i] == 21 or $days[$i] == 31) {
$sub = "st";
} elseif ( $days[$i] == 2 or $days[$i] == 22) {
$sub = "nd";
} elseif ( $days[$i] == 3 or $days[$i] == 23) {
$sub = "rd";
} else {
$sub = "th";
}
echo ". <a href='news_archive.php?year=$year&month=$month&day=$days[$i]'>$days[$i]$sub</a> (".$daysnum[$days[$i]].")<br />";
}
} else {
echo "<center><br />".$locale['NA_009']."<br /><br /></center>\n";
}
closetable();
}
if (isset($day)) {
tablebreak();
opentable($day);
$news = array();
$result = dbquery("SELECT * FROM ".DB_PREFIX."news ORDER BY news_datestamp $newsorder");
if (!$rowstart) $rowstart = 0;
while ($date = dbarray($result)){
$allyears = date('Y', $date[news_datestamp]);
[b]//$allmonths = date('F', $date[news_datestamp]);
$allmonths = showdate('%B', $date[news_datestamp]);[/b]
$alldays = date('d', $date[news_datestamp]);
if ($alldays == $day && $allmonths == $month && $allyears == $year){
$newsid = $date[news_id];
array_push($news, $newsid);
}
}
$rows = count($news);
listnews($news);
echo "<br /><div align='center' style='margin-top:5px;'>\n".makePageNav($rowstart,$numofnews,$rows,3,"$PHP_SELF?listtype=bymonth&year=$year&month=$month&day=$day&")."\n</div>\n";
closetable();
}
}
} else {
echo "<center><br />".$locale['NA_003']."<br /><br /></center>\n";
closetable();
}
include BASEDIR."side_right.php";
include BASEDIR."footer.php";
?>
zapisz i wyj teraz sprawdz czy pokazuja sie nazwy miesiecy po polsku
Pozdro!! |