Changeset 32
- Timestamp:
- 07/14/07 14:26:07 (18 months ago)
- Location:
- trunk/app
- Files:
-
- 4 modified
-
controllers/newsletters_controller.php (modified) (4 diffs)
-
controllers/pollrows_controller.php (modified) (4 diffs)
-
views/elements/poll.thtml (modified) (1 diff)
-
views/pollrows/results.thtml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/newsletters_controller.php
r1 r32 18 18 public function subscribe() 19 19 { 20 $this->set('subjects', $this->Portal->cms()); // Using Portal component 21 22 $this->set('randomQuote', $this->Portal->quote()); // quote footer 23 20 $this->set('Element', $this->Portal->statics()); // Charge Portal components aka Sidebars 24 21 } 22 25 23 public function single($id) 26 24 { … … 35 33 $this->set('data', $this->Newsletter->findAll($conditions, $fields)); 36 34 37 $this->set('subjects', $this->Portal->cms()); // Using Portal component 38 39 $this->set('randomQuote', $this->Portal->quote()); // quote footer 35 $this->set('Element', $this->Portal->statics()); // Charge Portal components aka Sidebars 40 36 } 41 37 … … 58 54 } 59 55 } 60 public function listing() 56 57 public function admin_listing() 61 58 { 62 59 $this->pageTitle = $this->othAuth->user('username') . '\'s News'; … … 96 93 97 94 public function delete($id) { 98 99 // deletes new from database100 95 96 // deletes new from database 97 101 98 if ( $this->Newsletter->del($id) ) 102 { 99 { 103 100 $this->flash('Your new have been removed', '/news/listing'); 104 } else { 101 } 102 else 103 { 105 104 $this->flash('Database error!', '/news/listing'); 106 105 } -
trunk/app/controllers/pollrows_controller.php
r31 r32 10 10 { 11 11 12 public $helpers = array('Form', 'Ajax' , 'Security');12 public $helpers = array('Form', 'Ajax'); 13 13 14 14 public function index() … … 23 23 24 24 // adds new vote to database 25 if (!empty($this->data ))25 if (!empty($this->data["Pollrow"])) 26 26 { 27 27 //die(print_r($this->data)); … … 30 30 31 31 $vote += 1; 32 32 33 //exit("votos " . $vote); 34 33 35 $this->data['Pollrow']['vote'] = $vote; // add vote 34 36 35 37 if ( $this->Pollrow->save( $this->data['Pollrow'] ) ) // add the Poll vote 36 38 { 37 //$this->Session->write('poll', $this->data['Pollrow']['poll_id']); //set session, only one vote per session39 $this->Session->write('poll', $this->data['Pollrow']['poll_id']); //set session, only one vote per session 38 40 39 41 $conditions = array("Pollrow.poll_id" => $this->data['Pollrow']['poll_id']); … … 41 43 $order = "Pollrow.id"; 42 44 43 $this->set(' poll', $this->Pollrow->findAll($conditions, $fields, $order));45 $this->set('data', $this->Pollrow->findAll($conditions, $fields, $order)); 44 46 45 47 $this->render('results', 'ajax'); -
trunk/app/views/elements/poll.thtml
r23 r32 1 <div class="menumain"> Opinión</div>1 <div class="menumain">Quickvote</div> 2 2 3 3 <div id="loading" style="display: none;"> -
trunk/app/views/pollrows/results.thtml
r1 r32 1 1 <?php 2 //die(print_r( $ poll));2 //die(print_r( $data )); 3 3 $total_votes = 0; 4 4 5 foreach ($ pollas $key => $val)5 foreach ($data as $key => $val) 6 6 { 7 $total_votes += $ poll[$key]["Pollrow"]["vote"]; // the total votes7 $total_votes += $data[$key]["Pollrow"]["vote"]; // the total votes 8 8 } 9 9 10 echo "<p><b>" . $ poll[0]['Poll']['question'] ."</b></p>";10 echo "<p><b>" . $data[0]['Poll']['question'] ."</b></p>"; 11 11 12 foreach ($ pollas $key => $val)12 foreach ($data as $key => $val) 13 13 { 14 $percent = ($ poll[$key]["Pollrow"]["vote"] * 100) / $total_votes; // % = votes * 100 / total14 $percent = ($data[$key]["Pollrow"]["vote"] * 100) / $total_votes; // % = votes * 100 / total 15 15 $width = number_format($percent, 0); 16 echo '<p><b>' . $ poll[$key]["Pollrow"]["answer"] . '</b> '.number_format($percent, 2).'% <br />';17 echo $html->image('static/poll/'.$ poll[$key]["Pollrow"]["color"].'.png',18 array("height"=>"10", "width"=>$width,"alt"=>$ poll[$key]["Pollrow"]["answer"], "title"=>$poll[$key]["Pollrow"]["answer"]) );19 echo " ". $ poll[$key]["Pollrow"]['vote'];16 echo '<p><b>' . $data[$key]["Pollrow"]["answer"] . '</b> '.number_format($percent, 2).'% <br />'; 17 echo $html->image('static/poll/'.$data[$key]["Pollrow"]["color"].'.png', 18 array("height"=>"10", "width"=>$width,"alt"=>$data[$key]["Pollrow"]["answer"], "title"=>$data[$key]["Pollrow"]["answer"]) ); 19 echo " ". $data[$key]["Pollrow"]['vote']; 20 20 } 21 21
