Changeset 636

Show
Ignore:
Timestamp:
07/09/08 21:55:19 (3 months ago)
Author:
aarkerio
Message:

Updates genrali

Location:
trunk/app
Files:
9 modified

Legend:

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

    r635 r636  
    2323    $this->Auth->allow(array('view', 'add')); 
    2424  } 
    25    
    26   public function view($username=null, $entry_id=null) 
    27   {     
    28     $this->pageTitle = $username . '\'s Comments'; 
    29        
    30     $conditions      = array("status"=>1); 
    31        
    32     if ($username != null): 
    33       $user_id    = $this->User->field('id', array("username"=>$username)); 
    34       $conditions["user_id"] = $user_id; 
    35     endif; 
    36        
    37     if ($entry_id != null): 
    38       $conditions["id"] = $entry_id;   
    39     endif; 
    40        
    41     $fields     = array("id", "title", "description", "pubdate", "size"); 
    42     $order      = "id DESC"; 
    43     $limit      = 12; 
    44        
    45     $this->set('username',$username); 
    46     $this->set('data', $this->Podcast->findAll($conditions, $fields, $order, $limit, null, true));  
    47   } 
    48   
     25    
    4926  public function add()  
    5027  { 
    51     if (!empty($this->data["Comment"]) ): 
    52           
     28    if (!empty($this->data['Comment']) ): 
     29       
    5330      $this->Sanitize = new Sanitize;  
    54       $this->Sanitize->clean($this->data["Comment"]); //Hopefully this is enough 
    55       $this->Comment->create(); 
    56         
    57       if ($this->Comment->save($this->data["Comment"])): 
     31      $this->Sanitize->clean($this->data['Comment']); //Hopefully this is enough 
     32       
     33      if ($this->Comment->save($this->data)): 
    5834           $this->msgFlash(__('Comment added', true), $this->data['Comment']['redirect_to'].'/#comments'); 
     35      else: 
     36           $this->flash('Problem, please report', $this->data['Comment']['redirect_to'].'/#comments'); 
    5937      endif; 
    6038    endif; 
     
    7048    $this->data['Comment']['id']     = $comment_id; 
    7149       
    72     if ($this->Comment->save($this->data['Comment'])): 
    73       $this->msgFlash('Comment status changed', '/admin/entries/comments'); 
     50    if ($this->Comment->save($this->data)): 
     51        $this->msgFlash('Comment status changed', '/admin/entries/comments'); 
    7452    endif; 
    7553  } 
     
    8058      
    8159    if ( empty( $this->data["Comment"] ) ): 
    82       $this->data      = $this->Comment->read(null, $id); 
     60       $this->data      = $this->Comment->read(null, $id); 
    8361    else: 
    84     $this->Sanitize = new Sanitize; 
     62      $this->Sanitize = new Sanitize; 
    8563          
    86     $this->Sanitize->html($this->data["Comment"]["comment"]); 
     64      $this->Sanitize->html($this->data["Comment"]["comment"]); 
    8765          
    88     if ($this->Comment->save($this->data["Comment"])):   
    89       $this->msgFlash('Comment saved!', '/admin/comments/edit/'.$this->data["Comment"]["id"]); 
    90     endif; 
    91     endif; 
     66      if ($this->Comment->save($this->data)):   
     67         $this->msgFlash('Comment saved!', '/admin/comments/edit/'.$this->data["Comment"]["id"]); 
     68      endif; 
     69   endif; 
    9270  } 
    9371  
    94   public function admin_delete($id) 
     72  public function admin_delete($comment_id) 
    9573  { 
    96     if ($this->Comment->del($id)): 
    97       $this->msgFlash('Comment deleted', '/admin/comments/listing'); 
     74    if ($this->Comment->del($comment_id)): 
     75       $this->msgFlash('Comment deleted', '/admin/comments/listing'); 
    9876    endif; 
    9977  } 
  • trunk/app/controllers/discussions_controller.php

    r540 r636  
    1919 
    2020 public $components    = array('Captcha', 'Email'); 
     21 
     22 public $paginate = array('limit' => 10, 'page' => 1, 'order' => array('Discussion.id' => 'DESC')); 
    2123 
    2224 public function beforeFilter()  
     
    5860         $this->data['Discussion']['user_id'] = 0; 
    5961     } 
    60       
    61      $this->Discussion->create(); 
    6262          
    63      if ( $this->Discussion->save($this->data['Discussion']) ):  //save the comment 
     63     if ( $this->Discussion->save($this->data) ):  //save the comment 
    6464 
    6565          $user_id  = $this->Discussion->News->field('user_id', array('News.id'=>$this->data['Discussion']['new_id'])); 
     
    121121   $conditions  = null; 
    122122    
    123    $fields = array('Discussion.id','News.id','News.title','Discussion.id','Discussion.comment', 'Discussion.created', 'Discussion.username', 'Discussion.user_id', 'Discussion.status'); 
     123   $fields = array('Discussion.id','News.id','News.title','Discussion.id','Discussion.comment', 'Discussion.created', 'Discussion.user_id', 'Discussion.status', 'User.username'); 
    124124 
    125125   $order  = "Discussion.id DESC"; 
  • trunk/app/controllers/news_controller.php

    r621 r636  
    3232   $this->layout = 'portal'; 
    3333         
    34    $this->pageTitle = 'Karamelo::Home'; 
    35          
    36    $conditions = array("News.status"=>1); 
    37          
    38    $fields     = null; 
    39          
    40    $order      = "News.id DESC"; 
    41                      
    42    $limit      = 8; 
    43          
    44    //$this->set('data', $this->News->findAll($conditions, $fields, $order, $limit)); 
     34   $this->pageTitle = 'News'; 
     35     
    4536   $data = $this->paginate('News', array('News.status = 1')); 
    4637 
     
    6152 
    6253  $this->News->User->unbindAll(); 
    63          
     54  $this->News->Discussion->unbindModel(array('belongsTo'=>array('News')));       
    6455  $conditions = array('News.status'=>1, 'News.id'=>$new_id); 
    6556         
  • trunk/app/models/comment.php

    r282 r636  
    2525   
    2626 public $validate = array( 
    27       'comment' => VALID_NOT_EMPTY,         //'/[a-z0-9\_\-]{3,}$/i', 
    28       'user_id' => VALID_NOT_EMPTY, 
     27      'comment'  => VALID_NOT_EMPTY,         //'/[a-z0-9\_\-]{3,}$/i', 
     28      'user_id'  => VALID_NOT_EMPTY, 
    2929      'entry_id' => VALID_NOT_EMPTY, 
    3030      'username' => VALID_NOT_EMPTY 
  • trunk/app/models/discussion.php

    r537 r636  
    1111  public $name = 'Discussion'; 
    1212   
    13   /* public $belongsTo = array('News' => 
    14                          array('className'     => 'News', 
    15                                'conditions'    => null, 
    16                                'order'         => null, 
    17                                'limit'         => null, 
    18                                'foreignKey'    => 'new_id', 
    19                                'dependent'     => true, 
    20                                'exclusive'     => false, 
    21                                'finderQuery'   => '' 
    22                          ) 
    23                   ); */ 
     13  public $belongsTo = array( 
     14                           'News' => 
     15                            array('className'     => 'News', 
     16                                  'conditions'    => null, 
     17                                  'order'         => null, 
     18                                  'limit'         => null, 
     19                                  'foreignKey'    => 'new_id', 
     20                                  'dependent'     => true, 
     21                                  'exclusive'     => false, 
     22                                  'finderQuery'   => '' 
     23                   ), 
     24                          'User' => 
     25                            array('className'     => 'User', 
     26                                  'conditions'    => null, 
     27                                  'fields'        => 'id, username', 
     28                                  'order'         => null, 
     29                                  'limit'         => null, 
     30                                  'foreignKey'    => 'user_id', 
     31                                  'dependent'     => true, 
     32                                  'exclusive'     => false, 
     33                                  'finderQuery'   => '' 
     34                   ) 
     35                  ); 
    2436 
    2537  public $validate = array( 
  • trunk/app/views/discussions/admin_listing.ctp

    r537 r636  
    88 
    99foreach ($data as $val): 
    10    $st   = ( $val['Discussion']['status'] == 1 ) ? 'Published' : 'Non published';  
     10   $st   = ( $val['Discussion']['status'] == 1 ) ? __('Published', true) : __('Non published', true);  
    1111   $tmp  = $html->link($val['News']['title'], '/news/view/'.$val['News']['id']) . '<br />'; 
    12    $tmp .= $val['Discussion']['created'].' <b>'.$val['Discussion']['username'].' wrote:</b><br />'; 
     12   $tmp .= $val['Discussion']['created'].' <b>'.$val['User']['username'].' wrote:</b><br />'; 
    1313   $tmp .= $html->para(null, $val['Discussion']['comment']); 
    1414   $tmp .= $html->para(null, $html->link($st, '/admin/discussions/change/'.$val['Discussion']['id'].'/'.$val['Discussion']['status'])); 
  • trunk/app/views/entries/view.ctp

    r635 r636  
    4949            echo $form->hidden('Comment.user_id',  array('value' => $session->read('Auth.User.id'))); 
    5050            echo $form->hidden('Comment.username', array('value' => $session->read('Auth.User.username'))); 
    51             echo $session->read('Auth.User.username') . "  writes:"; 
     51            echo $session->read('Auth.User.username') . ' '.  __('writes', true) .' '; 
    5252                  
    53             echo $form->label('Comment.comment', 'Comment:' ); 
    54             echo $form->textarea('Comment.comment', array("rows" => 10, "cols" => 50));  
     53            echo $form->label('Comment.comment', __('Comment',true)) .'<br />'; 
     54            echo $form->textarea('Comment.comment', array('rows' => 10, 'cols' => 50));  
    5555            echo $form->error('Comment.comment', 'A comment is required.');  
    5656          
  • trunk/app/views/news/display.ctp

    r621 r636  
    11<?php 
    2 // die(debug($_SERVER)); 
     2//die(debug($data)); 
    33 
    44echo $html->div('title_portal', __('News on Campus', true)); 
     
    2626 
    2727  if ($val['News']['comments'] == 1 ):  // comments enabled on this new 
    28      echo $html->para(null, $html->link(__('Put your comment', true), '/news/view/'.$val['News']['id'])); 
     28     e($html->para(null,$html->link(__('Put your comment', true).' ('. count($val['Discussion']).')','/news/view/'.$val['News']['id']))); 
    2929  endif; 
    3030?> 
  • trunk/app/views/news/view.ctp

    r620 r636  
    11<?php 
    2 // die(debug($data)); 
     2//die(debug($data)); 
    33 
    44echo $html->div('news_title', $html->link($data['News']['title'], '/news/view/'. $data['News']['id'])); 
     
    4747      $bg = ($i%2 == 0) ? "#e2e2e2" : "#fff"; 
    4848           
    49       $tmp  = $html->para(null,$time->timeAgoInWords($v['created']) . ' <b>'. $v['username']    . '</b> wrote:<br />', array('style'=>'font-size:8pt;font-family:Georgia;')); 
     49      $tmp  = $html->para(null,$time->timeAgoInWords($v['created']) . ' <b>'. $v['User']['username']    . '</b> wrote:<br />', array('style'=>'font-size:8pt;font-family:Georgia;')); 
    5050      $tmp .= $html->para(null, $v['comment']); 
    5151      echo $html->div('divblock', $tmp, array('style'=>'background-color:'.$bg));