統計
| ブランチ: | リビジョン:

pictcode / lib / Cake / Test / bake_compare / Controller / ActionsUsingSessions.ctp @ 0b1b8047

履歴 | 表示 | アノテート | ダウンロード (2.478 KB)

1 635eef61 spyder1211
2
/**
3
 * index method
4
 *
5
 * @return void
6
 */
7
	public function index() {
8
		$this->BakeArticle->recursive = 0;
9
		$this->set('bakeArticles', $this->Paginator->paginate());
10
	}
11
12
/**
13
 * view method
14
 *
15
 * @throws NotFoundException
16
 * @param string $id
17
 * @return void
18
 */
19
	public function view($id = null) {
20
		if (!$this->BakeArticle->exists($id)) {
21
			throw new NotFoundException(__('Invalid bake article'));
22
		}
23
		$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
24
		$this->set('bakeArticle', $this->BakeArticle->find('first', $options));
25
	}
26
27
/**
28
 * add method
29
 *
30
 * @return void
31
 */
32
	public function add() {
33
		if ($this->request->is('post')) {
34
			$this->BakeArticle->create();
35
			if ($this->BakeArticle->save($this->request->data)) {
36
				$this->Flash->success(__('The bake article has been saved.'));
37
				return $this->redirect(array('action' => 'index'));
38
			} else {
39
				$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
40
			}
41
		}
42
		$bakeTags = $this->BakeArticle->BakeTag->find('list');
43
		$this->set(compact('bakeTags'));
44
	}
45
46
/**
47
 * edit method
48
 *
49
 * @throws NotFoundException
50
 * @param string $id
51
 * @return void
52
 */
53
	public function edit($id = null) {
54
		if (!$this->BakeArticle->exists($id)) {
55
			throw new NotFoundException(__('Invalid bake article'));
56
		}
57
		if ($this->request->is(array('post', 'put'))) {
58
			if ($this->BakeArticle->save($this->request->data)) {
59
				$this->Flash->success(__('The bake article has been saved.'));
60
				return $this->redirect(array('action' => 'index'));
61
			} else {
62
				$this->Flash->error(__('The bake article could not be saved. Please, try again.'));
63
			}
64
		} else {
65
			$options = array('conditions' => array('BakeArticle.' . $this->BakeArticle->primaryKey => $id));
66
			$this->request->data = $this->BakeArticle->find('first', $options);
67
		}
68
		$bakeTags = $this->BakeArticle->BakeTag->find('list');
69
		$this->set(compact('bakeTags'));
70
	}
71
72
/**
73
 * delete method
74
 *
75
 * @throws NotFoundException
76
 * @param string $id
77
 * @return void
78
 */
79
	public function delete($id = null) {
80
		$this->BakeArticle->id = $id;
81
		if (!$this->BakeArticle->exists()) {
82
			throw new NotFoundException(__('Invalid bake article'));
83
		}
84
		$this->request->allowMethod('post', 'delete');
85
		if ($this->BakeArticle->delete()) {
86
			$this->Flash->success(__('The bake article has been deleted.'));
87
		} else {
88
			$this->Flash->error(__('The bake article could not be deleted. Please, try again.'));
89
		}
90
		return $this->redirect(array('action' => 'index'));
91
	}