| 1 | <?php |
|---|
| 2 | //exit(debug($data)); |
|---|
| 3 | // lazy ass! |
|---|
| 4 | $discution = $data['Entry']['discution']; |
|---|
| 5 | $entry_id = $data['Entry']['id']; |
|---|
| 6 | $user_id = $data['Entry']['user_id']; |
|---|
| 7 | |
|---|
| 8 | e($html->div('titentry', $data['Entry']['title'])); |
|---|
| 9 | e($html->div('redaction', 'From the <b>'.$data['Subject']['title'].'</b> dept. On '. $data['Entry']['created'])); |
|---|
| 10 | e($html->div('body_entry', $data['Entry']['body'])); |
|---|
| 11 | |
|---|
| 12 | $pl = 'http://' . $_SERVER['SERVER_NAME'] . '/entries/view/'.$blog['User']['username'].'/'.$entry_id; |
|---|
| 13 | |
|---|
| 14 | e($html->div('plink', $html->link('Permalink: '. $pl, $pl))); |
|---|
| 15 | |
|---|
| 16 | if ( $discution == 1 ): //is the comments in this entry actived by blogger? |
|---|
| 17 | |
|---|
| 18 | if ( $session->check('Auth.User') ): // if user logged, anchor to textarea |
|---|
| 19 | echo $html->div(null, $html->image('static/comment.gif', array('alt'=>'Comments')) . ' Comments:', array('id'=>'comments')); |
|---|
| 20 | else: |
|---|
| 21 | echo '<div id="comments">'.$html->image('static/comment.gif',array("alt"=>"Comments")) .' '.__('Comments',true).' :<a style="font-size:7pt" href="#new_comment">>></a></div>'; |
|---|
| 22 | endif; |
|---|
| 23 | |
|---|
| 24 | $k = 1; |
|---|
| 25 | |
|---|
| 26 | foreach ($data['Comment'] as $v): |
|---|
| 27 | |
|---|
| 28 | $bg = ($k%2==0) ? "#e2e2e2" : "#fff"; |
|---|
| 29 | |
|---|
| 30 | $user = $html->link($v['User']['username'], '/users/about/'.$v['User']['username']).' '.$html->link($html->image('avatars/'.$v['User']['avatar'], array('alt'=>$v['User']['username'],'title'=>$v['User']['username'], 'style'=>'width:20px')), '/users/about/'.$v['User']['username'], null, null, false); |
|---|
| 31 | |
|---|
| 32 | echo '<div style="border:2px dotted #e2e2e2;margin:15px 0 15px 0;padding:8px;background-color:'.$bg.'">' . $k++ . '.- <b>' . $user . '</b> wrote: <br />'; |
|---|
| 33 | |
|---|
| 34 | echo $html->para(null, nl2br($v['comment'])); |
|---|
| 35 | |
|---|
| 36 | echo '<span class="small" style="font-size:7pt;font-weight:bold;">' . $v['created'] . '</span></div>'; |
|---|
| 37 | endforeach; |
|---|
| 38 | echo "<div>"; |
|---|
| 39 | |
|---|
| 40 | echo $form->create('Comment', array('onsubmit'=>'return chkForm()', 'action'=>'add')); |
|---|
| 41 | echo $form->hidden('Comment.redirect_to', array('value'=>'/entries/view/'.$blog['User']['username'].'/'.$entry_id)); |
|---|
| 42 | echo $form->hidden('Comment.entry_id', array('value'=>$entry_id)); |
|---|
| 43 | |
|---|
| 44 | if ( $session->check('Auth.User') ): |
|---|
| 45 | ?> |
|---|
| 46 | <fieldset> |
|---|
| 47 | <legend id="new_comment"><?php __('New Comment', true);?></legend> |
|---|
| 48 | <?php |
|---|
| 49 | echo $form->hidden('Comment.user_id', array('value' => $session->read('Auth.User.id'))); |
|---|
| 50 | echo $form->hidden('Comment.username', array('value' => $session->read('Auth.User.username'))); |
|---|
| 51 | echo $session->read('Auth.User.username') . ' '. __('writes', true) .' '; |
|---|
| 52 | |
|---|
| 53 | echo $form->label('Comment.comment', __('Comment',true)) .'<br />'; |
|---|
| 54 | echo $form->textarea('Comment.comment', array('rows' => 10, 'cols' => 50)); |
|---|
| 55 | echo $form->error('Comment.comment', 'A comment is required.'); |
|---|
| 56 | |
|---|
| 57 | echo $form->end(__('Send', true)); |
|---|
| 58 | echo '</fieldset>'; |
|---|
| 59 | else: |
|---|
| 60 | echo $html->para(null, $html->link(__('You must be logged in to write a comment', true), '/users/login')); |
|---|
| 61 | endif; |
|---|
| 62 | |
|---|
| 63 | echo "</div>"; |
|---|
| 64 | endif; |
|---|
| 65 | ?> |
|---|
| 66 | <script type="text/javascript"> |
|---|
| 67 | /* <![CDATA[ */ |
|---|
| 68 | |
|---|
| 69 | function chkForm() |
|---|
| 70 | { |
|---|
| 71 | var title = document.getElementById("CommentComment"); |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | if (title.value.length < 2) |
|---|
| 75 | { |
|---|
| 76 | alert('Comment too short'); |
|---|
| 77 | title.focus(); |
|---|
| 78 | return false; |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | return true; |
|---|
| 82 | } |
|---|
| 83 | /* ]]> */ |
|---|
| 84 | </script> |
|---|