collapse

* Simple Portal Archived Forum

This is an Archive Forum.

The content in this forum may be out-of-date or have been superseded by newer information, and links in forum pages to other sites may not work.
This forum contains archives for future reference.

Visit our thread at Simple Machines Forum for current support.

SMF 2.1 users: EhPortal is a ported version of Simple Portal specifically designed for the SMF 2.1 branch.
Please visit web-develop.ca to download EhPortal and for its support.

* User Info

 
 
Welcome, Guest. Please login or register.

* Who's Online

  • Dot Guests: 799
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.

* Shoutbox

Refresh History
  • Shoutbox is not for support!
  • {OCS}MasterSeal: Yup, Still adore SP
    April 21, 2019, 07:08:06 PM
  • {OCS}MasterSeal: STILL love SP :)
    November 24, 2018, 05:05:50 AM
  • ♦ Ninja ZX-10RR ♦: <3 aegersz
    September 13, 2018, 03:36:09 PM
  • aegersz: I STILL <3 LOVE SimplePortal
    September 13, 2018, 07:11:39 AM
  • aegersz: o LOVE you guys - Simple Portal rocks !
    May 09, 2018, 05:18:59 AM
  • Chen Zhen: our apologies for the site being down.. please read server issues topic
    March 22, 2018, 05:32:38 AM
  • {OCS}MasterSeal: LOL PLEASE forget I just posted that. I found the answer in my own dang post back in 2015. lol sorry!
    July 04, 2017, 10:47:55 PM
  • {OCS}MasterSeal: I know this SB isnt' for support, but I just have a general question. Who would I contact to find out where SP stores its block info? Is it DB driven or files? I searched the site but came up with nothing. probably my fault any insight is appreciated.
    July 04, 2017, 10:43:36 PM
  • ♦ Ninja ZX-10RR ♦: Excuse me but what does Simpleportal have to deal with that?
    February 05, 2017, 08:21:14 PM
  • WhiteEagle: of course IMHO that site appears to be dead :(
    February 04, 2017, 01:08:05 PM
  • WhiteEagle: If I can get that, then I'll use it for that site...
    February 04, 2017, 01:07:35 PM
  • WhiteEagle: decided to not use SMF for any projects, unless I can get a copy of the premium version of the fanfiction archive plugin
    February 04, 2017, 01:06:54 PM
  • expertdecisions: cloudflare
    January 28, 2017, 08:01:47 AM
  • aegersz: SM release 2.0.13 !
    January 12, 2017, 06:00:13 AM
  • raffo: Tks Emanuele, even if I didn't understand the fix :D
    November 07, 2016, 02:01:20 AM
  • emanuele: [link]
    November 01, 2016, 12:43:50 PM
  • emanuele: raffo: the English support board is a good place. ;)
    November 01, 2016, 12:43:38 PM
  • raffo: Where can I find the fix for the shoutbox?
    November 01, 2016, 05:06:09 AM
  • {OCS}MasterSeal: To the SP team, I make a point to come here and thank you as much as possible for your work.  so again, THANK YOU!
    October 28, 2016, 10:38:05 AM
  • emanuele: That's indeed funny, the limit is present only in the patch and not the full install.
    October 22, 2016, 06:14:58 PM

* Recent Posts

Adding Forums Button to Nav bar by jirapon
[August 01, 2019, 09:07:12 AM]


Re: Board Icons by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 04:03:41 PM]


MOVED: Czech translation???? by ♦ Ninja ZX-10RR ♦
[July 30, 2019, 03:04:51 PM]


Board Icons by jirapon
[July 30, 2019, 07:28:44 AM]


Re: Thankyou Simpleportal, by ♦ Ninja ZX-10RR ♦
[July 29, 2019, 09:41:29 AM]

NEED HELP? If you're looking for support with Simple Portal, look no further than the Support Board!

Author Topic: Modified CalendarInformation block  (Read 4451 times)

0 Members and 1 Guest are viewing this topic.

Offline Hannilein

  • Semi Newbie
  • *
  • Posts: 14
  • Gender: Male
    • Homepage
  • SMF Version: 1.1.10
  • SP Version: 2.3.1
Modified CalendarInformation block
« on: May 08, 2009, 05:17:45 AM »
Hello,
first of all I want to thank you for this great and 'simple' to use portal. I added it some days ago to my little forum and I have fun with it.

Especially for the block 'CalendarInformation' I found some issues which made me feel uncomfortable, so I modified it (I should say that I'm relatively new to PHP programming so maybe the coding style of my mods are not perfect...).

1. If a event line breaks, the second part of the line displays below the icon. This looks bad. I modified it to use tables to make the line break look better.

2. With my settings the block shows the upcoming events of the next 14 days. If there is a multiple-day-event, it is displayed several times in the block. I modified it to display only once, together with the duration of the event.

Attached is my modified code of the function 'sp_calendarInformation' in the file 'SPortal1-1.php':

(my mods are marked with 'inserted by DiSc' or 'mod DiSc')

Code: [Select]
function sp_calendarInformation($parameters, $id, $return_parameters = false)
{
global $scripturl, $modSettings, $txt;

$block_parameters = array(
'events' => 'check',
'future' => 'int',
'birthdays' => 'check',
'holidays' => 'check',
);

if ($return_parameters)
return $block_parameters;

$show_event = !empty($parameters['events']);
$event_future = (int) $parameters['future'];
$event_future = abs($event_future);
$show_birthday = !empty($parameters['birthdays']);
$show_holiday = !empty($parameters['holidays']);
$show_titles = false;

if (!$show_event && !$show_birthday && !$show_holiday)
{
echo '
', $txt['sp_calendar_noEventsFound'];
return;
}

$now = forum_time();
$today_date = date("Y-m-d", $now);
$calendar_array = array(
'todayEvents' => array(),
'futureEvents' => array(),
'todayBirthdays' => array(),
'todayHolidays' => array()
);

    // inserted by DiSc
$shown = array();

if ($show_event)
{
if (!empty($event_future))
$event_future_date = date("Y-m-d", ($now + $event_future * 86400));
else
$event_future_date = $today_date;

$events = sp_loadCalendarData('getEvents', $today_date, $event_future_date);

if (!empty($events[$today_date]))
{
$calendar_array['todayEvents'] = $events[$today_date];
unset($events[$today_date]);
}

if (!empty($events))
{
ksort($events);
$calendar_array['futureEvents'] = $events;
}
}

if ($show_birthday)
{
$calendar_array['todayBirthdays'] = current(sp_loadCalendarData('getBirthdays', $today_date));
$show_titles = !empty($show_event) || !empty($show_holiday);
}

if ($show_holiday)
{
$calendar_array['todayHolidays'] = current(sp_loadCalendarData('getHolidays', $today_date));
$show_titles = !empty($show_event) || !empty($show_birthday);

if (timeformat(forum_time(), '%d-%m') == '25-08')
$calendar_array['todayHolidays']['e'] = base64_decode('RWxpYW5hIERheQ==');
}

if (empty($calendar_array['todayEvents']) && empty($calendar_array['futureEvents']) && empty($calendar_array['todayBirthdays']) && empty($calendar_array['todayHolidays']))
{
echo '
', $txt['sp_calendar_noEventsFound'];
return;
}
else

    /*
echo '
<ul class="sp_list">';
*/

        /*
if (!empty($calendar_array['todayHolidays']))
{
if ($show_titles)
echo '
<li><strong>', $txt['sp_calendar_holidays'] ,'</strong></li>';

foreach ($calendar_array['todayHolidays'] as $key => $holiday)
echo '
<li>', sp_embed_image($key === 'e' ? 'diamond' : 'holiday'), ' ', $holiday ,'</li>';
}
*/

/* mod DiSc */
if (!empty($calendar_array['todayHolidays']))
{
echo '
    <table cols=2>';
   
if ($show_titles)
{
echo '
<tr>
                        <td colspan="2">
<strong>', $txt['sp_calendar_holidays'] ,'</strong>
</td>
</tr>
                    ';
            }

        foreach ($calendar_array['todayHolidays'] as $key => $holiday)
    echo '
        <tr>
                            <td style="width:16px">',
                                sp_embed_image($key === 'e' ? 'diamond' : 'holiday'),'
                            </td>
                            <td style=align:left">',
$holiday,'
                            </td>
        </tr>
        ';
echo '
</table>
    ';
}


        /*
if (!empty($calendar_array['todayBirthdays']))
{
if ($show_titles)
echo '
<li><strong>', $txt['sp_calendar_birthdays'] ,'</strong></li>';

foreach ($calendar_array['todayBirthdays'] as $member)
echo '
<li>', sp_embed_image('birthday'), ' <a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a></li>';
}
*/

/* mod DiSc */
if (!empty($calendar_array['todayBirthdays']))
{
echo '
    <table cols=2>';

if ($show_titles)
{
echo '
<tr>
                        <td colspan="2">
<strong>', $txt['sp_calendar_birthdays'] ,'</strong>
</td>
</tr>
                    ';
            }

        foreach ($calendar_array['todayBirthdays'] as $member)
    echo '
        <tr>
                            <td style="width:16px">',
                                sp_embed_image('birthday'),'
                            </td>
                            <td style=align:left">
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>
                            </td>
        </tr>
        ';
echo '
</table>
    ';
}

/*
if (!empty($calendar_array['todayEvents']))
{
if ($show_titles)
echo '
<li><strong>', $txt['sp_calendar_events'] ,'</strong></li>';

foreach ($calendar_array['todayEvents'] as $event)
echo '
<li>', sp_embed_image('event'), ' ', $event['link'], !$show_titles ? ' - ' . timeformat(forum_time(), '%d %b') : '', '</li>';
}
*/

/* mod DiSc */
if (!empty($calendar_array['todayEvents']))
{
echo '
    <table cols=2>';

if ($show_titles)
{
echo '
<tr>
                        <td colspan="2">
<strong>', $txt['sp_calendar_events'] ,'</strong>
</td>
</tr>
                    ';
            }

        foreach ($calendar_array['todayEvents'] as $event)
    echo '
        <tr>
                            <td style="width:16px">',
                                sp_embed_image('event'),'
                            </td>
                            <td style=align:left">',
                                $event['link'],'
                            </td>
        </tr>
        ';
echo '
</table>
    ';
}

        /*
if (!empty($calendar_array['futureEvents']))
{
if ($show_titles)
echo '
<li><strong>', $txt['sp_calendar_upcomingEvents'] ,'</strong></li>';

foreach($calendar_array['futureEvents'] as $startdate => $events)
{
list($year, $month, $day) = explode('-', $startdate);
$currentDay = $day . '. ' . $txt['months_short'][(int) $month];

foreach($events as $event)
echo '
<li>', sp_embed_image('event'), ' ', $event['link'], ' - ', $currentDay;
}
}
*/
/* mod DiSc */
if (!empty($calendar_array['futureEvents']))
{
echo '
    <table cols=2>';
   
if ($show_titles)
{
echo '
<tr>
                        <td colspan="2">
<strong>', $txt['sp_calendar_upcomingEvents'] ,'</strong>
</td>
</tr>
                    ';
            }
foreach($calendar_array['futureEvents'] as $startdate => $events)
{
list($year, $month, $day) = explode('-', $startdate);
$currentDay = $day . '. ' . $txt['months_short'][(int) $month];

foreach($events as $event)
{
    list($year, $month, $day) = explode('-', $event['start_date']);
        $firstDay = $day . '. ' . $txt['months_short'][(int) $month];
                list($year, $month, $day) = explode('-', $event['end_date']);
      $lastDay = $day . '. ' . $txt['months_short'][(int) $month];

    if (!in_array($event['id'],$shown))
    {
        array_push($shown,$event['id']);
        echo '
          <tr>
                             <td style="width:16px">',
                                    sp_embed_image('event'),'
                                </td>
                                <td>',
                                    $event['link'],'<br />',
                                    $event['start_date'] != $event['end_date'] ? $firstDay. ' - ' . $lastDay : $txt['sp-dateat'] . $currentDay,'   
                                </td>
          </tr>
            ';
        /*
        echo '
          <tr>
                             <td style="width:16px">',
                                    sp_embed_image('event'),'
                                </td>
                                <td>',
                                    //$event['link'], '<br />', $currentDay,'
                                    $event['link'],'
                                </td>
          </tr>
          <tr>
                             <td style="width:16px">&nbsp;</td>
                                <td  style="vertical-align:top">',
                                    $event['start_date'] != $event['end_date'] ? $firstDay. ' - ' . $lastDay : $txt['sp-dateat'] . $currentDay,'   
                                </td>
          </tr>
            ';
            */
            }
            }
        }
echo '
</table>
    ';
}




        /*
echo '
</ul>';
*/
}
}

Not to forget, there is also a new language text entry needed:
Code: [Select]
$txt['sp-dateat'] = 'at ';

Kind regards, Dirk

p.s. Special regards to Eliana ;)

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Modified CalendarInformation block
« Reply #1 on: May 08, 2009, 06:49:49 AM »
First of all; welcome to SimplePortal!

1. Actually lists are the -semantically- most appropriate tags to use when listing events. However, the issue arises from the image not being a bullet icon, but an image. This was designed in this way so that there could be a fallback to default. If you are happy with your result, that's great.

2. That issue was reported sometime ago here and a fix is included. It will be fixed with the 2.2.1 version.

P.S. I hope that "regards" is not for something you shouldn't have seen. :P
And slowly, you come to realize... It's all as it should be...

Offline Hannilein

  • Semi Newbie
  • *
  • Posts: 14
  • Gender: Male
    • Homepage
  • SMF Version: 1.1.10
  • SP Version: 2.3.1
Re: Modified CalendarInformation block
« Reply #2 on: May 08, 2009, 07:13:41 AM »
Thank your for welcoming and your reply.

1. Actually lists are the -semantically- most appropriate tags to use when listing events. However, the issue arises from the image not being a bullet icon, but an image. This was designed in this way so that there could be a fallback to default. If you are happy with your result, that's great.
I found this behaviour (bad line breaks in lists) also in other block (e.g. 'Top Posters') and modified it also. Works fine for me, although maybe there will be some issues with upgrading later (?) :0

Quote
2. That issue was reported sometime ago here and a fix is included. It will be fixed with the 2.2.1 version.
Sorry for missing it. Certainly my mod and this fix will do almost the same, but I like also the displaying of the duration of the event :D

Quote
P.S. I hope that "regards" is not for something you shouldn't have seen. :P
I will not squeal about  ;P

Regards,
Dirk

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Modified CalendarInformation block
« Reply #3 on: May 09, 2009, 05:16:08 AM »
Quote
I found this behaviour (bad line breaks in lists) also in other block (e.g. 'Top Posters') and modified it also. Works fine for me, although maybe there will be some issues with upgrading later (?) :0

Top Posters block uses tables. So it should be fine I guess. Would you provide a screen shot?

No, you won't have issues. Except that you'll loose the changes you made in SimplePortal source files, including this. I can suggest that you add these codes as a PHP block and you won't loose them on upgrades.

Quote
I will not squeal about  ;P

Okay, no problems then. :D
And slowly, you come to realize... It's all as it should be...

Offline Hannilein

  • Semi Newbie
  • *
  • Posts: 14
  • Gender: Male
    • Homepage
  • SMF Version: 1.1.10
  • SP Version: 2.3.1
Re: Modified CalendarInformation block
« Reply #4 on: May 09, 2009, 05:38:51 AM »
Top Posters block uses tables. So it should be fine I guess. Would you provide a screen shot?
Oh sorry, my mistake. You see I'm already confused about my changes  ;) . I modified it to remove displaying the resized avatars, because my forum is hosted by a free hoster and there dynamically resized (also with "<img width=...") images are forbidden  :'(

For a live demo (instead of screenshot) please click the link to my little forum in my signature. The 'TopPosters' block is named "Schreiber der Woche" and the 'CalendarInformation' is named "Ereignisse".

Kind regards,
Dirk

Offline [SiNaN]

  • Mr. SimplePortal
  • Developer
  • *
  • Posts: 6782
  • SMF Version: 2.0.15
  • SP Version: 2.3.7
Re: Modified CalendarInformation block
« Reply #5 on: May 09, 2009, 05:47:55 AM »
I see you turned them into a regular list. I was curious if it was an error at SP end.
And slowly, you come to realize... It's all as it should be...