Author Topic: Download ProCalendar  (Read 1133 times)

Offline dbs

  • Betatester
  • **
  • Posts: 8010
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Download ProCalendar
« Reply #25 on: January 10, 2019, 10:20:00 AM »
Es gab mal ein Droplet minical_1_3. Das funktioniert.
Wirft leider eine Notice wegen each().

Dropletcode
Code: [Select]
global $wb, $database;
require_once(WB_PATH."/modules/procalendar/functions.php");

// --- config options; you may change these ---
// day names length; values > 3 = full name
$day_name_length = 2;
// first day of week; 0 = Sunday, 1 = Monday
$first_day       = 1;
// set locale to the value you need
// set to NULL to use the OS setting -> $locale = NULL;
$locale          = 'de_DE';

// --- do not change these! ---
$month_href = NULL;
$days = array();
if ( isset( $locale ) ) {
    // store old locale
    $oldlocale = setlocale(LC_TIME, NULL); #save current locale
    setlocale( LC_TIME, $locale );
}

// year and month defaults
if(!isset($year))  {$year  = date('Y', time()); }
if(!isset($month)) {$month = date('n', time()); }
if(isset($_GET['procal_next']) && $_GET['procal_next'] != "") {
$showDate = explode("_",$_GET['procal_next']);
$month = $showDate[0];
$year = $showDate[1];
}
if(!isset($section_id)) {$section_id = 0 ; }
if(isset($kat)) {$katstring = "AND acttype =".$kat; }
$nextYear = ($month +1) > 12 ? $year+1 : $year;
$nextMonth = ($month +1) > 12 ? 1 : $month +1;
$prevYear = ($month -1) > 0 ? $year : $year-1;
$prevMonth = ($month -1) > 0 ? $month -1 : 12;
$pn = array("<&nbsp;&nbsp;&nbsp;" => $_SERVER['SCRIPT_NAME']."?procal_next=".$prevMonth."_".$prevYear, "&nbsp;&nbsp;&nbsp;>" => $_SERVER['SCRIPT_NAME']."?procal_next=".$nextMonth."_".$nextYear); // array for prev/next links;

$extrasql = '';
$page_id = 0;
$page_link ='';
$datestart = "$year-$month-1";
$dayend = cal_days_in_month(CAL_GREGORIAN, $month,$year);
$dateend = "$year-$month-".$dayend;
$calendar = '<script type="text/javascript">
function showDate(event, elem){
popContent = elem.innerHTML.replace(/display:.?none/ig,"display:block");
popupWindow = document.getElementById("datePopup");
popupWindow.innerHTML = popContent;
popupWindow.style.left = event.clientX +"px";
popupWindow.style.top = event.clientY+ "px";
popupWindow.style.display = "block";
return false;
};
function hideDate(){
  popupWindow = document.getElementById("datePopup").style.display = "none";
}
</script>';
if ($section_id<>0) {
  $extrasql = " section_id = '".$section_id."' AND ";
  $sql = "SELECT page_id FROM ".TABLE_PREFIX."sections WHERE section_id = '".$section_id."'";
  $result = $database->query($sql);
  if ( $result->numRows() > 0 ) {
    while( $row = $result->fetchRow() ) {
      $page_id = $row['page_id'];
    }
  }
  if ($page_id <> 0) {
    $sql = "SELECT link FROM ".TABLE_PREFIX."pages WHERE page_id = '".$page_id."'";
    $result = $database->query($sql);
    if ( $result->numRows() > 0 ) {
      while( $row = $result->fetchRow() ) {
$page_link = page_link($row['link']);
      }
    }
  }
}

$actions  = fillActionArray($datestart, $dateend, $section_id);
if (is_array($actions)){
foreach($actions as $row){   // Build url like : pages/kalendar.php?id=2&detail=1   
  $page_url = $page_link.'?id='.$row['id'].'&amp;detail=1';
  if ($month == (int)substr($row['date_end'],5,2)){
    $dateend = (int)substr($row['date_end'],8);
  } else $dateend = $dayend;
  if ($month == (int)substr($row['date_start'],5,2)){
    $day = (int)substr($row['date_start'],-2);
  } else $day = 1;   
  while($day <= $dateend) {
    if (array_key_exists($day, $days)){
      //preg_match("#(title='.*?)'#",$days[$day][2],$title);
      //$days[$day][2] = preg_replace("#title='.*?'#",$title[1]." &#10".$row['name']."'",$days[$day][2]);
      $days[$day][3] = preg_replace("#</span>#i",'<br><a href="'.$page_url.'">'.$row["name"].'</a></span>',$days[$day][3]);
    } else {
      $days[$day] = array( NULL, NULL, "<span onmouseover=\"showDate(event, this.nextSibling);\" onmouseout=\"hideDate();\" style='font-weight: bold; border: 1px solid #f00;'><a href='".$page_url."' title1='".$row['name']."'>".$day."</a></span>" );
      $days[$day][3] = '<span style="display:none"><a href="'.$page_url.'">'.$row["name"].'</a></span>';
    }
    $day++;
  }
}
}
$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()

$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
   $day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name

if ( isset( $oldlocale ) ) {
    // reset locale
    setlocale(LC_TIME, $oldlocale);
}

list($month, $year, $month_name, $weekday)
    = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title   = htmlentities(ucfirst($month_name)).'&nbsp;'.$year;  #note that some locales don't capitalize month and day names

#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable
if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span>&nbsp;';
if($n) $n = '&nbsp;<span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar .= '<table width="168px" class="calendar">'."\n".
   '<caption class="calendar-month">'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</caption>\n<tr>";

if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
   #if day_name_length is >3, the full name of the day will be printed
   foreach($day_names as $d)
      $calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
   $calendar .= "</tr>\n<tr>";
}

if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'">&nbsp;</td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
   if($weekday == 7){
      $weekday   = 0; #start a new week
      $calendar .= "</tr>\n<tr>";
   }
   if(isset($days[$day]) and is_array($days[$day])){
      @list($link, $classes, $content, $popup) = $days[$day];
      if(is_null($content))  $content  = $day;
      $calendar .= '<td align="center" '.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
         ($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).$popup.'</td>';
   }
   else $calendar .= "<td align=\"center\">$day</td>";
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'">&nbsp;</td>'; #remaining "empty" days

return $calendar."</tr>\n</table>\n <span id=\"datePopup\" onmouseover=\"this.style.display = 'block';\" onmouseout=\"this.style.display = 'none';\" style=\"display:none;max-width:200px;padding:3px;padding-left:12px;position:fixed;z-index:99;border: 1px solid;background: #FFFFD4\"></span>";

Offline hgs

  • Betatester
  • **
  • Posts: 1116
    • EFG MG
Re: Download ProCalendar
« Reply #26 on: January 10, 2019, 12:01:19 PM »
Stimmt, und bei mir sind in diesem MiniCalender keine Links vorhanden, also nur die Anzeige von einem Monat und die Möglichkeit vor und zurück zu springen .
Ist das bei dir auch so?
LG Harald

"Fange nie an, aufzuhören - höre nie auf, anzufangen." Marcus Tullius Cicero (106-43 v.Chr.)

Offline dbs

  • Betatester
  • **
  • Posts: 8010
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Download ProCalendar
« Reply #27 on: January 10, 2019, 12:07:33 PM »
Er zeigt Termine darin an und springt bei Klick ins Detail des Termins.

Offline FrankHA

  • Posts: 12
  • Marmot
Re: Download ProCalendar
« Reply #28 on: January 11, 2019, 12:10:44 AM »
habe jetzt auch einmal Droplet minical_1_3 installiert.
Also bei mir funktioniert leider nichts. Es wird überhaupt nichts angezeigt.  :-(

VG FrankHA

Offline dbs

  • Betatester
  • **
  • Posts: 8010
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Download ProCalendar
« Reply #29 on: January 11, 2019, 08:01:04 AM »
Morgen, außer ?section_id=xx braucht der nichts um zu funktionieren.
Allerdings führten die Links einen Tag später nicht mehr zur Detailseite.
Mir unerklärlich.

Offline hgs

  • Betatester
  • **
  • Posts: 1116
    • EFG MG
Re: Download ProCalendar
« Reply #30 on: January 11, 2019, 10:37:40 AM »
Zur Zeit gibt es nur das Droplet "eventlist", dass die richtigen Links zur Detailansicht erzeugt.
Weiter oben habe ich ja schon mal den Code dazu im Vergleich gepostet.

Alle anderen Dorplet die ich habe
minical_1_3 (erzeugt einen kleinen Monatskalender)
procal_cal_1_3 (erzeugt einen "große Monatsübersicht als Tabelle)

erzeugen einen Link der ins Leere führt.

Wer kann sich dem mal annehmen?
LG Harald

"Fange nie an, aufzuhören - höre nie auf, anzufangen." Marcus Tullius Cicero (106-43 v.Chr.)

Offline dbs

  • Betatester
  • **
  • Posts: 8010
  • Gender: Male
  • tioz4ever
    • WebsiteBaker - jQuery-Plugins - Module - Droplets - Tests
Re: Download ProCalendar
« Reply #31 on: January 11, 2019, 11:13:30 AM »
Ok, hab mir das Droplet nochmal angesehen und mit eventlist verglichen.
Jetzt sollte es gehen.

Code: [Select]
global $wb, $database;
require_once(WB_PATH."/modules/procalendar/functions.php");

// --- config options; you may change these ---
// day names length; values > 3 = full name
$day_name_length = 2;
// first day of week; 0 = Sunday, 1 = Monday
$first_day       = 1;
// set locale to the value you need
// set to NULL to use the OS setting -> $locale = NULL;
$locale          = 'de_DE';

// --- do not change these! ---
$month_href = NULL;
$days = [];
if ( isset( $locale ) ) {
    // store old locale
    $oldlocale = setlocale(LC_TIME, NULL); #save current locale
    setlocale( LC_TIME, $locale );
}

// year and month defaults
if(!isset($year))  {$year  = date('Y', time()); }
if(!isset($month)) {$month = date('n', time()); }
if(isset($_GET['procal_next']) && $_GET['procal_next'] != "") {
$showDate = explode("_",$_GET['procal_next']);
$month = $showDate[0];
$year = $showDate[1];
}
if(!isset($section_id)) {$section_id = 0 ; }
if(isset($kat)) {$katstring = "AND `acttype` = ".$kat; }
$nextYear = ($month +1) > 12 ? $year+1 : $year;
$nextMonth = ($month +1) > 12 ? 1 : $month +1;
$prevYear = ($month -1) > 0 ? $year : $year-1;
$prevMonth = ($month -1) > 0 ? $month -1 : 12;
$pn = array("<&nbsp;&nbsp;&nbsp;" => $_SERVER['SCRIPT_NAME']."?procal_next=".$prevMonth."_".$prevYear, "&nbsp;&nbsp;&nbsp;>" => $_SERVER['SCRIPT_NAME']."?procal_next=".$nextMonth."_".$nextYear); // array for prev/next links;

$extrasql = '';
$page_id = 0;
$page_link ='';
$datestart = "$year-$month-1";
$dayend = cal_days_in_month(CAL_GREGORIAN, $month,$year);
$dateend = "$year-$month-".$dayend;
$calendar = '<script>
function showDate(event, elem){
popContent = elem.innerHTML.replace(/display:.?none/ig,"display:block");
popupWindow = document.getElementById("datePopup");
popupWindow.innerHTML = popContent;
popupWindow.style.left = event.clientX +"px";
popupWindow.style.top = event.clientY+ "px";
popupWindow.style.display = "block";
return false;
};
function hideDate(){
  popupWindow = document.getElementById("datePopup").style.display = "none";
}
</script>';
if ($section_id<>0) {
  $extrasql = " `section_id` = ".$section_id." AND ";
  $sql = "SELECT `page_id` FROM `".TABLE_PREFIX."sections` WHERE `section_id` = ".$section_id;
  $result = $database->query($sql);
  if ( $result->numRows() > 0 ) {
    while( $row = $result->fetchRow() ) {
      $page_id = $row['page_id'];
    }
  }
  if ($page_id <> 0) {
    $sql = "SELECT `link` FROM `".TABLE_PREFIX."pages` WHERE `page_id` = ".$page_id;
    $result = $database->query($sql);
    if ( $result->numRows() > 0 ) {
      while( $row = $result->fetchRow() ) {
$page_link = page_link($row['link']);
      }
    }
  }
}

$actions  = fillActionArray($datestart, $dateend, $section_id);
if (is_array($actions)){
foreach($actions as $row){   // Build url like : pages/kalendar.php?year=1900&month=01&day=03&id=2&detail=1   
  $ds = $row['date_start']." ".substr($row['time_start'],0,5);
          $de = $row['date_end'] . " ".substr($row['time_end'],0,5);
 
  $page_url = $page_link.'?year='.$year.'&amp;month='.$month.'&amp;day='.(substr($ds,8,2)).'&amp;id='.$row['id'].'&amp;detail=1';
  if ($month == (int)substr($row['date_end'],5,2)){
    $dateend = (int)substr($row['date_end'],8);
  } else $dateend = $dayend;
  if ($month == (int)substr($row['date_start'],5,2)){
    $day = (int)substr($row['date_start'],-2);
  } else $day = 1;   
  while($day <= $dateend) {
    if (array_key_exists($day, $days)){
      //preg_match("#(title='.*?)'#",$days[$day][2],$title);
      //$days[$day][2] = preg_replace("#title='.*?'#",$title[1]." &#10".$row['name']."'",$days[$day][2]);
      $days[$day][3] = preg_replace("#</span>#i",'<br><a href="/'.$page_url.'&amp;day='.$day.'">'.$row["name"].'</a></span>',$days[$day][3]);
    } else {
      $days[$day] = array( NULL, NULL, "<span onmouseover=\"showDate(event, this.nextSibling);\" onmouseout=\"hideDate();\" style='font-weight: bold; border: 1px solid #f00;'><a href='".$page_url."' title1='".$row['name']."'>".$day."</a></span>" );
      $days[$day][3] = '<span style="display:none"><a href="/'.$page_url.'&amp;day='.$day.'">'.$row["name"].'</a></span>';
    }
    $day++;
  }
}
}
$first_of_month = gmmktime(0,0,0,$month,1,$year);
#remember that mktime will automatically correct if invalid dates are entered
# for instance, mktime(0,0,0,12,32,1997) will be the date for Jan 1, 1998
# this provides a built in "rounding" feature to generate_calendar()

$day_names = array(); #generate all the day names according to the current locale
for($n=0,$t=(3+$first_day)*86400; $n<7; $n++,$t+=86400) #January 4, 1970 was a Sunday
   $day_names[$n] = ucfirst(gmstrftime('%A',$t)); #%A means full textual day name

if ( isset( $oldlocale ) ) {
    // reset locale
    setlocale(LC_TIME, $oldlocale);
}

list($month, $year, $month_name, $weekday)
    = explode(',',gmstrftime('%m,%Y,%B,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; #adjust for $first_day
$title   = htmlentities(ucfirst($month_name)).'&nbsp;'.$year;  #note that some locales don't capitalize month and day names

#Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03
// original line, but with notices for each()
@list($p, $pl) = each($pn); @list($n, $nl) = each($pn); #previous and next links, if applicable

if($p) $p = '<span class="calendar-prev">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span>&nbsp;';
if($n) $n = '&nbsp;<span class="calendar-next">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar .= '<table width="168px" class="calendar">'."\n".
   '<caption class="calendar-month">'.$p.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title).$n."</caption>\n<tr>";

if($day_name_length){ #if the day names should be shown ($day_name_length > 0)
   #if day_name_length is >3, the full name of the day will be printed
   foreach($day_names as $d)
      $calendar .= '<th abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
   $calendar .= "</tr>\n<tr>";
}

if($weekday > 0) $calendar .= '<td colspan="'.$weekday.'">&nbsp;</td>'; #initial 'empty' days
for($day=1,$days_in_month=gmdate('t',$first_of_month); $day<=$days_in_month; $day++,$weekday++){
   if($weekday == 7){
      $weekday   = 0; #start a new week
      $calendar .= "</tr>\n<tr>";
   }
   if(isset($days[$day]) and is_array($days[$day])){
      @list($link, $classes, $content, $popup) = $days[$day];
      if(is_null($content))  $content  = $day;
      $calendar .= '<td align="center" '.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
         ($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).$popup.'</td>';
   }
   else $calendar .= "<td align=\"center\">$day</td>";
}
if($weekday != 7) $calendar .= '<td colspan="'.(7-$weekday).'">&nbsp;</td>'; #remaining "empty" days

return $calendar."</tr>\n</table>\n <span id=\"datePopup\" onmouseover=\"this.style.display = 'block';\" onmouseout=\"this.style.display = 'none';\" style=\"display:none;max-width:200px;padding:3px;padding-left:12px;position:fixed;z-index:99;border: 1px solid;background: #FFFFD4\"></span>";

Wer shorturl benutzt sollte sich ans Ende der letzten Zeile, nach dem span nochmal sein Droplet reinsetzen. Ungefähr so:
Code: [Select]
return $calendar."</tr>\n</table>\n <span id=\"datePopup\" onmouseover=\"this.style.display = 'block';\" onmouseout=\"this.style.display = 'none';\" style=\"display:none;max-width:200px;padding:3px;padding-left:12px;position:fixed;z-index:99;border: 1px solid;background: #FFFFD4\"></span>[[short-url5?info=procal]]";
Gestyled ist der Kalender jetzt nicht wirklich...

edit: im oberen Teil ?procal_prev zu ?procal_next geändert, sonst keine Umschaltung zu Jahr 2018 möglich
« Last Edit: January 11, 2019, 12:55:58 PM by dbs »

Offline FrankHA

  • Posts: 12
  • Marmot
Re: Download ProCalendar
« Reply #32 on: January 11, 2019, 10:34:54 PM »
den Fehler warum ich überhaupt nichts sehen konnte lag daran, das die angegebene [[tiny_calendar?section_id=<xx>]]
falsch ist, es sollte sein [[minical_1_3?section_id=xx]].
Jetzt funktioniert es auch ohne die Änderung von dbs. Ich kann in den Monaten vor- und zurückgehen, die Datumlinks werden per Mini-Popup angezeigt und auf die entsprechende Detailseite geführt.
Alles Prima.
Die einzige Bitte noch, wie stelle ich auf das Datumsformat Deutsch im Kalendermonat des Minikalenders um?

VG FrankHA

 

postern-length