Kucki2
Beiträge: 146
Registriert: 18. Feb 2008, 22:12

MyEvents – Termine am "heutigen" Tag werden nicht angezeigt

21. Apr 2017, 11:29

Aktuell werden Termine, die am "heutigen" Tag statt finden, schon nicht mehr in der Eventliste angezeigt. Die Uhrzeit ist hier nicht relevant, wird also ignoriert. Es wäre schön, wenn diese Termine zumindest bis zur angegebenen Uhrzeit oder alternativ bis 23:59 Uhr sichtbar sind.

Hier die Standardmodul-Ausgabe, die mit dem Addon mitgeliefert wird:

Code: Alles auswählen

<section class="white-bg pb-20 ">
      <div class="container">
        <div class="row">
<div class="col-xs-12 col-sm-12 ">
<?php

    $languageId =  rex_clang::getCurrentId();
    if (rex_addon::get('textile')->isAvailable()) {

        $myeventsList       =  array();
        $tableDates         =  rex_addon::get('myevents')->getProperty('table_dates');
        $tableContent       =  rex_addon::get('myevents')->getProperty('table_content');

        $myeventsMaximum    =  strlen("REX_VALUE[1]")? (int)"REX_VALUE[1]" : 0;
        $myeventsMonths     =  (int)"REX_VALUE[2]";

        $periodTimeStart    =  time();
        $periodMonthEnd     =  (int)date("n", $periodTimeStart)  + $myeventsMonths;
        $periodTimeEnd      =  mktime (date("H", $periodTimeStart), date("i", $periodTimeStart), date("s", $periodTimeStart), $periodMonthEnd, date("j", $periodTimeStart), date("Y", $periodTimeStart));

        # create mysql timestamps to get events by it's enddate
        $myeventsStartDate  =  date("Y-m-d", $periodTimeStart);
        $myeventsEndDate    =  date("Y-m-d", $periodTimeEnd);

        # display month-names as string
        $monthNames =  array(
            1 => array('Januar','Februar','März','April','Mai','Juni','Juli','August','September','Oktober','November','Dezember',),
            2 => array('January','February','March','April','May','June','July','August','September','October','November','December',),
        );
        $timeFormat =  array(
            1 => 'H:i \U\h\r',
            2 => 'h:i a',
        );
        $andStringLocalized =  array(
            1 => 'und',
            2 => 'and',
        );

        # --------------------------------
        # load data from given year
        # ordered by startdate
        # --------------------------------
        $sql =  rex_sql::factory();
        $sql->setQuery( "select * from `" . $tableDates . "` " .
                "a left join `" . $tableContent . "` b on a.id = b.event_id " .
                "where (a.enddate > \"" . $myeventsStartDate . "\" and a.startdate < \"" . $myeventsEndDate . "\") " .
                "and b.clang = " . $languageId . " order by a.startdate");

        if ($sql->getRows() > 0 ) {

            # loop rows
            for ($i = 1; $i <= $sql->getRows(); $i++) {

                $myeventsDates      =  "";
                $myeventsDatesArray =  array();
                $myeventsHour       =  false;
                $myeventsMinutes    =  false;
                $myeventsTimeString =  false;
                $myeventsSortKey    =  false;

                # turn Unix-Timestamps-string into parts
                $myeventsTimes =  explode(",", $sql->getValue('dates'));
                foreach($myeventsTimes as $time) {

                    # ignore all dates of an event in the past or future
                    if ((int)$time < $periodTimeStart || (int)$time > $periodTimeEnd) {
                        continue;
                    }

                    # these data we need to get only once
                    if ($myeventsHour === false) {

                        $myeventsHour       =  date("G", $time);
                        $myeventsMinutes    =  date("i", $time);
                        $myeventsYear       =  date("Y", $time);
                        $myeventsTimeString =  date($timeFormat[$languageId], $time);

                        # use the first upcomming date of an event as sort-key
                        $myeventsSortKey    =  $time + $i;
                    }

                    # store days again in an array, month-index is the key
                    # we might ignore here some dates of myeventsTimes
                    # cause they are in the past already...
                    # so it is easier to format later
                    $monthIndex                         =  ((int)date("n", $time) -1);
                    $myeventsDatesArray[$monthIndex][]  =  date("d", $time);
                }

                # create formatted day(s) strings depending on language
                # we do not use "date" cause we might deal with multiple dates...
                foreach($myeventsDatesArray as $month_idx => $days) {

                    switch($languageId) {
                        case 1:
                            $myeventsDates .= (strlen($myeventsDates)? " " . $andStringLocalized[$languageId] . " " : "");
                            $myeventsDates .= implode(", ", $days) . " " . $monthNames[$languageId][$month_idx];
                            break;
                        default:
                            $myeventsDates .= (strlen($myeventsDates)? " " . $andStringLocalized[$language_id] . " " : "");
                            $myeventsDates .= $monthNames[$language_id][$month_idx] . " " . implode(", ", $days);
                    }
                }

                # you never know...
                if ($myeventsSortKey) {
                    $myeventsList[$myeventsSortKey] =  array(
                        'myeventsId'            =>  $sql->getValue('id'),
                        'myeventsDates'         =>  $myeventsDates,
                        'myeventsTimes'         =>  $myeventsTimes,
                        'myeventsHour'          =>  $myeventsHour,
                        'myeventsMinutes'       =>  $myeventsMinutes,
                        'myeventsYear'          =>  $myeventsYear,
                        'myeventsTimeString'    =>  $myeventsTimeString,
                        'myeventsTitle'         =>  $sql->getValue('title'),
                        'myeventsLocal'         =>  $sql->getValue('local'),
                        'myeventsContent'       =>  $sql->getValue('content'),
                        'myeventsDisplayTime'   =>  $sql->getValue('dpltime'),
                        'myeventsAddContent'    =>  $sql->getValue('addcontent'),

                    );
                }

                # next result row
                $sql->next();
            }

            # sort by first upcomming date
            ksort($myeventsList);
        } else {
            $myeventsList =  false;
        }

        # ---------------------------------
        # output
        # ---------------------------------
    ?>
        <div class="myevents-container">
            <?php if ($myeventsList) { ?>
                <ul class="myevents-list">
                    <?php
                        $eventCounter =  1;
                        foreach ($myeventsList as $myevent) {

                            # all we need only
                            if ($myeventsMaximum && $eventCounter > $myeventsMaximum) {
                                break;
                            }
                            $eventCounter ++;

                            # allow html, chars must be decoded
                            # replace br-tags
                            # replace leading whitespace after double line-break
                            # textile
                            # wrap in div and p
                            $textile = htmlspecialchars_decode($myevent['myeventsContent']);
                            $textile = str_replace("<br />","",$textile);
                            $textile = preg_replace("#\r#","",$textile);
                            $textile = preg_replace("#\n\s*\n\s*#","\n\n",$textile);
                            $textile = preg_replace("#\|\s+\n#","|\n",$textile); // no whitespaces after tailing "|"
                            $textile = rex_textile::parse($textile);
                    ?>
                        <li class="myevents-wrapper">
                            <h2><span class="myevent-dates">
                                <?php echo $myevent['myeventsDates']?>
                                <?php if ($myevent['myeventsDisplayTime']) {?>,
                                    <?php echo $myevent['myeventsTimeString']?>
                                <?php }?>
                            </span>
                            <?php echo $myevent['myeventsTitle']?></h2>
                            <?php if ($myevent['myeventsLocal']) { ?>
                                <p><?php echo $myevent['myeventsLocal'] ?>
                            <?php } ?>
                            <?php if($myevent['myeventsAddContent']) { ?>
                                // Kategorie <?php echo $myevent['myeventsAddContent'] ?></p>
                            <?php }?>
                            <div class="myevents-content">
                                <?php echo $textile ?>
                            </div><hr>
                        </li>
                    <?php }?>
                </ul>
            <?php } ?>
        </div>
    <?php
        # ---------------------------------
        # end output
        # --------------------------------

        # no textile
    } else {
        echo rex_view::warning('Dieses Modul benötigt das "textile" Addon!');
    }
?>

        </div>
      </div>
      </div>
   </section>
Gibt es eine einfache Möglichkeit, die Anzeige über das Modul zu ändern?

Grüße, Kucki2.

Zurück zu „AddOns / Packages [R5]“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 3 Gäste