Vanilla 1 is no longer supported or maintained. If you need a copy, you can get it here.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Help needed with Countdown Calendar extension
This discussion has been closed.
Comments
If I leave it as it is, will it work in both 1.0 and 1.0.1? If so, I'd like to keep it that way if possible I think ;o
I add that to my extensions to to be sure people know they need Vanilla 1.0.1:
// check if you have the right version of vanilla for this add-on if (!version_compare(APPLICATION_VERSION, '1.0.1', '>=')) { //Language definitions for vanilla 1.0 $Context->Dictionary['EmailVerification_ErrVanillaVersion'] = 'Vanilla 1.0.1 or higher is required for the Applicant Email Verification'; //display an error message on the extension page and registration page when the extension is used with Vanilla 1.0.0 if ( $Context->SelfUrl == 'settings.php' && in_array(ForceIncomingString('PostBackAction', ''), array('Extensions', 'RegistrationChange')) ) $Context->WarningCollector->Add($Context->GetDefinition('EmailVerification_ErrVanillaVersion')); } else { ... // my script here
"Taking Names, BWP and All City Uproar", 1161070200, "Le Pub, Newport", "http://www.glosunit.co.uk/discussion/1758/"
Which of course should show up today @ 7:30pm, and give me a nice countdown to it, but for some reason it's not appearing at all and I can't see a problem in either that line of csv, nor the code itself:
<?php /* Extension Name: Gig Calendar Extension Url: http://lussumo.com/community/discussion/3446/ Description: Shows upcoming gigs Version: 1.0 Author: Nick Drew Author Url: http://www.glosunit.co.uk Comments: Huge thanks to SirNot, jimw, Minisweeper ... etc */ $Context->Configuration['PREFERENCE_CalendarEnabled'] = 1; $Context->Dictionary['EnableCalendar'] = 'Enable the gig calendar?'; $Context->AddToDelegate('PreferencesForm', 'Constructor', 'GigCalender_Preferences'); function GigCalender_Preferences(&$Prefs) { if($Prefs->IsPostBack) $Prefs->AddPreference('Calendar', 'EnableCalendar', 'CalendarEnabled'); } if($Context->Session->User->Preference('CalendarEnabled')) { if(!isset($Panel)) return; $Panel->AddList('Gig Calendar', 200); $fp = fopen('extensions/Calendar/cal.txt', 'rb'); // Reads the text file if(!$fp) return; while ($row = fgetcsv($fp, 1000)) { list($title, $date, $venue, $url) = $row; $diff = $date - time(); $diff = $diff + 3600; // Ammendment made due to server being one hour out of synch if ($diff >= 2592000) // Checks if the time difference is more than a month (roughly translated as 30 days) { $diff = $diff / 2592000; $diff = round($diff); if ($diff < 2) // if there's only one month left, will remove the 's' after month $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>1 month left, at '.$venue.'</i></font>', $url); else $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>'.$diff.' months left, at '.$venue.'</i></font>', $url); } else if ($diff >= 86400 and $diff < 2592000) // Checks if the time difference is more than a day { $diff = $diff / 86400; $diff = round($diff); if ($diff < 2) // if there's only one day left, will remove the 's' after day $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>1 day left, at '.$venue.'</i></font>', $url); else $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>'.$diff.' days left, at '.$venue.'</i></font>', $url); } else if ($diff > 0 and $diff < 86400 ) // Checks if the time difference is less than a day { $diff = $diff / 3600; $diff = round($diff); if ($diff < 2) // if there's only one hour left, will remove the 's' after hour $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>1 hour left, at '.$venue.'</i></font>', $url); else $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>'.$diff.' hours left, at '.$venue.'</i></font>', $url); } } fclose($fp); } ?>
list($month, $day, $year, $hour, $minute, $second ) = sscanf($date, "%d/%d/%d %d:%d:%d");
$curdate = mktime( $hour, $minute, $second, $month, $day, $year );
$diff = $curdate - time(); // the number of hours
In the cal.txt file, I would have the event time in the format like 10/17/06 15:30.
list($title, $date, $venue, $url) = $row; $diff = $date - time();
Reads...
list($month, $day, $year, $hour, $minute, $second ) = sscanf($date, "%d/%d/%d %d:%d:%d"); $curdate = mktime( $hour, $minute, $second, $month, $day, $year ); $diff = $curdate - time(); // the number of hours
Thanks!
<?php /* Extension Name: Gig Calendar Extension Url: http://lussumo.com/community/discussion/3446/ Description: Shows upcoming gigs Version: 1.0 Author: Nick Drew Author Url: http://www.glosunit.co.uk Comments: Huge thanks to SirNot, jimw, Minisweeper and the guys from #php on Efnet for making this possible. */ $Context->Configuration['PREFERENCE_CalendarEnabled'] = 1; $Context->Dictionary['EnableCalendar'] = 'Enable the gig calendar?'; $Context->AddToDelegate('PreferencesForm', 'Constructor', 'GigCalender_Preferences'); function GigCalender_Preferences(&$Prefs) { if($Prefs->IsPostBack) $Prefs->AddPreference('Calendar', 'EnableCalendar', 'CalendarEnabled'); } if($Context->Session->User->Preference('CalendarEnabled')) { if(!isset($Panel)) return; $Panel->AddList('Gig Calendar', 200); $fp = fopen('extensions/Calendar/cal.txt', 'rb'); // Reads the text file if(!$fp) return; while ($row = fgetcsv($fp, 1000)) { list($title, $date, $venue, $url) = $row; list($month, $day, $year, $hour, $minute, $second ) = sscanf($date, "%d/%d/%d %d:%d:%d"); $curdate = mktime( $hour, $minute, $second, $month, $day, $year ); $diff = $curdate - time(); // the number of hours if ($diff >= 2592000) // Checks if the time difference is more than a month (roughly translated as 30 days) { $diff = $diff / 2592000; $diff = round($diff); if ($diff < 2) // if there's only one month left, will remove the 's' after month, got to be grammatically correct eh? $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>1 month left, at '.$venue.'</i></font>', $url); else $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>'.$diff.' months left, at '.$venue.'</i></font>', $url); } else if ($diff >= 86400 and $diff < 2592000) // Checks if the time difference is more than a day { $diff = $diff / 86400; $diff = round($diff); if ($diff < 2) // if there's only one day left, will remove the 's' after day, got to be grammatically correct eh? $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>1 day left, at '.$venue.'</i></font>', $url); else $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>'.$diff.' days left, at '.$venue.'</i></font>', $url); } else if ($diff > 0 and $diff < 86400 ) // Checks if the time difference is less than a day { $diff = $diff / 3600; $diff = round($diff); if ($diff < 2) // if there's only one hour left, will remove the 's' after hour, got to be grammatically correct eh? $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>1 hour left, at '.$venue.'</i></font>', $url); else $Panel->AddListItem('Gig Calendar', ''.$title.'<br><font color="#999999"><i>'.$diff.' hours left, at '.$venue.'</i></font>', $url); } } fclose($fp); } ?>
One of my own personal little crusades By all means allow the display in whatever format you like, but please make sure your extensions use this internally so that it can at least talk to other things in a universally understood format.