source: trunk/www/Module/News/View.php

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