00001 <?php
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 require_once('./general.php');
00030 require_once('./lib/field.php');
00031 require_once('./lib/guild.php');
00032 require_once ( './lib/towninfo.php' );
00033
00034
00035 $oStyle->setTemplate( 'field.html' );
00036 $oStyle->split_area('DisplayField');
00037 $oStyle->split_area('DisplayMore');
00038 $oStyle->split_area('DisplayOwner');
00039 $oStyle->split_area('EditOwner');
00040 $oStyle->split_area('EditLink');
00041 $oStyle->split_area('ListLink');
00042 $oStyle->split_area('Option');
00043
00044 $oTown = new TownInfo( $oMysql, $oLog );
00045 $oField = new Field( $oMysql, $oUser, $oTown, $oLog );
00046
00047
00048 $action = isset( $_GET['action'] ) ? $_GET['action'] : '';
00049 $x = isset( $_GET['x'] ) ? intval( $_GET['x'] ) : 0;
00050 $y = isset( $_GET['y'] ) ? intval( $_GET['y'] ) : 0;
00051
00052 if( $action == 'save' && $oUser->isAdmin( 'town_edit' ) )
00053 {
00054 $strPlayer = isset( $_POST['player'] ) ? trim( $_POST['player'] ) : '';
00055 $strTown = isset( $_POST['town'] ) ? trim( $_POST['town'] ) : '';
00056 $intGuild = isset( $_POST['guild'] ) ? intval( $_POST['guild'] ) : 1;
00057 $intRace = isset( $_POST['race'] ) ? intval( $_POST['race'] ) : 0;
00058 $intType = isset( $_POST['type'] ) ? intval( $_POST['type'] ) : 0;
00059 $intTown = isset( $_POST['stadttyp'] )? intval( $_POST['stadttyp'] ) : 0;
00060 $intSight = isset( $_POST['sight'] ) ? intval( $_POST['sight'] ) : 0;
00061
00062 $oField->set( $x, $y, $strPlayer, $strTown, $intGuild, $intType, $intRace, $intTown, $intSight );
00063 }
00064 elseif( $action == 'delete' && $oUser->isAdmin( 'town_del' ) )
00065 {
00066 $oField->delete( $x, $y );
00067 }
00068 elseif( $action == 'new' && $oUser->isAdmin( 'town_add' ))
00069 {
00070 $booReturn = $oField->add( $x, $y );
00071 }
00072 elseif( $action == 'new_village' )
00073 {
00074 $booReturn = $oField->add( $x, $y, -11 );
00075 }
00076
00077
00078
00079 $aField = $oField->get( $x, $y );
00080
00081 $strMore = '';
00082 $strEditLink = '';
00083 $strSaveLink = '';
00084
00085 $booCreateDummy = false;
00086 $booEditOwner = false;
00087
00088 $strTerrain = isset( $aField['terrain'] ) ? $aTerrainText[$aField['terrain']] : $aTerrainText[0];
00089 $strPlayer = isset( $aField['name'] ) ? htmlspecialchars( $aField['name'] ) : '';
00090 $intType = isset( $aField['typ'] ) ? $aField['typ'] : 0;
00091 $intRace = isset( $aField['race'] ) ? $aField['race'] : 0;
00092 $intGuild = isset( $aField['guild_id'] ) ? $aField['guild_id'] : 1;
00093 $intSight = isset( $aField['sight'] ) ? intval( $aField['sight'] ) : 0;
00094 $strRace = $aRaces[$intRace];
00095 $strType = $aTypes[$intType];
00096
00097
00098 $oGuild = new Guild( $oMysql, $oLog, $oUser );
00099 $aGuildInfo = $oGuild->get( $intGuild );
00100 $strGuild = $aGuildInfo['tag'];
00101
00102 if( !$oUser->check( $x, $y ) )
00103 {
00104 echo $oStyle->get_area( 'NoDisplayField' );
00105 die();
00106 }
00107
00108 elseif( $aField === false )
00109 {
00110 $booCreateDummy = true;
00111 }
00112 elseif( $action == 'edit' && $oUser->isAdmin( 'town_edit' ) )
00113 {
00114 $oStyle->addReplacements( array( 'FIELD_X' => $x, 'FIELD_Y' => $y ) );
00115 $strEditLink = $oStyle->get_area( 'EditLink' );
00116 $strSaveLink = 'field.php?action=save&x='.$x.'&y='.$y;
00117
00118 $strTowns = '';
00119 $strRaces = '';
00120 $strTypes = '';
00121 $strGuilds = '';
00122
00123 foreach( $aTowns AS $opt_id => $opt_name)
00124 {
00125 $strSelected = ($aField['building'] == $opt_id) ? ' selected="selected"' : '';
00126 $oStyle->addReplacements( array( 'OPT_ID' => $opt_id, 'OPT_SEL' => $strSelected, 'OPT_NAME' => $opt_name ) );
00127 $strTowns .= $oStyle->get_area( 'Option' );
00128 }
00129 foreach( $aRaces AS $opt_id => $opt_name)
00130 {
00131 $strSelected = ($intRace == $opt_id) ? ' selected="selected"' : '';
00132 $oStyle->addReplacements( array( 'OPT_ID' => $opt_id, 'OPT_SEL' => $strSelected, 'OPT_NAME' => $opt_name ) );
00133 $strRaces .= $oStyle->get_area( 'Option' );
00134 }
00135 foreach( $aTypes AS $opt_id => $opt_name) {
00136 $strSelected = ($intType == $opt_id) ? ' selected="selected"' : '';
00137 $oStyle->addReplacements( array( 'OPT_ID' => $opt_id, 'OPT_SEL' => $strSelected, 'OPT_NAME' => $opt_name ) );
00138 $strTypes .= $oStyle->get_area( 'Option' );
00139 }
00140
00141 $aGuilds = $oGuild->getAll();
00142 foreach( $aGuilds AS $aData )
00143 {
00144 $strSelected = ($intGuild == $aData['guild_id']) ? ' selected="selected"' : '';
00145 $strSelected .= ' style="background:#'.$aData['bgcolor'].'; color:#'.$aData['fgcolor'].'"';
00146 $oStyle->addReplacements( array( 'OPT_ID' => $aData['guild_id'], 'OPT_SEL' => $strSelected, 'OPT_NAME' => $aData['tag'] ) );
00147 $strGuilds .= $oStyle->get_area( 'Option' );
00148 }
00149
00150 $oStyle->addReplacements( array( 'BUILDING_INFO' => $strTowns,
00151 'FIELD_SIGHT' => $intSight,
00152 'FIELD_RACES' => $strRaces,
00153 'FIELD_TYPES' => $strTypes,
00154 'FIELD_PLAYER' => $strPlayer,
00155 'FIELD_TOWN' => htmlspecialchars( $aField['town_name'] ),
00156 'FIELD_GUILDS' => $strGuilds ) );
00157 $strMore .= $oStyle->get_area( 'EditOwner' );
00158 }
00159 else
00160 {
00161
00162
00163 if( $aField['town_id'] != NULL )
00164 {
00165 $booEditOwner = true;
00166 }
00167
00168
00169 if( $aField['building'] != NULL )
00170 {
00171
00172 $strMoreTitle = 'Gebäude';
00173 $strMoreText = ( $aField['building'] < 0 ) ? $aTowns[$aField['building']] : $aBuildingText[$aField['building']];
00174
00175 if( isset( $aTowns[$aField['building']] ) )
00176 {
00177
00178 $booEditOwner = true;
00179 }
00180 elseif( $aField['building'] == -1 )
00181 {
00182
00183 $booEditOwner = true;
00184 }
00185 elseif( $strMoreText == NULL)
00186 {
00187
00188 $strMoreText = 'Unbekannt';
00189 }
00190 $oStyle->addReplacements( array( 'MORE_TITLE' => $strMoreTitle,
00191 'MORE_TEXT' => $strMoreText ) );
00192 $strMore .= $oStyle->get_area( 'DisplayMore' );
00193 }
00194 else
00195 {
00196
00197 $booCreateDummy = true;
00198 }
00199
00200
00201 if( $aField['town_id'] != NULL )
00202 {
00203 $oStyle->addReplacements( array( 'FIELD_PLAYER' => $strPlayer,
00204 'FIELD_TOWN' => htmlspecialchars( $aField['town_name'] ),
00205 'FIELD_SIGHT' => $intSight,
00206 'FIELD_RACE' => $strRace,
00207 'FIELD_TYPE' => $strType,
00208 'FIELD_GUILD' => $strGuild ) );
00209 $strMore .= $oStyle->get_area( 'DisplayOwner' );
00210 }
00211 }
00212
00213
00214
00215 if( $booEditOwner )
00216 {
00217 if( $oUser->isAdmin( 'town_edit' ) && $oUser->isAdmin( 'town_del' ) )
00218 {
00219 $oStyle->addReplacements( array( 'FIELD_X' => $x, 'FIELD_Y' => $y, 'FIELD_TOWN' => $aField['town_id'] ) );
00220 $strEditLink = $oStyle->get_area( 'ListLink3' );
00221 }
00222 elseif( $oUser->isAdmin( 'town_edit' ) )
00223 {
00224 $oStyle->addReplacements( array( 'FIELD_X' => $x, 'FIELD_Y' => $y, 'FIELD_TOWN' => $aField['town_id'] ) );
00225 $strEditLink = $oStyle->get_area( 'ListLink1' );
00226 }
00227 elseif( $oUser->isAdmin( 'town_del' ) )
00228 {
00229 $oStyle->addReplacements( array( 'FIELD_X' => $x, 'FIELD_Y' => $y, 'FIELD_TOWN' => $aField['town_id'] ) );
00230 $strEditLink = $oStyle->get_area( 'ListLink2' );
00231 }
00232 else
00233 {
00234 $oStyle->addReplacements( array( 'FIELD_X' => $x, 'FIELD_Y' => $y, 'FIELD_TOWN' => $aField['town_id'] ) );
00235 $strEditLink = $oStyle->get_area( 'ListLink0' );
00236 }
00237
00238 }
00239
00240 if( $booCreateDummy && $oUser->isAdmin( 'town_add' ) )
00241 {
00242 $strEditLink .= '<td><a href="field.php?action=new&x='.$x.'&y='.$y.'">Neue Stadt</a></td>';
00243 }
00244 if( $booCreateDummy )
00245 {
00246 $strEditLink .= '<td><a href="field.php?action=new_village&x='.$x.'&y='.$y.'">Geplantes Dorf</a></td>';
00247 }
00248
00249 $oStyle->addReplacements( array( 'FIELD_X' => $x,
00250 'FIELD_Y' => $y,
00251 'KOORDS_LINK' => "map.php?x=$x&y=$y",
00252 'FIELD_TERRAIN' => $strTerrain,
00253 'TEMPLATES' => $oStyle->getPath(),
00254 'FIELD_MORE' => $strMore,
00255 'FIELD_EDIT' => $strEditLink,
00256 'FIELD_SAVE' => $strSaveLink ) );
00257 echo $oStyle->get_area( 'DisplayField' );
00258 die();