Changeset 63 for trunk/Modules/Event


Ignore:
Timestamp:
Aug 3, 2021, 11:20:41 AM (3 years ago)
Author:
chronos
Message:
  • Modified: Used explicit types where possible for better error reporting.
  • Modified: Updated Common packaged to newer version.
  • Modified: Simplified pages title.
  • Added: Simple keyword based spam filter for meet items.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        1 nbproject
        2 Config.php
        31.settings
        42.project
        53.buildpath
         4.htaccess
  • trunk/Modules/Event/Event.php

    r61 r63  
    33include_once(dirname(__FILE__).'/Import/JoeClub.php');
    44
    5 function GetDefaultEventFilter($Table = '')
     5function GetDefaultEventFilter(string $Table = ''): string
    66{
    77  global $Config;
     
    99  if ($Table != '') $Table = $Table.'.';
    1010
    11   return '('.$Table.'Hidden=0) AND ('.$Table.'TimeFrom > "'.TimeToMysqlDateTime(time() - $Config['EventInterval']).'")';
     11  return '('.$Table.'Hidden=0) AND ('.$Table.'TimeFrom > "'.TimeToMysqlDateTime(time() - (int)$Config['EventInterval']).'")';
    1212}
    1313
    14 function ReduceSpaces($Content)
     14function ReduceSpaces(string $Content): string
    1515{
    1616  while (strpos($Content, '  ') !== false) $Content = str_replace('  ', ' ', $Content);
     
    1818}
    1919
    20 function RemoveLines($Content)
     20function RemoveLines(string $Content): string
    2121{
    2222  while (strpos($Content, "\n") !== false) $Content = str_replace("\n", ' ', $Content);
     
    2424}
    2525
    26 function RemoveTabs($Content)
     26function RemoveTabs(string $Content): string
    2727{
    2828  while (strpos($Content, "\t") !== false) $Content = str_replace("\t", '', $Content);
     
    3434  public $Database;
    3535
    36   function Parse($Id = null)
     36  function Parse(int $Id = null): string
    3737  {
    3838    $Output = '';
     
    7373  }
    7474
    75   function Import()
     75  function Import(): string
    7676  {
    7777    $this->AddedCount = 0;
     
    9999  var $Price = 0;
    100100
    101   function AddIfNotExist($TimeInterval = 0, $CompareTime = true, $CompareRemoteId = false)
     101  function AddIfNotExist(int $TimeInterval = 0, bool $CompareTime = true, bool $CompareRemoteId = false): int
    102102  {
    103103    $Where = '(`Description` = "'.$this->Database->real_escape_string($this->Description).'") AND '.
  • trunk/Modules/Event/EventPage.php

    r62 r63  
    11<?php
    22
    3 class ModuleEvent extends AppModule
     3class ModuleEvent extends Module
    44{
    55  function __construct($System)
     
    1515  }
    1616
    17   function Start()
    18   {
    19     $this->System->RegisterPage('udalosti', 'PageEventList');
    20     $this->System->RegisterPage(array('udalosti', 'udalost'), 'PageEventItem');
    21     $this->System->RegisterPage(array('udalosti', 'aktualizace'), 'PageEventUpdate');
    22     $this->System->RegisterPage(array('udalosti', 'rss'), 'PageEventRss');
    23     $this->System->RegisterMenuItem('/udalosti', 'Události');
     17  function Start(): void
     18  {
     19    $this->System->RegisterPage(['udalosti'], 'PageEventList');
     20    $this->System->RegisterPage(['udalosti', 'udalost'], 'PageEventItem');
     21    $this->System->RegisterPage(['udalosti', 'aktualizace'], 'PageEventUpdate');
     22    $this->System->RegisterPage(['udalosti', 'rss'], 'PageEventRss');
     23    Core::Cast($this->System)->RegisterMenuItem('/udalosti', 'Události');
    2424  }
    2525}
     
    3030  {
    3131    parent::__construct($System);
    32     $this->FullTitle = 'Taneční události';
    33     $this->ShortTitle = 'Události';
    34   }
    35 
    36   function Show()
     32    $this->Title = 'Události';
     33    $this->Description = 'Taneční události';
     34  }
     35
     36  function Show(): string
    3737  {
    3838    $Filter = new Filter();
     
    4747
    4848    $Output = '';
    49     $this->Title = 'Události - '.$this->Title;
    5049    if (array_key_exists('lvm', $_GET) and ($_GET['lvm'] == 'seznam'))
    5150      $this->RawPage = true;
     
    111110  {
    112111    parent::__construct($System);
    113     $this->FullTitle = 'Aktualizace tanečních událostí';
    114     $this->ShortTitle = 'Aktualizace událostí';
    115   }
    116 
    117   function Show()
     112    $this->Title = 'Aktualizace událostí';
     113    $this->Description = 'Aktualizace tanečních událostí';
     114  }
     115
     116  function Show(): string
    118117  {
    119118    $EventSources = new EventSources();
     
    130129  {
    131130    parent::__construct($System);
    132     $this->FullTitle = 'Taneční událost';
    133     $this->ShortTitle = 'Událost';
    134   }
    135 
    136   function Show()
    137   {
    138     $this->Title = 'Událost - Události - '.$this->Title;
     131    $this->Title = 'Událost';
     132    $this->Description = 'Taneční událost';
     133  }
     134
     135  function Show(): string
     136  {
    139137    $Output = '';
    140138    if (count($this->System->PathItems) > 2)
     
    142140      $id = $this->System->PathItems[2] * 1;
    143141    } else return 'Položka nenalezena';
    144     if ($this->System->IsAdmin())
     142    if (Core::Cast($this->System)->IsAdmin())
    145143    {
    146144      if (array_key_exists('hide', $_GET)) $this->Database->update('Event', 'Id='.$id, array('Hidden' => 1));
     
    154152    {
    155153      $Event = $DbResult->fetch_assoc();
    156       if (($Event['Filter'] == '0') and !$this->System->IsAdmin())
     154      if (($Event['Filter'] == '0') and !Core::Cast($this->System)->IsAdmin())
    157155        return 'Položka nenalezena';
    158156      if ($Event['Link'] != '') $Link = '<a href="'.$Event['Link'].'">Odkaz</a>';
     
    168166        '<tr><th>Zdroj importu</th><td><a href="'.$Event['SourceURL'].'">'.$Event['SourceName'].'</a></td></tr>';
    169167      $Output .= '</table>';
    170       if ($this->System->IsAdmin()) {
     168      if (Core::Cast($this->System)->IsAdmin()) {
    171169        if ($Event['Hidden'] == '1')
    172170          $Output .= '<div>Skrytá položka <a href="?unhide">Zviditelnit</a></div>';
     
    183181  {
    184182    parent::__construct($System);
    185     $this->FullTitle = 'RSS kanál tanečních událostí';
    186     $this->ShortTitle = 'RSS taneční událostí';
    187   }
    188 
    189   function Show()
     183    $this->Title = 'RSS tanečních událostí';
     184    $this->Description = 'RSS kanál tanečních událostí';
     185  }
     186
     187  function Show(): string
    190188  {
    191189    global $Config;
  • trunk/Modules/Event/Import/JoeClub.php

    r55 r63  
    33class EventSourceJoeClub extends EventSource
    44{
    5   function ImportInternal()
     5  function ImportInternal(): string
    66  {
    77    $Output = '';
Note: See TracChangeset for help on using the changeset viewer.