Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Nedeľa, 21. júl 2024

Súbor: [Platon] / Metafox / libpub / calendar / calendar1.php (stiahnutie)

Revízia 1.4, Fri Jun 9 15:13:00 2017 UTC (7 years, 1 month ago) by igor


Zmeny od 1.3: +3 -3 [lines]

changed functions mysql_* to mysqli_* for PHP/7.0

<?php

/*
 * Developed by Igor Mino <igor@platon.org>
 * Copyright (c) 2009 Platon Technologies Ltd, http://platon.sk
 * All rights reserved.
 */
 
require_once dirname(__FILE__)."/../../config/db-config.inc.php";
require_once dirname(__FILE__)."/../../lib/db-core/db-core.inc.php";


function getEventsOfMonth($date = NULL) { // vrati daneho mesiaca
     
      if (($date==NULL) or ($date=="")) { return NULL; }

      $date1=date("Y-m-01",strtotime($date));
      $date2=date("Y-m-t",strtotime($date));

      ezin_open_db_connection();
      $query = sprintf('SELECT *'
                    .' FROM ezin_articles'
                    .' WHERE calendar_flag >= "%s"'
                    .' AND calendar_flag <= "%s"',
                    $date1,
                    $date2);
      $result = mysqli_query($GLOBALS["ezin_db_handle"], $query);
   
     $return=Array();
   
    while (($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) != null) {
          $day = date("j",strtotime($row['calendar_flag']));
          //echo $day."<br>";
          $return[$day][$row['id']] = $row;
          
    }
    mysqli_free_result($result);
     
     ezin_close_db_connection();
     
     //print_r($return);
     return $return;

}



$get_position=$_POST["position"];
$get_idCalendar=$_POST["idCalendar"];
$requestFromWeb=0; // ak bolo volana sluzba uz z webu = 1, ak zo sablony = 0
$calendar_linkForArticle_end="&ezin_tmpl_calendar_source=1"; // ak =1 potom kalendarik ostava v tom istom mesiaci

if (isset($get_position)) { 
     $calendar_linkForArticle="<ezin_url>article.php?";
     if (isset($get_idCalendar)) {
          $requestFromWeb=1; 
          echo getCalendar($get_position,$get_idCalendar);          
      }
      else {
          echo getCalendar($get_position);      
      }      
      
}    
else {
     $calendar_linkForArticle=$ezin_url."article.php?";
}


function getCalendar($position = NULL, $idCalendar = NULL ) {  // position je typu datetime (YYYY-MM-DD HH:MM:SS)
     if ($idCalendar==NULL) {$idCalendar="cal-".Time().Rand(1,1000);}
     
     $ret="";
  
     if ($GLOBALS["requestFromWeb"]==1) {
          $ret=$ret.$idCalendar."|";
     }
  
     $DATA_eventsOfDay=""; 
     
     if ($position==NULL) {$position=Time();}
     else {$position=strtotime($position);}
     
     $numberOfDays=date("t",$position);  // pocet dni v mesiaci
     
     $firstDayOfMonth=date("Y-m-",$position)."01";  // datum prveho dna v mesiaci   
     $firstDayOfMonth=date("N",strtotime($firstDayOfMonth));  // prvy den v mesiaci  1=Pondelok ... 7=Nedela
     
     $startPoint=2-$firstDayOfMonth;  // pocitadlo pri vpisovani dni do tabulky 
     
     $nameOfMonth=Array("JanuĂĄr","FebruĂĄr","Marec","AprĂ­l","MĂĄj","JĂşn","JĂşl",
                        "August","September","OktĂłber","November","December");
     $numberOfMonth=date("m",$position); // cislo mesiaca
     $numberOfYear=date("Y",$position);  // cislo roku
     
     $ret_eventsOfMonth=getEventsOfMonth($numberOfYear."-".$numberOfMonth."-1");
     
     $numberOfNextMonth=$numberOfMonth+1;
     if ($numberOfNextMonth>12) {$numberOfNextMonth=1; $numberOfNextYear=$numberOfYear+1;} 
     else {$numberOfNextYear=$numberOfYear;}
     
     $numberOfPreviousMonth=$numberOfMonth-1;
     if ($numberOfPreviousMonth<1) {$numberOfPreviousMonth=12; $numberOfPreviousYear=$numberOfYear-1;} 
     else {$numberOfPreviousYear=$numberOfYear;}
      
      $ret=$ret."<div id=\"popup-".$idCalendar."\" class=\"popup-window\" 
                         onmouseout=\"document.getElementById('popup-".$idCalendar."').style.visibility='hidden';\"
                         onmouseover=\"document.getElementById('popup-".$idCalendar."').style.visibility='visible';\"                          
                         ></div>                        
       ";
       
      if ($GLOBALS["requestFromWeb"]!=1) { $ret=$ret."<div id=\"".$idCalendar."\">"; }
          $ret=$ret."
            <table class=\"month\" align=\"center\" cellspacing=\"3\" border=\"0\">
              <tr>
                  <td class=\"monthnavigation\">
                   <a class=\"anket\" onclick=\"loadMonth('position=".$numberOfPreviousYear."-".$numberOfPreviousMonth."-01&idCalendar=".$idCalendar."');\">
                        <!-- <img class=\"button-".$idCalendar."-back\" alt=\"&lt;&lt;\"> -->
                        <div class=\"button-".$idCalendar."-back\"></div>
                   </a>
                  </td>
                  <td class=\"monthname\" colspan=\"5\">
                   ".$nameOfMonth[$numberOfMonth-1]."<br>".$numberOfYear."
                  </td>
                  <td class=\"monthnavigation\">
                   <a class=\"anket\" onclick=\"loadMonth('position=".$numberOfNextYear."-".$numberOfNextMonth."-01&idCalendar=".$idCalendar."');\">
                        <!-- <img class=\"button-".$idCalendar."-next\" alt=\"&gt;&gt;\"> -->
                        <div class=\"button-".$idCalendar."-next\"></div>
                   </a>
                  </td>
              
              </tr>
              <tr>
                  <td class=\"dayname\">P</td>
                  <td class=\"dayname\">U</td>
                  <td class=\"dayname\">S</td>
                  <td class=\"dayname\">Ĺ </td>
                  <td class=\"dayname\">P</td>
                  <td class=\"dayname\">S</td>
                  <td class=\"dayname\">N</td>
              </tr>
              <tr>
                  <td colspan=\"7\">
                      <div class=\"days-bottom-line\"></div>
                  </td>
              </tr>
              ";

            $DATA_eventsOfDay="\n<!-- DATA_eventsOfDay -->\n";
            for ($a=0; $a<=5; $a++) {
               $ret .= "\n<tr>";
               for ($b=1; $b<=7; $b++) {
                    $events=NULL;
                    $numberId=($a*7)+$b;
                    if (($startPoint>0) and ($startPoint<=$numberOfDays)) {                    
                         $numberDay=$startPoint;
                         $classDay="monthday";
                         //$events=getEventsOfDay($numberOfYear."-".$numberOfMonth."-".$numberDay);
                         $events=$ret_eventsOfMonth[$numberDay];                    
                    } else {
                         $numberDay="";
                         $classDay="nomonthday";
                    }                                                                                               
                    $startPoint++;
                    if ($events==NULL) { 
                      $ret=$ret."
                           <td id=\"cellDay".$numberId."\" class=\"".$classDay."\">".$numberDay."</td>
                      ";               
                    }
                    else {
                      $ret=$ret."                         
                         <td id=\"cellDay".$numberId."-".$idCalendar."\" class=\"selectedday\" onmouseover=\"showPopup('cellDay".$numberId."-".$idCalendar."',".$numberDay.",'popup-".$idCalendar."');\">
                          <a href=\"#\">".$numberDay."</a>
                         </td>
                         ";

                      $keysOfEvents=array_keys($events);
                      $DATA_eventsOfDay=$DATA_eventsOfDay."<div id=\"data_cellDay".$numberId."-".$idCalendar."\" style=\"visibility:hidden;
                                                                                                         height:0px;                          
                                                                                                         width:0px;
                                                                                                         display:none;\">\n";
                      $DATA_eventsOfDay .= "<div id=\"calendar-popup\" >\n";                                                                                                         
                  $DATA_eventsOfDay .= "<ul>\n";
                      for ($c=0; $c<=count($keysOfEvents)-1; $c++ ) {
                         $eventsIdOfArticle=$keysOfEvents[$c];
                         $eventsTitleOfArticle=$events[$eventsIdOfArticle]['title'];
                         $eventsTitleOfArticle = str_replace('~', '&nbsp;', $eventsTitleOfArticle);

                         $DATA_eventsOfDay .= "<li>\n";
                         if (strlen($events[$eventsIdOfArticle]['bodytext']) > 0) {
                             $DATA_eventsOfDay .= '<a href="'.$GLOBALS["calendar_linkForArticle"]
                                                 .$eventsIdOfArticle
                                                 .$GLOBALS["calendar_linkForArticle_end"].'">';
                         }
                         $DATA_eventsOfDay .= $eventsTitleOfArticle;
                         if (strlen($events[$eventsIdOfArticle]['bodytext']) > 0) {
                             $DATA_eventsOfDay .= '</a>';
                         }
                         $DATA_eventsOfDay .= "\n";
                         $DATA_eventsOfDay .= "</li>\n";
                      }
                      $DATA_eventsOfDay .= "</ul>\n";
                      $DATA_eventsOfDay .= "</div>\n"; // id=calendar-popup   
                      $DATA_eventsOfDay .= "</div>\n";   
                    }
               }                        
               
               
               $ret=$ret."                    
                </tr>";
              
            }  

            $DATA_eventsOfDay .= "\n<!-- END DATA_eventsOfDay -->\n";
                        
          $ret=$ret."
            </table>
          
          ";
          if ($GLOBALS["requestFromWeb"]!=1) { $ret=$ret."</div>"; }
                    
     $ret=$ret.$DATA_eventsOfDay;
     
     
     return $ret;
}



?>

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok