Changeset 630

Show
Ignore:
Timestamp:
07/07/08 20:31:55 (3 months ago)
Author:
aarkerio
Message:

Adding annotations

Location:
trunk/app
Files:
3 added
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/app/config/sql/postgresql/karamelo.sql

    r618 r630  
    8585\i ./uploads.sql 
    8686\i ./reports.sql 
     87\i ./comments_lessons.sql 
  • trunk/app/models/lesson.php

    r535 r630  
    88class Lesson extends AppModel 
    99{ 
    10     // Its always good practice to include this variable. 
    11     public $name        = 'Lesson'; 
     10  // Its always good practice to include this variable. 
     11  public $name        = 'Lesson'; 
    1212     
    1313  public $belongsTo = array('User' => 
     
    2424                  ) 
    2525                ); 
    26      
    27     public $validate = array( 
     26 
     27  public $hasMany = array('CommentsLesson' => 
     28                        array('className'     => 'CommentsLesson', 
     29                  'conditions'    =>  null, 
     30                  'order'         => 'CommentsLesson.created', 
     31                  'limit'         => null, 
     32                  'foreignKey'    => 'lesson_id', 
     33                  'dependent'     => true, 
     34                      'exclusive'     => false, 
     35                      'finderQuery'   => '' 
     36                      ) 
     37                 );   
     38 
     39  public $validate = array( 
    2840      'title' => VALID_NOT_EMPTY,         //'/[a-z0-9\_\-]{3,}$/i', 
    2941      'body' => VALID_NOT_EMPTY, 
  • trunk/app/views/lessons/view.ctp

    r312 r630  
    11<?php 
    2 echo '<h1>'  .$data['Lesson']['title']   . '</h1>'; 
    3 echo '<div>' .$data['Lesson']['body']    . '</div>'; 
    4 echo '<div>' .$data['Lesson']['created'] . '</div>'; 
     2  echo '<h1>'  .$data['Lesson']['title']   . '</h1>'; 
     3  echo $html->div(null, $data['Lesson']['body']); 
     4  echo $html->div(null, __('Last edition', true). ': '.$data['Lesson']['created']); 
     5   
     6  echo $form->create('CommentsLesson', array('onsubmit'=>'return chkForm()', 'action'=>'add')); 
     7  echo $form->hidden('CommentsLesson.redirect_to', array('value'=>'/lessons/view/'.$blog['User']['username'].'/'.$data['Lesson']['id'])); 
     8  echo $form->hidden('CommentsLesson.lesson_id', array('value'=>$data['Lesson']['id'])); 
     9        
     10  if ( $session->check('Auth.User') ): 
    511?> 
     12 <fieldset> 
     13 <legend id="new_comment"><?php __('New Comment'); ?></legend>  
     14 <?php 
     15   echo $session->read('Auth.User.username') . ' ' . __('writes', true); 
     16                  
     17   echo $form->label('CommentsLesson.comment', 'Comment'); 
     18   echo $form->textarea('CommentsLesson.comment', array('rows' => 10, 'cols' => 50)); 
     19   echo $form->error('CommentsLesson.comment', 'A comment is required.'); 
     20         
     21   echo $form->end(__('Send', true)); 
     22   echo '</fieldset>';        
     23 
     24else: 
     25    echo $html->para(null, $html->link('You must be logged in to write a comment', '/users/login')); 
     26endif; 
     27?> 
     28<script type="text/javascript"> 
     29/* <![CDATA[ */ 
     30 
     31 function chkForm() 
     32 { 
     33  var title   = document.getElementById("CommentsLessonCommentsLesson"); 
     34 
     35  if (title.value.length < 2) 
     36  { 
     37    alert('Comment too short'); 
     38    title.focus(); 
     39    return false; 
     40  } 
     41  return true; 
     42} 
     43 /* ]]> */ 
     44</script>