public function index() { $this->->recursive = 0; $this->set('', $this->paginate()); } public function view($id = null) { if (!$id) { $this->Session->setFlash(__('Invalid ')); $this->redirect(array('action' => 'index')); $this->flash(__('Invalid '), array('action' => 'index')); } $this->set('', $this->->read(null, $id)); } public function add() { if ($this->request->is('post')) { $this->->create(); if ($this->->save($this->request->data)) { $this->Session->setFlash(__('The has been saved')); $this->redirect(array('action' => 'index')); $this->flash(__(' saved.'), array('action' => 'index')); } else { $this->Session->setFlash(__('The could not be saved. Please, try again.')); } } {$assoc} as $associationName => $relation): if (!empty($associationName)): $otherModelName = $this->_modelName($associationName); $otherPluralName = $this->_pluralName($associationName); echo "\t\t\${$otherPluralName} = \$this->{$currentModelName}->{$otherModelName}->find('list');\n"; $compact[] = "'{$otherPluralName}'"; endif; endforeach; endforeach; if (!empty($compact)): echo "\t\t\$this->set(compact(".join(', ', $compact)."));\n"; endif; ?> } public function edit($id = null) { if (!$id && empty($this->request->data)) { $this->Session->setFlash(__('Invalid ')); $this->redirect(array('action' => 'index')); $this->flash(__('Invalid '), array('action' => 'index')); } if ($this->request->is('post')) { if ($this->->save($this->request->data)) { $this->Session->setFlash(__('The has been saved')); $this->redirect(array('action' => 'index')); $this->flash(__('The has been saved.'), array('action' => 'index')); } else { $this->Session->setFlash(__('The could not be saved. Please, try again.')); } } if (!$this->request->is('post')) { $this->data = $this->->read(null, $id); } {$assoc} as $associationName => $relation): if (!empty($associationName)): $otherModelName = $this->_modelName($associationName); $otherPluralName = $this->_pluralName($associationName); echo "\t\t\${$otherPluralName} = \$this->{$currentModelName}->{$otherModelName}->find('list');\n"; $compact[] = "'{$otherPluralName}'"; endif; endforeach; endforeach; if (!empty($compact)): echo "\t\t\$this->set(compact(".join(', ', $compact)."));\n"; endif; ?> } public function delete($id = null) { if (!$this->request->is('post')) { throw new MethodNotAllowedException(); } if (!$id) { $this->Session->setFlash(__('Invalid id for ')); $this->redirect(array('action'=>'index')); $this->flash(__('Invalid '), array('action' => 'index')); } if ($this->->delete($id)) { $this->Session->setFlash(__(' deleted')); $this->redirect(array('action'=>'index')); $this->flash(__(' deleted'), array('action' => 'index')); } $this->Session->setFlash(__(' was not deleted')); $this->flash(__(' was not deleted'), array('action' => 'index')); $this->redirect(array('action' => 'index')); }