Mini Shell

Direktori : /home/brasafestival/www/old/bkp_2023/app/Plugin/Contatos/Controller/
Upload File :
Current File : /home/brasafestival/www/old/bkp_2023/app/Plugin/Contatos/Controller/ContatosController.php

<?PHP
class ContatosController extends ContatosAppController{
    
    public $paginate=array('limit'=>10,'order'=>'id DESC');
    
    public function index(){
        $this->Seo->title('Contato');
        if($this->data && $this->request->is('post')){
            if($this->data['Contato']['nome'] === ''){
                $this->message_empty('ATENÇÃO: Preencha o campo Nome.'); 
            }else if($this->data['Contato']['email'] === ''){
                $this->message_empty('ATENÇÃO: Preencha o campo E-mail.'); 
            }else if($this->data['Contato']['telefone'] === ''){
                $this->message_empty('ATENÇÃO: Preencha o campo Telefone.'); 
            }
            
            if($this->Contato->save($this->data)){
                $this->set('add_sucess',true);
            }else{
                $this->message_empty('ERRO: Não foi possível enviar seus dados, tente novamente mais tarde'); 
            }
        }
    }
    
    public function admin_index(){
        $this->layout="Painel.admin";
        $this->paginate['order'] = 'Contato.created DESC';
        $this->set('posts',$this->paginate('Contato'));
        $this->set('total',$this->Contato->find('count'));
    }
    
    public function admin_view($id){
        $this->layout="Painel.admin";
        $this->set('post',$this->Contato->read('*',$id));
    }
    
    public function admin_delete($id){
        $this->autoRender=false;
        if($this->Contato->delete($id)) $this->redirect(array('action'=>'index'));
    }
    
    public function message_empty($text){
        echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';
        echo '<script type="text/javascript">';
        echo 'alert("'.$text.'");';
        echo 'history.go(-1);';
        echo '</script>';
        exit; 
    }
}

Zerion Mini Shell 1.0