source: trunk/www/Application/View/News.php@ 72

Last change on this file since 72 was 72, checked in by george, 16 years ago
  • Přidáno: Doplněny další Controllery.
File size: 1.6 KB
Line 
1<?php
2
3class NewsView extends Module
4{
5 var $ItemFormClass = array(
6 'Title' => 'Aktualita',
7 'Table' => 'News',
8 'Items' => array(
9 'Title' => array('Type' => 'String', 'Caption' => 'Titulek', 'Default' => ''),
10 'Content' => array('Type' => 'Text', 'Caption' => 'Obsah', 'Default' => ''),
11 ),
12 );
13
14 function AddFinish()
15 {
16 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)
17 {
18 $Form = new Form($this->System, $this->ItemFormClass);
19 $Form->LoadValuesFromForm();
20 $Form->Values['Time'] = 'NOW()';
21 $Form->Values['User'] = $this->System->Modules['User']->User['Id'];
22 $Form->SaveValuesToDatabase(0);
23 $Output = $this->System->SystemMessage('Nová aktualita', 'Přidáno');
24 } else $Output = USER_BAD_ROLE;
25 return($Output);
26 }
27
28 function Add()
29 {
30 if($this->System->Modules['User']->User['Role'] >= USER_ROLE_ADMINISTRATOR)
31 {
32 $Form = new Form($this->System, $this->ItemFormClass);
33 $Form->OnSubmit = '?Module=News&amp;Action=AddFinish';
34 $Output = $Form->ShowEditForm();
35 } else $Output = USER_BAD_ROLE;
36 return($Output);
37 }
38
39 function View()
40 {
41 $Output = '<td class="News"><strong>Aktuálně:</strong><br />';
42 $DbResult = $this->Database->query('SELECT * FROM News ORDER BY Time DESC LIMIT 10');
43 while($DbRow = $DbResult->fetch_assoc())
44 {
45 $Output .= '<div><strong>'.$DbRow['Title'].'</strong>('.HumanDate($DbRow['Time']).')<br />'.$DbRow['Content'].'</div>';
46 }
47 $Output .= '</td>';
48 return($Output);
49 }
50}
51
52?>
Note: See TracBrowser for help on using the repository browser.