Changeset 679 for trunk/app/controllers

Show
Ignore:
Timestamp:
07/29/08 18:18:05 (4 months ago)
Author:
aarkerio
Message:

Update helps

Files:
1 modified

Legend:

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

    r548 r679  
    3232 public function display($a, $b, $c)  
    3333 { 
    34         $url = '/'.$a .'/'.$b .'/'.$c; 
    35         //exit($url); 
    36         $this->layout    = 'help'; 
    37         $this->pageTitle = 'Karamelo Help'; 
    38         $conditions      = array('url'=>$url); 
    39         $fields          = array('help', 'url', 'lang');   
    40         $this->set('data', $this->Help->find($conditions, $fields)); 
     34   $url  = '/'.$a .'/'.$b .'/'.$c; 
     35   $lang = (Configure::read('Config.language')) ?  Configure::read('Config.language') : 'en'; 
     36    
     37   $this->layout    = 'help'; 
     38   $this->pageTitle = 'Karamelo ' . __('Help', true); 
     39   $conditions      = array('url'=>$url, 'lang'=> $lang); 
     40   $fields          = array('help', 'url', 'lang');   
     41   $this->set('data', $this->Help->find($conditions, $fields)); 
    4142 } 
    4243 
    4344 public function index($set=null)  
    4445 { 
    45         $this->layout    = ( isset($set) ) ? 'admin' : 'help'; //small window or admin panel? 
    46         $this->pageTitle = 'Karamelo Help'; 
    47         $conditions      = array("lang"=>"en"); 
    48         $fields          = array('help', 'url', 'lang');   
    49         $this->set('data', $this->Help->findAll($conditions, $fields)); 
     46  $lang = (Configure::read('Config.language')) ?  Configure::read('Config.language') : 'en'; 
     47  $this->layout    = ( isset($set) ) ? 'admin' : 'help'; //small window or admin panel? 
     48  $this->pageTitle = 'Karamelo '. __('Help', true); 
     49  $conditions      = array('lang'=>$lang); 
     50  $fields          = array('help', 'url', 'lang');   
     51  $order           = 'url'; 
     52  $this->set('data', $this->Help->findAll($conditions, $fields, $order)); 
    5053 } 
    5154  
     
    5457 public function admin_newticket()  
    5558 { 
    56         $this->layout    = 'admin'; 
    57         $this->pageTitle = 'Karamelo Help'; 
    58         $conditions      = array("lang"=>"en"); 
    59         $fields          = array('help', 'url', 'lang');   
    60         $this->set('data', $this->Help->findAll($conditions, $fields)); 
     59  $this->layout    = 'admin'; 
     60  $this->pageTitle = 'Karamelo Help'; 
     61  $conditions      = array("lang"=>"en"); 
     62  $fields          = array('help', 'url', 'lang');   
     63  $this->set('data', $this->Help->findAll($conditions, $fields)); 
    6164 } 
    6265  
    6366 public function admin_submit() 
    6467 {      
    65        if ( !empty( $this->data['Help'] ) ) 
    66        {   
     68   if ( !empty( $this->data['Help'] ) ):  
    6769      $this->Sanitize = new Sanitize; 
    6870           
     
    7678                  $this->msgFlash('Email sent, Thanks!', '/admin/entries/start'); 
    7779      endif; 
    78            
    79         } 
     80  endif; 
    8081 } 
    8182  
     
    104105     $this->layout = 'admin'; 
    105106      
    106      if (!empty($this->data['Help'])) 
    107      { 
    108           //die(debug($this->data['Help'])); 
     107     if (!empty($this->data['Help'])): 
     108         //die(debug($this->data['Help'])); 
    109109        $this->Sanitize = new Sanitize; 
    110110         
     
    115115        $this->Help->create(); 
    116116 
    117         if ($this->Help->save($this->data['Help'])) 
    118          { 
    119                $id = $this->Help->getLastInsertID(); 
    120               $this->msgFlash('Help saved','/admin/helps/edit/'.$id); 
    121          } 
    122       }  
     117        if ($this->Help->save($this->data)): 
     118          $id = $this->Help->getLastInsertID(); 
     119              $this->msgFlash(__('Data saved', true),'/admin/helps/edit/'.$id); 
     120    endif; 
     121    endif; 
    123122 } 
    124123  
     
    130129         
    131130        $this->data = $this->Help->read(null, $help_id); 
    132      
    133131    else: 
    134      
    135         if ($this->Help->save($this->data['Help'])): 
    136               $this->msgFlash('Help updated.','/admin/helps/edit/'.$this->data['Help']['id']); 
     132        if ( $this->Help->save($this->data) ): 
     133        if ( $this->data['Help']['end'] == 1 ): 
     134            $return = '/admin/helps/listing';  
     135        else: 
     136            $return = '/admin/helps/edit/'.$this->data['Help']['id']; 
     137        endif; 
     138            $this->msgFlash(__('Data saved', true), $return);     
    137139    endif; 
    138  
    139140    endif; 
    140141 } 
    141142  
    142  public function admin_delete($id) 
     143 public function admin_delete($help_id) 
    143144 { 
    144    if ( $this->Help->del($id) ): 
    145               $this->msgFlash('Help deleted','/admin/helps/listing'); 
     145   if ( $this->Help->del($help_id) ): 
     146           $this->msgFlash(__('Help deleted', true),'/admin/helps/listing'); 
    146147   endif; 
    147148 } 
     
    162163    $this->set('report', $report); 
    163164    //Do not pass any args to send()  
    164     if ( $this->Email->send() )  
    165     { 
     165    if ( $this->Email->send() ): 
    166166            return true;  
    167     }  
    168     else 
    169     { 
     167    else: 
    170168            return false; 
    171     } 
     169    endif; 
    172170 } 
    173171}