Changeset 887 for trunk/Modules/News/News.php
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/News/News.php
r878 r887 13 13 class ModuleNews extends AppModule 14 14 { 15 var$NewsCountPerCategory = 3;16 var$UploadedFilesFolder = 'files/news/';17 18 function __construct( $System)15 public int $NewsCountPerCategory = 3; 16 public string $UploadedFilesFolder = 'files/news/'; 17 18 function __construct(System $System) 19 19 { 20 20 parent::__construct($System); … … 28 28 } 29 29 30 function DoInstall() 31 { 32 } 33 34 function DoUnInstall() 35 { 36 } 37 38 function DoStart() 39 { 40 $this->System->RegisterPage('aktuality', 'PageNews'); 41 $this->System->RegisterPage(array('aktuality', 'aktualizace'), 'PageNewsUpdate'); 30 function DoInstall(): void 31 { 32 } 33 34 function DoUnInstall(): void 35 { 36 } 37 38 function DoStart(): void 39 { 40 $this->System->RegisterPage(['aktuality'], 'PageNews'); 41 $this->System->RegisterPage(['aktuality', 'subscription'], 'PageNewsSubscription'); 42 $this->System->RegisterPage(['aktuality', 'rss'], 'PageNewsRss'); 43 $this->System->RegisterPage(['aktuality', 'aktualizace'], 'PageNewsUpdate'); 42 44 $this->System->FormManager->RegisterClass('News', array( 43 45 'Title' => 'Aktualita', … … 86 88 if ($this->System->ModuleManager->ModulePresent('Search')) 87 89 { 88 $this->System->ModuleManager->Modules['Search']->RegisterSearch('Novinky', 'News', array('Title', 'Content'));89 } 90 } 91 92 function ShowNews( $Category, $ItemCount, $DaysAgo)90 ModuleSearch::Cast($this->System->GetModule('Search'))->RegisterSearch('Novinky', 'News', array('Title', 'Content')); 91 } 92 } 93 94 function ShowNews(string $Category, int $ItemCount, int $DaysAgo): string 93 95 { 94 96 $ItemCount = abs($ItemCount); … … 98 100 $Output = '<div class="NewsPanel"><div class="Title">'.$Row['Caption']; 99 101 $Output .= '<div class="Action"><a href="aktuality/?category='.$Category.'">Zobrazit</a>'; 100 if ( $this->System->User->CheckPermission('News', 'Insert', 'Group', $Category))102 if (ModuleUser::Cast($this->System->GetModule('User'))->User->CheckPermission('News', 'Insert', 'Group', $Category)) 101 103 $Output .= ' <a href="aktuality/?action=add&category='.$Category.'">Přidat</a>'; 102 104 $Output .= '</div></div><div class="Content">'; … … 139 141 } 140 142 141 function LoadSettingsFromCookies() 143 function LoadSettingsFromCookies(): void 142 144 { 143 145 // Initialize default news setting … … 163 165 } 164 166 165 function Show() 167 function Show(): string 166 168 { 167 169 $Output = ''; … … 197 199 } 198 200 199 function ShowCustomizeMenu() 201 function ShowCustomizeMenu(): string 200 202 { 201 203 $Output = '<form action="?Action=CustomizeNewsSave" method="post">'; … … 220 222 } 221 223 222 function CustomizeSave() 224 function CustomizeSave(): void 223 225 { 224 226 $Checkbox = array('' => 0, 'on' => 1); … … 245 247 } 246 248 247 function ModifyContent( $Content)249 function ModifyContent(string $Content): string 248 250 { 249 251 $Result = ''; … … 254 256 { 255 257 $I = strpos($Content, 'http://'); 256 if (($I > 0) and ($Content {$I - 1}!= '"'))258 if (($I > 0) and ($Content[$I - 1] != '"')) 257 259 { 258 260 $Result .= substr($Content, 0, $I); … … 272 274 return $Result; 273 275 } 276 277 static function Cast(AppModule $AppModule): ModuleNews 278 { 279 if ($AppModule instanceof ModuleNews) 280 { 281 return $AppModule; 282 } 283 throw new Exception('Expected ModuleNews type but got '.gettype($AppModule)); 284 } 274 285 }
Note:
See TracChangeset
for help on using the changeset viewer.