Mini Shell
<?PHP
class ContatoTabelaController extends ContatosAppController{
public $paginate = array('limit'=>10,'order'=>'id DESC');
public $components = array('Painel.Uploading');
public function index(){
$this->Seo->title('Solicitar Contato');
if($this->data && $this->request->is('post')){
if($this->data['ContatoTabela']['nome'] === ''){
$this->message_empty('ATENÇÃO: Preencha o campo Nome.');
}else if($this->data['ContatoTabela']['email'] === ''){
$this->message_empty('ATENÇÃO: Preencha o campo E-mail.');
}else if($this->data['ContatoTabela']['telefone'] === ''){
$this->message_empty('ATENÇÃO: Preencha o campo Telefone.');
}
if($this->ContatoTabela->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'] = 'ContatoTabela.created DESC';
$this->set('posts',$this->paginate('ContatoTabela'));
$this->set('total',$this->ContatoTabela->find('count'));
}
public function admin_view($id){
$this->layout = 'Painel.admin';
$this->set('post',$this->ContatoTabela->read('*',$id));
}
public function admin_delete($id){
$this->autoRender = false;
if($this->ContatoTabela->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