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: 355
  • 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: Código para adicionar o calendário do fórum ao seu Portal  (Read 21779 times)

0 Members and 1 Guest are viewing this topic.

Offline Costa

  • Full Member
  • ***
  • Posts: 246
  • Gender: Male
  • Don't feed the trolls...
Código para adicionar o calendário do fórum ao seu Portal
« on: November 01, 2008, 10:19:26 AM »
Criem um bloco de PHP e insiram o seguinte código:

Code: [Select]
$now = mktime();
         $today = date('j',$now);
         $year = date("Y",$now);
         $month = date("n",$now);
         $days = array($today=>array(NULL,NULL,'<a class="smalltext" style="color: steelblue; font-weight: bold; border: solid 1px black; background-color: white; padding: 0px 4px 0px 4px;" href="'.$scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today.'" target="_self">'.$today.'</a>'));

         $day_name_length = 3;
         $month_href = $scripturl . '?action=calendar';
         $first_day = 1;
         $pn = array();

$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

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)).' '.$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="smalltext">'.($pl ? '<a href="'.htmlspecialchars($pl).'">'.$p.'</a>' : $p).'</span> ';
if($n) $n = ' <span class="smalltext">'.($nl ? '<a href="'.htmlspecialchars($nl).'">'.$n.'</a>' : $n).'</span>';
$calendar = '<table>'."\n".
'<caption >'.$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 class="smalltext" abbr="'.htmlentities($d).'">'.htmlentities($day_name_length < 4 ? substr($d,0,$day_name_length) : $d).'</th>';
$calendar .= "</tr>\n<tr style=\"text-align:right;\">";
}

if($weekday > 0) $calendar .= '<td class="smalltext" colspan="'.$weekday.'"> </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 style=\"text-align:right;\">";
}
if(isset($days[$day]) and is_array($days[$day])){
@list($link, $classes, $content) = $days[$day];
if(is_null($content))  $content  = $day;
$calendar .= '<td "'.($classes ? ' class="'.htmlspecialchars($classes).'">' : '>').
($link ? '<a href="'.htmlspecialchars($link).'">'.$content.'</a>' : $content).'</td>';
}
else
{
$calendar .= "<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0)||((($weekday+$first_day) % 7)==6))
{
$calendar .= ' style="color:#C00000;"';
}
$calendar .= " href=\"".$scripturl."?action=calendar;sa=post;month=".$month.";year=".$year.";day=".$day."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; #remaining "empty" days

echo $calendar."</tr>\n</table>\n";

Este código irá "ler" o calendário do seu fórum.
O resultado está abaixo


Farebem
- Costa
« Last Edit: November 05, 2008, 02:08:37 PM by Costa »
Hugo "Costa" FernandesCrudelius est quam semper mortem timere

Offline Costa

  • Full Member
  • ***
  • Posts: 246
  • Gender: Male
  • Don't feed the trolls...
Re: Código para adicionar o calendário do fórum ao seu Portal
« Reply #1 on: November 10, 2008, 12:02:34 PM »
Um pequeno update
Agradecimentos a ???1031

Code: [Select]
/*
Calender DIN1031 Version 08-11-2008-1
This is a costumizable calendar php block
It will show a calendar, and add the Today Events, Holidays and Birthdays.
Normal it's programmed and tested for SMF 1.1.X
I don't use any SSI.php, because all data that needed is loaded.
*/
global $scripturl, $modSettings, $sourcedir, $txt;

//With that you can start the calander on a other day
//-1 = Start on Saturaday, 0 = Start on Sunday, 1 = Start on Monday, 2 = Start on Thusday...
$first_day = 1;

//How long should the day, if the number higher 3 than the complete dayname will be shown
$day_name_length = 0; //0 is short day name 1 is full day name :)

//The background color of days with Events, birthdays or holidays, you can use css colors
$color_background_items_mixed = 'lightblue';
$color_background_items_event = 'lightblue';
$color_background_items_birthday = 'lightblue';
$color_background_items_holiday = 'lightblue';

//The textcolor of days with Events, birthdays or holidays, you can use css colors
$color_text_items_mixed = 'steelblue';
$color_text_items_event = 'steelblue';
$color_text_items_birthday = 'steelblue';
$color_text_items_holiday = 'steelblue';

//The Color of the todays background / text
$color_background_today = 'white';
$color_text_today = 'green';

//The Textcolor for the standard days
$color_text = 'steelblue';

//The Textcolor for the Sundays
$color_text_sunday = '#C00000';

//If you have a diffrent calender you can change the link to it here
$month_href = $scripturl . '?action=calendar';

//What should the callendar show?
$show_events = 1; //0 No, 1 Yes
$show_birthdays = 1; //0 No, 1 Yes
$show_holidays = 1; //0 No, 1 Yes
//Show the single events and items of the day :)
$show_today = 1; //0 No, 1 Yes

//Okay please don't do anything here if you not now what you do
/**************************************************************/
// You can't do anything if the calendar is off!
if (empty($modSettings['cal_enabled']))
fatal_lang_error('calendar_off', false);

$now = mktime() + $modSettings['time_offset'] * 3600;
$today = date('j',$now);
$year = date("Y",$now);
$month = date("n",$now);
$days = array();
$pn = array();

$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()
*/

//retrieve this month events, holydays and birthdays
$days_in_month = gmdate('t',$first_of_month);
include_once($sourcedir . '/Calendar.php');
$low_date = $year.'-'.$month.'-01';
$high_date = $year.'-'.$month.'-'.$days_in_month;
$can_post_calendar = allowedTo('calendar_post');
$calendarDataToday = array('events' => array(), 'birthdays' => array(), 'holidays' => array());
$todayDate = date("Y-m-d", time());

//add important days to the days array
if(!empty($show_events)) {
$events = calendarEventArray($low_date, $high_date);
foreach($events as $startdate => $event) {
//This insert the today events if they exist
if($todayDate == $startdate)
$calendarDataToday['events'] = $event;
$cday = (int) substr($startdate,8,2);
//We must select between create or only show!
$href_calendar = $can_post_calendar && $cday >= $today ? $scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday : $scripturl.'?action=calendar';
$days[$cday] = '<a class="smalltext" style="color: '.$color_text_items_event.'; font-weight: bold; background-color: '.$color_background_items_event.'; padding: 0px 4px 0px 4px;" href="'.$href_calendar.'" target="_self">'.$cday.'</a>';
}
}
//Add holidays into the day array?
if(!empty($show_birthdays)) {
$birthdays = calendarBirthdayArray($low_date, $high_date);
foreach($birthdays as $startdate => $birth) {
//This insert the today events if they exist
if($todayDate == $startdate)
$calendarDataToday['birthdays'] = $birth;
$cday = (int) substr($startdate,8,2);
//We must select between create or only show!
$href_calendar = $can_post_calendar && $cday >= $today ? $scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday : $scripturl.'?action=calendar';
//Mixed color?
$text_color = !empty($days[$cday]) ? $color_text_items_mixed : $color_text_items_birthday;
$background_color = !empty($days[$cday]) ? $color_background_items_mixed : $color_background_items_birthday;
$days[$cday] = '<a class="smalltext" style="color: '.$text_color.'; font-weight: bold; background-color: '.$background_color.'; padding: 0px 4px 0px 4px;" href="'.$href_calendar.'" target="_self">'.$cday.'</a>';
}
}
//Add holidays into the day array?
if(!empty($show_holidays)) {
$holidays = calendarHolidayArray($low_date, $high_date);
foreach($holidays as $startdate => $holiday) {
//This insert the today events if they exist
if($todayDate == $startdate)
$calendarDataToday['holidays'] = $holiday;
$cday = (int) substr($startdate,8,2);
//We must select between create or only show!
$text_color = !empty($days[$cday]) ? $color_text_items_mixed : $color_text_items_holiday;
$background_color = !empty($days[$cday]) ? $color_background_items_mixed : $color_background_items_holiday;
$href_calendar = $can_post_calendar && $cday >= $today ? $scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$cday : $scripturl.'?action=calendar';
$days[$cday] = '<a class="smalltext" style="color: '.$text_color.'; font-weight: bold; background-color: '.$background_color.'; padding: 0px 4px 0px 4px;" href="'.$href_calendar.'" target="_self">'.$cday.'</a>';
}
}

//So Todays it's an diffrent color :D
$href_calendar = $can_post_calendar ? $scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$today : $scripturl.'?action=calendar';
$days[$today] = '<a class="smalltext" style="color: '.$color_text_today.'; font-weight: bold; border: solid 1px black; background-color: '.$color_background_today.'; padding: 0px 4px 0px 4px;" href="'.$href_calendar.'" target="_self">'.$today.'</a>';

//Wellcome to the smf way of Day building with existing Language strings :D
$day_names = $txt['days'];
$day_names_short = $txt['days_short'];
//So lets see $firstday = 0 means sunday this is the first day :)
//if there is a higher number than i need to resort them
//negativ values can also be used :)
if(!empty($first_day)) {
if($first_day < 0)
$first_day = 7-(abs($first_day)%7);
else
$first_day = ($first_day%7);
}
if(!empty($first_day)) {
$old = $day_names;
$old_s = $day_names_short;
$day_names = array();
$day_names_short = array();
//Create the new day order :)
for($n=0; $n<7; $n++) {
$c = (($first_day+$n)%7);
$day_names[$n] = $old[$c];
$day_names_short[$n] = $old_s[$c];
}
}

list($month, $year, $weekday) = explode(',',gmstrftime('%m,%Y,%w',$first_of_month));
$weekday = ($weekday + 7 - $first_day) % 7; //adjust for $first_day
$title = $txt['months_titles'][$month].' '.$year;  //This is the SMF Text string, so it should be corrected for ut8 or iso

/* Begin calendar. Uses a real <caption>. See http://diveintomark.org/archives/2002/07/03 */
$calendar = '
<table>
<caption>'.($month_href ? '<a href="'.htmlspecialchars($month_href).'">'.$title.'</a>' : $title)."</caption>
<tr>";

//Put out the Daynames :)
foreach($day_names as $k => $d)
$calendar .= '
<th class="smalltext" abbr="'.$d.'">'.(!empty($day_name_length) ? $d : $day_names_short[$k]).'</th>';
$calendar .= "
</tr>
<tr style=\"text-align:right;\">";

if($weekday > 0) $calendar .= '
<td class="smalltext" colspan="'.$weekday.'"> </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>
<tr style=\"text-align:right;\">";
}
if(isset($days[$day])){
$calendar .= '
<td>'.$days[$day].'</td>';
}
else
{
$href_calendar = $can_post_calendar && $day >= $today ? $scripturl.'?action=calendar;sa=post;month='.$month.';year='.$year.';day='.$day : $scripturl.'?action=calendar';
$calendar .= "
<td class=\"smalltext\" style=\"padding-right:4px;\"><a";
if(((($weekday+$first_day) % 7)==0))
{
$calendar .= ' style="color:'.$color_text_sunday.';"';
}
$calendar .= " href=\"".$href_calendar."\" target=\"_self\">$day</a></td>";
}
}
if($weekday != 7) $calendar .= '
<td class="smalltext" colspan="'.(7-$weekday).'"> </td>'; //remaining "empty" days

echo $calendar.'
</tr>';


if (!empty($show_today) && (!empty($calendarDataToday['events']) || !empty($calendarDataToday['birthdays']) || !empty($calendarDataToday['holidays']))) {

if(!empty($calendarDataToday['holidays'])){
echo '
<tr><td>
<hr />
</td>
<td colspan="5" class="smalltext" align="center" style="color: ' . $color_text_items_holiday . ';">
<b>Holidays</b>
</td><td>
<hr />
</td>
</tr>
<td colspan="7" class="smalltext">';
foreach( $calendarDataToday['holidays'] as $holiday )
echo '
', $holiday['name'], '<br />';
echo '
</td></tr>';
}

if(!empty($calendarDataToday['birthdays'])){
echo '
<tr><td>
<hr />
</td>
<td colspan="5" class="smalltext" align="center" style="color: ' . $color_text_items_birthday . ';">
<b>Aniversários</b>
</td><td>
<hr />
</td></tr>
<td colspan="7" class="smalltext">';
foreach( $calendarDataToday['birthdays'] as $member )
echo '
<a href="', $scripturl, '?action=profile;u=', $member['id'], '">', $member['name'], isset($member['age']) ? ' (' . $member['age'] . ')' : '', '</a>', '<br />';
echo '
</td></tr>';
}

if(!empty($calendarDataToday['events']))
{
echo '
<tr><td>
<hr />
</td>
<td colspan="5" class="smalltext" align="center" style="color: ' . $color_text_items_event . ';">
<b>Eventos</b>
</td><td>
<hr />
</td></tr>
<td colspan="7" class="smalltext">';
foreach ($calendarDataToday['events'] as $event)
{
if ($event['can_edit'])
echo '
<a href="' . $event['modify_href'] . '" style="color: #FF0000;">*</a> ';
echo '
' . $event['link'] . '<br />';
}
}
  echo '
  </td></tr>';
}

echo '
</table>';
Hugo "Costa" FernandesCrudelius est quam semper mortem timere

Offline mariluz

  • Semi Newbie
  • *
  • Posts: 30
Re: Código para adicionar o calendário do fórum ao seu Portal
« Reply #2 on: November 16, 2008, 04:40:52 PM »
 :D

Este novo dá para o smf 1.1.6 ?
Obrigado

Offline Costa

  • Full Member
  • ***
  • Posts: 246
  • Gender: Male
  • Don't feed the trolls...
Re: Código para adicionar o calendário do fórum ao seu Portal
« Reply #3 on: November 16, 2008, 05:08:56 PM »
Dápara qqer SMF 1.1x
Hugo "Costa" FernandesCrudelius est quam semper mortem timere

Offline mariluz

  • Semi Newbie
  • *
  • Posts: 30
Re: Código para adicionar o calendário do fórum ao seu Portal
« Reply #4 on: November 20, 2008, 05:01:52 PM »
 ;)
Amigo instalei o novo... mas não aparece como mostra na imagem.
Alguma ideia?

Offline Costa

  • Full Member
  • ***
  • Posts: 246
  • Gender: Male
  • Don't feed the trolls...
Re: Código para adicionar o calendário do fórum ao seu Portal
« Reply #5 on: November 21, 2008, 06:47:05 AM »
abris-te um bloco de php?
Hugo "Costa" FernandesCrudelius est quam semper mortem timere

Offline mariluz

  • Semi Newbie
  • *
  • Posts: 30
Re: Código para adicionar o calendário do fórum ao seu Portal
« Reply #6 on: November 22, 2008, 07:19:05 AM »
 :D

Olá Amigo
Pois eu até utilizei o mesmo bloco que tinha... apenas substitui.
Mas vou tentar abrindo um novo e por lá...