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 Hotel
00038 {
00039 var $id;
00040 var $parentConvention;
00041
00042 var $name;
00043 var $description;
00044 var $longDescription;
00045
00046 var $floors;
00047
00048
00049
00050
00051 var $averagePerRoom;
00052
00060 function Hotel( $parentConvention, $id = NULL )
00061 {
00062 $this->parentConvention = &$parentConvention;
00063 $this->id = $id;
00064
00065 if( $this->id !== NULL )
00066 $this->load();
00067 }
00068
00069 function load()
00070 {
00071 $filename = $this->parentConvention->conventionBasedir . "/hotels/" . $this->id . ".php";
00072
00073 if( file_exists( $filename ) )
00074 include( $filename );
00075
00076 foreach( $settings as $key => $value )
00077 $this->$key = $value;
00078
00079 if( !is_array( $this->floors ) )
00080 $this->floors = array();
00081 }
00082
00083 function save()
00084 {
00085 $basedir = $this->parentConvention->conventionBasedir . "/hotels";
00086 if( ! file_exists( $basedir ) )
00087 mkdir( $basedir );
00088
00089 $filename = $basedir . "/" . $this->id . ".php";
00090 if( file_exists( $filename ) )
00091 unlink( $filename );
00092
00093 $settings["name"] = $this->name;
00094 $settings["description"] = $this->description;
00095 $settings["longDescription"] = $this->longDescription;
00096 $settings["floors"] = $this->floors;
00097 $settings["rooms"] = $this->rooms;
00098 $settings["beds"] = $this->beds;
00099
00100 file_put_contents( $filename, array_export( $settings, "settings" ) );
00101 }
00102
00103 function renderEditor()
00104 {
00105 global $conventionSettings, $globalID, $usermanager;
00106
00107 $splitID = explode( "/", $globalID );
00108
00109 if( $splitID[3] == "cons" )
00110 {
00111 $thisGlobalID = "setup/modulesetup/convention/cons/" . $this->parentConvention->id . "/hotels/" . $this->id;
00112 $editFloor = $splitID[7];
00113 $editRoom = $splitID[8];
00114 $editBed = $splitID[9];
00115 $bedAction = $splitID[10];
00116 }
00117 else
00118 {
00119 $thisGlobalID = "setup/modulesetup/convention/hotels/" . $this->id;
00120 $editFloor = $splitID[5];
00121 $editRoom = $splitID[6];
00122 $editBed = $splitID[7];
00123 $bedAction = $splitID[8];
00124 }
00125
00126 if( is_numeric( $editFloor ) )
00127 {
00128 if( is_numeric( $editRoom ) )
00129 {
00130 if( is_numeric( $editBed ) )
00131 {
00132 if( $bedAction == "delete" )
00133 {
00134 $panel = new optionsPanel("beddelete");
00135 $panel->showHeader = false;
00136 $panel->saveTitle = i18n("Confirm selection");
00137 $panel->resetTitle = i18n("Reset choices");
00138
00139 $panel->addOption( i18n("The bed in question"), "", $this->floors[$editFloor]["rooms"][$editRoom]["beds"][$editBed]["name"] , "roomname", "label" );
00140 $panel->addOption( i18n("Check to delete"), i18n("Just leave unchecked and click Confirm selection to abort the deletion process"), 0, "confirmDelete", "checkbox" );
00141
00142 if( $panel->submitted )
00143 {
00144 if( $panel->options["confirmDelete"]["current"] == true )
00145 {
00146 unset( $this->floors[$editFloor]["rooms"][$editRoom]["beds"][$editBed] );
00147 $this->save();
00148 }
00149 header( "Location: " . globalIDtoURL( "$thisGlobalID" ) );
00150 }
00151
00152 $renderedData .= renderInformationBox( i18n( "Delete ##0##?", array( $this->floors[$editFloor]["rooms"][$editRoom]["beds"][$editBed]["name"] ) ), "<form action=\"" . globalIDtoURL("$thisGlobalID/$editFloor/$editRoom/$editBed/delete") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00153 }
00154 else
00155 {
00156 $panel = new optionsPanel("editbed");
00157 $panel->showHeader = false;
00158 $panel->saveTitle = i18n("Save bed");
00159 $panel->revertTitle = i18n("Revert to default");
00160
00161 $panel->addOption( i18n("Name"), i18n("The name of the bed, most often simply the bed's number. For example: Bed 1. It can of course also be descriptive, such as for example: Sofa bed, or Main bed"), $this->floors[$editFloor]["rooms"][$editRoom]["beds"][$editBed]["name"], "name", "text" );
00162 $panel->addOption( i18n("Capacity"), i18n("The capacity of this bed"), $this->floors[$editFloor]["rooms"][$editRoom]["beds"][$editBed]["capacity"], "capacity", "text" );
00163
00164 if( $panel->submitted )
00165 {
00166 $this->floors[$editFloor]["rooms"][$editRoom]["beds"][$editBed]["name"] = $panel->options["name"]["current"];
00167 $this->floors[$editFloor]["rooms"][$editRoom]["beds"][$editBed]["capacity"] = $panel->options["capacity"]["current"];
00168 $this->save();
00169 header( "Location: " . globalIDtoURL($thisGlobalID) );
00170 }
00171
00172 $renderedData .= renderInformationBox( i18n( "Edit this bed" ), "<form action=\"" . globalIDtoURL("$thisGlobalID/$editFloor/$editRoom/$editFloor/$editBed") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00173 }
00174 }
00175 else if( $editBed == "newbed" )
00176 {
00177 $panel = new optionsPanel("newbed");
00178 $panel->showHeader = false;
00179 $panel->saveTitle = i18n("Create bed");
00180 $panel->revertTitle = i18n("Revert to default");
00181
00182 $panel->addOption( i18n("Name"), i18n("The name of the bed, most often simply the bed's number. For example: Bed 1. It can of course also be descriptive, such as for example: Sofa bed, or Main bed"), "", "name", "text" );
00183 $panel->addOption( i18n("Capacity"), i18n("The capacity of this bed"), "1", "capacity", "text" );
00184
00185 if( $panel->submitted )
00186 {
00187 $this->floors[$editFloor]["rooms"][$editRoom]["beds"][] = array( "name" => $panel->options["name"]["current"], "capacity" => $panel->options["capacity"]["current"] );
00188 $this->save();
00189 header( "Location: " . globalIDtoURL($thisGlobalID) );
00190 }
00191
00192 $renderedData .= renderInformationBox( i18n( "Create a new bed" ), "<form action=\"" . globalIDtoURL("$thisGlobalID/$editFloor/$editRoom/newbed") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00193 }
00194 else if( $editBed == "delete" )
00195 {
00196 $panel = new optionsPanel("roomdelete");
00197 $panel->showHeader = false;
00198 $panel->saveTitle = i18n("Confirm selection");
00199 $panel->resetTitle = i18n("Reset choices");
00200
00201 $panel->addOption( i18n("The room in question"), "", $this->floors[$editFloor]["rooms"][$editRoom]["name"] , "roomname", "label" );
00202 $panel->addOption( i18n("Check to delete"), i18n("Just leave unchecked and click Confirm selection to abort the deletion process"), 0, "confirmDelete", "checkbox" );
00203
00204 if( $panel->submitted )
00205 {
00206 if( $panel->options["confirmDelete"]["current"] == true )
00207 {
00208 unset( $this->floors[$editFloor]["rooms"][$editRoom] );
00209 $this->save();
00210 }
00211 header( "Location: " . globalIDtoURL( "$thisGlobalID" ) );
00212 }
00213
00214 $renderedData .= renderInformationBox( i18n( "Delete ##0##?", array( $this->floors[$editFloor]["rooms"][$editRoom]["name"] ) ), "<form action=\"" . globalIDtoURL("$thisGlobalID/$editFloor/$editRoom/delete") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00215 }
00216 else if( $editBed == "duplicate" )
00217 {
00218 $panel = new optionsPanel("duplicateroom");
00219 $panel->showHeader = false;
00220 $panel->saveTitle = i18n("Duplicate room");
00221 $panel->revertTitle = i18n("Revert to default");
00222
00223 $panel->addOption( i18n("Name"), i18n("The name of the duplicate. For example: Room 3.14"), $this->floors[$editFloor]["rooms"][$editRoom]["name"], "name", "text" );
00224
00225 if( $panel->submitted )
00226 {
00227 $tempRoom = $this->floors[$editFloor]["rooms"][$editRoom];
00228 $tempRoom["name"] = $panel->options["name"]["current"];
00229 $this->floors[$editFloor]["rooms"][] = $tempRoom;
00230 $this->save();
00231 header( "Location: " . globalIDtoURL($thisGlobalID) );
00232 }
00233
00234 $renderedData .= renderInformationBox( i18n( "Duplicate room" ), "<form action=\"" . globalIDtoURL("$thisGlobalID/$editFloor/$editRoom/duplicate") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00235 }
00236 else
00237 {
00238 $panel = new optionsPanel("editroom");
00239 $panel->showHeader = false;
00240 $panel->saveTitle = i18n("Save room");
00241 $panel->revertTitle = i18n("Revert to default");
00242
00243 $panel->addOption( i18n("Name"), i18n("The name of the room, most often simply the room's number. For example: Room 3.14"), $this->floors[$editFloor]["rooms"][$editRoom]["name"], "name", "text" );
00244 $panel->addOption( i18n("Event space"), i18n("The amount of seats available for events in this room. If the number of seats is above 0, the room is not available for accomodation, and you cannot add beds to it."), $this->floors[$editFloor]["rooms"][$editRoom]["eventspace"], "eventspace", "text" );
00245
00246 if( $panel->submitted )
00247 {
00248 $this->floors[$editFloor]["rooms"][$editRoom]["name"] = $panel->options["name"]["current"];
00249 $this->floors[$editFloor]["rooms"][$editRoom]["eventspace"] = $panel->options["eventspace"]["current"];
00250 $this->save();
00251 header( "Location: " . globalIDtoURL($thisGlobalID) );
00252 }
00253
00254 $renderedData .= renderInformationBox( i18n( "Edit room" ), "<form action=\"" . globalIDtoURL("$thisGlobalID/$editFloor/$editRoom") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00255 }
00256 }
00257 else if( $editRoom == "newroom" )
00258 {
00259 $panel = new optionsPanel("newroom");
00260 $panel->showHeader = false;
00261 $panel->saveTitle = i18n("Create room");
00262 $panel->revertTitle = i18n("Revert to default");
00263
00264 $panel->addOption( i18n("Name"), i18n("The name of the room, most often simply the room's number. For example: Room 3.14"), "", "name", "text" );
00265 $panel->addOption( i18n("Event space"), i18n("The amount of space available for events in this room. If the space is above 0, the room is not available for accomodation, and you cannot add beds to it."), "0", "eventspace", "text" );
00266
00267 if( $panel->submitted )
00268 {
00269 $this->floors[$editFloor]["rooms"][] = array( "name" => $panel->options["name"]["current"], "eventspace" => $panel->options["eventspace"]["current"], "beds" => array() );
00270 $this->save();
00271 header( "Location: " . globalIDtoURL($thisGlobalID) );
00272 }
00273
00274 $renderedData .= renderInformationBox( i18n( "Create a new room" ), "<form action=\"" . globalIDtoURL("$thisGlobalID/$editFloor/newroom") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00275 }
00276 else if( $editRoom == "delete" )
00277 {
00278 $panel = new optionsPanel("floordelete");
00279 $panel->showHeader = false;
00280 $panel->saveTitle = i18n("Confirm selection");
00281 $panel->resetTitle = i18n("Reset choices");
00282
00283 $panel->addOption( i18n("The floor in question"), "", $this->floors[$editFloor]["name"] , "floorname", "label" );
00284 $panel->addOption( i18n("Check to delete"), i18n("Just leave unchecked and click Confirm selection to abort the deletion process"), 0, "confirmDelete", "checkbox" );
00285
00286 if( $panel->submitted )
00287 {
00288 if( $panel->options["confirmDelete"]["current"] == true )
00289 {
00290 unset( $this->floors[$editFloor] );
00291 $this->save();
00292 }
00293 header( "Location: " . globalIDtoURL( "$thisGlobalID" ) );
00294 }
00295
00296 $renderedData .= renderInformationBox( i18n( "Delete ##0##?", array( $this->floors[$editFloor]["name"] ) ), "<form action=\"" . globalIDtoURL("$thisGlobalID/$editFloor/delete") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00297 }
00298 else
00299 {
00300 $panel = new optionsPanel("editfloor");
00301 $panel->showHeader = false;
00302 $panel->saveTitle = i18n("Save floor");
00303 $panel->revertTitle = i18n("Revert to default");
00304
00305 $panel->addOption( i18n("Name"), i18n("The name of the floor, most often simply the floor's number. For example: Floor 3"), $this->floors[$editFloor]["name"], "name", "text" );
00306
00307 if( $panel->submitted )
00308 {
00309 $this->floors[$editFloor]["name"] = $panel->options["name"]["current"];
00310 $this->save();
00311 header( "Location: " . globalIDtoURL($thisGlobalID) );
00312 }
00313
00314 $renderedData .= renderInformationBox( i18n( "Edit the floor" ), "<form action=\"" . globalIDtoURL("$thisGlobalID/$editFloor") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00315 }
00316 }
00317 else if( $editFloor == "newfloor" )
00318 {
00319 $panel = new optionsPanel("newfloor");
00320 $panel->showHeader = false;
00321 $panel->saveTitle = i18n("Create floor");
00322 $panel->revertTitle = i18n("Revert to default");
00323
00324 $panel->addOption( i18n("Name"), i18n("The name of the floor, most often simply the floor's number. For example: Floor 3"), "", "name", "text" );
00325
00326 if( $panel->submitted )
00327 {
00328 $this->floors[] = array( "name" => $panel->options["name"]["current"], "rooms" => array() );
00329 $this->save();
00330 header( "Location: " . globalIDtoURL($thisGlobalID) );
00331 }
00332
00333 $renderedData .= renderInformationBox( i18n( "Create a new floor" ), "<form action=\"" . globalIDtoURL("$thisGlobalID/newfloor") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00334 }
00335 else if( $editFloor == "sort" || $editFloor == "sortdeep" )
00336 {
00337 usort( $this->floors, "ConventionHotelCompareName" );
00338 if( $editFloor == "sortdeep" )
00339 {
00340 foreach( $this->floors as $key => $value )
00341 {
00342 usort( $this->floors[$key]["rooms"], "ConventionHotelCompareName" );
00343 foreach( $this->floors[$key]["rooms"] as $key2 => $value2 )
00344 usort( $this->floors[$key]["rooms"][$key2]["beds"], "ConventionHotelCompareName" );
00345 }
00346 }
00347 $this->save();
00348 header( "Location: " . globalIDtoURL($thisGlobalID) );
00349 }
00350 else
00351 {
00352 if( count( $this->floors ) < 1 )
00353 {
00354 $renderedData = renderInformationBox( i18n("No floors"), i18n("There is currently not defined any floors in this hotel. Please add a floor to begin.") );
00355 }
00356 else
00357 {
00358 $renderedData = "";
00359
00360 foreach( $this->floors as $key => $value )
00361 {
00362 $renderedData .= "<div class=\"convention-setup-hotel-floor\">" . $value["name"] . "
00363 " . drawCommand( i18n("Add room"), i18n("Add a new room to this floor"), globalIDtoURL("$thisGlobalID/$key/newroom") ) . "
00364 <div class=\"convention-setup-hotel-floor-rooms\">";
00365
00366 foreach( $value["rooms"] as $key2 => $value2 )
00367 {
00368 $renderedData .= "<div class=\"convention-setup-hotel-room\">";
00369
00370 if( $value2["eventspace"] > 0 )
00371 {
00372 $renderedData .= "<span class=\"convention-setup-hotel-room-event\">" . i18n( "Event space: ##0##", array( $value2["eventspace"] ) ) . "</span>";
00373 }
00374 else
00375 {
00376
00377 foreach( $value2["beds"] as $key3 => $value3 )
00378 $renderedData .= "<span class=\"convention-setup-hotel-bed\">" . drawCommand( i18n("Bed: ##0## (##1##)", array( $value3["name"], $value3["capacity"] ) ), i18n("Edit this bed"), globalIDtoURL("$thisGlobalID/$key/$key2/$key3") ) . "</span>";
00379
00380 $renderedData .= "<span class=\"convention-setup-hotel-room-bed-add\">" . drawCommand( i18n("Add bed"), i18n("Add a new bed to this room"), globalIDtoURL("$thisGlobalID/$key/$key2/newbed") ) . "</span>";
00381 }
00382 $renderedData .= $value2["name"]
00383 . "<span class=\"convention-setup-hotel-room-control\">"
00384 . drawCommand( i18n("Edit"), i18n("Edit this room"), globalIDtoURL("$thisGlobalID/$key/$key2") ) . " "
00385 . drawCommand( i18n("Duplicate"), i18n("Duplicate this room"), globalIDtoURL("$thisGlobalID/$key/$key2/duplicate") ) . " "
00386 . drawCommand( i18n("Delete"), i18n("Delete this room"), globalIDtoURL("$thisGlobalID/$key/$key2/delete") )
00387 . "</span>";
00388 $renderedData .= "</div>";
00389 }
00390 $renderedData .= "</div><div class=\"wikirightalign\">
00391 " . drawCommand( i18n("Delete"), i18n("Delete this floor and all rooms and beds contained"), globalIDtoURL("$thisGlobalID/$key/delete") ) . "
00392 " . drawCommand( i18n("Edit"), i18n("Edit this floor"), globalIDtoURL("$thisGlobalID/$key") ) . "
00393 </div></div>";
00394 }
00395 }
00396
00397 $renderedData .= "<div class=\"wikirightalign\">
00398 " . drawCommand( i18n("Sort everything"), i18n("Sort beds, rooms and floors in this hotel in natural order by their name"), globalIDtoURL("$thisGlobalID/sortdeep") ) . "
00399 " . drawCommand( i18n("Sort floors"), i18n("Sort the floors of this hotel in natural order by their name"), globalIDtoURL("$thisGlobalID/sort") ) . "
00400 " . drawCommand( i18n("New floor"), i18n("Create a new floor in this hotel"), globalIDtoURL("$thisGlobalID/newfloor") ) . "
00401 </div>";
00402
00403 $panel = new optionsPanel("hotel");
00404 $panel->showHeader = false;
00405 $panel->saveTitle = i18n("Save hotel");
00406 $panel->revertTitle = i18n("Revert to saved");
00407
00408 $panel->addOption( i18n("Name"), i18n("The name of this hotel"), $this->name, "name", "text" );
00409 $panel->addOption( i18n("Description"), i18n("A shortish description of the hotel"), $this->description , "description", "textbox" );
00410 $panel->addOption( i18n("Long description"), "", $this->longDescription, "longDescription", "pagedata" );
00411
00412 if( $panel->submitted )
00413 {
00414 $this->name = $panel->options["name"]["current"];
00415 $this->description = $panel->options["description"]["current"];
00416 $this->longDescription = $panel->options["longDescription"]["current"];
00417 $this->save();
00418 header( "Location: " . globalIDtoURL("$thisGlobalID") );
00419 }
00420
00421 $renderedData .= renderInformationBox( i18n( "Edit the hotel details" ), "<form action=\"" . globalIDtoURL("$thisGlobalID") . "\" method=\"POST\">" . $panel->render() . "</form>", false );
00422 }
00423
00424 return $renderedData;
00425 }
00426
00427 function render($editThis = false)
00428 {
00429 global $globalID;
00430 if( $editThis )
00431 $renderedData = $this->renderEditor();
00432 else
00433 {
00434 $splitID = explode( "/", $globalID );
00435
00436 if( $splitID[3] == "cons" )
00437 $thisGlobalID = "setup/modulesetup/convention/cons/" . $this->parentConvention->id . "/hotels";
00438 else
00439 $thisGlobalID = "setup/modulesetup/convention/hotels";
00440
00441 $renderedData = "
00442 <tr class=\"convention-setup-hotel-list\">
00443 <td class=\"convention-setup-hotel-list\">" . $this->name . "<small class=\"comment\">" . $this->description . "</small></td>
00444 <td class=\"convention-setup-hotel-list wikirightalign\">
00445 " . drawCommand( i18n("Delete"), i18n("Delete this hotel and all things contained within"), globalIDtoURL( "$thisGlobalID/delete/" . $this->id ) ) . "
00446 " . drawCommand( i18n("Edit"), i18n("Edit this hotel"), globalIDtoURL( "$thisGlobalID/" . $this->id ) ) . "
00447 </td>
00448 </tr>";
00449 }
00450
00451 return $renderedData;
00452 }
00453 }
00454
00455 function ConventionHotelCompareName($x, $y) { return arrayColumnCompare($x, $y, "name"); }
00456 ?>