Changeset 887 for trunk/Modules/WebCam/WebCam.php
- Timestamp:
- Nov 20, 2020, 12:08:12 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/WebCam/WebCam.php
r874 r887 3 3 class PageWebcam extends Page 4 4 { 5 var $FullTitle = 'Webová kamera'; 6 var $ShortTitle = 'Kamera'; 7 var $ParentClass = 'PagePortal'; 5 function __construct(System $System) 6 { 7 parent::__construct($System); 8 $this->FullTitle = 'Webová kamera'; 9 $this->ShortTitle = 'Kamera'; 10 $this->ParentClass = 'PagePortal'; 11 } 8 12 9 function Show() 13 function Show(): string 10 14 { 11 if (file_exists( $this->System->ModuleManager->Modules['WebCam']->ImageFileName))15 if (file_exists(ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName)) 12 16 { 13 17 $Output = '<script language="JavaScript"> 14 var ImageURL = "'.$this->System->Config['Web']['RootFolder'].'/webcam/'. $this->System->Modules['Webcam']->ImageFileName.'";18 var ImageURL = "'.$this->System->Config['Web']['RootFolder'].'/webcam/'.ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName.'"; 15 19 16 20 // Force an immediate image load … … 32 36 </script>'; 33 37 34 $Output .= '<br /><div align="center"><img name="theImage" src="" idth="640" height="480" alt="Webcam image"><br>Poslední aktualizace: '.date('j.n.Y G:i', filemtime($this->System->Modules['Webcam']->ImageFileName)).'<br>Obnovování po '.$this->System->Config['Web']['WebcamRefresh'].' sekundách</div><br />'; 38 $Output .= '<br /><div align="center"><img name="theImage" src="" idth="640" height="480" alt="Webcam image"><br>Poslední aktualizace: '. 39 date('j.n.Y G:i', filemtime(ModuleWebCam::Cast($this->System->GetModule('WebCam'))->ImageFileName)). 40 '<br>Obnovování po '.$this->System->Config['Web']['WebcamRefresh'].' sekundách</div><br />'; 35 41 } else $Output = '<br />Obrázek nenalezen.<br /><br />'; 36 42 … … 44 50 class ModuleWebCam extends AppModule 45 51 { 46 var$ImageFileName = 'webcam.jpg';52 public string $ImageFileName = 'webcam.jpg'; 47 53 48 function __construct( $System)54 function __construct(System $System) 49 55 { 50 56 parent::__construct($System); … … 58 64 } 59 65 60 function DoStart() 66 function DoStart(): void 61 67 { 62 68 $this->System->Pages['webcam'] = 'PageWebcam'; 63 69 } 64 70 65 function ShowImage() 71 function ShowImage(): string 66 72 { 67 73 global $Config; … … 74 80 return $Output; 75 81 } 82 83 static function Cast(AppModule $AppModule): ModuleWebCam 84 { 85 if ($AppModule instanceof ModuleWebCam) 86 { 87 return $AppModule; 88 } 89 throw new Exception('Expected ModuleWebCam type but got '.gettype($AppModule)); 90 } 76 91 }
Note:
See TracChangeset
for help on using the changeset viewer.