00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00037 class Event
00038 {
00039 var $id;
00040 var $parentConvention;
00041
00042 var $title;
00043 var $blurb;
00044 var $description;
00045
00046 var $hotelID;
00047 var $floorID;
00048 var $roomID;
00049
00050 var $owner;
00051 var $startTime;
00052 var $duration;
00053 var $customClass;
00054
00062 function Event( $parentConvention, $id = NULL )
00063 {
00064 $this->parentConvention = &$parentConvention;
00065 $this->id = $id;
00066
00067 if( $this->id !== NULL )
00068 $this->load();
00069 }
00070
00071 function load()
00072 {
00073 $filename = $this->parentConvention->conventionBasedir . "/events/" . $this->id . ".php";
00074
00075 if( file_exists( $filename ) )
00076 include( $filename );
00077
00078 foreach( $settings as $key => $value )
00079 $this->$key = $value;
00080 }
00081
00082 function save()
00083 {
00084 $basedir = $this->parentConvention->conventionBasedir . "/events";
00085 if( ! file_exists( $basedir ) )
00086 mkdir( $basedir );
00087
00088 $filename = $basedir . "/" . $this->id . ".php";
00089 if( file_exists( $filename ) )
00090 unlink( $filename );
00091
00092 $settings["name"] = $this->name;
00093 $settings["blurb"] = $this->blurb;
00094 $settings["description"] = $this->description;
00095 $settings["hotelID"] = $this->hotelID;
00096 $settings["floorID"] = $this->floorID;
00097 $settings["roomID"] = $this->roomID;
00098 $settings["owner"] = $this->owner;
00099 $settings["startTime"] = $this->startTime;
00100 $settings["duration"] = $this->duration;
00101 $settings["customClass"] = $this->customClass;
00102
00103 file_put_contents( $filename, array_export( $settings, "settings" ) );
00104 }
00105
00106 function renderEditor($editThis)
00107 {
00108
00109 $i = 0;
00110 foreach( $this->parentConvention->hotels as $hotelID => $hotel )
00111 {
00112 foreach( $this->parentConvention->hotels[$hotelID]->floors as $floorID => $floor )
00113 {
00114 foreach( $this->parentConvention->hotels[$hotelID]->floors[$floorID]["rooms"] as $roomID => $room )
00115 {
00116 if( $room["eventspace"] > 0 )
00117 {
00118 $eventrooms[$i] = array( "hotelID" => $hotelID, "floorID" => $floorID, "roomID" => $roomID, "room" => &$this->parentConvention->hotels[$hotelID]->floors[$floorID]["rooms"][$roomID] );
00119 if( $hotelID == $this->hotelID && $floorID == $this->floorID && $roomID == $this->roomID )
00120 $thisRoom = $i;
00121 $i++;
00122 }
00123 }
00124 }
00125 }
00126
00127 for( $i = $this->parentConvention->eventLapse ; $i <= 1440 ; $i = $i + $this->parentConvention->eventLapse )
00128 {
00129 if( $i < 60 )
00130 $eventLapses[$i] = i18n( "##0## minutes", array($i) );
00131 else
00132 {
00133 $hours = floor( $i / 60 );
00134 $minutes = $i % 60;
00135 if( $minutes < 1 )
00136 $eventLapses[$i] = i18n( "##0## hours", array( $hours ) );
00137 else
00138 $eventLapses[$i] = i18n( "##0##:##1## hours", array( $hours, $minutes ) );
00139 }
00140 }
00141
00142 foreach( $eventrooms as $key => $value )
00143 $rooms[$key] = $value["room"]["name"];
00144
00145 $panel = new optionsPanel("editevent");
00146 $panel->showHeader = false;
00147 $panel->saveTitle = i18n("Save event");
00148 $panel->revertTitle = i18n("Revert to saved");
00149
00150 $panel->addOption( i18n("Name"), i18n("The title text which will be shown in the table view"), $this->name, "name", "text" );
00151 $panel->addOption( i18n("Blurb"), i18n("A text which will be used for both a link tooltip and the first, bolded paragraph of the full description"), $this->blurb, "blurb", "textbox" );
00152 $panel->addOption( i18n("Event room"), i18n("In which room will this event take place?"), $thisRoom, "room", "select", $rooms );
00153 $panel->addOption( i18n("Owner"), i18n("The person responsible for this event"), $this->owner, "owner", "select", allUsersArray( true, true ) );
00154 $panel->addOption( i18n("Custom CSS class"), i18n("An optional extra CSS class to set for the cell containing this event in the overview table"), $this->customClass, "customClass", "text" );
00155 $panel->addOption( i18n("Start time"), i18n("When the event starts"), $this->startTime, "startTime", "datetime" );
00156 $panel->addOption( i18n("Duration"), i18n("How long the event goes on for"), $this->duration, "duration", "select", $eventLapses );
00157 $panel->addOption( i18n("Long description"), "", $this->description, "description", "pagedata" );
00158
00159 if( $panel->submitted )
00160 {
00161 $this->name = $panel->options["name"]["current"];
00162 $this->blurb = $panel->options["blurb"]["current"];
00163 $this->description = $panel->options["description"]["current"];
00164 $this->hotelID = $eventrooms[$panel->options["room"]["current"]]["hotelID"];
00165 $this->floorID = $eventrooms[$panel->options["room"]["current"]]["floorID"];
00166 $this->roomID = $eventrooms[$panel->options["room"]["current"]]["roomID"];
00167 $this->owner = $panel->options["owner"]["current"];
00168 $this->startTime = $panel->options["startTime"]["current"];
00169 $this->duration = $panel->options["duration"]["current"];
00170 $this->customClass = $panel->options["customClass"]["current"];
00171 $this->save();
00172 header( "Location: " . globalIDtoURL("$editThis/events") );
00173 }
00174
00175 return renderInformationBox( i18n("Create new event"), $panel->render(), false );
00176 }
00177
00178 function renderLink( $globalID )
00179 {
00180 if( $globalID != "convention/events" )
00181 $link = $this->name . "\n"
00182 . drawCommand( i18n("Edit"), i18n("Edit this event"), globalIDtoURL( "$globalID/" . $this->id ) ) . " "
00183 . drawCommand( i18n("Delete"), i18n("Delete this event"), globalIDtoURL( "$globalID/" . $this->id . "/delete" ) );
00184 else
00185 $link = "<a href=\"" . globalIDtoURL( "convention/events/" . $this->id ) . "\" class=\"convention-events-link\">" . $this->name . "</a>";
00186
00187 return $link;
00188 }
00189
00190 function render($editThis = false)
00191 {
00192 if( $editThis != false )
00193 $renderedData = $this->renderEditor( $editThis );
00194 else
00195 {
00196 $renderedData = "<div class=\"wikirightalign\">" . drawCommand( i18n( "##0## Back", array("«") ), i18n("Return to the events main page"), globalIDtoURL("convention/events") ) . "</div>";
00197 $renderedData .= "<h2 class=\"convention-events-title\">" . $this->name . "<h2>";
00198 $renderedData .= "<div class=\"convention-events-blurb\">" . $this->blurb . "</div>";
00199 $renderedData .= "<div class=\"convention-events-description\">" . parse_page_data($this->description) . "</div>";
00200 $renderedData .= "<h3 class=\"convention-events-owner\">" . i18n("This event is run by") . "</h3>";
00201
00202
00203
00204 $avatarthumbfile = getAvatarThumbnail( $this->owner );
00205 list($avatarwidth,$avatarheight) = getimagesize($avatarthumbfile);
00206 $avatarthumbfile = siteURL(true) . $avatarthumbfile;
00207
00208 $renderedData .= "<div class=\"convention-events-owner\"><a class=\"convention-events-owner\" href=\"" . globalIDtoURL( "user/" . $this->owner ) . "\"><img border=\"0\" src=\"$avatarthumbfile\" width=\"$avatarwidth\" height=\"$avatarheight\" /><br />" . getUserInfo( $this->owner, "name" ) . "</a></div>";
00209 }
00210
00211 return $renderedData;
00212 }
00213
00214 }
00215 ?>