Changeset 78
- Timestamp:
- 07/06/07 10:39:49 (1 year ago)
- Files:
-
- branch/controllers/venues_controller.php (moved) (moved from branch/controllers/points_controller.php) (6 diffs)
- branch/models/venue.php (moved) (moved from branch/models/point.php) (1 diff)
- branch/tests/cases/controllers/venues_controller.test.php (added)
- branch/tests/cases/models/venue.test.php (added)
- branch/views/venues (copied) (copied from branch/views/points)
- branch/views/venues/add.ctp (copied) (copied from branch/views/points/add.ctp) (2 diffs)
- branch/views/venues/index.ctp (copied) (copied from branch/views/points/index.ctp) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branch/controllers/venues_controller.php
r77 r78 1 1 <?php 2 class PointsController extends AppController2 class VenuesController extends AppController 3 3 { 4 4 //var $scaffold; 5 var $name = ' Points';5 var $name = 'Venues'; 6 6 var $helpers = array('Html', 'Form', 'Ajax', 'Javascript','GoogleMap' ); 7 7 8 function index() {8 function admin_index() { 9 9 $this->layout = "map"; 10 $this-> Point->recursive = 0;11 $this->set('points', $this-> Point->findAll());10 $this->Venue->recursive = 0; 11 $this->set('points', $this->Venue->findAll()); 12 12 } 13 13 14 function ad d() {14 function admin_add() { 15 15 $this->layout = "map"; 16 16 if(empty($this->data)) { … … 19 19 $this->cleanUpFields(); 20 20 21 $address = $this->data[' Point'];21 $address = $this->data['Venue']; 22 22 unset( 23 23 $address['id'], … … 32 32 $geo = $googleGeo->geo(); 33 33 var_dump($geo); 34 $this->data = array_merge($this->data[' Point'],$geo);34 $this->data = array_merge($this->data['Venue'],$geo); 35 35 36 if($this-> Point->save($this->data)) {37 $this->Session->setFlash('The Pointhas been saved');36 if($this->Venue->save($this->data)) { 37 $this->Session->setFlash('The Venue has been saved'); 38 38 //$this->redirect('/points/index'); 39 39 } else { … … 42 42 } 43 43 } 44 /* 45 function edit($id) {44 45 function admin_edit($id) { 46 46 if(empty($this->data)) { 47 $this->data = $this-> Point->read(null, $id);47 $this->data = $this->Venue->read(null, $id); 48 48 } else { 49 49 $this->cleanUpFields(); … … 60 60 $this->data = array_merge($this->data,$geo); 61 61 62 if($this-> Point->save($this->data)) {63 $this->Session->setFlash('The Pointhas been saved');62 if($this->Venue->save($this->data)) { 63 $this->Session->setFlash('The Venue has been saved'); 64 64 $this->redirect('/points/index'); 65 65 } else { … … 69 69 } 70 70 71 function view($id) {71 function admin_view($id) { 72 72 $this->layout = "map"; 73 $this->set('point', $this-> Point->read(null, $id));73 $this->set('point', $this->Venue->read(null, $id)); 74 74 } 75 75 76 function delete($id) {77 if($this-> Point->del($id)) {78 $this->Session->setFlash('The Pointdeleted: id '.$id.'');76 function admin_delete($id) { 77 if($this->Venue->del($id)) { 78 $this->Session->setFlash('The Venue deleted: id '.$id.''); 79 79 $this->redirect('/points/index'); 80 80 } 81 81 } 82 */ 82 83 83 } 84 84 ?> branch/models/venue.php
r76 r78 1 1 <?php 2 class Pointextends AppModel {2 class Venue extends AppModel { 3 3 4 var $name = 'Point'; 4 var $name = 'Venue'; 5 6 //The Associations below have been created with all possible keys, those that are not needed can be removed 7 var $hasMany = array( 8 'Event' => array('className' => 'Event', 9 'foreignKey' => 'venue_id', 10 'conditions' => '', 11 'fields' => '', 12 'order' => '', 13 'limit' => '', 14 'offset' => '', 15 'dependent' => '', 16 'exclusive' => '', 17 'finderQuery' => '', 18 'counterQuery' => ''), 19 ); 5 20 6 21 } branch/views/venues/add.ctp
r77 r78 3 3 <div style="float:left;width:800px;"> 4 4 <?php 5 $default = array('type'=>' 0','zoom'=>13,'lat'=>'55.868272','long'=>'-4.271121');5 $default = array('type'=>'2','zoom'=>13,'lat'=>'55.868272','long'=>'-4.271121'); 6 6 echo $googleMap->map($default, $style = 'width:100%; height: 600px' ); 7 7 //if(isset($points)){ … … 18 18 </p> 19 19 20 <?php e($form->create('Point'));?>21 20 22 <?php e($form->input('postcode'));?>23 21 24 <input type="text" id="postcode" size="25" /><br /> 25 <input type="submit" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, setCenterToPoint)" value="Center Map"/> 26 <input type="submit" value="Place Marker" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, placeMarkerAtPoint)" /> 27 <input type="submit" value="Do whatever" onclick="javascript:usePointFromPostcode(document.getElementById('postcode').value, function (point) { alert('Latitude: ' + point.lat() + '\nLongitude: ' + point.lng());})" /> 22 <?php e($form->input('findaddress', array('label'=>'Enter Address or Postcode')));?> 23 <input type="submit" onclick="javascript:usePointFromPostcode(document.getElementById('Findaddress').value, setCenterToPoint)" value="Locate on Map"/> 28 24 <br /> 29 25 <input id="lat" /><input id="lng" /> 30 26 31 27 <?php e($form->create('Venue'));?> 32 28 33 29 <?php e($form->input('name'));?> branch/views/venues/index.ctp
r77 r78 1 <h2>List Points</h2>1 <h2>List Venues</h2> 2 2 <div style="float:left;width:80%;"> 3 3 <?php … … 7 7 8 8 foreach($points as $n=>$point){ 9 $points[$n][' Point']['title'] = "<b>".$point['Point']['name']."</b>";10 $points[$n][' Point']['html'] = $point['Point']['description'];11 $avg_lat += $point[' Point']['latitude'];12 $avg_lon += $point[' Point']['longitude'];9 $points[$n]['Venue']['title'] = "<b>".$point['Venue']['name']."</b>"; 10 $points[$n]['Venue']['html'] = $point['Venue']['description']; 11 $avg_lat += $point['Venue']['latitude']; 12 $avg_lon += $point['Venue']['longitude']; 13 13 $count++; 14 14 } … … 32 32 </style> 33 33 <div style="float:left;width:15%"> 34 <span style="font-size:12pt;font-weight:bold;background:#239855;"><?php echo $html->link('Create A New Point', '/points/add'); ?></span>34 <span style="font-size:12pt;font-weight:bold;background:#239855;"><?php echo $html->link('Create A New Venue', '/points/add'); ?></span> 35 35 <table cellpadding="0" cellspacing="0"> 36 36 <tr> … … 40 40 </tr> 41 41 <?php foreach ($points as $point): ?> 42 <tr onclick="<?php echo $point[' Point']['js'] ?>" >43 <td><?php echo $point[' Point']['name'] ?></td>44 <td><?php echo $point[' Point']['city'] ?></td>45 <td><?php echo $point[' Point']['state'] ?></td>42 <tr onclick="<?php echo $point['Venue']['js'] ?>" > 43 <td><?php echo $point['Venue']['name'] ?></td> 44 <td><?php echo $point['Venue']['city'] ?></td> 45 <td><?php echo $point['Venue']['state'] ?></td> 46 46 </tr> 47 47 <?php endforeach; ?>