IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

[Dates] Navigation dans le calendrier


Sujet :

Langage PHP

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    34
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 34
    Points : 16
    Points
    16
    Par défaut [Dates] Navigation dans le calendrier
    bonjour,

    bonjour,

    Voilà le calendrier en question vous pouvez le voir à l'adresse suivante colonne de gauche : http://www.fireworkszone.com/index?a...h&d=2006/01/01

    Vous remarquerez que lorsque vous arriverez sur la page vous avez 'January 2006' avec une flèche de navigation à droite (pour aller vers Février) et une flèche de navigation à gauche (pour aller vers Décembre 2005)

    Si vous cliquez sur la flèche gauche pour allez vers décembre 2005 et vous vous apercevrez que vous n'avez plus qu'une seule flèche de présente celle de gauche (pour remonter le temps) la droite ayant disparue.

    Je souhaiterai pouvoir naviguer entre les années en gardant les 2 flèches de navigation en consultant le code ci-dessous.


    Merci de votre aide
    <?php
    // ----------------------------------------------------------------------------
    // MyPHPNews - Le gestionnaire de news
    // ----------------------------------------------------------------------------
    // Copyright (C) 2001-2002 - Régis GAIDOT - MyPHPSoft (http://www.myphpsoft.net)
    // Contact: rgaidot@myphpsoft.net
    // ----------------------------------------------------------------------------
    // 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.
    // ----------------------------------------------------------------------------
    if (!defined("GRAB_GLOBALS_VARS")){
    define( "GRAB_GLOBALS_VARS", 1 );
    include( "conf/grabglobals_vars.inc.php" );
    @require_once($_SERVER['DOCUMENT_ROOT'].'/conf/grabglobals_vars.inc.php');

    }
    if (!defined("_CONFIG_PHP")){
    define( "_CONFIG_PHP", 1 );
    @require_once($_SERVER['DOCUMENT_ROOT'].'/conf/cfg.inc.php');

    }
    if (!defined("_CLASS_DATE")){
    define( "_CLASS_DATE", 1 );
    @require_once($_SERVER['DOCUMENT_ROOT'].'/conf/class_date.php');

    }
    if (!defined("_CONFIG_CLASSBD")){
    define( "_CONFIG_CLASSBD", 1 );
    @require_once($_SERVER['DOCUMENT_ROOT'].'/conf/class_mysql.php');
    }
    if (!defined("_CACHE_PHP")){
    define( "_CACHE_PHP", 1 );
    @require_once($_SERVER['DOCUMENT_ROOT'].'/conf/class_cache_scr.php');
    }

    $var = "act=date&";
    $curmonth = date("m");
    $curday = date("d");
    if(!isset($d)) $d=date("Y/m/d");

    $tbdate = explode("/",$d);
    $month = (integer) $tbdate[1];
    $year = (integer) $tbdate[0];
    $day = (integer) $tbdate[2];
    $cache = new cache("Calendar".$month."_".$day,$TimeCache,"cache/");
    if($cache->isExpered()){
    $date = new mydate($day,$month,$year);
    $NbDayOfMonth = $date->GetNumDayOfMonth();
    $FirstDayOfMonth = date("w",mktime(0,0,1,$month,01,$year));

    $genNewsCalendar.= "<div id='calendar'><table border='1' width='100%' cellpadding='0' cellspacing='0'><tr><td>\n";
    $genNewsCalendar.= "<table border='0' cellspacing='0' cellpadding='0' >";
    $genNewsCalendar.= "<thead><tr>";

    if(intval($month)==1){
    $genNewsCalendar.= "<td><a href=\"index?act=archmonth&d=".sprintf("%04d/%02d/%02d",$year-1,12,01)."\"><img src='pictures/arrows/left_arrow.gif' width='14' height='14' border='0' alt='".sprintf("%04d/%02d/%02d",$year-1,12,01)."' title='".sprintf("%04d/%02d/%02d",$year-1,12,01)."'/></a></td>";
    }else{
    $genNewsCalendar.= "<td ><a href=\"index?act=archmonth&d=".sprintf("%04d/%02d/%02d",$year,$month-1,01)."\"><img src='pictures/arrows/left_arrow.gif' width='14' height='14' border='0' alt='".sprintf("%04d/%02d/%02d",$year,$month-1,01)."' title='".sprintf("%04d/%02d/%02d",$year,$month-1,01)."'/></a></td>";
    }

    $genNewsCalendar.= "<td colspan='5' align=center><b><center><a href=\"index?act=archmonth&d=".sprintf("%04d/%02d/%02d",$year,$month,01)."\" alt=\"$ResStrArchivOfMonth\" title=\"$ResStrArchivOfMonth\"><b>".$date->GetMonthName()." ".$year."</b></a></center></b></td>";

    if($curmonth>$month){
    if((intval($month)==12)){

    $genNewsCalendar.= "<td><a href=\"index?act=archmonth&d=".sprintf("%04d/%02d/%02d",$year,$month,01)."\"><img src='pictures/arrows/right_arrow.gif' width='14' height='14' border='0' alt='".sprintf("%04d/%02d/%02d",$year,$month,01)."' title='".sprintf("%04d/%02d/%02d",$year,$month,01)."'/></a></td>";

    }else{

    $genNewsCalendar.= "<td ><a href=\"index?act=archmonth&d=".sprintf("%04d/%02d/%02d",$year,$month+1,01)."\"><img src='pictures/arrows/right_arrow.gif' width='14' height='14' border='0' alt='".sprintf("%04d/%02d/%02d",$year,$month+1,01)."' title='".sprintf("%04d/%02d/%02d",$year,$month+1,01)."'/></a></td>";
    }
    }else $genNewsCalendar.= "<td>&nbsp;</td>";
    $genNewsCalendar.= "</tr></thead>\n";
    $genNewsCalendar.= "<tr>
    <th title='Monday'><acronym title='Monday'>M</acronym></th>
    <th ><acronym title='Tuesday'>T</acronym></th>
    <th ><acronym title='Wednesday'>W</acronym></th>
    <th ><acronym title='Thursday'>T</acronym></th>
    <th ><acronym title='Friday'>F</acronym></th>
    <th ><acronym title='Saturday'>S</acronym></th>
    <th ><acronym title='Sunday'>S</acronym></th>
    </tr>\n";

    if($FirstDayOfMonth==0) $FirstDayOfMonth=7;
    $genNewsCalendar.= "<tr>";

    $dbs = new data(0,$MyPHPNewsHote, $MyPHPNewsBase, $MyPHPNewsUser, $MyPHPNewsPass);
    if(!$dbs->connect())
    die($dbs->error);
    if(!$dbs->query("SELECT COUNT(id) AS nb, DATE_FORMAT(date,'%d') as d1, titre FROM ".$MyPHPNewsTBNews." WHERE activ='1' AND date LIKE '".$year."/".sprintf("%02d",$month)."%' GROUP BY d1 ORDER BY date"))
    die($dbs->error);
    while($dbs->nextrecord()){
    $key = $dbs->value("d1");
    $arrayofdate[$key] = $dbs->value("nb");
    }
    for($i=1;$i<$FirstDayOfMonth;$i++)
    $genNewsCalendar.= "<td width='20' class='monthdays'>&nbsp;</td>";

    $j = $FirstDayOfMonth;
    for($i=1;$i<=$NbDayOfMonth;$i++){
    $datej = new mydate($i,$month,$year);
    $bankday = $datej->isBankHolidays();
    $nameofbankday = $datej->GetNameBankHolidays();
    if($arrayofdate[sprintf("%02d",$i)]!=0){

    $genNewsCalendar.=

    "<td class='today' ".(($day==$i) ? "" : "" ).">
    <a href=\"?".$var."d=".sprintf("%04d/%02d/%02d",$year,$month,$i)."\" title=\"".$i."/".$curmonth."/".$year."\">".(($day==$i) ? "".$i."" : $i)."</a></td>";

    }else{

    $genNewsCalendar.= "<td width='20' ".(($day==$i) ?" class='today' " : "" ).">".(($day==$i) ? "".$i."" : $i)."</td>";

    }
    if($j==7){
    if($i<$NbDayOfMonth){
    $genNewsCalendar.= "</tr>\n";

    $genNewsCalendar.= "<tr class='monthdays'>";
    $j = 1;
    }
    }else{
    $j ++;
    }
    }
    $genNewsCalendar.= "</tr>\n";
    $genNewsCalendar.= "</table>\n";
    $genNewsCalendar.= "</td></tr></table></div>\n";
    $cache->SetCache($genNewsCalendar);
    }echo $cache->GetCache("Calendar".$month."_".$day);
    ?>

  2. #2
    Membre régulier Avatar de BGDC
    Profil pro
    Inscrit en
    Septembre 2003
    Messages
    102
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Septembre 2003
    Messages : 102
    Points : 121
    Points
    121
    Par défaut
    Salut,

    je ne peux pas tester, je suis au boulot, mais à ta place je regarderais l'utilité de ce test :
    if($curmonth>$month)
    avant le test du mois =12.

    Bon courage.
    Bon allez, cette fois c'est sur, ça marche........bon aller je réessaye......

Discussions similaires

  1. Sélection d'une date dans un calendrier
    Par navis84 dans le forum Général JavaScript
    Réponses: 11
    Dernier message: 17/04/2012, 17h12
  2. [Dates] requete dans un calendrier
    Par popline7 dans le forum Langage
    Réponses: 2
    Dernier message: 14/06/2006, 09h15
  3. [Calendrier] Choisir une date dans un calendrier
    Par yoyothebest dans le forum EDI, CMS, Outils, Scripts et API
    Réponses: 3
    Dernier message: 19/05/2006, 10h39
  4. Selection de date dans un calendrier
    Par Gob4 dans le forum Général JavaScript
    Réponses: 7
    Dernier message: 15/05/2006, 14h37
  5. [VBA-E] choisir une date dans un calendrier
    Par yaya54 dans le forum Macros et VBA Excel
    Réponses: 2
    Dernier message: 07/03/2006, 09h05

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo