Changeset 32

Show
Ignore:
Timestamp:
07/14/07 14:26:07 (18 months ago)
Author:
aarkerio
Message:

Poll fixed

Location:
trunk/app
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/controllers/newsletters_controller.php

    r1 r32  
    1818    public function subscribe() 
    1919    { 
    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 
    2421    } 
     22     
    2523    public function  single($id) 
    2624    { 
     
    3533        $this->set('data', $this->Newsletter->findAll($conditions, $fields)); 
    3634         
    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 
    4036    } 
    4137   
     
    5854        } 
    5955    } 
    60   public function listing() 
     56    
     57  public function admin_listing() 
    6158  {    
    6259        $this->pageTitle = $this->othAuth->user('username') . '\'s News'; 
     
    9693     
    9794    public function  delete($id) { 
    98          
    99       // deletes new from database 
    100        
     95       
     96       // deletes new from database 
     97        
    10198      if ( $this->Newsletter->del($id) ) 
    102       {  
     99      { 
    103100            $this->flash('Your new have been removed', '/news/listing'); 
    104       } else { 
     101      } 
     102      else 
     103      { 
    105104            $this->flash('Database error!', '/news/listing'); 
    106105      } 
  • trunk/app/controllers/pollrows_controller.php

    r31 r32  
    1010{ 
    1111     
    12     public $helpers = array('Form', 'Ajax', 'Security'); 
     12    public $helpers = array('Form', 'Ajax'); 
    1313     
    1414    public function index() 
     
    2323     
    2424    // adds new vote to database 
    25     if (!empty($this->data)) 
     25    if (!empty($this->data["Pollrow"])) 
    2626    {  
    2727           //die(print_r($this->data)); 
     
    3030            
    3131           $vote += 1; 
     32            
    3233           //exit("votos " . $vote); 
     34            
    3335           $this->data['Pollrow']['vote'] = $vote;  // add vote 
    3436               
    3537           if ( $this->Pollrow->save( $this->data['Pollrow'] ) )  // add the Poll vote 
    3638            { 
    37                     //$this->Session->write('poll',  $this->data['Pollrow']['poll_id']); //set session, only one vote per session 
     39                    $this->Session->write('poll',  $this->data['Pollrow']['poll_id']); //set session, only one vote per session 
    3840                     
    3941                    $conditions = array("Pollrow.poll_id" => $this->data['Pollrow']['poll_id']); 
     
    4143                    $order      = "Pollrow.id"; 
    4244                     
    43                     $this->set('poll', $this->Pollrow->findAll($conditions, $fields, $order)); 
     45                    $this->set('data', $this->Pollrow->findAll($conditions, $fields, $order)); 
    4446                     
    4547                    $this->render('results', 'ajax'); 
  • trunk/app/views/elements/poll.thtml

    r23 r32  
    1 <div class="menumain">Opini&oacute;n</div> 
     1<div class="menumain">Quickvote</div> 
    22 
    33<div id="loading" style="display: none;"> 
  • trunk/app/views/pollrows/results.thtml

    r1 r32  
    11<?php 
    2   //die(print_r( $poll )); 
     2  //die(print_r( $data )); 
    33  $total_votes = 0; 
    44   
    5   foreach ($poll as $key => $val)  
     5  foreach ($data as $key => $val)  
    66  { 
    7        $total_votes += $poll[$key]["Pollrow"]["vote"];  // the total votes 
     7       $total_votes += $data[$key]["Pollrow"]["vote"];  // the total votes 
    88  } 
    99   
    10   echo "<p><b>" . $poll[0]['Poll']['question'] ."</b></p>"; 
     10  echo "<p><b>" . $data[0]['Poll']['question'] ."</b></p>"; 
    1111   
    12   foreach ($poll as $key => $val)  
     12  foreach ($data as $key => $val)  
    1313  { 
    14              $percent = ($poll[$key]["Pollrow"]["vote"] * 100) / $total_votes;  // % = votes * 100 / total 
     14             $percent = ($data[$key]["Pollrow"]["vote"] * 100) / $total_votes;  // % = votes * 100 / total 
    1515             $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']; 
    2020  } 
    2121