Changeset 661
- Timestamp:
- 07/21/08 22:11:14 (4 months ago)
- Location:
- trunk/app
- Files:
-
- 3 modified
-
controllers/subjects_controller.php (modified) (1 diff)
-
models/subject.php (modified) (1 diff)
-
views/subjects/view.ctp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/app/controllers/subjects_controller.php
r660 r661 45 45 46 46 $this->title = __('Subject', true); 47 48 $conditions = array('Subject.code'=>$code);49 47 50 $this->set('data', $this->Subject-> find($conditions));48 $this->set('data', $this->Subject->getSubject($code)); 51 49 } 52 53 50 54 51 /** ==== ADMIN METHODS ==== */ -
trunk/app/models/subject.php
r660 r661 44 44 ); 45 45 46 public $validate = array(46 public $validate = array( 47 47 'title' => VALID_NOT_EMPTY, //'/[a-z0-9\_\-]{3,}$/i', 48 48 'id' => VALID_NOT_EMPTY 49 ); 49 ); 50 51 public function getSubject($code) 52 { 53 $data = array(); 54 $this->unbindAll(); 55 $data['S'] = $this->find(array('Subject.code'=>$code), array('Subject.id', 'Subject.code', 'Subject.title')); 56 57 $conditions = array('Lesson.subject_id'=>$data['S']['Subject']['id']); 58 $fields = array('Lesson.id', 'Lesson.title', 'User.username', 'User.id'); 59 $order = 'Lesson.id DESC'; 60 $limit = 10; 61 $data['Lesson'] = $this->Lesson->findAll($conditions, $fields, $order, $limit); 62 63 64 $conditions = array('Entry.subject_id'=>$data['S']['Subject']['id']); 65 $fields = array('Entry.id', 'Entry.title', 'User.username', 'User.id'); 66 $order = 'Entry.id DESC'; 67 $limit = 10; 68 $data['Entry'] = $this->Entry->findAll($conditions, $fields, $order, $limit); 69 70 71 $conditions = array('Share.subject_id'=>$data['S']['Subject']['id'], 'Share.public'=>1); 72 $fields = array('Share.secret', 'Share.description', 'User.username', 'User.id'); 73 $order = 'Share.id DESC'; 74 $limit = 10; 75 $data['Share'] = $this->Share->findAll($conditions, $fields, $order, $limit); 76 77 return $data; 78 } 79 50 80 /* 51 81 public $validate = array( -
trunk/app/views/subjects/view.ctp
r660 r661 2 2 //die(debug($data)); 3 3 4 echo '<h1>'. $data['Subject']['title']. ' '. $data['Subject']['code'] .'</h1>'; 4 echo '<h1>'. $data['S']['Subject']['title']. ' '. $data['S']['Subject']['code'] .'</h1>'; 5 6 echo '<br />'; 5 7 6 8 if ( count($data['Lesson']) < 1 ): … … 11 13 12 14 foreach($data['Lesson'] as $l): 13 echo $html->link('⺠'.$l[' title'], '/lessons/view/'.$l['id']). '<br />';15 echo $html->link('⺠'.$l['Lesson']['title'], '/lessons/view/'.$l['Lesson']['id']). '<br />'; 14 16 endforeach; 15 17 16 18 echo '<br /><br />'; 17 19 18 20 if ( count($data['Entry']) < 1 ): … … 23 25 24 26 foreach($data['Entry'] as $e): 25 echo $html->link('⺠'.$e[' title'], '/lessons/view/'.$e['id']). '<br />';27 echo $html->link('⺠'.$e['Entry']['title'], '/lessons/view/'.$e['Entry']['id']). '<br />'; 26 28 endforeach; 27 29 28 30 echo '<br /><br />'; 29 31 30 32 if ( count($data['Share']) < 1 ): … … 35 37 36 38 foreach($data['Share'] as $s): 37 echo $html->link('⺠'.$s[' description'], '/shares/view/'.$s['secret']). '<br />';39 echo $html->link('⺠'.$s['Share']['description'], '/shares/view/'.$s['Share']['secret']). '<br />'; 38 40 endforeach; 39 41
