Changeset 888


Ignore:
Timestamp:
Dec 27, 2022, 7:50:23 PM (16 months ago)
Author:
chronos
Message:
  • Modified: Updated Common package to latest version.
  • Modified: Fixes related to PHP 8.x.
Location:
trunk
Files:
13 added
1 deleted
68 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/Application/Core.php

    r884 r888  
    11<?php
    22
    3 class Core extends Application
     3class Core extends System
    44{
    5   var $Config;
    6   var $PathItems;
    7   var $Menu;
    8   var $DoNotShowPage;
    9   var $OnPageNotFound;
    10   var $Pages;
    11   /* @var LocaleManager */
    12   var $LocaleManager;
    13   var $Bars;
    14   var $PageHeaders;
    15   var $BaseURL;
     5  public array $Config;
     6  public array $PathItems;
     7  public array $Menu;
     8  public bool $DoNotShowPage;
     9  public array $OnPageNotFound;
     10  public LocaleManager $LocaleManager;
     11  public array $Bars;
     12  public array $PageHeaders;
     13  public string $BaseURL;
    1614
    1715  function __construct()
     
    103101  }
    104102
    105   function Run()
     103  static function Cast(System $System): Core
     104  {
     105    if ($System instanceof Core)
     106    {
     107      return $System;
     108    }
     109    throw new Exception('Expected Core type but '.gettype($System));
     110  }
     111
     112  function Run(): void
    106113  {
    107114    global $ScriptStartTime, $StopAfterUpdateManager,
     
    126133    $this->Init();
    127134
    128     // Register and start existing modules
    129     $this->Setup = new Setup($this);
    130     $this->Setup->Start();
    131     $this->Setup->UpdateManager->VersionTable = 'DbVersion';
    132     if ($this->Setup->CheckState())
    133     {
    134       $this->ModuleManager->Start();
    135     }
     135    $this->StartModules();
    136136
    137137    $this->BaseView = new BaseView($this);
     
    142142  }
    143143
     144  function StartModules(): void
     145  {
     146    $ModuleSetup = $this->ModuleManager->LoadModule(dirname(__FILE__).'/../Packages/Common/Modules/Setup.php');
     147    ModuleSetup::Cast($ModuleSetup)->UpdateManager->VersionTable = 'DbVersion';
     148    $ModuleSetup->Install();
     149    $ModuleSetup->Start();
     150    $this->ModuleManager->LoadModules();
     151    $this->ModuleManager->LoadModule(dirname(__FILE__).'/../Packages/Common/Modules/ModuleManager.php');
     152    if (file_exists($this->ModuleManager->FileName)) $this->ModuleManager->LoadState();
     153    if (ModuleSetup::Cast($ModuleSetup)->CheckState())
     154    {
     155      $this->ModuleManager->StartAll(array(ModuleCondition::Enabled));
     156    }
     157  }
     158
    144159  function GetMicrotime()
    145160  {
     
    148163  }
    149164
    150   function Link($Target)
     165  function Link(string $Target): string
    151166  {
    152167    if (substr($Target, 0, strlen($this->BaseURL)) == $this->BaseURL)
     
    235250      return $this->BaseURL.$Target;
    236251    return $this->BaseURL.'/'.$Locale.$Target;
    237   }
    238 
    239   function RegisterPage($Path, $Handler)
    240   {
    241     if (is_array($Path))
    242     {
    243       $Page = &$this->Pages;
    244       $LastKey = array_pop($Path);
    245       foreach ($Path as $PathItem)
    246       {
    247         $Page = &$Page[$PathItem];
    248       }
    249       if (!is_array($Page)) $Page = array('' => $Page);
    250       $Page[$LastKey] = $Handler;
    251     } else $this->Pages[$Path] = $Handler;
    252252  }
    253253
  • trunk/Application/UpdateTrace.php

    r880 r888  
    29672967}
    29682968
     2969function UpdateTo887($Manager)
     2970{
     2971  $Manager->Execute('ALTER TABLE `Referrer` CHANGE `LastIP` `LastIP` VARCHAR(46) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL;');
     2972}
     2973
    29692974class Updates
    29702975{
     
    30063011      867 => array('Revision' => 872, 'Function' => 'UpdateTo872'),
    30073012      872 => array('Revision' => 873, 'Function' => 'UpdateTo873'),
     3013      873 => array('Revision' => 887, 'Function' => 'UpdateTo887'),
    30083014    );
    30093015  }
  • trunk/Application/Version.php

    r884 r888  
    77
    88$Version = '1.0';
    9 $Revision = 884; // Subversion revision
    10 $DatabaseRevision = 873; // Database structure revision
    11 $ReleaseDate = strtotime('2020-04-08');
     9$Revision = 887; // Subversion revision
     10$DatabaseRevision = 887; // Database structure revision
     11$ReleaseDate = strtotime('2022-12-27');
  • trunk/Application/View.php

    r884 r888  
    1616      if ($Locale['Code'] == $this->System->LocaleManager->CurrentLocale->Texts->Code) $Selected = ' selected="selected"';
    1717        else $Selected = '';
    18       $Remaining = $this->System->TranslateReverseURL($Remaining, $this->System->LocaleManager->LangCode);
     18      $Remaining = Core::Cast($this->System)->TranslateReverseURL($Remaining, $this->System->LocaleManager->LangCode);
    1919
    20       $URL = $this->System->LinkLocale($Remaining, $Locale['Code']);
     20      $URL = Core::Cast($this->System)->LinkLocale($Remaining, $Locale['Code']);
    2121      $Output .= '<option title="" value="'.$URL.'"'.$Selected.' onchange="this.form.submit()">'.$Locale['Title'].'</option>';
    2222    }
     
    126126    $Output .= '</td>';
    127127    $Output .= '</tr><tr>'.
    128       '<td colspan="4" class="page-bottom">'.T('Version').': '.$Version.' '.T('Revision').': '.$Revision.' ('.$this->System->HumanDate($ReleaseDate).')'.
     128      '<td colspan="4" class="page-bottom">'.T('Version').': '.$Version.' '.T('Revision').': '.$Revision.' ('.Core::Cast($this->System)->HumanDate($ReleaseDate).')'.
    129129      ' &nbsp; <a href="https://app.zdechov.net/wowpreklad/browser/trunk">'.T('Source code').'</a> &nbsp; '.
    130130      '<a href="https://app.zdechov.net/wowpreklad/log/trunk?verbose=on">'.T('Changelog').'</a> &nbsp; '.
  • trunk/HTML/BBCodeParser2.php

    r887 r888  
    8484     * @var      array
    8585     */
    86     var $_definedTags  = array();
     86    private array $_definedTags  = array();
    8787
    8888    /**
     
    9292     * @var      string
    9393     */
    94     var $_text          = '';
     94    public string $_text = '';
    9595
    9696    /**
     
    100100     * @var      string
    101101     */
    102     var $_preparsed    = '';
     102    private string $_preparsed = '';
    103103
    104104    /**
     
    108108     * @var      array
    109109     */
    110     var $_tagArray      = array();
     110    private array $_tagArray = array();
    111111
    112112    /**
     
    116116     * @var      string
    117117     */
    118     var $_parsed        = '';
     118   private string $_parsed = '';
    119119
    120120    /**
     
    124124     * @var      array
    125125     */
    126     var $_options = array(
     126    public array $_options = array(
    127127        'quotestyle'    => 'double',
    128128        'quotewhat'     => 'all',
     
    139139     * @var      array
    140140     */
    141     var $_filters      = array();
     141    private array $_filters = array();
    142142
    143143    /**
     
    155155     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    156156     */
    157     function __construct($options = array())
     157    function __construct(array $options = array())
    158158    {
    159159        // set the options passed as an argument
    160         foreach ($options as $k => $v )  {
     160        foreach ($options as $k => $v )
     161        {
    161162            $this->_options[$k] = $v;
    162163        }
     
    166167        if ($this->_options['open'] != '' && strpos($preg_escape, $this->_options['open'])) {
    167168            $this->_options['open_esc'] = "\\".$this->_options['open'];
    168         } else {
     169        } else
     170        {
    169171            $this->_options['open_esc'] = $this->_options['open'];
    170172        }
    171173        if ($this->_options['close'] != '' && strpos($preg_escape, $this->_options['close'])) {
    172174            $this->_options['close_esc'] = "\\".$this->_options['close'];
    173         } else {
     175        } else
     176        {
    174177            $this->_options['close_esc'] = $this->_options['close'];
    175178        }
     
    180183
    181184        // return if this is a subclass
    182         if (is_subclass_of($this, 'HTML_BBCodeParser2_Filter')) {
     185        if (is_subclass_of($this, 'HTML_BBCodeParser2_Filter'))
     186        {
    183187            return;
    184188        }
     
    195199     * @author Lorenzo Alberton <l.alberton@quipo.it>
    196200     */
    197     function setOption($name, $value)
     201    function setOption(string $name, $value): void
    198202    {
    199203        $this->_options[$name] = $value;
     
    206210     * @author Lorenzo Alberton <l.alberton@quipo.it>
    207211     */
    208     function addFilter($filter)
     212    function addFilter(string $filter)
    209213    {
    210214        $filter = ucfirst($filter);
    211         if (!array_key_exists($filter, $this->_filters)) {
     215        if (!array_key_exists($filter, $this->_filters))
     216        {
    212217            $class = 'HTML_BBCodeParser2_Filter_'.$filter;
    213218            @include_once 'HTML/BBCodeParser2/Filter/'.$filter.'.php';
    214             if (!class_exists($class)) {
     219            if (!class_exists($class))
     220            {
    215221                throw new InvalidArgumentException("Failed to load filter $filter");
    216222            }
     
    229235     * @author Lorenzo Alberton <l.alberton@quipo.it>
    230236     */
    231     function removeFilter($filter)
     237    function removeFilter($filter): void
    232238    {
    233239        $filter = ucfirst(trim($filter));
    234         if (!empty($filter) && array_key_exists($filter, $this->_filters)) {
     240        if (!empty($filter) && array_key_exists($filter, $this->_filters))
     241        {
    235242            unset($this->_filters[$filter]);
    236243        }
     
    238245        // preserving the others
    239246        $this->_definedTags = array();
    240         foreach (array_keys($this->_filters) as $filter) {
     247        foreach (array_keys($this->_filters) as $filter)
     248        {
    241249            $this->_definedTags = array_merge(
    242250                $this->_definedTags,
     
    253261     * @author Lorenzo Alberton <l.alberton@quipo.it>
    254262     */
    255     function addFilters($filters)
    256     {
    257         if (is_string($filters)) {
     263    function addFilters($filters): bool
     264    {
     265        if (is_string($filters))
     266        {
    258267            //comma-separated list
    259             if (strpos($filters, ',') !== false) {
     268            if (strpos($filters, ',') !== false)
     269            {
    260270                $filters = explode(',', $filters);
    261             } else {
     271            } else
     272            {
    262273                $filters = array($filters);
    263274            }
    264275        }
    265         if (!is_array($filters)) {
     276        if (!is_array($filters))
     277        {
    266278            //invalid format
    267279            return false;
    268280        }
    269         foreach ($filters as $filter) {
    270             if (trim($filter)){
     281        foreach ($filters as $filter)
     282        {
     283            if (trim($filter))
     284            {
    271285                $this->addFilter($filter);
    272286            }
     
    291305     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    292306     */
    293     function _preparse()
     307    function _preparse(): void
    294308    {
    295309        // default: assign _text to _preparsed, to be overwritten by filters
     
    297311
    298312        // return if this is a subclass
    299         if (is_subclass_of($this, 'HTML_BBCodeParser2')) {
     313        if (is_subclass_of($this, 'HTML_BBCodeParser2'))
     314        {
    300315            return;
    301316        }
    302317
    303318        // walk through the filters and execute _preparse
    304         foreach ($this->_filters as $filter) {
     319        foreach ($this->_filters as $filter)
     320        {
    305321            $filter->setText($this->_preparsed);
    306322            $filter->_preparse();
     
    326342     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    327343     */
    328     function _buildTagArray()
     344    function _buildTagArray(): void
    329345    {
    330346        $this->_tagArray = array();
     
    333349        $strLength = strlen($str);
    334350
    335         while (($strPos < $strLength)) {
     351        while (($strPos < $strLength))
     352        {
    336353            $tag = array();
    337354            $openPos = strpos($str, $this->_options['open'], $strPos);
    338             if ($openPos === false) {
     355            if ($openPos === false)
     356            {
    339357                $openPos = $strLength;
    340358                $nextOpenPos = $strLength;
    341359            }
    342             if ($openPos + 1 > $strLength) {
     360            if ($openPos + 1 > $strLength)
     361            {
    343362                $nextOpenPos = $strLength;
    344             } else {
     363            } else
     364            {
    345365                $nextOpenPos = strpos($str, $this->_options['open'], $openPos + 1);
    346                 if ($nextOpenPos === false) {
     366                if ($nextOpenPos === false)
     367                {
    347368                    $nextOpenPos = $strLength;
    348369                }
    349370            }
    350371            $closePos = strpos($str, $this->_options['close'], $strPos);
    351             if ($closePos === false) {
     372            if ($closePos === false)
     373            {
    352374                $closePos = $strLength + 1;
    353375            }
    354376
    355             if ($openPos == $strPos) {
    356                 if (($nextOpenPos < $closePos)) {
     377            if ($openPos == $strPos)
     378            {
     379                if (($nextOpenPos < $closePos))
     380                {
    357381                    // new open tag before closing tag: treat as text
    358382                    $newPos = $nextOpenPos;
    359383                    $tag['text'] = substr($str, $strPos, $nextOpenPos - $strPos);
    360384                    $tag['type'] = 0;
    361                 } else {
     385                } else
     386                {
    362387                    // possible valid tag
    363388                    $newPos = $closePos + 1;
    364389                    $newTag = $this->_buildTag(substr($str, $strPos, $closePos - $strPos + 1));
    365                     if (($newTag !== false)) {
     390                    if (($newTag !== false))
     391                    {
    366392                        $tag = $newTag;
    367                     } else {
     393                    } else
     394                    {
    368395                        // no valid tag after all
    369396                        $tag['text'] = substr($str, $strPos, $closePos - $strPos + 1);
     
    371398                    }
    372399                }
    373             } else {
     400            } else
     401            {
    374402                // just text
    375403                $newPos = $openPos;
     
    379407
    380408            // join 2 following text elements
    381             if ($tag['type'] === 0 && isset($prev) && $prev['type'] === 0) {
     409            if ($tag['type'] === 0 && isset($prev) && $prev['type'] === 0)
     410            {
    382411                $tag['text'] = $prev['text'].$tag['text'];
    383412                array_pop($this->_tagArray);
     
    404433     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    405434     */
    406     function _buildTag($str)
     435    function _buildTag(string $str): bool|array
    407436    {
    408437        $tag = array('text' => $str, 'attributes' => array());
    409438
    410         if (substr($str, 1, 1) == '/') {        // closing tag
    411 
     439        if (substr($str, 1, 1) == '/')
     440        {        // closing tag
    412441            $tag['tag'] = strtolower(substr($str, 2, strlen($str) - 3));
    413             if (!in_array($tag['tag'], array_keys($this->_definedTags))) {
     442            if (!in_array($tag['tag'], array_keys($this->_definedTags)))
     443            {
    414444                return false;                   // nope, it's not valid
    415             } else {
     445            } else
     446            {
    416447                $tag['type'] = 2;
    417448                return $tag;
    418449            }
    419         } else {                                // opening tag
    420 
     450        } else
     451        {                                // opening tag
    421452            $tag['type'] = 1;
    422             if (strpos($str, ' ') && (strpos($str, '=') === false)) {
     453            if (strpos($str, ' ') && (strpos($str, '=') === false))
     454            {
    423455                return false;                   // nope, it's not valid
    424456            }
     
    429461            $ce = $this->_options['close_esc'];
    430462            $tagArray = array();
    431             if (preg_match("!$oe([a-z0-9]+)[^$ce]*$ce!i", $str, $tagArray) == 0) {
     463            if (preg_match("!$oe([a-z0-9]+)[^$ce]*$ce!i", $str, $tagArray) == 0)
     464            {
    432465                return false;
    433466            }
    434467            $tag['tag'] = strtolower($tagArray[1]);
    435             if (!in_array($tag['tag'], array_keys($this->_definedTags))) {
     468            if (!in_array($tag['tag'], array_keys($this->_definedTags)))
     469            {
    436470                return false;                   // nope, it's not valid
    437471            }
     
    441475            $attributeArray = array();
    442476            $regex = "![\s$oe]([a-z0-9]+)=(\"[^\s$ce]+\"|[^\s$ce]";
    443             if ($tag['tag'] != 'url') {
     477            if ($tag['tag'] != 'url')
     478            {
    444479                $regex .= "[^=]";
    445480            }
    446481            $regex .= "+)(?=[\s$ce])!i";
    447482            preg_match_all($regex, $str, $attributeArray, PREG_SET_ORDER);
    448             foreach ($attributeArray as $attribute) {
     483            foreach ($attributeArray as $attribute)
     484            {
    449485                $attNam = strtolower($attribute[1]);
    450                 if (in_array($attNam, array_keys($this->_definedTags[$tag['tag']]['attributes']))) {
    451                     if ($attribute[2][0] == '"' && $attribute[2][strlen($attribute[2])-1] == '"') {
     486                if (in_array($attNam, array_keys($this->_definedTags[$tag['tag']]['attributes'])))
     487                {
     488                    if ($attribute[2][0] == '"' && $attribute[2][strlen($attribute[2])-1] == '"')
     489                    {
    452490                        $tag['attributes'][$attNam] = substr($attribute[2], 1, -1);
    453                     } else {
     491                    } else
     492                    {
    454493                        $tag['attributes'][$attNam] = $attribute[2];
    455494                    }
     
    476515     * @author   Stijn de Reede  <sjr@gmx.co.uk>, Seth Price <seth@pricepages.org>
    477516     */
    478     function _validateTagArray()
     517    function _validateTagArray(): void
    479518    {
    480519        $newTagArray = array();
    481520        $openTags = array();
    482         foreach ($this->_tagArray as $tag) {
     521        foreach ($this->_tagArray as $tag)
     522        {
     523            echo('newTagArray: ');
     524            print_r($newTagArray);
    483525            $prevTag = end($newTagArray);
    484526
    485527            // TODO: why prevTag cann by type bool?
    486             if (!is_array($prevTag)) continue;
     528            if (!is_array($prevTag))
     529            {
     530                echo('tag: ');
     531                print_r($tag);
     532                continue;
     533            }
    487534
    488535            switch ($tag['type']) {
     
    497544                    $child !== true )
    498545                {
    499                     if (trim($tag['text']) == '') {
     546                    if (trim($tag['text']) == '')
     547                    {
    500548                        //just an empty indentation or newline without value?
    501                         continue;
     549                        continue 2;
    502550                    }
    503551                    $newTagArray[] = $child;
     
    505553                }
    506554
    507                 if ($prevTag['type'] === 0) {
     555                if ($prevTag['type'] === 0)
     556                {
    508557                    $tag['text'] = $prevTag['text'].$tag['text'];
    509558                    array_pop($newTagArray);
     
    515564                if (!$this->_isAllowed(end($openTags), $tag['tag']) ||
    516565                   ($parent = $this->_parentNeeded(end($openTags), $tag['tag'])) === true ||
    517                    ($child  = $this->_childNeeded(end($openTags),  $tag['tag'])) === true) {
     566                   ($child  = $this->_childNeeded(end($openTags),  $tag['tag'])) === true)
     567                   {
    518568                    $tag['type'] = 0;
    519                     if ($prevTag['type'] === 0) {
     569                    if ($prevTag['type'] === 0)
     570                    {
    520571                        $tag['text'] = $prevTag['text'].$tag['text'];
    521572                        array_pop($newTagArray);
    522573                    }
    523                 } else {
    524                     if ($parent) {
     574                } else
     575                {
     576                    if ($parent)
     577                    {
    525578                        /*
    526579                         * Avoid use of parent if we can help it. If we are
     
    531584                         * current tag.
    532585                         */
    533                         if ($tag['tag'] == end($openTags)){
     586                        if ($tag['tag'] == end($openTags))
     587                        {
    534588                            $newTagArray[] = $this->_buildTag('[/'.$tag['tag'].']');
    535589                            array_pop($openTags);
    536                         } else {
     590                        } else
     591                        {
    537592                            $newTagArray[] = $parent;
    538593                            $openTags[] = $parent['tag'];
     
    549604
    550605            case 2:
    551                 if (($tag['tag'] == end($openTags) || $this->_isAllowed(end($openTags), $tag['tag']))) {
    552                     if (in_array($tag['tag'], $openTags)) {
     606                if (($tag['tag'] == end($openTags) || $this->_isAllowed(end($openTags), $tag['tag'])))
     607                {
     608                    if (in_array($tag['tag'], $openTags))
     609                    {
    553610                        $tmpOpenTags = array();
    554                         while (end($openTags) != $tag['tag']) {
     611                        while (end($openTags) != $tag['tag'])
     612                        {
    555613                            $newTagArray[] = $this->_buildTag('[/'.end($openTags).']');
    556614                            $tmpOpenTags[] = end($openTags);
     
    569627                        }*/
    570628                    }
    571                 } else {
     629                } else
     630                {
    572631                    $tag['type'] = 0;
    573                     if ($prevTag['type'] === 0) {
     632                    if ($prevTag['type'] === 0)
     633                    {
    574634                        $tag['text'] = $prevTag['text'].$tag['text'];
    575635                        array_pop($newTagArray);
     
    580640            }
    581641        }
    582         while (end($openTags)) {
     642        while (end($openTags))
     643        {
    583644            $newTagArray[] = $this->_buildTag('[/'.end($openTags).']');
    584645            array_pop($openTags);
     
    605666    {
    606667        if (!isset($this->_definedTags[$in]['parent']) ||
    607             ($this->_definedTags[$in]['parent'] == 'all')
    608         ) {
     668            ($this->_definedTags[$in]['parent'] == 'all'))
     669        {
    609670            return false;
    610671        }
     
    612673        $ar = explode('^', $this->_definedTags[$in]['parent']);
    613674        $tags = explode(',', $ar[1]);
    614         if ($ar[0] == 'none'){
    615             if ($out && in_array($out, $tags)) {
     675        if ($ar[0] == 'none')
     676        {
     677            if ($out && in_array($out, $tags))
     678            {
    616679                return false;
    617680            }
     
    619682            return $this->_buildTag('['.$tags[0].']');
    620683        }
    621         if ($ar[0] == 'all' && $out && !in_array($out, $tags)) {
     684        if ($ar[0] == 'all' && $out && !in_array($out, $tags))
     685        {
    622686            return false;
    623687        }
     
    642706     * @author   Seth Price <seth@pricepages.org>
    643707     */
    644     function _childNeeded($out, $in)
     708    function _childNeeded($out, $in): bool
    645709    {
    646710        if (!isset($this->_definedTags[$out]['child']) ||
    647            ($this->_definedTags[$out]['child'] == 'all')
    648         ) {
     711           ($this->_definedTags[$out]['child'] == 'all'))
     712        {
    649713            return false;
    650714        }
     
    652716        $ar = explode('^', $this->_definedTags[$out]['child']);
    653717        $tags = explode(',', $ar[1]);
    654         if ($ar[0] == 'none'){
    655             if ($in && in_array($in, $tags)) {
     718        if ($ar[0] == 'none')
     719        {
     720            if ($in && in_array($in, $tags))
     721            {
    656722                return false;
    657723            }
     
    659725            return $this->_buildTag('['.$tags[0].']');
    660726        }
    661         if ($ar[0] == 'all' && $in && !in_array($in, $tags)) {
     727        if ($ar[0] == 'all' && $in && !in_array($in, $tags))
     728        {
    662729            return false;
    663730        }
     
    680747     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    681748     */
    682     function _isAllowed($out, $in)
    683     {
    684         if (!$out || ($this->_definedTags[$out]['allowed'] == 'all')) {
     749    function _isAllowed($out, $in): bool
     750    {
     751        if (!$out || ($this->_definedTags[$out]['allowed'] == 'all'))
     752        {
    685753            return true;
    686754        }
    687         if ($this->_definedTags[$out]['allowed'] == 'none') {
     755        if ($this->_definedTags[$out]['allowed'] == 'none')
     756        {
    688757            return false;
    689758        }
     
    691760        $ar = explode('^', $this->_definedTags[$out]['allowed']);
    692761        $tags = explode(',', $ar[1]);
    693         if ($ar[0] == 'none' && in_array($in, $tags)) {
     762        if ($ar[0] == 'none' && in_array($in, $tags))
     763        {
    694764            return true;
    695765        }
    696         if ($ar[0] == 'all'  && in_array($in, $tags)) {
     766        if ($ar[0] == 'all'  && in_array($in, $tags))
     767        {
    697768            return false;
    698769        }
     
    712783     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    713784     */
    714     function _buildParsedString()
     785    function _buildParsedString(): void
    715786    {
    716787        $this->_parsed = '';
    717         foreach ($this->_tagArray as $tag) {
    718             switch ($tag['type']) {
     788        foreach ($this->_tagArray as $tag)
     789        {
     790            switch ($tag['type'])
     791            {
    719792
    720793            // just text
     
    728801                if ($this->_options['quotestyle'] == 'single') $q = "'";
    729802                if ($this->_options['quotestyle'] == 'double') $q = '"';
    730                 foreach ($tag['attributes'] as $a => $v) {
     803                foreach ($tag['attributes'] as $a => $v)
     804                {
    731805                    //prevent XSS attacks. IMHO this is not enough, though...
    732806                    //@see http://pear.php.net/bugs/bug.php?id=5609
     
    736810
    737811                    if (($this->_options['quotewhat'] == 'nothing') ||
    738                         (($this->_options['quotewhat'] == 'strings') && is_numeric($v))
    739                     ) {
     812                        (($this->_options['quotewhat'] == 'strings') && is_numeric($v)))
     813                    {
    740814                        $this->_parsed .= ' '.sprintf($this->_definedTags[$tag['tag']]['attributes'][$a], $v, '');
    741                     } else {
     815                    } else
     816                    {
    742817                        $this->_parsed .= ' '.sprintf($this->_definedTags[$tag['tag']]['attributes'][$a], $v, $q);
    743818                    }
    744819                }
    745                 if ($this->_definedTags[$tag['tag']]['htmlclose'] == '' && $this->_options['xmlclose']) {
     820                if ($this->_definedTags[$tag['tag']]['htmlclose'] == '' && $this->_options['xmlclose'])
     821                {
    746822                    $this->_parsed .= ' /';
    747823                }
     
    751827            // closing tag
    752828            case 2:
    753                 if ($this->_definedTags[$tag['tag']]['htmlclose'] != '') {
     829                if ($this->_definedTags[$tag['tag']]['htmlclose'] != '')
     830                {
    754831                    $this->_parsed .= '</'.$this->_definedTags[$tag['tag']]['htmlclose'].'>';
    755832                }
     
    769846     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    770847     */
    771     function setText($str)
     848    function setText(string $str): void
    772849    {
    773850        $this->_text = $str;
     
    783860     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    784861     */
    785     function getText()
     862    function getText(): string
    786863    {
    787864        return $this->_text;
     
    797874     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    798875     */
    799     function getPreparsed()
     876    function getPreparsed(): string
    800877    {
    801878        return $this->_preparsed;
     
    811888     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    812889     */
    813     function getParsed()
     890    function getParsed(): string
    814891    {
    815892        return $this->_parsed;
     
    827904     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    828905     */
    829     function parse()
     906    function parse(): void
    830907    {
    831908        $this->_preparse();
     
    838915     * Quick method to do setText(), parse() and getParsed at once
    839916     *
     917     * @return   string
     918     * @access   public
     919     * @see      parse()
     920     * @see      $_text
     921     * @author   Stijn de Reede  <sjr@gmx.co.uk>
     922     */
     923    function qparse(string $str): string
     924    {
     925        $this->_text = $str;
     926        $this->parse();
     927        return $this->_parsed;
     928    }
     929
     930    /**
     931     * Quick static method to do setText(), parse() and getParsed at once
     932     *
    840933     * @return   none
    841934     * @access   public
     
    844937     * @author   Stijn de Reede  <sjr@gmx.co.uk>
    845938     */
    846     function qparse($str)
    847     {
    848         $this->_text = $str;
    849         $this->parse();
    850         return $this->_parsed;
    851     }
    852 
    853     /**
    854      * Quick static method to do setText(), parse() and getParsed at once
    855      *
    856      * @return   none
    857      * @access   public
    858      * @see      parse()
    859      * @see      $_text
    860      * @author   Stijn de Reede  <sjr@gmx.co.uk>
    861      */
    862     function staticQparse($str)
    863     {
    864         $p = new HTML_BBCodeParser2();
    865         $str = $p->qparse($str);
    866         unset($p);
     939    function staticQparse(string $str): string
     940    {
     941        $Parser = new HTML_BBCodeParser2();
     942        $str = $Parser->qparse($str);
     943        unset($Parser);
    867944        return $str;
    868945    }
    869946}
    870 ?>
  • trunk/HTML/BBCodeParser2/Filter/Basic.php

    r760 r888  
    2525*/
    2626
    27 
    2827require_once 'HTML/BBCodeParser2/Filter.php';
    29 
    30 
    31 
    3228
    3329class HTML_BBCodeParser2_Filter_Basic extends HTML_BBCodeParser2_Filter
     
    6561                                                'attributes'=> array())
    6662                            );
    67 
    6863}
  • trunk/HTML/BBCodeParser2/Filter/Email.php

    r760 r888  
    6565    * @author   Stijn de Reede  <sjr@gmx.co.uk>
    6666    */
    67     function _preparse()
     67    function _preparse(): void
    6868    {
    6969        $options = $this->_options;
  • trunk/HTML/BBCodeParser2/Filter/Images.php

    r816 r888  
    2828class HTML_BBCodeParser2_Filter_Images extends HTML_BBCodeParser2_Filter
    2929{
    30 
    3130    /**
    3231    * An array of tags parsed by the engine
     
    6564    * @author   Stijn de Reede  <sjr@gmx.co.uk>
    6665    */
    67     function _preparse()
     66    function _preparse(): void
    6867    {
    6968        $options = $this->_options;
  • trunk/HTML/BBCodeParser2/Filter/Links.php

    r815 r888  
    8181     * @author   Seth Price <seth@pricepages.org>
    8282     */
    83     function _preparse()
     83    function _preparse(): void
    8484    {
    8585        $options = $this->_options;
  • trunk/HTML/BBCodeParser2/Filter/Lists.php

    r815 r888  
    7777    * @author   Stijn de Reede <sjr@gmx.co.uk>, Seth Price <seth@pricepages.org>
    7878    */
    79     function _preparse()
     79    function _preparse(): void
    8080    {
    8181        $options = $this->_options;
  • trunk/Modules/Admin/Admin.php

    r884 r888  
    11<?php
    22
    3 class ModuleAdmin extends AppModule
     3class ModuleAdmin extends Module
    44{
    55  function __construct(System $System)
     
    1414  }
    1515
    16   function DoStart()
    17   {
    18     $this->System->RegisterMenuItem(array(
     16  function DoStart(): void
     17  {
     18    Core::Cast($this->System)->RegisterMenuItem(array(
    1919      'Title' => T('Administration'),
    2020      'Hint' => T('Administration tools'),
     
    2323      'Icon' => '',
    2424    ));
    25     $this->System->RegisterPage('admin', 'PageAdmin');
     25    $this->System->RegisterPage(['admin'], 'PageAdmin');
    2626  }
    2727}
     
    305305  }
    306306
    307   function Show()
     307  function Show(): string
    308308  {
    309309    $this->Title = T('Administration');
  • trunk/Modules/AoWoW/AoWoW.php

    r880 r888  
    11<?php
    22
    3 class ModuleAoWoW extends AppModule
     3class ModuleAoWoW extends Module
    44{
    55  function __construct(System $System)
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    18     $this->System->RegisterMenuItem(array(
     18    Core::Cast($this->System)->RegisterMenuItem(array(
    1919      'Title' => 'AoWoW',
    2020      'Hint' => 'Vyhledávací databáze podobná WoWHead s překlady',
  • trunk/Modules/ClientVersion/ClientVersion.php

    r880 r888  
    11<?php
    22
    3 class ModuleClientVersion extends AppModule
     3class ModuleClientVersion extends Module
    44{
    55  function __construct(System $System)
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    18     $this->System->RegisterPage('client-version', 'PageClientVersion');
    19     $this->System->RegisterMenuItem(array(
     18    $this->System->RegisterPage(['client-version'], 'PageClientVersion');
     19    Core::Cast($this->System)->RegisterMenuItem(array(
    2020      'Title' => T('Game version'),
    2121      'Hint' => T('List of the game client versions'),
     
    2929class PageClientVersion extends Page
    3030{
    31   function Show()
     31  function Show(): string
    3232  {
    3333    if (array_key_exists('action', $_GET))
  • trunk/Modules/Dictionary/Dictionary.php

    r880 r888  
    11<?php
    22
    3 class ModuleDictionary extends AppModule
     3class ModuleDictionary extends Module
    44{
    55  function __construct(System $System)
     
    1414  }
    1515
    16   function DoStart()
    17   {
    18     $this->System->RegisterPage('dictionary', 'PageDictionary');
    19     $this->System->RegisterMenuItem(array(
     16  function DoStart(): void
     17  {
     18    $this->System->RegisterPage(['dictionary'], 'PageDictionary');
     19    Core::Cast($this->System)->RegisterMenuItem(array(
    2020      'Name' => 'Dictionary',
    2121      'Title' => T('Dictionary'),
     
    311311  }
    312312
    313   function Show()
     313  function Show(): string
    314314  {
    315315    global $LanguageList;
  • trunk/Modules/Download/Download.php

    r880 r888  
    11<?php
    22
    3 class ModuleDownload extends AppModule
     3class ModuleDownload extends Module
    44{
    55  function __construct(System $System)
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    18     $this->System->RegisterPage('download', 'PageDownload');
    19     $this->System->RegisterMenuItem(array(
     18    $this->System->RegisterPage(['download'], 'PageDownload');
     19    Core::Cast($this->System)->RegisterMenuItem(array(
    2020      'Title' => T('Download'),
    2121      'Hint' => T('List of files for download'),
     
    147147  }
    148148
    149   function Show()
     149  function Show(): string
    150150  {
    151151    $this->Title = T('Download');
  • trunk/Modules/Error/Error.php

    r880 r888  
    11<?php
    22
    3 class ModuleError extends AppModule
     3class ModuleError extends Module
    44{
    55  var $OnError;
     
    2121  }
    2222
    23   function DoStart()
     23  function DoStart(): void
    2424  {
    2525    if (isset($this->System->Config['Web']['ShowPHPError']))
     
    2929  }
    3030
    31   function DoStop()
     31  function DoStop(): void
    3232  {
    3333    $this->ErrorHandler->Stop();
  • trunk/Modules/Export/CreateAddon.php

    r880 r888  
    267267    $Buffer = '
    268268 Čeština pro klienty:
    269   Vytvořeno v projektu http://wowpreklad.zdechov.net/
     269  Vytvořeno v projektu https://wowpreklad.zdechov.net/
    270270  Obsahuje Fonty pro správné zobrazování českých znaků, WoW addon překládající
    271271texty
  • trunk/Modules/Export/Export.php

    r882 r888  
    11<?php
     2
     3class ModuleExport extends Module
     4{
     5  function __construct(System $System)
     6  {
     7    parent::__construct($System);
     8    $this->Name = 'Export';
     9    $this->Version = '1.0';
     10    $this->Creator = 'Chronos';
     11    $this->License = 'GNU/GPL';
     12    $this->Description = 'Allow parametric export of translated texts to various supported output formats';
     13    $this->Dependencies = array('Translation');
     14  }
     15
     16  function DoStart(): void
     17  {
     18    $this->System->RegisterPage(['export'], 'PageExport');
     19    $this->System->RegisterPage(['export', 'progress'], 'PageExportProgress');
     20    Core::Cast($this->System)->RegisterMenuItem(array(
     21      'Title' => 'Exporty',
     22      'Hint' => 'Zde si můžete stáhnout přeložené texty',
     23      'Link' => $this->System->Link('/export/'),
     24      'Permission' => LICENCE_ANONYMOUS,
     25      'Icon' => '',
     26    ), 2);
     27  }
     28
     29  function GetTaskProgress($TaskId)
     30  {
     31    $Output = '';
     32    $DbResult = $this->Database->query('SELECT * FROM `ExportTask` '.
     33      'LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE '.
     34      '((`Export`.`OutputType` = 9) OR (`Export`.`OutputType` = 10)) AND '.
     35      '(`TimeFinish` IS NULL) OR (`Export` ='.$TaskId.') ORDER BY `TimeQueued`'); // `Export`='.$Export->Id
     36    while ($Task = $DbResult->fetch_assoc())
     37    {
     38      $Export = '<a href="'.$this->System->Link('/export/?Action=View&amp;ExportId='.$Task['Export']).'">'.$Task['Export'].'</a>';
     39      if ($TaskId == $Task['Export'])
     40        $Export = ''.$Export.' (tento)';
     41
     42      // Show progress bar
     43      $Output .= ' <strong>Export '.$Export.':</strong> <div id="progress'.$Task['Export'].'">'.
     44        '<strong>'.ProgressBar(300, $Task['Progress']).'</strong> ';
     45
     46      // Show estimated time to complete
     47      $PrefixMultiplier = new PrefixMultiplier();
     48      if ($Task['Progress'] > 0) {
     49        $ElapsedTime = time() - MysqlDateTimeToTime($Task['TimeStart']);
     50        $Output .= T('Elapsed time').': <strong>'.$PrefixMultiplier->Add($ElapsedTime, '', 4, 'Time').'</strong> / ';
     51        $EstimatedTime = (time() - MysqlDateTimeToTime($Task['TimeStart'])) / $Task['Progress'] * (100 - $Task['Progress']);
     52        $Output .= T('Estimated remaining time').': <strong>'.$PrefixMultiplier->Add($EstimatedTime, '', 4, 'Time').'</strong><br/>';
     53      }
     54      $Output .= '</div>';
     55
     56      if ($Task['Progress'] > 99)
     57        $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
     58        'setTimeout("parent.location.href=\''.$this->System->Link('/export/?Action=View&Tab=7&ExportId='.$TaskId).'\'", 500)'.
     59        '</script>';
     60    }
     61    return $Output;
     62  }
     63}
    264
    365class Export extends Model
     
    601663'<table cellspacing="10"><tr><td valign="top">'.
    602664
    603 '<p>Texty přebírány z projektu <a href="http://wowpreklad.zdechov.net/">wowpreklad.zdechov.net</a><br>'.
    604 '<a href="http://wowpreklad.zdechov.net/export/?Action=View&ExportId='.$this->Id.'&Tab=0">Export '.$this->Id.'</a></p><br>'.
     665'<p>Texty přebírány z projektu <a href="https://wowpreklad.zdechov.net/">wowpreklad.zdechov.net</a><br>'.
     666'<a href="http://wowpreklad.zdechov.nets/export/?Action=View&ExportId='.$this->Id.'&Tab=0">Export '.$this->Id.'</a></p><br>'.
    605667
    606668
     
    609671'<li>Požadovaná verze klienta: '.$this->ClientVersion['Version'].'</li>'.
    610672'<li>Datum uvolnění: '.date('d.m.Y h:m',time()).'</li>'.
    611 '<li>Sestaveno automaticky překladovým systémem <a href="http://wowpreklad.zdechov.net/">WoW překlad</a></li>'.
     673'<li>Sestaveno automaticky překladovým systémem <a href="https://wowpreklad.zdechov.net/">WoW překlad</a></li>'.
    612674//'<li>Tento soubor se generuje každý den. Pokud se zapojíte do překladu, zítra můžete stáhnout tento soubor znovu včetně svých překladů</li>'.
    613675//'<li>Sestavil: Maron</li>'.
     
    716778include_once(dirname(__FILE__).'/ExportOutput.php');
    717779
    718 class ModuleExport extends AppModule
    719 {
    720   function __construct(System $System)
    721   {
    722     parent::__construct($System);
    723     $this->Name = 'Export';
    724     $this->Version = '1.0';
    725     $this->Creator = 'Chronos';
    726     $this->License = 'GNU/GPL';
    727     $this->Description = 'Allow parametric export of translated texts to various supported output formats';
    728     $this->Dependencies = array('Translation');
    729   }
    730 
    731   function DoStart()
    732   {
    733     $this->System->RegisterPage('export', 'PageExport');
    734     $this->System->RegisterPage(array('export', 'progress'), 'PageExportProgress');
    735     $this->System->RegisterMenuItem(array(
    736       'Title' => 'Exporty',
    737       'Hint' => 'Zde si můžete stáhnout přeložené texty',
    738       'Link' => $this->System->Link('/export/'),
    739       'Permission' => LICENCE_ANONYMOUS,
    740       'Icon' => '',
    741     ), 2);
    742   }
    743 
    744   function GetTaskProgress($TaskId)
    745   {
    746     $Output = '';
    747     $DbResult = $this->Database->query('SELECT * FROM `ExportTask` '.
    748       'LEFT JOIN `Export` ON `Export`.`Id` = `ExportTask`.`Export` WHERE '.
    749       '((`Export`.`OutputType` = 9) OR (`Export`.`OutputType` = 10)) AND '.
    750       '(`TimeFinish` IS NULL) OR (`Export` ='.$TaskId.') ORDER BY `TimeQueued`'); // `Export`='.$Export->Id
    751     while ($Task = $DbResult->fetch_assoc())
    752     {
    753       $Export = '<a href="'.$this->System->Link('/export/?Action=View&amp;ExportId='.$Task['Export']).'">'.$Task['Export'].'</a>';
    754       if ($TaskId == $Task['Export'])
    755         $Export = ''.$Export.' (tento)';
    756 
    757       // Show progress bar
    758       $Output .= ' <strong>Export '.$Export.':</strong> <div id="progress'.$Task['Export'].'">'.
    759         '<strong>'.ProgressBar(300, $Task['Progress']).'</strong> ';
    760 
    761       // Show estimated time to complete
    762       $PrefixMultiplier = new PrefixMultiplier();
    763       if ($Task['Progress'] > 0) {
    764         $ElapsedTime = time() - MysqlDateTimeToTime($Task['TimeStart']);
    765         $Output .= T('Elapsed time').': <strong>'.$PrefixMultiplier->Add($ElapsedTime, '', 4, 'Time').'</strong> / ';
    766         $EstimatedTime = (time() - MysqlDateTimeToTime($Task['TimeStart'])) / $Task['Progress'] * (100 - $Task['Progress']);
    767         $Output .= T('Estimated remaining time').': <strong>'.$PrefixMultiplier->Add($EstimatedTime, '', 4, 'Time').'</strong><br/>';
    768       }
    769       $Output .= '</div>';
    770 
    771       if ($Task['Progress'] > 99)
    772         $Output .= '<script type="text/javascript" language="JavaScript" charset="utf-8">'.
    773         'setTimeout("parent.location.href=\''.$this->System->Link('/export/?Action=View&Tab=7&ExportId='.$TaskId).'\'", 500)'.
    774         '</script>';
    775     }
    776     return $Output;
    777   }
    778 }
  • trunk/Modules/Export/Page.php

    r880 r888  
    813813  }
    814814
    815   function Show()
     815  function Show(): string
    816816  {
    817817    $this->Title = T('Export');
     
    837837  }
    838838
    839   function Show()
     839  function Show(): string
    840840  {
    841841    if (array_key_exists('i', $_GET))
  • trunk/Modules/Export/cmdmpqexport.php

    r880 r888  
    138138'<table cellspacing="10"><tr><td valign="top">'.
    139139
    140 '<p>Texty přebírány z projektu <a href="http://wowpreklad.zdechov.net/">wowpreklad.zdechov.net</a><br>'.
    141 '<a href="http://wowpreklad.zdechov.net/export/?Action=View&ExportId='.$_GET['ExportId'].'&Tab=0">Export '.$_GET['ExportId'].'</a></p><br>'.
     140'<p>Texty přebírány z projektu <a href="https://wowpreklad.zdechov.net/">wowpreklad.zdechov.net</a><br>'.
     141'<a href="https://wowpreklad.zdechov.net/export/?Action=View&ExportId='.$_GET['ExportId'].'&Tab=0">Export '.$_GET['ExportId'].'</a></p><br>'.
    142142
    143143
     
    146146'<li>Požadovaná verze klienta: '.$Export->ClientVersion['Version'].'</li>'.
    147147'<li>Datum uvolnění: '.date('d.m.Y h:m',time()).'</li>'.
    148 '<li>Sestaveno automaticky překladovým systémem <a href="http://wowpreklad.zdechov.net/">WoW překlad</a></li>'.
     148'<li>Sestaveno automaticky překladovým systémem <a href="https://wowpreklad.zdechov.net/">WoW překlad</a></li>'.
    149149//'<li>Tento soubor se generuje každý den. Pokud se zapojíte do překladu, zítra můžete stáhnout tento soubor znovu včetně svých překladů</li>'.
    150150//'<li>Sestavil: Maron</li>'.
  • trunk/Modules/Forum/Forum.php

    r880 r888  
    11<?php
    22
    3 class ModuleForum extends AppModule
     3class ModuleForum extends Module
    44{
    55  function __construct(System $System)
     
    1414  }
    1515
    16   function DoStart()
    17   {
    18     $this->System->RegisterPage('forum', 'PageForum');
     16  function DoStart(): void
     17  {
     18    $this->System->RegisterPage(['forum'], 'PageForum');
    1919    $this->System->ModuleManager->Modules['News']->RegisterRSS(array(
    2020      'Title' => T('Forum'), 'Channel' => 'forum', 'Callback' => array('PageForum', 'ShowRSS'),
     
    2929      $this->System->Link('/forum/?search='));
    3030
    31     $this->System->RegisterMenuItem(array(
     31    Core::Cast($this->System)->RegisterMenuItem(array(
    3232      'Title' => T('Forum'),
    3333      'Hint' => T('Forum about translation wow'),
     
    6868class PageForum extends Page
    6969{
    70   function Show()
     70  function Show(): string
    7171  {
    7272    $Output = '';
     
    181181    $Output = '';
    182182
    183     $parser = new HTML_BBCodeParser2(array('filters' => array('Basic','Extended','Images','Links','Lists','Email')));
     183    $Parser = new HTML_BBCodeParser2(array('filters' => array('Basic', 'Extended', 'Images', 'Links', 'Lists', 'Email')));
    184184
    185185    if (array_key_exists('search', $_GET)) $_SESSION['search'] = $_GET['search'];
     
    205205    $Output .= '<div class="shoutbox">';
    206206    $DbResult = $this->System->Database->query('SELECT * FROM `ForumText` WHERE `Thread` = '.
    207       ($_GET['Thread']*1).' '.$SearchQuery.' ORDER BY `ID` DESC '.$PageList['SQLLimit']);
    208     while ($Line = $DbResult->fetch_assoc()) {
     207      ($_GET['Thread'] * 1).' '.$SearchQuery.' ORDER BY `ID` DESC '.$PageList['SQLLimit']);
     208    while ($Line = $DbResult->fetch_assoc())
     209    {
    209210      if ($this->System->User->Id == $Line['User'])
     211      {
    210212        $edit = '<a href="?Edit='.$Line['ID'].'">'.T('edit').'</a>';
    211       else $edit = '';
     213      } else $edit = '';
     214      $Text = str_replace("\n", '<br />', $Parser->qparse(htmlspecialchars($Line['Text'])));
    212215      $Output .= '<div><span style="float:right;">'.$edit.' ('.HumanDate($Line['Date']).
    213         ')</span><strong>'.$Line['UserName'].'</strong>: '.str_replace("\n", '<br />',
    214         $parser->qparse(htmlspecialchars($Line['Text']))).'  </div> ';
     216        ')</span><strong>'.$Line['UserName'].'</strong>: '.$Text.'  </div> ';
    215217    }
    216218    $Output .= '</div>'.$PageList['Output'];
     
    243245    if ($this->System->User->Licence(LICENCE_USER))
    244246    {
    245         $Output .= '<form action="?" method="post">'.
    246             '<fieldset><legend>'.T('New thread').'</legend>'.
    247             T('User').': ';
    248         if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';
     247      $Output .= '<form action="?" method="post">'.
     248        '<fieldset><legend>'.T('New thread').'</legend>'.T('User').': ';
     249      if ($this->System->User->Licence(LICENCE_USER)) $Output .= '<b>'.$this->System->User->Name.'</b><br />';
    249250        else $Output .= '<input type="text" name="user" /><br />';
    250251      $Output .= T('Name of thread').': <br />'.
  • trunk/Modules/FrontPage/FrontPage.php

    r880 r888  
    11<?php
    22
    3 class ModuleFrontPage extends AppModule
     3class ModuleFrontPage extends Module
    44{
    55  function __construct(System $System)
     
    1515  }
    1616
    17   function DoStart()
     17  function DoStart(): void
    1818  {
    19     $this->System->RegisterPage('', 'PageFrontPage');
    20     $this->System->RegisterMenuItem(array(
     19    $this->System->RegisterPage([''], 'PageFrontPage');
     20    Core::Cast($this->System)->RegisterMenuItem(array(
    2121      'Title' => T('Home'),
    2222      'Hint' => T('Main page'),
     
    7171class PageFrontPage extends Page
    7272{
    73   function Show()
     73  function Show(): string
    7474  {
    7575    global $Message, $MessageType;
  • trunk/Modules/Import/Import.php

    r880 r888  
    55
    66
    7 class ModuleImport extends AppModule
     7class ModuleImport extends Module
    88{
    99  function __construct(System $System)
     
    1818  }
    1919
    20   function DoStart()
    21   {
    22     $this->System->RegisterPage('import', 'PageImport');
     20  function DoStart(): void
     21  {
     22    $this->System->RegisterPage(['import'], 'PageImport');
    2323  }
    2424}
  • trunk/Modules/Import/Manage.php

    r880 r888  
    9696  }
    9797
    98   function Show()
     98  function Show(): string
    9999  {
    100100    $this->Title = T('Import');
  • trunk/Modules/Info/Info.php

    r880 r888  
    11<?php
    22
    3 class ModuleInfo extends AppModule
     3class ModuleInfo extends Module
    44{
    55  function __construct(System $System)
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    18     $this->System->RegisterMenuItem(array(
     18    Core::Cast($this->System)->RegisterMenuItem(array(
    1919      'Title' => T('Instructions'),
    2020      'Hint' => 'Informace k překladu hry',
     
    2323      'Icon' => '',
    2424    ));
    25     $this->System->RegisterPage('info', 'PageInfo');
    26     $this->System->RegisterMenuItem(array(
     25    $this->System->RegisterPage(['info'], 'PageInfo');
     26    Core::Cast($this->System)->RegisterMenuItem(array(
    2727      'Title' => T('Presentation'),
    2828      'Hint' => 'Prezentace a motivace překladu',
     
    3131      'Icon' => '',
    3232    ));
    33     $this->System->RegisterPage('promotion', 'PagePromotion');
     33    $this->System->RegisterPage(['promotion'], 'PagePromotion');
    3434  }
    3535}
     
    3737class PageInfo extends Page
    3838{
    39   function Show()
     39  function Show(): string
    4040  {
    4141    $this->Title = T('Information for translators');
     
    7575class PagePromotion extends Page
    7676{
    77   function Show()
     77  function Show(): string
    7878  {
    7979    $this->Title = T('Promotion');
  • trunk/Modules/Log/Log.php

    r884 r888  
    11<?php
    22
    3 class ModuleLog extends AppModule
     3class ModuleLog extends Module
    44{
    55  var $Excludes;
     
    1818  }
    1919
    20   function DoStart()
    21   {
    22     $this->System->RegisterPage('log', 'PageLog');
     20  function DoStart(): void
     21  {
     22    $this->System->RegisterPage(['log'], 'PageLog');
    2323    $this->System->ModuleManager->Modules['Error']->OnError[] = array($this, 'DoAddItem');
    2424    $this->System->ModuleManager->Modules['News']->RegisterRSS(array('Title' => T('Logs'),
     
    109109  }
    110110
    111   function Show()
     111  function Show(): string
    112112  {
    113113    if (array_key_exists('a', $_POST)) $Action = $_POST['a'];
  • trunk/Modules/News/News.php

    r880 r888  
    33include_once(dirname(__FILE__).'/RSS.php');
    44
    5 class ModuleNews extends AppModule
     5class ModuleNews extends Module
    66{
    77  var $RSSChannels;
     
    1919  }
    2020
    21   function DoStart()
     21  function DoStart(): void
    2222  {
    23     $this->System->RegisterPage('news', 'PageNews');
    24     $this->System->RegisterPage('rss', 'PageRSS');
     23    $this->System->RegisterPage(['news'], 'PageNews');
     24    $this->System->RegisterPage(['rss'], 'PageRSS');
    2525    $this->RegisterRSS(array('Title' => T('News'), 'Channel' => 'news',
    2626      'Callback' => array('PageNews', 'ShowRSS'), 'Permission' => LICENCE_ANONYMOUS));
    27     $this->System->RegisterPageHeader('New', array($this, 'ShowRSSHeader'));
     27      Core::Cast($this->System)->RegisterPageHeader('New', array($this, 'ShowRSSHeader'));
    2828  }
    2929
     
    6969class PageNews extends Page
    7070{
    71   function Show()
     71  function Show(): string
    7272  {
    7373    $this->Title = T('News');
  • trunk/Modules/News/RSS.php

    r880 r888  
    3131class PageRSS extends Page
    3232{
    33   function Show()
     33  function Show(): string
    3434  {
    3535    $this->RawPage = true;
  • trunk/Modules/Redirection/Redirection.php

    r880 r888  
    11<?php
    22
    3 class ModuleRedirection extends AppModule
     3class ModuleRedirection extends Module
    44{
    55  function __construct(System $System)
     
    1515  }
    1616
    17   function DoStart()
     17  function DoStart(): void
    1818  {
    1919    $this->System->OnPageNotFound = array($this, 'ShowRedirect');
  • trunk/Modules/Referrer/Referrer.php

    r880 r888  
    11<?php
    22
    3 class ModuleReferrer extends AppModule
     3class ModuleReferrer extends Module
    44{
    55  var $Excludes;
     
    1818  }
    1919
    20   function DoStart()
     20  function DoStart(): void
    2121  {
    2222    $this->Excludes[] = $this->System->Config['Web']['Host'];
    2323    $this->Log();
    24     $this->System->RegisterPage('referrer', 'PageReferrer');
    25     $this->System->RegisterMenuItem(array(
     24    $this->System->RegisterPage(['referrer'], 'PageReferrer');
     25    Core::Cast($this->System)->RegisterMenuItem(array(
    2626      'Title' => T('Promotion'),
    2727      'Hint' => 'Informace k propagaci tohoto projektu',
     
    246246  }
    247247
    248   function Show()
     248  function Show(): string
    249249  {
    250250    $this->Title = T('Promotion');
  • trunk/Modules/Search/Search.php

    r880 r888  
    11<?php
    22
    3 class ModuleSearch extends AppModule
     3class ModuleSearch extends Module
    44{
    55  var $SearchItems;
     
    1717  }
    1818
    19   function DoStart()
     19  function DoStart(): void
    2020  {
    21     $this->System->RegisterPage('search', 'PageSearch');
    22     $this->System->RegisterPageBarItem('Left', 'Search', array($this, 'ShowSearchBox'));
     21    $this->System->RegisterPage(['search'], 'PageSearch');
     22    Core::Cast($this->System)->RegisterPageBarItem('Left', 'Search', array($this, 'ShowSearchBox'));
    2323  }
    2424
     
    5454class PageSearch extends Page
    5555{
    56   function Show()
     56  function Show(): string
    5757  {
    5858    $this->Title = T('Search');
  • trunk/Modules/Server/Server.php

    r880 r888  
    11<?php
    22
    3 class ModuleServer extends AppModule
     3class ModuleServer extends Module
    44{
    55  function __construct(System $System)
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    18     $this->System->RegisterPage('server', 'PageServerList');
    19     $this->System->RegisterMenuItem(array(
     18    $this->System->RegisterPage(['server'], 'PageServerList');
     19    Core::Cast($this->System)->RegisterMenuItem(array(
    2020      'Title' => T('Servers'),
    2121      'Hint' => 'Seznam serverů, kde je nasazena čeština v praxi',
  • trunk/Modules/ShoutBox/ShoutBox.php

    r880 r888  
    11<?php
    22
    3 class ModuleShoutBox extends AppModule
     3class ModuleShoutBox extends Module
    44{
    55  function __construct(System $System)
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    18     $this->System->RegisterPage('shoutbox', 'PageShoutBox');
     18    $this->System->RegisterPage(['shoutbox'], 'PageShoutBox');
    1919    $this->System->ModuleManager->Modules['News']->RegisterRSS(array(
    2020      'Title' => T('Shoutbox'), 'Channel' => 'shoutbox', 'Callback' => array('PageShoutBox', 'ShowRSS'),
     
    4242class PageShoutBox extends Page
    4343{
    44   function Show()
     44  function Show(): string
    4545  {
    4646    $this->Title = T('Shoutbox');
  • trunk/Modules/Team/Team.php

    r880 r888  
    11<?php
    22
    3 class ModuleTeam extends AppModule
     3class ModuleTeam extends Module
    44{
    55  function __construct(System $System)
     
    1414  }
    1515
    16   function DoStart()
    17   {
    18     $this->System->RegisterPage('team', 'PageTeam');
    19     $this->System->RegisterMenuItem(array(
     16  function DoStart(): void
     17  {
     18    $this->System->RegisterPage(['team'], 'PageTeam');
     19    Core::Cast($this->System)->RegisterMenuItem(array(
    2020      'Title' => T('Teams'),
    2121      'Hint' => T('List of translating teams'),
     
    162162            '<tr><td colspan="2"><input type="submit" value="'.T('Save').'" /></td></tr>'.
    163163            '</table></fieldset></form>';
    164         } else $Output = ShowMesage('Tým nenalezen.', MESSAGE_CRITICAL);
     164        } else $Output = ShowMessage('Tým nenalezen.', MESSAGE_CRITICAL);
    165165      } else $Output = ShowMessage('Nezadáno id týmu', MESSAGE_CRITICAL);
    166166    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
     
    328328  }
    329329
    330   function Show()
     330  function Show(): string
    331331  {
    332332    if (array_key_exists('action', $_GET))
  • trunk/Modules/Translation/Comparison.php

    r880 r888  
    3838  }
    3939
    40   function Show()
     40  function Show(): string
    4141  {
    4242    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
  • trunk/Modules/Translation/Form.php

    r880 r888  
    66  var $ID;
    77
    8   function Show()
     8  function Show(): string
    99  {
    1010    $this->Title = T('Translation');
     
    1717  }
    1818
    19   function ShowForm()
     19  function ShowForm(): string
    2020  {
    2121    $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
  • trunk/Modules/Translation/LoadNames.php

    r880 r888  
    9090    }
    9191
    92   function Show()
     92  function Show(): string
    9393  {
    9494    $this->RawPage = true;
  • trunk/Modules/Translation/Progress.php

    r880 r888  
    6464  }
    6565
    66   function Show()
     66  function Show(): string
    6767  {
    6868    $this->Title = T('Progress');
  • trunk/Modules/Translation/Save.php

    r880 r888  
    174174  }
    175175
    176   function Show()
     176  function Show(): string
    177177  {
    178178    global $Message, $MessageType;
  • trunk/Modules/Translation/Translation.php

    r880 r888  
    99include_once(dirname(__FILE__).'/UserLevel.php');
    1010
    11 class ModuleTranslation extends AppModule
     11class ModuleTranslation extends Module
    1212{
    1313  function __construct(System $System)
     
    2222  }
    2323
    24   function DoStart()
    25   {
    26     $this->System->RegisterPage('comparison.php', 'PageTranslationComparison');
    27     $this->System->RegisterPage('form.php', 'PageTranslationForm');
    28     $this->System->RegisterPage('save.php', 'PageTranslationSave');
    29     $this->System->RegisterPage('progress', 'PageProgress');
    30     $this->System->RegisterPage('translation-groups', 'PageTranslationGroups');
    31     $this->System->RegisterPage('TranslationList.php', 'PageTranslationList');
    32     $this->System->RegisterPage('LoadNames.php', 'PageLoadNames');
     24  function DoStart(): void
     25  {
     26    $this->System->RegisterPage(['comparison.php'], 'PageTranslationComparison');
     27    $this->System->RegisterPage(['form.php'], 'PageTranslationForm');
     28    $this->System->RegisterPage(['save.php'], 'PageTranslationSave');
     29    $this->System->RegisterPage(['progress'], 'PageProgress');
     30    $this->System->RegisterPage(['translation-groups'], 'PageTranslationGroups');
     31    $this->System->RegisterPage(['TranslationList.php'], 'PageTranslationList');
     32    $this->System->RegisterPage(['LoadNames.php'], 'PageLoadNames');
    3333    $this->System->ModuleManager->Modules['News']->RegisterRSS(array('Title' => T('Last translations'),
    3434      'Channel' => 'translation', 'Callback' => array($this, 'ShowRSS'), 'Permission' => LICENCE_ANONYMOUS));
    35     $this->System->RegisterMenuItem(array(
     35    Core::Cast($this->System)->RegisterMenuItem(array(
    3636      'Title' => T('Completion status'),
    3737      'Hint' => 'Stav dokončení překládů',
     
    4040      'Icon' => '',
    4141    ), 1);
    42     $this->System->RegisterMenuItem(array(
     42    Core::Cast($this->System)->RegisterMenuItem(array(
    4343      'Title' => T('Data source'),
    4444      'Hint' => 'Informace o překladových skupinách',
     
    6666      }
    6767    }
    68     $this->System->RegisterPageBarItem('Right', 'TranslatedMenu', array($this, 'ShowTranslatedMenu'));
     68    Core::Cast($this->System)->RegisterPageBarItem('Right', 'TranslatedMenu', array($this, 'ShowTranslatedMenu'));
    6969  }
    7070
  • trunk/Modules/Translation/TranslationList.php

    r880 r888  
    376376  }
    377377
    378   function Show()
     378  function Show(): string
    379379  {
    380380    $this->Title = T('Translation groups');
     
    521521  }
    522522
    523   function Show()
     523  function Show(): string
    524524  {
    525525    $this->Title = T('Translation groups');
  • trunk/Modules/User/Options.php

    r884 r888  
    134134  }
    135135
    136   function Show()
     136  function Show(): string
    137137  {
    138138    $this->Title = T('User settings');
  • trunk/Modules/User/Profile.php

    r880 r888  
    246246  }
    247247
    248   function Show()
     248  function Show(): string
    249249  {
    250250    $this->Title = T('User profile');
  • trunk/Modules/User/Registration.php

    r884 r888  
    159159  }
    160160
    161   function Show()
     161  function Show(): string
    162162  {
    163163    $this->Title = T('User registration');
  • trunk/Modules/User/User.php

    r884 r888  
    66include_once(dirname(__FILE__).'/Profile.php');
    77
    8 class ModuleUser extends AppModule
     8class ModuleUser extends Module
    99{
    1010  function __construct(System $System)
     
    1919  }
    2020
    21   function DoStart()
     21  function DoStart(): void
    2222  {
    2323    $this->System->User = new User($this->System);
    24     $this->System->RegisterPage('users', 'PageUserList');
    25     $this->System->RegisterPage('options', 'PageUserOptions');
    26     $this->System->RegisterPage('registration', 'PageUserRegistration');
    27     $this->System->RegisterPage('user', 'PageUserProfile');
    28     $this->System->RegisterPage('login', 'PageUserLogin');
    29     $this->System->RegisterMenuItem(array(
     24    $this->System->RegisterPage(['users'], 'PageUserList');
     25    $this->System->RegisterPage(['options'], 'PageUserOptions');
     26    $this->System->RegisterPage(['registration'], 'PageUserRegistration');
     27    $this->System->RegisterPage(['user'], 'PageUserProfile');
     28    $this->System->RegisterPage(['login'], 'PageUserLogin');
     29    Core::Cast($this->System)->RegisterMenuItem(array(
    3030      'Title' => T('Translators'),
    3131      'Hint' => 'Seznam registrovaných uživatelů',
     
    3737      $this->System->ModuleManager->Modules['Search']->RegisterSearch('user',
    3838      T('Translators'), array('Name'), '`User`', $this->System->Link('/users/?search='));
    39     $this->System->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback'));
    40     $this->System->RegisterPageBarItem('Left', 'User', array($this, 'ShowOnlineList'));
     39      Core::Cast($this->System)->RegisterPageBarItem('Top', 'User', array($this, 'TopBarCallback'));
     40      Core::Cast($this->System)->RegisterPageBarItem('Left', 'User', array($this, 'ShowOnlineList'));
    4141  }
    4242
     
    8585class PageUserLogin extends Page
    8686{
    87   function Show()
     87  function Show(): string
    8888  {
    8989    $Output = '<form action="'.$this->System->Link('/?action=login').'" method="post" class="Form">'.
  • trunk/Modules/User/UserList.php

    r880 r888  
    33class PageUserList extends Page
    44{
    5   function Show()
     5  function Show(): string
    66  {
    77    $this->Title = T('Translators');
  • trunk/Modules/Wiki/Wiki.php

    r880 r888  
    11<?php
    22
    3 class ModuleWiki extends AppModule
     3class ModuleWiki extends Module
    44{
    55  function __construct(System $System)
     
    1414  }
    1515
    16   function DoStart()
     16  function DoStart(): void
    1717  {
    1818    $this->LoadPages();
     
    2525    {
    2626      $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki');
    27       $this->System->RegisterMenuItem(array(
     27      Core::Cast($this->System)->RegisterMenuItem(array(
    2828          'Title' => $DbRow['Name'],
    2929          'Hint' => '',
     
    3838class PageWiki extends Page
    3939{
    40   function Show()
     40  function Show(): string
    4141  {
    4242    if (array_key_exists('Action', $_GET))
  • trunk/Packages/Common/Base.php

    r861 r888  
    11<?php
    2 
    3 class System
    4 {
    5   /* @var Database */
    6   var $Database;
    7 
    8   function __construct()
    9   {
    10     $this->Database = new Database();
    11   }
    12 }
    132
    143class Base
    154{
    16   /** @var Application */
    17   var $System;
    18   /* @var Database */
    19   var $Database;
     5  public System $System;
     6  public Database $Database;
    207
    21   function __construct(Application $System)
     8  function __construct(System $System)
    229  {
    2310    $this->System = &$System;
    2411    $this->Database = &$System->Database;
    2512  }
     13
     14  static function GetClassName()
     15  {
     16    return get_called_class();
     17  }
    2618}
    27 
    28 class Model extends Base
    29 {
    30 
    31 }
    32 
    33 class View extends Base
    34 {
    35 
    36 }
    37 
    38 class Controller extends Base
    39 {
    40 
    41 }
  • trunk/Packages/Common/Common.php

    r881 r888  
    1111include_once(dirname(__FILE__).'/Error.php');
    1212include_once(dirname(__FILE__).'/Base.php');
    13 include_once(dirname(__FILE__).'/Application.php');
    14 include_once(dirname(__FILE__).'/AppModule.php');
     13include_once(dirname(__FILE__).'/View.php');
     14include_once(dirname(__FILE__).'/Model.php');
     15include_once(dirname(__FILE__).'/ModelDesc.php');
     16include_once(dirname(__FILE__).'/Controller.php');
     17include_once(dirname(__FILE__).'/System.php');
     18include_once(dirname(__FILE__).'/Module.php');
     19include_once(dirname(__FILE__).'/ModuleManager.php');
    1520include_once(dirname(__FILE__).'/Config.php');
    1621include_once(dirname(__FILE__).'/Page.php');
    1722include_once(dirname(__FILE__).'/Locale.php');
    1823include_once(dirname(__FILE__).'/Update.php');
    19 include_once(dirname(__FILE__).'/Setup.php');
    2024include_once(dirname(__FILE__).'/Table.php');
     25include_once(dirname(__FILE__).'/Process.php');
     26include_once(dirname(__FILE__).'/Generics.php');
     27include_once(dirname(__FILE__).'/BigInt.php');
     28include_once(dirname(__FILE__).'/Int128.php');
     29include_once(dirname(__FILE__).'/Pdf.php');
     30include_once(dirname(__FILE__).'/Modules/Setup.php');
     31include_once(dirname(__FILE__).'/Modules/ModuleManager.php');
    2132
    2233class PackageCommon
    2334{
    24   var $Name;
    25   var $Version;
    26   var $License;
    27   var $Creator;
    28   var $Homepage;
     35  public string $Name;
     36  public string $Version;
     37  public int $ReleaseDate;
     38  public string $License;
     39  public string $Creator;
     40  public string $Homepage;
    2941
    3042  function __construct()
    3143  {
    3244    $this->Name = 'Common';
    33     $this->Version = '1.1';
     45    $this->Version = '1.2';
     46    $this->ReleaseDate = strtotime('2020-03-29');
    3447    $this->Creator = 'Chronos';
    35     $this->License = 'GNU/GPL';
     48    $this->License = 'GNU/GPLv3';
    3649    $this->Homepage = 'https://svn.zdechov.net/PHPlib/Common/';
    3750  }
     
    4053class Paging
    4154{
    42   var $TotalCount;
    43   var $ItemPerPage;
    44   var $Around;
    45   var $SQLLimit;
    46   var $Page;
     55  public int $TotalCount;
     56  public int $ItemPerPage;
     57  public int $Around;
     58  public string $SQLLimit;
     59  public int $Page;
    4760
    4861  function __construct()
     
    5467  }
    5568
    56   function Show()
     69  function Show(): string
    5770  {
    5871    $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
  • trunk/Packages/Common/Config.php

    r880 r888  
    33class Config
    44{
    5   var $Data;
     5  public array $Data;
    66
    77  function __construct()
     
    1010  }
    1111
    12   function ReadValue($Name)
     12  function ReadValue(string $Name)
    1313  {
    1414    if (!is_array($Name)) $Name = explode('/', $Name);
     
    2222  }
    2323
    24   function WriteValue($Name, $Value)
     24  function WriteValue(string $Name, $Value)
    2525  {
    2626    if (!is_array($Name)) $Name = explode('/', $Name);
     
    3434  }
    3535
    36   function LoadFromFile($FileName)
     36  function LoadFromFile(string $FileName): void
    3737  {
    3838    $ConfigData = array();
     
    4040    foreach ($this->Data as $Index => $Item)
    4141    {
    42       if (array_key_exits($Index, $ConfigData))
     42      if (array_key_exists($Index, $ConfigData))
    4343        $this->Data[$Index] = $ConfigData[$Index];
    4444    }
    4545  }
    4646
    47   function SaveToFile($FileName)
     47  function SaveToFile(string $FileName): void
    4848  {
    4949    file_put_contents($FileName, "<?php \n\n\$ConfigData = ".var_export($this->Data, true).";\n");
    5050  }
    5151
    52   function GetAsArray()
     52  function GetAsArray(): array
    5353  {
    5454    return $this->Data;
  • trunk/Packages/Common/Database.php

    r880 r888  
    22
    33// Extended database class
    4 // Date: 2016-01-11
     4// Date: 2020-11-10
     5
     6function microtime_float()
     7{
     8  list($usec, $sec) = explode(" ", microtime());
     9  return (float)$usec + (float)$sec;
     10}
    511
    612class DatabaseResult
    713{
    8   var $PDOStatement;
    9   var $num_rows = 0;
     14  public PDOStatement $PDOStatement;
     15  public int $num_rows = 0;
    1016
    1117  function fetch_assoc()
     
    2733class Database
    2834{
    29   var $Prefix;
    30   var $Functions;
    31   var $Type;
    32   var $PDO;
    33   var $Error;
    34   var $insert_id;
    35   var $LastQuery;
    36   var $ShowSQLError;
    37   var $ShowSQLQuery;
    38   var $LogSQLQuery;
    39   var $LogFile;
     35  public string $Prefix;
     36  public array $Functions;
     37  public string $Type;
     38  public PDO $PDO;
     39  public string $Error;
     40  public string $insert_id;
     41  public string $LastQuery;
     42  public bool $ShowSQLError;
     43  public bool $ShowSQLQuery;
     44  public bool $LogSQLQuery;
     45  public string $LogFile;
     46  public string $Database;
    4047
    4148  function __construct()
    4249  {
    4350    $this->Prefix = '';
    44     $this->Functions = array('NOW()', 'CURDATE()', 'CURTIME()', 'UUID()');
     51    $this->Functions = array('NOW(', 'CURDATE(', 'CURTIME(', 'UUID(', 'SHA1(');
    4552    $this->Type = 'mysql';  // mysql, pgsql
    4653    $this->Error = '';
     
    5057    $this->LogSQLQuery = false;
    5158    $this->LogFile = dirname(__FILE__).'/../../Query.log';
    52   }
    53 
    54   function Connect($Host, $User, $Password, $Database)
     59    $this->Database = '';
     60  }
     61
     62  function Connect(string $Host, string $User, string $Password, string $Database): void
    5563  {
    5664    if ($this->Type == 'mysql') $ConnectionString = 'mysql:host='.$Host.';dbname='.$Database;
    5765      else if ($this->Type == 'pgsql') $ConnectionString = 'pgsql:dbname='.$Database.';host='.$Host;
    5866      else $ConnectionString = '';
     67    $this->Database = $Database;
    5968    try {
    6069      $this->PDO = new PDO($ConnectionString, $User, $Password);
    61 
    6270    } catch (Exception $E)
    6371    {
     
    6775  }
    6876
    69   function Disconnect()
     77  function Disconnect(): void
    7078  {
    7179    unset($this->PDO);
    7280  }
    7381
    74   function Connected()
     82  function Connected(): bool
    7583  {
    7684    return isset($this->PDO);
    7785  }
    7886
    79   function select_db($Database)
     87  function select_db(string $Database)
    8088  {
    8189    $this->query('USE `'.$Database.'`');
    8290  }
    8391
    84   function query($Query)
     92  function query($Query): DatabaseResult
    8593  {
    8694    if (!$this->Connected()) throw new Exception(T('Not connected to database'));
    87     if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime();
     95    if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true)) $QueryStartTime = microtime_float();
    8896    $this->LastQuery = $Query;
    8997    if (($this->ShowSQLQuery == true) or ($this->LogSQLQuery == true))
    90       $Duration = ' ; '.round(microtime() - $QueryStartTime, 4). ' s';
    91     if ($this->LogSQLQuery == true)
     98    {
     99      $Time = round(microtime_float() - $QueryStartTime, 4);
     100      $Duration = ' ; '.$Time. ' s';
     101    }
     102    if (($this->LogSQLQuery == true) and ($Time != 0))
    92103      file_put_contents($this->LogFile, $Query.$Duration."\n", FILE_APPEND);
    93104    if ($this->ShowSQLQuery == true)
     
    95106      'padding-bottom: 3px; padding-top: 3px; font-size: 12px; font-family: Arial;">'.$Query.$Duration.'</div>'."\n");
    96107    $Result = new DatabaseResult();
    97     $Result->PDOStatement = $this->PDO->query($Query);
    98     if ($Result->PDOStatement)
    99     {
    100       $Result->num_rows = $Result->PDOStatement->rowCount();
     108    $Statement = $this->PDO->query($Query);
     109    if ($Statement)
     110    {
     111      $Result->PDOStatement = $Statement;
     112      $Result->num_rows = $Statement->rowCount();
    101113      $this->insert_id = $this->PDO->lastInsertId();
    102114    } else
    103115    {
    104       $this->Error = $this->PDO->errorInfo();
    105       $this->Error = $this->Error[2];
     116      $Error = $this->PDO->errorInfo();
     117      $this->Error = $Error[2];
    106118      if (($this->Error != '') and ($this->ShowSQLError == true))
    107119        echo('<div><strong>SQL Error: </strong>'.$this->Error.'<br />'.$Query.'</div>');
     
    111123  }
    112124
    113   function select($Table, $What = '*', $Condition = 1)
     125  function select(string $Table, string $What = '*', string $Condition = '1'): DatabaseResult
    114126  {
    115127    return $this->query('SELECT '.$What.' FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition);
    116128  }
    117129
    118   function delete($Table, $Condition)
     130  function delete(string $Table, string $Condition): void
    119131  {
    120132    $this->query('DELETE FROM `'.$this->Prefix.$Table.'` WHERE '.$Condition);
    121133  }
    122134
    123   function insert($Table, $Data)
     135  function insert(string $Table, array $Data): int
     136  {
     137    $this->query($this->GetInsert($Table, $Data));
     138    $this->insert_id = $this->PDO->lastInsertId();
     139    return $this->insert_id;
     140  }
     141
     142  function IsFunction(string $Text): bool
     143  {
     144    $Pos = strpos($Text, '(');
     145    return ($Pos !== false) && in_array(substr($Text, 0, $Pos + 1), $this->Functions);
     146  }
     147
     148  function GetInsert(string $Table, array $Data): string
    124149  {
    125150    $Name = '';
     
    128153    {
    129154      $Name .= ',`'.$Key.'`';
    130       if (!in_array($Value, $this->Functions))
     155      if (is_null($Value)) $Value = 'NULL';
     156      else if (!$this->IsFunction($Value))
    131157      {
    132         if (is_null($Value)) $Value = 'NULL';
    133         else $Value = $this->PDO->quote($Value);
     158        $Value = $this->PDO->quote($Value);
    134159      }
    135160      $Values .= ','.$Value;
     
    137162    $Name = substr($Name, 1);
    138163    $Values = substr($Values, 1);
    139     $this->query('INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    140     $this->insert_id = $this->PDO->lastInsertId();
    141   }
    142 
    143   function update($Table, $Condition, $Data)
     164    return 'INSERT INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')';
     165  }
     166
     167  function update(string $Table, string $Condition, array $Data): void
     168  {
     169    $this->query($this->GetUpdate($Table, $Condition, $Data));
     170  }
     171
     172  function GetUpdate(string $Table, string $Condition, array $Data): string
    144173  {
    145174    $Values = '';
    146175    foreach ($Data as $Key => $Value)
    147176    {
    148       if (!in_array($Value, $this->Functions))
     177      if (is_null($Value)) $Value = 'NULL';
     178      else if (!$this->IsFunction($Value))
    149179      {
    150         if (is_null($Value)) $Value = 'NULL';
    151         else $Value = $this->PDO->quote($Value);
     180        $Value = $this->PDO->quote($Value);
    152181      }
    153182      $Values .= ', `'.$Key.'`='.$Value;
    154183    }
    155184    $Values = substr($Values, 2);
    156     $this->query('UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')');
    157   }
    158 
    159   function replace($Table, $Data)
     185    return 'UPDATE `'.$this->Prefix.$Table.'` SET '.$Values.' WHERE ('.$Condition.')';
     186  }
     187
     188  function replace(string $Table, array $Data): void
    160189  {
    161190    $Name = '';
     
    163192    foreach ($Data as $Key => $Value)
    164193    {
    165       if (!in_array($Value, $this->Functions))
     194      if (is_null($Value)) $Value = 'NULL';
     195      else if (!$this->IsFunction($Value))
    166196      {
    167         if (is_null($Value)) $Value = 'NULL';
    168         else $Value = $this->PDO->quote($Value);
     197        $Value = $this->PDO->quote($Value);
    169198      }
    170199      $Name .= ',`'.$Key.'`';
     
    173202    $Name = substr($Name, 1);
    174203    $Values = substr($Values, 1);
    175     //echo('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES ('.$Values.')<br />');
    176204    $this->query('REPLACE INTO `'.$this->Prefix.$Table.'` ('.$Name.') VALUES('.$Values.')');
    177     //echo($this->error().'<br>');
    178   }
    179 
    180   function charset($Charset)
     205  }
     206
     207  function charset(string $Charset): void
    181208  {
    182209    $this->query('SET NAMES "'.$Charset.'"');
    183210  }
    184211
    185   function real_escape_string($Text)
     212  function real_escape_string(string $Text): string
    186213  {
    187214    return addslashes($Text);
    188215  }
    189216
    190   function quote($Text)
     217  function quote(string $Text): string
    191218  {
    192219    return $this->PDO->quote($Text);
    193220  }
    194221
    195   public function __sleep()
     222  public function __sleep(): array
    196223  {
    197224    return array('LastQuery');
    198225  }
    199226
    200   public function __wakeup()
    201   {
     227  public function __wakeup(): void
     228  {
     229  }
     230
     231  public function Transaction(array $Queries): void
     232  {
     233    $this->PDO->beginTransaction();
     234    foreach ($Queries as $Query)
     235    {
     236      $Statement = $this->PDO->prepare($Query);
     237      $Statement->execute();
     238    }
     239    $this->PDO->commit();
     240  }
     241
     242  public function TableExists(string $Name): bool
     243  {
     244    $DbResult = $this->query('SELECT * FROM information_schema.tables  WHERE table_schema = "'.$this->Database.
     245    '" AND table_name = "'.$Name.'" LIMIT 1');
     246    return $DbResult->num_rows != 0;
    202247  }
    203248}
  • trunk/Packages/Common/Error.php

    r887 r888  
    1616  }
    1717
    18   function Start()
     18  function Start(): void
    1919  {
    2020    set_error_handler(array($this, 'ErrorHandler'));
     
    2222  }
    2323
    24   function Stop()
     24  function Stop(): void
    2525  {
    2626    restore_error_handler();
     
    2828  }
    2929
    30   function ErrorHandler($Number, $Message, $FileName, $LineNumber)
     30  function ErrorHandler(int $Number, string $Message, string $FileName, int $LineNumber, array $Variables = array()): bool
    3131  {
    3232    $ErrorType = array
     
    6363  }
    6464
    65   function ExceptionHandler(Throwable $Exception)
     65  function ExceptionHandler(Throwable $Exception): void
    6666  {
    6767    $Backtrace = $Exception->getTrace();
     
    8888  }
    8989
    90   function Report($Backtrace)
     90  function Report(array $Backtrace): void
    9191  {
    9292    $Date = date('Y-m-d H:i:s');
  • trunk/Packages/Common/Image.php

    r880 r888  
    99class Font
    1010{
    11   var $Size;
    12   var $FileName;
    13   var $Color;
     11  public int $Size;
     12  public string $FileName;
     13  public int $Color;
    1414
    1515  function __construct()
     
    2323class Pen
    2424{
    25   var $Color;
    26   var $X;
    27   var $Y;
     25  public int $Color;
     26  public int $X;
     27  public int $Y;
    2828
    2929  function __construct()
     
    3838class Brush
    3939{
    40   var $Color;
     40  public int $Color;
    4141
    4242  function __construct()
     
    4949class Image
    5050{
    51   var $Image;
    52   var $Type;
    53   var $Font;
    54   var $Pen;
     51  public $Image;
     52  public int $Type;
     53  public Font $Font;
     54  public Pen $Pen;
     55  public Brush $Brush;
    5556
    5657  function __construct()
     
    6364  }
    6465
    65   function SaveToFile($FileName)
     66  function SaveToFile(string $FileName): void
    6667  {
    6768    if ($this->Type == IMAGETYPE_JPEG)
     
    7980  }
    8081
    81   function LoadFromFile($FileName)
     82  function LoadFromFile(string $FileName): void
    8283  {
    8384    $ImageInfo = getimagesize($FileName);
     
    8990    if ($this->Type == IMAGETYPE_GIF)
    9091    {
    91       $this->Image = imagecreatefromgif($FileName);
     92      $this->Image = imagecreatefromgif ($FileName);
    9293    } else
    9394    if ( $this->Type == IMAGETYPE_PNG)
     
    9798  }
    9899
    99   function Output()
     100  function Output(): void
    100101  {
    101102    $this->SaveToFile(NULL);
    102103  }
    103104
    104   function SetSize($Width, $Height)
     105  function SetSize(int $Width, int $Height): void
    105106  {
    106107    $NewImage = imagecreatetruecolor($Width, $Height);
     
    110111  }
    111112
    112   function GetWidth()
     113  function GetWidth(): int
    113114  {
    114115    return imagesx($this->Image);
    115116  }
    116117
    117   function GetHeight()
     118  function GetHeight(): int
    118119  {
    119120    return imagesy($this->Image);
    120121  }
    121122
    122   function TextOut($X, $Y, $Text)
     123  function TextOut(int $X, int $Y, string $Text): void
    123124  {
    124125    imagettftext($this->Image, $this->Font->Size, 0, $X, $Y, $this->ConvertColor($this->Font->Color), $this->Font->FileName, $Text);
    125126  }
    126127
    127   function ConvertColor($Color)
     128  function ConvertColor(int $Color): int
    128129  {
    129130    return imagecolorallocate($this->Image, ($Color >> 16) & 0xff, ($Color >> 8) & 0xff, $Color & 0xff);
    130131  }
    131132
    132   function FillRect($X1, $Y1, $X2, $Y2)
     133  function FillRect(int $X1, int $Y1, int $X2, int $Y2): void
    133134  {
    134135    imagefilledrectangle($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Brush->Color));
    135136  }
    136137
    137   function Line($X1, $Y1, $X2, $Y2)
     138  function Line(int $X1, int $Y1, int $X2, int $Y2): void
    138139  {
    139140    imageline($this->Image, $X1, $Y1, $X2, $Y2, $this->ConvertColor($this->Pen->Color));
  • trunk/Packages/Common/Locale.php

    r884 r888  
    33class LocaleText
    44{
    5   var $Data;
    6   var $Code;
    7   var $Title;
     5  public array $Data;
     6  public string $Code;
     7  public string $Title;
    88
    99  function __construct()
     
    1414  }
    1515
    16   function Load()
    17   {
    18   }
    19 
    20   function Translate($Text, $Group = '')
     16  function Load(): void
     17  {
     18  }
     19
     20  function Translate(string $Text, string $Group = ''): string
    2121  {
    2222    if (array_key_exists($Text, $this->Data[$Group]) and ($this->Data[$Group][$Text] != ''))
     
    2525  }
    2626
    27   function TranslateReverse($Text, $Group = '')
     27  function TranslateReverse(string $Text, string $Group = ''): string
    2828  {
    2929    $Key = array_search($Text, $this->Data[$Group]);
     
    3535class LocaleFile extends Model
    3636{
    37   var $Texts;
    38   var $Dir;
     37  public LocaleText $Texts;
     38  public string $Dir;
    3939
    4040  function __construct(System $System)
     
    4444  }
    4545
    46   function Load($Language)
     46  function Load(string $Language): void
    4747  {
    4848    $FileName = $this->Dir.'/'.$Language.'.php';
     
    5555  }
    5656
    57   function AnalyzeCode($Path)
     57  function AnalyzeCode(string $Path): void
    5858  {
    5959    // Search for php files
     
    7575            $Previous = strtolower(substr($Content, strpos($Content, 'T(') - 1, 1));
    7676            $Content = substr($Content, strpos($Content, 'T(') + 2);
    77             $Ord = ord($Previous);
    78             //echo($Ord.',');
     77            $Ord = ord($Previous);           
    7978            if (!(($Ord >= ord('a')) and ($Ord <= ord('z'))))
    8079            {
     
    9897  }
    9998
    100   function SaveToFile($FileName)
     99  function SaveToFile(string $FileName): void
    101100  {
    102101    $Content = '<?php'."\n".
     
    119118  }
    120119
    121   function LoadFromDatabase($Database, $LangCode)
     120  function LoadFromDatabase(Database $Database, string $LangCode): void
    122121  {
    123122    $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode));
     
    132131  }
    133132
    134   function SaveToDatabase(Database $Database, $LangCode)
    135   {
    136     $DbResult = $Database->select('Language', '*', 'Code='.$Database->quote($LangCode));
     133  function SaveToDatabase(string $LangCode): void
     134  {
     135    $DbResult = $this->Database->select('Language', '*', 'Code='.$this->Database->quote($LangCode));
    137136    if ($DbResult->num_rows > 0)
    138137    {
    139138      $Language = $DbResult->fetch_assoc();
    140       $Database->delete('Locale', '`Language`='.$Language['Id']);
     139      $this->Database->delete('Locale', '`Language`='.$Language['Id']);
    141140      foreach ($this->Texts->Data as $Index => $Item)
    142         $Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '.
    143         'VALUES('.$Language['Id'].','.$Database->quote($Index).','.$Database->quote($Item).')');
    144     }
    145   }
    146 
    147   function UpdateToDatabase(Database $Database, $LangCode)
    148   {
    149     $DbResult = $Database->select('Language', '*', '`Code`='.$Database->quote($LangCode));
     141        $this->Database->query('INSERT INTO `Locale` (`Language`,`Original`,`Translated`) '.
     142        'VALUES('.$Language['Id'].','.$this->Database->quote($Index).','.$this->Database->quote($Item).')');
     143    }
     144  }
     145
     146  function UpdateToDatabase(string $LangCode): void
     147  {
     148    $DbResult = $this->Database->select('Language', '*', '`Code`='.$this->Database->quote($LangCode));
    150149    if ($DbResult->num_rows > 0)
    151150    {
     
    153152      foreach ($this->Texts->Data as $Index => $Item)
    154153      {
    155         if (is_array($Item)) continue;
    156         $DbResult = $Database->select('Locale', '*', '(`Original` ='.$Database->quote($Index).
     154        $DbResult = $this->Database->select('Locale', '*', '(`Original` ='.$this->Database->quote($Index).
    157155          ') AND (`Language`='.($Language['Id']).')');
    158156        if ($DbResult->num_rows > 0)
    159         {
    160           $Database->update('Locale', '(`Language`='.($Language['Id']).') AND '.
    161             '(`Original` ='.$Database->quote($Index).')', array('Translated' => $Item));
    162         } else
    163         {
    164           $Database->insert('Locale', array('Language' => $Language['Id'],
    165            'Original' => $Index, 'Translated' => $Item, 'Fuzzy' => 0));
    166         }
     157        $this->Database->update('Locale', '(`Language`='.($Language['Id']).') AND '.
     158          '(`Original` ='.$this->Database->quote($Index).')', array('Translated' => $Item));
     159        else $this->Database->insert('Locale', array('Language' => $Language['Id'],
     160         'Original' => $Index, 'Translated' => $Item));
    167161      }
    168162    }
     
    172166class LocaleManager extends Model
    173167{
    174   var $CurrentLocale;
    175   var $Codes;
    176   var $Dir;
    177   var $LangCode;
    178   var $DefaultLangCode;
    179   var $Available;
     168  public LocaleFile $CurrentLocale;
     169  public array $Codes;
     170  public string $Dir;
     171  public string $LangCode;
     172  public string $DefaultLangCode;
     173  public array $Available;
    180174
    181175  function __construct(System $System)
     
    187181    $this->DefaultLangCode = 'en';
    188182    $this->Available = array();
    189   }
    190 
    191   function LoadAvailable()
     183    $this->Dir = '';
     184  }
     185
     186  function LoadAvailable(): void
    192187  {
    193188    $this->Available = array();
     
    206201  }
    207202
    208   function UpdateAll($Directory)
     203  function UpdateAll(string $Directory): void
    209204  {
    210205    $Locale = new LocaleFile($this->System);
     
    227222          if (!array_key_exists($Index, $Locale->Texts->Data))
    228223            unset($FileLocale->Texts->Data[$Index]);
    229         $FileLocale->UpdateToDatabase($this->System->Database, $FileLocale->Texts->Code);
     224        $FileLocale->UpdateToDatabase($FileLocale->Texts->Code);
    230225        $FileName = $this->Dir.'/'.$FileLocale->Texts->Code.'.php';
    231226        $FileLocale->SaveToFile($FileName);
     
    235230  }
    236231
    237   function LoadLocale($Code)
     232  function LoadLocale(string $Code): void
    238233  {
    239234    if (array_key_exists($Code, $this->Available))
     
    246241
    247242// Short named global translation function
    248 function T($Text, $Group = '')
     243function T(string $Text, string $Group = ''): string
    249244{
    250245  global $GlobalLocaleManager;
  • trunk/Packages/Common/Mail.php

    r880 r888  
    99class Mail
    1010{
    11   var $Priorities;
    12   var $Subject;
    13   var $From;
    14   var $Recipients;
    15   var $Bodies;
    16   var $Attachments;
    17   var $AgentIdent;
    18   var $Organization;
    19   var $ReplyTo;
    20   var $Headers;
     11  public string $Subject;
     12  public string $From;
     13  public array $Recipients;
     14  public array $Bodies;
     15  public array $Attachments;
     16  public string $AgentIdent;
     17  public string $Organization;
     18  public string $ReplyTo;
     19  public array $Headers;
     20  private array $Priorities;
     21  private string $Boundary;
     22  public bool $TestMode;
    2123
    2224  function __construct()
     
    2527    $this->Boundary = md5(date('r', time()));
    2628    $this->AgentIdent = 'PHP/Mail';
     29    $this->TestMode = false;
    2730    $this->Clear();
    2831  }
    2932
    30   function Clear()
     33  function Clear(): void
    3134  {
    3235    $this->Bodies = array();
     
    4144  }
    4245
    43   function AddToCombined($Address)
     46  function AddToCombined(string $Address): void
    4447  {
    4548    $this->Recipients[] = array('Address' => $Address, 'Type' => 'SendCombined');
    4649  }
    4750
    48   function AddTo($Address, $Name)
     51  function AddTo(string $Address, string $Name): void
    4952  {
    5053    $this->Recipients[] = array('Address' => $Address, 'Name' => $Name, 'Type' => 'Send');
    5154  }
    5255
    53   function AddCc($Address, $Name)
     56  function AddCc(string $Address, string $Name): void
    5457  {
    5558    $this->Recipients[] = array('Address' => $Address, 'Name' => $Name, 'Type' => 'Copy');
    5659  }
    5760
    58   function AddBcc($Address, $Name)
     61  function AddBcc(string $Address, string $Name): void
    5962  {
    6063    $this->Recipients[] = array('Address' => $Address, 'Name' => $Name, 'Type' => 'HiddenCopy');
    6164  }
    6265
    63   function AddBody($Content, $MimeType = 'text/plain', $Charset = 'utf-8')
     66  function AddBody(string $Content, string $MimeType = 'text/plain', string $Charset = 'utf-8'): void
    6467  {
    6568    $this->Bodies[] = array('Content' => $Content, 'Type' => strtolower($MimeType),
     
    6770  }
    6871
    69   function Organization($org)
     72  function Organization(string $org): void
    7073  {
    7174    if (trim($org != '')) $this->xheaders['Organization'] = $org;
    7275  }
    7376
    74   function Priority($Priority)
     77  function Priority(int $Priority): bool
    7578  {
    7679    if (!intval($Priority)) return false;
    7780
    78     if (!isset($this->priorities[$Priority - 1])) return false;
    79 
    80     $this->xheaders['X-Priority'] = $this->priorities[$Priority - 1];
     81    if (!isset($this->Priorities[$Priority - 1])) return false;
     82
     83    $this->xheaders['X-Priority'] = $this->Priorities[$Priority - 1];
    8184    return true;
    8285  }
    8386
    84   function AttachFile($FileName, $FileType, $Disposition = DISPOSITION_ATTACHMENT)
     87  function AttachFile($FileName, $FileType, $Disposition = DISPOSITION_ATTACHMENT): void
    8588  {
    8689    $this->Attachments[] = array('FileName' => $FileName, 'FileType' => $FileType,
     
    8891  }
    8992
    90   function AttachData($FileName, $FileType, $Data, $Disposition = DISPOSITION_ATTACHMENT)
     93  function AttachData($FileName, $FileType, $Data, $Disposition = DISPOSITION_ATTACHMENT): void
    9194  {
    9295    $this->Attachments[] = array('FileName' => $FileName, 'FileType' => $FileType,
     
    9497  }
    9598
    96   function Send()
     99  function Send(): bool
    97100  {
    98101    if (count($this->Bodies) == 0) throw new Exception(T('Mail message need at least one text body'));
     
    132135    if ($this->AgentIdent != '') $this->Headers['X-Mailer'] = $this->AgentIdent;
    133136    if ($this->ReplyTo != '') $this->Headers['Reply-To'] = $this->ReplyTo;
    134     if ($this->From != '') $this->Headers['From'] = $this->From;
     137    if ($this->From != '')
     138    {
     139      $IndexStart = strpos($this->From, '<');
     140      if ($IndexStart !== false)
     141      {
     142        $this->Headers['From'] = '=?utf-8?Q?'.quoted_printable_encode(trim(substr($this->From, 0, $IndexStart))).'?= '.substr($this->From, $IndexStart);
     143      } else
     144      {
     145        $this->Headers['From'] = $this->From;
     146      }
     147    }
    135148
    136149    $Headers = '';
     
    144157    if ($this->Subject == '') throw new Exception(T('Mail message missing Subject'));
    145158
    146 
    147     $res = mail($To, $this->Subject, $Body, $Headers);
     159    if ($this->TestMode)
     160    {
     161      echo('to: '.$To.', subject: '.$this->Subject.', body: '.$Body.', headers: '.$Headers);
     162      $res = true;
     163    } else
     164    {
     165      $res = mail($To, $this->Subject, $Body, $Headers);
     166    }
    148167    return $res;
    149168  }
    150169
    151   function ValidEmail($Address)
    152   {
    153     if (ereg(".*<(.+)>", $Address, $regs)) $Address = $regs[1];
    154     if (ereg("^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address))
     170  function ValidEmail(string $Address): bool
     171  {
     172    if (preg_match(".*<(.+)>", $Address, $regs)) $Address = $regs[1];
     173    if (preg_match("^[^@  ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$", $Address))
    155174      return true;
    156175      else return false;
    157176  }
    158177
    159   function CheckAdresses($Addresses)
     178  function CheckAdresses(array $Addresses): void
    160179  {
    161180    foreach ($Addresses as $Address)
    162181    {
    163182      if (!$this->ValidEmail($Address))
    164   throw new Exception(sprintf(T('Mail message invalid address %s'), $Address));
    165     }
    166   }
    167 
    168   private function ContentEncoding($Charset)
     183      {
     184        throw new Exception(sprintf(T('Mail message invalid address %s'), $Address));
     185      }
     186    }
     187  }
     188
     189  private function ContentEncoding($Charset): string
    169190  {
    170191    if ($Charset != CHARSET_ASCII) return '8bit';
     
    172193  }
    173194
    174   private function BuildAttachment($Body)
     195  private function BuildAttachment($Body): string
    175196  {
    176197    if (count($this->Attachments) > 0)
     
    206227  }
    207228
    208   private function BuildBody()
     229  private function BuildBody(): string
    209230  {
    210231    $Result = '';
     
    219240      $this->Headers['Content-Transfer-Encoding'] = $this->ContentEncoding($this->Bodies[0]['Charset']);
    220241    }
    221 
    222242
    223243    foreach ($this->Bodies as $Body)
  • trunk/Packages/Common/Module.php

    r887 r888  
    11<?php
    22
    3 /* This implementation will not support installation from remote source. Just
    4  * installation of already presented modules mainly to persistence preparation.
    5  */
    6 
    73class ModuleType
    84{
    95  const System = 0;
    10   const Normal = 1;
     6  const Library = 1;
    117  const Application = 2;
    128}
     
    2117  const Enable = 5;
    2218  const Disable = 6;
     19  const InsertSampleData = 7;
    2320}
    2421
     
    3229  const Running = 5;
    3330  const NotRunning = 6;
    34 }
    35 
    36 class AppModule
    37 {
    38   var $Id;
    39   var $Name;
    40   var $Title;
    41   var $Version;
    42   var $License;
    43   var $Creator;
    44   var $HomePage;
    45   var $Description;
    46   var $Running;
    47   var $Enabled;
    48   var $Installed;
    49   var $InstalledVersion;
    50   /** @var ModuleType */
    51   var $Type;
    52   var $Dependencies;
    53   /** @var Database */
    54   var $Database;
    55   /** @var System */
    56   var $System;
    57   /** @var AppModuleManager */
    58   var $Manager;
    59   var $OnChange;
     31  const System = 7;
     32  const Library = 8;
     33  const Application = 9;
     34}
     35
     36class Module extends Model
     37{
     38  public int $Id;
     39  public string $Name;
     40  public string $Title;
     41  public string $Version;
     42  public string $License;
     43  public string $Creator;
     44  public string $HomePage;
     45  public string $Description;
     46  public int $Type; // ModuleType
     47  public array $Dependencies;
     48  public array $Models; // Model
     49  public bool $Running;
     50  public bool $Enabled;
     51  public bool $Installed;
     52  public string $InstalledVersion;
     53  public Database $Database;
     54  public System $System;
     55  public ModuleManager $Manager;
     56  public $OnChange;
    6057
    6158  function __construct(System $System)
    6259  {
    63     $this->System = &$System;
    64     $this->Database = &$System->Database;
    65     $this->Installed = false;
    66     $this->Enabled = false;
    67     $this->Running = false;
     60    parent::__construct($System);
     61    $this->Name = '';
    6862    $this->HomePage = '';
    6963    $this->License = '';
    7064    $this->Version = '';
    7165    $this->Creator = '';
     66    $this->Title = '';
    7267    $this->Description = '';
    7368    $this->Dependencies = array();
    74     $this->Type = ModuleType::Normal;
    75   }
    76 
    77   function Install()
     69    $this->Models = array();
     70    $this->Type = ModuleType::Library;
     71    $this->Installed = false;
     72    $this->InstalledVersion = '';
     73    $this->Enabled = false;
     74    $this->Running = false;
     75  }
     76
     77  static function GetName()
     78  {
     79    $ClassName = get_called_class();
     80    if (substr($ClassName, 0, 6) == 'Module') return substr($ClassName, 6);
     81      else return $ClassName;
     82  }
     83
     84  static function GetModelDesc(): ModelDesc
     85  {
     86    $Desc = new ModelDesc(self::GetClassName());
     87    $Desc->AddString('Name');
     88    $Desc->AddString('Title');
     89    $Desc->AddString('Creator');
     90    $Desc->AddString('Version');
     91    $Desc->AddString('License');
     92    $Desc->AddBoolean('Installed');
     93    $Desc->AddString('InstalledVersion');
     94    $Desc->AddString('Description');
     95    return $Desc;
     96  }
     97
     98  function Install(): void
    7899  {
    79100    if ($this->Installed) return;
    80101    $List = array();
    81102    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotInstalled));
    82     $this->Manager->Perform($List, array(ModuleAction::Install), array(ModuleCondition::NotInstalled));
    83     $this->DoInstall();
     103    $this->Manager->PerformList($List, array(ModuleAction::Install), array(ModuleCondition::NotInstalled));
    84104    $this->Installed = true;
     105    $this->Enabled = true; // Automatically enable installed module
    85106    $this->InstalledVersion = $this->Version;
    86107    $this->Manager->Modules[$this->Name] = $this;
    87   }
    88 
    89   function Uninstall()
     108    $this->DoBeforeInstall();
     109    if ($this->Manager->OnInstallModule != null)
     110    {
     111      call_user_func($this->Manager->OnInstallModule, $this);
     112    }
     113    $this->InstallModels($this->Models);
     114    $this->DoInstall();
     115  }
     116
     117  function Uninstall(): void
    90118  {
    91119    if (!$this->Installed) return;
     
    94122    $List = array();
    95123    $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed));
    96     $this->Manager->Perform($List, array(ModuleAction::Uninstall), array(ModuleCondition::Installed));
     124    $this->Manager->PerformList($List, array(ModuleAction::Uninstall), array(ModuleCondition::Installed));
    97125    $this->DoUninstall();
    98   }
    99 
    100   function Upgrade()
     126    $this->UninstallModels($this->Models);
     127    if ($this->Manager->OnUninstallModule != null)
     128    {
     129      call_user_func($this->Manager->OnUninstallModule, $this);
     130    }
     131    $this->DoAfterUninstall();
     132  }
     133
     134  function Upgrade(): void
    101135  {
    102136    if (!$this->Installed) return;
     
    104138    $List = array();
    105139    $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Installed));
    106     $this->Manager->Perform($List, array(ModuleAction::Upgrade), array(ModuleCondition::Installed));
     140    $this->Manager->PerformList($List, array(ModuleAction::Upgrade), array(ModuleCondition::Installed));
    107141    $this->DoUpgrade();
    108142  }
    109143
    110   function Reinstall()
     144  function InsertSampleData(): void
     145  {
     146    $this->DoInsertSampleData();
     147  }
     148
     149  function Reinstall(): void
    111150  {
    112151    $this->Uninstall();
     
    115154  }
    116155
    117   function Start()
     156  function Start(): void
    118157  {
    119158    if ($this->Running) return;
     
    121160    $List = array();
    122161    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotRunning));
    123     $this->Manager->Perform($List, array(ModuleAction::Start), array(ModuleCondition::NotRunning));
     162    $this->Manager->PerformList($List, array(ModuleAction::Start), array(ModuleCondition::NotRunning));
    124163    $this->DoStart();
    125164    $this->Running = true;
    126165  }
    127166
    128   function Stop()
     167  function Stop(): void
    129168  {
    130169    if (!$this->Running) return;
     
    132171    $List = array();
    133172    $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Running));
    134     $this->Manager->Perform($List, array(ModuleAction::Stop), array(ModuleCondition::Running));
     173    $this->Manager->PerformList($List, array(ModuleAction::Stop), array(ModuleCondition::Running));
    135174    $this->DoStop();
    136175  }
    137176
    138   function Restart()
     177  function Restart(): void
    139178  {
    140179    $this->Stop();
     
    142181  }
    143182
    144   function Enable()
     183  function Enable(): void
    145184  {
    146185    if ($this->Enabled) return;
     
    148187    $List = array();
    149188    $this->Manager->EnumDependenciesCascade($this, $List, array(ModuleCondition::NotEnabled));
    150     $this->Manager->Perform($List, array(ModuleAction::Enable), array(ModuleCondition::NotEnabled));
     189    $this->Manager->PerformList($List, array(ModuleAction::Enable), array(ModuleCondition::NotEnabled));
    151190    $this->Enabled = true;
    152191  }
    153192
    154   function Disable()
     193  function Disable(): void
    155194  {
    156195    if (!$this->Enabled) return;
     
    159198    $List = array();
    160199    $this->Manager->EnumSuperiorDependenciesCascade($this, $List, array(ModuleCondition::Enabled));
    161     $this->Manager->Perform($List, array(ModuleAction::Disable), array(ModuleCondition::Enabled));
    162   }
    163 
    164   protected function DoStart()
    165   {
    166   }
    167 
    168   protected function DoStop()
    169   {
    170   }
    171 
    172   protected function DoInstall()
    173   {
    174   }
    175 
    176   protected function DoUninstall()
    177   {
    178   }
    179 
    180   protected function DoUpgrade()
    181   {
    182 
    183   }
    184 }
    185 
    186 /* Manage installed modules */
    187 class AppModuleManager
    188 {
    189   var $Modules;
    190   var $System;
    191   var $FileName;
    192   var $ModulesDir;
    193   var $OnLoadModules;
    194 
    195   function __construct(System $System)
    196   {
    197     $this->Modules = array();
    198     $this->System = &$System;
    199     $this->FileName = dirname(__FILE__).'/../../Config/ModulesConfig.php';
    200     $this->ModulesDir = dirname(__FILE__).'/../../Modules';
    201   }
    202 
    203   function Perform($List, $Actions, $Conditions = array(ModuleCondition::All))
    204   {
    205     foreach ($List as $Index => $Module)
    206     {
    207       if (in_array(ModuleCondition::All, $Conditions) or
    208         ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
    209         (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or
    210         ($Module->Installed and in_array(ModuleCondition::Installed, $Conditions)) or
    211         (!$Module->Installed and in_array(ModuleCondition::NotInstalled, $Conditions)) or
    212         ($Module->Enabled and in_array(ModuleCondition::Enabled, $Conditions)) or
    213         (!$Module->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions)))
     200    $this->Manager->PerformList($List, array(ModuleAction::Disable), array(ModuleCondition::Enabled));
     201  }
     202
     203  protected function DoStart(): void
     204  {
     205  }
     206
     207  protected function DoStop(): void
     208  {
     209  }
     210
     211  protected function DoBeforeInstall(): void
     212  {
     213  }
     214
     215  protected function DoInstall(): void
     216  {
     217  }
     218
     219  protected function DoUninstall(): void
     220  {
     221  }
     222
     223  protected function DoAfterUninstall(): void
     224  {
     225  }
     226
     227  protected function DoUpgrade(): string
     228  {
     229    return '';
     230  }
     231
     232  protected function DoInsertSampleData(): void
     233  {
     234  }
     235
     236  function AddModel(Model $Model): void
     237  {
     238    $this->Models[get_class($Model)] = $Model;
     239  }
     240
     241  function InstallModels(array $Models): void
     242  {
     243    if ($this->Manager->OnInstallModel != null)
     244    {
     245      foreach ($Models as $Model)
    214246      {
    215         foreach ($Actions as $Action)
    216         {
    217           if ($Action == ModuleAction::Start) $Module->Start();
    218           if ($Action == ModuleAction::Stop) $Module->Stop();
    219           if ($Action == ModuleAction::Install) $Module->Install();
    220           if ($Action == ModuleAction::Uninstall) $Module->Uninstall();
    221           if ($Action == ModuleAction::Enable) $Module->Enable();
    222           if ($Action == ModuleAction::Disable) $Module->Disable();
    223           if ($Action == ModuleAction::Upgrade) $Module->Upgrade();
    224         }
     247        call_user_func($this->Manager->OnInstallModel, $Model::GetModelDesc(), $this);
    225248      }
    226249    }
    227250  }
    228251
    229   function EnumDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All))
    230   {
    231     foreach ($Module->Dependencies as $Dependency)
    232     {
    233       if (!array_key_exists($Dependency, $this->Modules))
    234         throw new Exception(sprintf(T('Module "%s" dependency "%s" not found'), $Module->Name, $Dependency));
    235       $DepModule = $this->Modules[$Dependency];
    236       if (in_array(ModuleCondition::All, $Conditions) or
    237         ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
    238         (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or
    239         ($Module->Enabled and in_array(ModuleCondition::Enabled, $Conditions)) or
    240         (!$Module->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions)) or
    241         ($Module->Installed and in_array(ModuleCondition::Installed, $Conditions)) or
    242         (!$Module->Installed and in_array(ModuleCondition::NotInstalled, $Conditions)))
     252  function UninstallModels(array $Models): void
     253  {
     254    if ($this->Manager->OnUninstallModel != null)
     255    {
     256      foreach (array_reverse($Models) as $Model)
    243257      {
    244         array_push($List, $DepModule);
    245         $this->EnumDependenciesCascade($DepModule, $List, $Conditions);
     258        call_user_func($this->Manager->OnUninstallModel, $Model::GetModelDesc(), $this);
    246259      }
    247260    }
    248261  }
    249 
    250   function EnumSuperiorDependenciesCascade($Module, &$List, $Conditions = array(ModuleCondition::All))
    251   {
    252     foreach ($this->Modules as $RefModule)
    253     {
    254       if (in_array($Module->Name, $RefModule->Dependencies) and
    255           (in_array(ModuleCondition::All, $Conditions) or
    256           ($Module->Running and in_array(ModuleCondition::Running, $Conditions)) or
    257           (!$Module->Running and in_array(ModuleCondition::NotRunning, $Conditions)) or
    258           ($Module->Enabled and in_array(ModuleCondition::Enabled, $Conditions)) or
    259           (!$Module->Enabled and in_array(ModuleCondition::NotEnabled, $Conditions)) or
    260           ($Module->Installed and in_array(ModuleCondition::Installed, $Conditions)) or
    261           (!$Module->Installed and in_array(ModuleCondition::NotInstalled, $Conditions))))
    262       {
    263         array_push($List, $RefModule);
    264         $this->EnumSuperiorDependenciesCascade($RefModule, $List, $Conditions);
    265       }
    266     }
    267   }
    268 
    269   function Start()
    270   {
    271     $this->LoadModules();
    272     if (file_exists($this->FileName)) $this->LoadState();
    273     $this->StartEnabled();
    274   }
    275 
    276   function StartAll()
    277   {
    278     $this->Perform($this->Modules, array(ModuleAction::Start));
    279   }
    280 
    281   function StartEnabled()
    282   {
    283     $this->Perform($this->Modules, array(ModuleAction::Start), array(ModuleCondition::Enabled));
    284   }
    285 
    286   function StopAll()
    287   {
    288     $this->Perform($this->Modules, array(ModuleAction::Stop));
    289   }
    290 
    291   function InstallAll()
    292   {
    293     $this->Perform($this->Modules, array(ModuleAction::Install));
    294     $this->SaveState();
    295   }
    296 
    297   function UninstallAll()
    298   {
    299     $this->Perform($this->Modules, array(ModuleAction::Uninstall));
    300     $this->SaveState();
    301   }
    302 
    303   function EnableAll()
    304   {
    305     $this->Perform($this->Modules, array(ModuleAction::Enable));
    306     $this->SaveState();
    307   }
    308 
    309   function DisableAll()
    310   {
    311     $this->Perform($this->Modules, array(ModuleAction::Disable));
    312     $this->SaveState();
    313   }
    314 
    315   function ModulePresent($Name)
    316   {
    317     return array_key_exists($Name, $this->Modules);
    318   }
    319 
    320   function ModuleEnabled($Name)
    321   {
    322     return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Enabled;
    323   }
    324 
    325   function ModuleRunning($Name)
    326   {
    327     return array_key_exists($Name, $this->Modules) and $this->Modules[$Name]->Running;
    328   }
    329 
    330   /* @return Module */
    331   function SearchModuleById($Id)
    332   {
    333     foreach ($this->Modules as $Module)
    334     {
    335       //DebugLog($Module->Name.' '.$Module->Id);
    336       if ($Module->Id == $Id) return $Module->Name;
    337     }
    338     return '';
    339   }
    340 
    341   function LoadState()
    342   {
    343     $ConfigModules = array();
    344     include($this->FileName);
    345     foreach ($ConfigModules as $Mod)
    346     {
    347       if (array_key_exists($Mod['Name'], $this->Modules))
    348       {
    349         $this->Modules[$Mod['Name']] = $this->Modules[$Mod['Name']];
    350         $this->Modules[$Mod['Name']]->Enabled = $Mod['Enabled'];
    351         $this->Modules[$Mod['Name']]->Installed = $Mod['Installed'];
    352         $this->Modules[$Mod['Name']]->InstalledVersion = $Mod['Version'];
    353       }
    354     }
    355   }
    356 
    357   function SaveState()
    358   {
    359     $Data = array();
    360     foreach ($this->Modules as $Module)
    361     {
    362       $Data[] = array('Name' => $Module->Name, 'Enabled' => $Module->Enabled,
    363         'Version' => $Module->Version, 'Installed' => $Module->Installed);
    364     }
    365     file_put_contents($this->FileName, "<?php \n\n\$ConfigModules = ".var_export($Data, true).";\n");
    366   }
    367 
    368   function RegisterModule(AppModule $Module)
    369   {
    370     $this->Modules[$Module->Name] = &$Module;
    371     $Module->Manager = &$this;
    372     $Module->OnChange = &$this->OnModuleChange;
    373   }
    374 
    375   function UnregisterModule(AppModule $Module)
    376   {
    377     unset($this->Modules[array_search($Module, $this->Modules)]);
    378   }
    379 
    380   function LoadModulesFromDir($Directory)
    381   {
    382     $List = scandir($Directory);
    383     foreach ($List as $Item)
    384     {
    385       if (is_dir($Directory.'/'.$Item) and ($Item != '.') and ($Item != '..') and ($Item != '.svn'))
    386       {
    387         include_once($Directory.'/'.$Item.'/'.$Item.'.php');
    388         $ModuleName = 'Module'.$Item;
    389         $this->RegisterModule(new $ModuleName($this->System));
    390       }
    391     }
    392   }
    393 
    394   function LoadModules(): void
    395   {
    396     if (is_array($this->OnLoadModules) and (count($this->OnLoadModules) == 2) and method_exists($this->OnLoadModules[0], $this->OnLoadModules[1]))
    397       call_user_func($this->OnLoadModules);
    398     else $this->LoadModulesFromDir($this->ModulesDir);
    399   }
    400 }
     262}
  • trunk/Packages/Common/Modules/Setup.php

    r887 r888  
    11<?php
     2
     3class ModuleSetup extends Module
     4{
     5  public UpdateManager $UpdateManager;
     6
     7  function __construct(System $System)
     8  {
     9    global $DatabaseRevision;
     10
     11    parent::__construct($System);
     12    $this->Name = 'Setup';
     13    $this->Version = '1.0';
     14    $this->Creator = 'Chronos';
     15    $this->License = 'GNU/GPLv3';
     16    $this->Description = 'Base setup module';
     17    $this->Revision = 1;
     18    $this->Type = ModuleType::System;
     19
     20    // Check database persistence structure
     21    $this->UpdateManager = new UpdateManager();
     22    $this->UpdateManager->Database = &$this->Database;
     23    $this->UpdateManager->Revision = $DatabaseRevision;
     24    $this->UpdateManager->InstallMethod = 'FullInstall';
     25  }
     26
     27  static function Cast(Module $Module): ModuleSetup
     28  {
     29    if ($Module instanceof ModuleSetup)
     30    {
     31      return $Module;
     32    }
     33    throw new Exception('Expected ModuleSetup type but '.gettype($Module));
     34  }
     35
     36  function DoStart(): void
     37  {
     38    Core::Cast($this->System)->RegisterPage([''], 'PageSetupRedirect');
     39    Core::Cast($this->System)->RegisterPage(['setup'], 'PageSetup');
     40  }
     41
     42  function DoStop(): void
     43  {
     44    unset($this->UpdateManager);
     45    Core::Cast($this->System)->UnregisterPage(['']);
     46    Core::Cast($this->System)->UnregisterPage(['setup']);
     47  }
     48
     49  function CheckState(): bool
     50  {
     51    return $this->Database->Connected() and $this->UpdateManager->IsInstalled() and
     52      $this->UpdateManager->IsUpToDate();
     53  }
     54
     55  function DoUpgrade(): string
     56  {
     57    $Updates = new Updates();
     58    $this->UpdateManager->Trace = $Updates->Get();
     59    $Output = $this->UpdateManager->Upgrade();
     60    return $Output;
     61  }
     62}
    263
    364class PageSetup extends Page
    465{
    5   var $UpdateManager;
    6   var $ConfigDefinition;
    7   var $Config;
    8   var $DatabaseRevision;
    9   var $Revision;
    10   var $Updates;
    11   var $ConfigDir;
    12 
    13   function __construct($System)
     66  public UpdateManager $UpdateManager;
     67  public array $ConfigDefinition;
     68  public array $Config;
     69  public int $DatabaseRevision;
     70  public int $Revision;
     71  public string $ConfigDir;
     72  public array $YesNo;
     73
     74  function __construct(System $System)
    1475  {
    1576    parent::__construct($System);
    1677    $this->Title = T('Application setup');
    17     //$this->ParentClass = 'PagePortal';
     78    //$this->ParentClass = 'PageSetupRedirect';
    1879    $this->ConfigDir = dirname(dirname(dirname(__FILE__))).'/Config';
    1980    $this->YesNo = array(false => T('No'), true => T('Yes'));
    2081  }
    2182
    22   function LoginPanel()
     83  function LoginPanel(): string
    2384  {
    2485    $Output = '<h3>Přihlášení k instalaci</h3>'.
     
    3293  }
    3394
    34   function ControlPanel()
     95  function ControlPanel(): string
    3596  {
    3697    $Output = '<h3>'.T('Instance management').'</h3>';
     
    49110          $Output .= '<a href="?action=upgrade">'.T('Upgrade').'</a> ';
    50111        $Output .= '<a href="?action=insert_sample_data">Vložit vzorová data</a> ';
    51         $Output .= '<a href="?action=reload_modules">Obnovit seznam modulů</a> ';
     112        $Output .= '<a href="?action=reload-modules">Obnovit seznam modulů</a> ';
    52113        $Output .= '<a href="?action=uninstall">Odinstalovat</a> ';
    53         $Output .= '<a href="?action=modules">Správa modulů</a> ';
     114        $Output .= '<a href="'.$this->System->Link('/modules/').'">Správa modulů</a> ';
    54115        $Output .= '<a href="?action=models">Přegenerovat modely</a> ';
    55116      } else $Output .= '<a href="?action=install">Instalovat</a> ';
     
    62123  }
    63124
    64   function Show()
     125  function Show(): string
    65126  {
    66127    global $ConfigDefinition, $DatabaseRevision, $Config, $Updates;
    67128
    68     $this->UpdateManager = $this->System->Setup->UpdateManager;
     129    $this->UpdateManager = ModuleSetup::Cast($this->System->GetModule('Setup'))->UpdateManager;
    69130    $DefaultConfig = new DefaultConfig();
    70131    $this->ConfigDefinition = $DefaultConfig->Get();
     
    89150          $Output .= 'Odhlášen';
    90151          $Output .= $this->LoginPanel();
    91         } else
    92         if ($Action == 'models')
     152        }
     153        else if ($Action == 'models')
    93154        {
    94155          $this->System->FormManager->UpdateSQLMeta();
    95         } else
    96         if ($Action == 'upgrade')
     156        }
     157        else if ($Action == 'upgrade')
    97158        {
    98159          $Output .= '<h3>Povýšení</h3>';
    99           try {
    100             $Output .= $this->System->Setup->Upgrade();
    101           } catch (Exception $E) {
     160          try
     161          {
     162            $Output .= ModuleSetup::Cast($this->System->GetModule('Setup'))->DoUpgrade();
     163            $this->System->ModuleManager->UpgradeAll(array(ModuleCondition::System));
     164          } catch (Exception $E)
     165          {
    102166            $Output .= $this->SystemMessage('Chyba aktualizace',
    103167              'Došlo k chybě v SQL dotazu při aktualizaci: <br/>'.$E->getMessage());
    104168          }
    105169          $Output .= $this->ControlPanel();
    106         } else
    107         if ($Action == 'install')
    108         {
    109           $Output .= '<h3>Instalace</h3>';
    110           $this->System->Setup->Install();
     170        }
     171        else if ($Action == 'install')
     172        {
     173          $Output .= '<h3>Instalace systém</h3>';
     174          global $DatabaseRevision;
     175
     176          $this->Database->query("CREATE TABLE IF NOT EXISTS `".$this->UpdateManager->VersionTable."` (".
     177            '`Id` int(11) NOT NULL AUTO_INCREMENT, '.
     178            '`Revision` int(11) NOT NULL, '.
     179            'PRIMARY KEY (`Id`) '.
     180            ') ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
     181          $DbResult = $this->Database->select($this->UpdateManager->VersionTable, 'Id');
     182          if ($DbResult->num_rows == 0)
     183          {
     184            $this->Database->query("INSERT INTO `".$this->UpdateManager->VersionTable.
     185              "` (`Id`, `Revision`) VALUES (1, ".$DatabaseRevision.");");
     186          }
     187          $this->System->ModuleManager->InstallAll(array(ModuleCondition::System));
    111188          $this->System->ModuleManager->LoadModules();
    112189          $this->System->ModuleManager->SaveState();
    113           //$Output .= $this->System->Setup->Upgrade();
    114           $Output .= $this->ControlPanel();
    115         } else
    116         if ($Action == 'uninstall')
    117         {
    118           $Output .= '<h3>Odinstalace</h3>';
    119           $this->System->Setup->Uninstall();
    120           $Output .= $this->ControlPanel();
    121         } else
    122         if ($Action == 'reload_modules')
     190          //$Output .= ModuleSetup::Cast($this->System->GetModule('Setup'))->Upgrade();
     191          $Output .= $this->ControlPanel();
     192        }
     193        else if ($Action == 'uninstall')
     194        {
     195          $Output .= '<h3>Odinstalace vše</h3>';
     196          $this->System->ModuleManager->UninstallAll(array(ModuleCondition::All));
     197          $this->Database->query('DROP TABLE IF EXISTS `'.$this->UpdateManager->VersionTable.'`');
     198          $Output .= $this->ControlPanel();
     199        }
     200        else if ($Action == 'reload-modules')
    123201        {
    124202          $Output .= '<h3>Znovunačtení seznamu modulů</h3>';
     
    126204          $this->System->ModuleManager->SaveState();
    127205          $Output .= $this->ControlPanel();
    128         } else
    129         if ($Action == 'insert_sample_data')
     206        }
     207        else if ($Action == 'insert_sample_data')
    130208        {
    131209          $Output .= '<h3>Vložení vzorových dat</h3>';
    132           $this->System->Setup->InsertSampleData();
    133           $Output .= $this->ControlPanel();
    134         } else
    135         if ($Action == 'modules')
    136         {
    137           $Output .= $this->ShowModules();
    138         } else
    139         if ($Action == 'configure_save')
     210          $this->System->ModuleManager->Perform(array(ModuleAction::InsertSampleData), array(ModuleCondition::Installed));
     211          $Output .= $this->ControlPanel();
     212        }
     213        else if ($Action == 'configure_save')
    140214        {
    141215           $Output .= $this->ConfigSave($this->Config);
    142216           $Output .= $this->ControlPanel();
    143         } else
    144         if ($Action == 'configure')
     217        }
     218        else if ($Action == 'configure')
    145219        {
    146220          $Output .= $this->PrepareConfig($this->Config);
    147         } else
     221        }
     222        else
    148223        {
    149224          $Output .= $this->ControlPanel();
     
    163238  }
    164239
    165   function ShowModules()
    166   {
    167     $Output = '';
    168     if (array_key_exists('op', $_GET)) $Operation = $_GET['op'];
    169       else $Operation = '';
    170     if ($Operation == 'install')
    171     {
    172       $this->System->ModuleManager->Modules[$_GET['name']]->Install();
    173       $this->System->ModuleManager->SaveState();
    174       $Output .= 'Modul '.$_GET['name'].' instalován<br/>';
    175     } else
    176     if ($Operation == 'uninstall')
    177     {
    178       $this->System->ModuleManager->Modules[$_GET['name']]->Uninstall();
    179       $this->System->ModuleManager->SaveState();
    180       $Output .= 'Modul '.$_GET['name'].' odinstalován<br/>';
    181     } else
    182     if ($Operation == 'enable')
    183     {
    184       $this->System->ModuleManager->Modules[$_GET['name']]->Enable();
    185       $this->System->ModuleManager->SaveState();
    186       $Output .= 'Modul '.$_GET['name'].' povolen<br/>';
    187     } else
    188     if ($Operation == 'disable')
    189     {
    190       $this->System->ModuleManager->Modules[$_GET['name']]->Disable();
    191       $this->System->ModuleManager->SaveState();
    192       $Output .= 'Modul '.$_GET['name'].' zakázán<br/>';
    193     } else
    194     if ($Operation == 'upgrade')
    195     {
    196       $this->System->ModuleManager->Modules[$_GET['name']]->Upgrade();
    197       $this->System->ModuleManager->SaveState();
    198       $Output .= 'Modul '.$_GET['name'].' povýšen<br/>';
    199     }
    200     $Output .= '<h3>Správa modulů</h3>';
    201     $Output .= $this->ShowList();
    202     return $Output;
    203   }
    204 
    205   function ShowList()
    206   {
    207     $Output = '';
    208 
    209     $Pageing = new Paging();
    210     $Pageing->TotalCount = count($this->System->ModuleManager->Modules);
    211     $Table = new VisualTable();
    212     $Table->SetColumns(array(
    213       array('Name' => 'Name', 'Title' => 'Jméno'),
    214       array('Name' => 'Creator', 'Title' => 'Tvůrce'),
    215       array('Name' => 'Version', 'Title' => 'Verze'),
    216       array('Name' => 'License', 'Title' => 'Licence'),
    217       array('Name' => 'Installed', 'Title' => 'Instalováno'),
    218       array('Name' => 'Enabled', 'Title' => 'Povoleno'),
    219       array('Name' => 'Description', 'Title' => 'Popis'),
    220       array('Name' => 'Dependencies', 'Title' => 'Závislosti'),
    221       array('Name' => '', 'Title' => 'Akce'),
    222     ));
    223     foreach ($this->System->ModuleManager->Modules as $Module)
    224     {
    225       if (($Module->Dependencies) > 0) $Dependencies = implode(',', $Module->Dependencies);
    226        else $Dependencies = '&nbsp;';
    227       $Actions = '';
    228       if ($Module->Installed == true)
    229       {
    230         $Actions .= ' <a href="?action=modules&amp;op=uninstall&amp;name='.$Module->Name.'">Odinstalovat</a>';
    231         if ($Module->Enabled == true) $Actions .= ' <a href="?action=modules&amp;op=disable&amp;name='.$Module->Name.'">Zakázat</a>';
    232         else $Actions .= ' <a href="?action=modules&amp;op=enable&amp;name='.$Module->Name.'">Povolit</a>';
    233         if ($Module->InstalledVersion != $Module->Version) $Actions .= ' <a href="?action=modules&amp;op=upgrade&amp;name='.$Module->Name.'">Povýšit</a>';
    234       } else $Actions .= ' <a href="?action=modules&amp;op=install&amp;name='.$Module->Name.'">Instalovat</a>';
    235 
    236       $Table->Table->Cells[] = array($Module->Name,
    237         $Module->Creator, $Module->Version,
    238         $Module->License, $this->YesNo[$Module->Installed],
    239         $this->YesNo[$Module->Enabled], $Module->Description,
    240         $Dependencies, $Actions);
    241     }
    242     $Output .= $Pageing->Show();
    243     $Output .= $Table->Show();
    244     $Output .= $Pageing->Show();
    245     //$Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>';
    246     return $Output;
    247   }
    248 
    249   function PrepareConfig($Config)
     240  function PrepareConfig($Config): string
    250241  {
    251242    $Output = '';
     
    255246      $Output .= 'Varování: Konfigurační soubor nebude možné zapsat, protože soubor "'.$this->ConfigDir.'/Config.php" není povolen pro zápis!';
    256247    $Output .= '<h3>Nastavení systému</h3>'.
    257         '<form action="?action=configure_save" method="post">'.
    258         '<table>';
     248      '<form action="?action=configure_save" method="post">'.
     249      '<table>';
    259250    foreach ($this->ConfigDefinition as $Def)
    260251    {
     
    278269    }
    279270    $Output .= '</td></tr>'.
    280         '<tr><td colspan="2"><input type="submit" name="configure_save" value="'.T('Save').'"/></td></tr>'.
    281         '</table>'.
    282         '</form>';
     271      '<tr><td colspan="2"><input type="submit" name="configure_save" value="'.T('Save').'"/></td></tr>'.
     272      '</table>'.
     273      '</form>';
    283274    return $Output;
    284275  }
     
    322313  }
    323314
    324   function CreateConfig($Config)
     315  function CreateConfig($Config): string
    325316  {
    326317    $Output = "<?php\n\n".
     
    359350class PageSetupRedirect extends Page
    360351{
    361   function Show()
     352  function Show(): string
    362353  {
    363354    $Output = '';
    364     if (!$this->Database->Connected()) $Output .= T('Can\'t connect to database').'<br>';
    365     else {
    366       if (!$this->System->Setup->UpdateManager->IsInstalled())
    367         $Output .= T('System requires database initialization').'<br>';
    368       else
    369       if (!$this->System->Setup->UpdateManager->IsUpToDate())
    370         $Output .= T('System requires database upgrade').'<br>';
    371     }
    372     $Output .= sprintf(T('Front page was not configured. Continue to %s'), '<a href="'.$this->System->Link('/setup/').'">'.T('setup').'</a>');
     355    if (!$this->Database->Connected())
     356    {
     357      $Output .= T('Can\'t connect to database.').'<br>';
     358    } else
     359    {
     360      if (!ModuleSetup::Cast($this->System->GetModule('Setup'))->UpdateManager->IsInstalled())
     361      {
     362        $Output .= T('System requires database initialization.').'<br>';
     363      } else
     364      if (!ModuleSetup::Cast($this->System->GetModule('Setup'))->UpdateManager->IsUpToDate())
     365      {
     366        $Output .= T('System requires database upgrade.').'<br>';
     367      }
     368    }
     369    $Output .= sprintf(T('Front page was not configured. Continue to %s.'), '<a href="'.$this->System->Link('/setup/').'">'.T('setup').'</a>');
    373370    return $Output;
    374371  }
    375372}
    376 
    377 class Setup extends Model
    378 {
    379   var $UpdateManager;
    380 
    381   function Start()
    382   {
    383     global $DatabaseRevision;
    384 
    385     $this->System->RegisterPage('', 'PageSetupRedirect');
    386     $this->System->RegisterPage('setup', 'PageSetup');
    387 
    388     // Check database persistence structure
    389     $this->UpdateManager = new UpdateManager();
    390     $this->UpdateManager->Database = &$this->Database;
    391     $this->UpdateManager->Revision = $DatabaseRevision;
    392     $this->UpdateManager->InstallMethod = 'FullInstall';
    393   }
    394 
    395   function Stop()
    396   {
    397     unset($this->UpdateManager);
    398     $this->System->UnregisterPage('');
    399     $this->System->UnregisterPage('setup');
    400   }
    401 
    402   function CheckState()
    403   {
    404     return $this->Database->Connected() and $this->UpdateManager->IsInstalled() and
    405       $this->UpdateManager->IsUpToDate();
    406   }
    407 
    408   function Install()
    409   {
    410     global $DatabaseRevision;
    411 
    412     $this->Database->query('CREATE TABLE IF NOT EXISTS `'.$this->UpdateManager->VersionTable.'` (
    413   `Id` int(11) NOT NULL AUTO_INCREMENT,
    414   `Revision` int(11) NOT NULL,
    415   PRIMARY KEY (`Id`)
    416 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;');
    417     $this->Database->query('INSERT INTO `'.$this->UpdateManager->VersionTable.'` (`Id`, `Revision`) VALUES
    418       (1, '.$DatabaseRevision.');');
    419     $this->Database->query("CREATE TABLE IF NOT EXISTS `Module` (
    420   `Id` int(11) NOT NULL AUTO_INCREMENT,
    421   `Name` varchar(255) NOT NULL,
    422   `Title` varchar(255) NOT NULL,
    423   PRIMARY KEY (`Id`)
    424 ) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;");
    425   }
    426 
    427   function Uninstall()
    428   {
    429     $this->System->ModuleManager->UninstallAll();
    430     $this->Database->query('DROP TABLE `Module`');
    431     $this->Database->query('DROP TABLE `'.$this->UpdateManager->VersionTable.'`');
    432   }
    433 
    434   function IsInstalled()
    435   {
    436     $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->UpdateManager->VersionTable.'"');
    437     return $DbResult->num_rows > 0;
    438   }
    439 
    440   function Upgrade()
    441   {
    442     $Updates = new Updates();
    443     $this->UpdateManager->Trace = $Updates->Get();
    444     $Output = $this->UpdateManager->Upgrade();
    445     return $Output;
    446   }
    447 }
  • trunk/Packages/Common/NetworkAddress.php

    r880 r888  
    11<?php
     2
     3define('IPV4_BIT_WIDTH', 32);
    24
    35class NetworkAddressIPv4
    46{
    5   var $Address;
    6   var $Prefix;
     7  public int $Address;
     8  public int $Prefix;
    79
    810  function __construct()
     
    1214  }
    1315
    14   function GetNetMask()
     16  function GetNetMask(): int
    1517  {
    16     return 0xffffffff ^ ((1 << (32 - $this->Prefix)) - 1);
     18    return ((1 << IPV4_BIT_WIDTH) - 1) ^ ((1 << (IPV4_BIT_WIDTH - $this->Prefix)) - 1);
    1719  }
    1820
    19   function AddressToString()
     21  function AddressToString(): string
    2022  {
    2123    return implode('.', array(($this->Address >> 24) & 255, ($this->Address >> 16) & 255, ($this->Address >> 8) & 255, ($this->Address & 255)));
    2224  }
    2325
    24   function AddressFromString($Value)
     26  function AddressFromString(string $Value): void
    2527  {
    2628    $Parts = explode('.', $Value);
     
    2830  }
    2931
    30   function GetRange()
     32  function GetRange(): array
    3133  {
    3234    $From = new NetworkAddressIPv4();
    3335    $From->Address = $this->Address;
    34     $From->Prefix = 32;
     36    $From->Prefix = IPV4_BIT_WIDTH;
    3537    $HostMask = 0xffffffff ^ $this->GetNetMask();
    3638    $To = new NetworkAddressIPv4();
    3739    $To->Address = $From->Address + $HostMask;
    38     $To->Prefix = 32;
     40    $To->Prefix = IPV4_BIT_WIDTH;
    3941    return array('From' => $From, 'To' => $To);
    4042  }
    4143
    42   function ChangePrefix($NewPrefix)
     44  function ChangePrefix(int $NewPrefix): void
    4345  {
    4446    $this->Prefix = $NewPrefix;
    45     if ($this->Prefix > 32) $this->Prefix = 32;
     47    if ($this->Prefix > IPV4_BIT_WIDTH) $this->Prefix = IPV4_BIT_WIDTH;
    4648    if ($this->Prefix < 0) $this->Prefix = 0;
    4749    $this->Address = $this->Address & $this->GetNetMask();
    4850  }
    4951
    50   function Contain($Address)
     52  function Contain(NetworkAddressIPv4 $Address): bool
    5153  {
    5254    $UpperNetmask = $this->GetNetMask();
    5355    if (($this->Prefix < $Address->Prefix) and (($Address->Address & $UpperNetmask) == ($this->Address & $UpperNetmask))) $Result = true;
    5456      else $Result = false;
    55     //echo($Address->AddressToString().'/'.$Address->Prefix.' in '.$this->AddressToString().'/'.$this->Prefix.' '.$Result."\n");
    5657    return $Result;
    5758  }
    5859}
    5960
     61define('IPV6_BIT_WIDTH', 128);
     62
    6063class NetworkAddressIPv6
    6164{
    62   var $Address;
    63   var $Prefix;
     65  public string $Address;
     66  public int $Prefix;
    6467
    6568  function __construct()
     
    6972  }
    7073
    71   function AddressToString()
     74  function GetNetMask(): string
     75  {
     76    return Int128Xor(Int128Sub(Int128Shl(IntToInt128(1), IntToInt128(IPV6_BIT_WIDTH)), IntToInt128(1)),
     77      Int128Sub(Int128Shl(IntToInt128(1), IntToInt128(IPV6_BIT_WIDTH - $this->Prefix)), IntToInt128(1)));
     78  }
     79
     80  function AddressToString(): string
    7281  {
    7382    return inet_ntop($this->Address);
    7483  }
    7584
    76   function AddressFromString($Value)
     85  function AddressFromString(string $Value)
    7786  {
    7887    $this->Address = inet_pton($Value);
    7988  }
    8089
    81   function GetOctets()
     90  function ChangePrefix(int $NewPrefix): void
     91  {
     92    $this->Prefix = $NewPrefix;
     93    if ($this->Prefix > IPV6_BIT_WIDTH) $this->Prefix = IPV6_BIT_WIDTH;
     94    if ($this->Prefix < 0) $this->Prefix = 0;
     95    $this->Address = Int128And($this->Address, $this->GetNetMask());
     96  }
     97
     98  function GetOctets(): array
    8299  {
    83100    $Result = array();
     
    85102    foreach ($Data as $Item)
    86103    {
    87 
    88104      $Result[] = dechex($Item & 15);
    89105      $Result[] = dechex(($Item >> 4) & 15);
     
    92108  }
    93109
    94   function EncodeMAC($MAC)
     110  function EncodeMAC(string $MAC): void
    95111  {
    96112    $MAC = explode(':', $MAC);
     
    107123  }
    108124
     125  function Contain(NetworkAddressIPv6 $Address): bool
     126  {
     127    $UpperNetmask = $this->GetNetMask();
     128    if (($this->Prefix < $Address->Prefix) and ((Int128Equal(Int128And($Address->Address, $UpperNetmask), Int128And($this->Address, $UpperNetmask))))) $Result = true;
     129      else $Result = false;
     130    return $Result;
     131  }
    109132}
  • trunk/Packages/Common/Page.php

    r880 r888  
    33class Page extends View
    44{
    5   var $Title;
    6   var $ParentClass;
    7   var $RawPage;
    8   var $OnSystemMessage;
     5  public string $Title;
     6  public string $Description;
     7  public string $ParentClass;
     8  public bool $RawPage;
     9  public $OnSystemMessage;
     10  public string $Load;
     11  public string $Unload;
    912
    1013  function __construct(System $System)
     
    1316    $this->RawPage = false;
    1417    $this->OnSystemMessage = array();
     18    $this->Title = "";
     19    $this->Description = "";
     20    $this->ParentClass = "";
    1521  }
    1622
    17   function Show()
     23  function Show(): string
    1824  {
    1925    return '';
    2026  }
    2127
    22   function GetOutput()
     28  function GetOutput(): string
    2329  {
    2430    $Output = $this->Show();
     
    2632  }
    2733
    28   function SystemMessage($Title, $Text)
     34  function SystemMessage(string $Title, string $Text): string
    2935  {
    3036    return call_user_func_array($this->OnSystemMessage, array($Title, $Text));
  • trunk/Packages/Common/PrefixMultiplier.php

    r880 r888  
    7272class PrefixMultiplier
    7373{
    74   function TruncateDigits($Value, $Digits = 4)
     74  function TruncateDigits($Value, $Digits = 4): string
    7575  {
    7676    for ($II = 2; $II > -6; $II--)
     
    8787  }
    8888
    89   function Add($Value, $Unit, $Digits = 4, $PrefixType = 'Decimal')
     89  function Add($Value, $Unit, $Digits = 4, $PrefixType = 'Decimal'): string
    9090  {
    9191    global $PrefixMultipliers;
  • trunk/Packages/Common/RSS.php

    r880 r888  
    33class RSS
    44{
    5   var $Charset;
    6   var $Title;
    7   var $Link;
    8   var $Description;
    9   var $WebmasterEmail;
    10   var $Items;
     5  public string $Charset;
     6  public string $Title;
     7  public string $Link;
     8  public string $Description;
     9  public string $WebmasterEmail;
     10  public array $Items;
    1111
    1212  function __construct()
    1313  {
    1414    $this->Charset = 'utf8';
     15    $this->Title = '';
     16    $this->Link = '';
     17    $this->Description = '';
     18    $this->WebmasterEmail = '';
    1519    $this->Items = array();
    1620  }
    1721
    18   function Generate()
     22  function Generate(): string
    1923  {
    2024    $Result = '<?xml version="1.0" encoding="'.$this->Charset.'" ?>'."\n". //<?
  • trunk/Packages/Common/Table.php

    r880 r888  
    33class Control
    44{
    5   var $Name;
     5  public string $Name;
    66
    7   function Show()
     7  function Show(): string
    88  {
    99    return '';
     
    1313class Table
    1414{
    15   function GetCell($Y, $X)
     15  function GetCell($Y, $X): string
    1616  {
    1717    return '';
     
    2626  }
    2727
    28   function RowsCount()
     28  function RowsCount(): int
    2929  {
    3030    return 0;
     
    3434class TableMemory extends Table
    3535{
    36   var $Cells;
     36  public array $Cells;
    3737
    38   function GetCell($Y, $X)
     38  function GetCell($Y, $X): string
    3939  {
    4040    return $this->Cells[$Y][$X];
    4141  }
    4242
    43   function RowsCount()
     43  function RowsCount(): int
    4444  {
    4545    return count($this->Cells);
     
    4949class TableSQL extends Table
    5050{
    51   var $Query;
    52   var $Database;
    53   var $Cells;
     51  public string $Query;
     52  public Database $Database;
     53  public array $Cells;
    5454
    55   function GetCell($Y, $X)
     55  function GetCell($Y, $X): string
    5656  {
    5757    return $this->Cells[$Y][$X];
     
    7373  }
    7474
    75   function RowsCount()
     75  function RowsCount(): int
    7676  {
    7777    return count($this->Cells);
     
    8181class TableColumn
    8282{
    83   var $Name;
    84   var $Title;
     83  public string $Name;
     84  public string $Title;
    8585}
    8686
    8787class VisualTable extends Control
    8888{
    89   var $Cells;
    90   var $Columns;
    91   var $OrderSQL;
    92   var $OrderColumn;
    93   var $OrderDirection;
    94   var $OrderArrowImage;
    95   var $DefaultColumn;
    96   var $DefaultOrder;
    97   var $Table;
    98   var $Style;
     89  public array $Cells;
     90  public array $Columns;
     91  public string $OrderSQL;
     92  public string $OrderColumn;
     93  public int $OrderDirection;
     94  public array $OrderArrowImage;
     95  public string $DefaultColumn;
     96  public int $DefaultOrder;
     97  public TableMemory $Table;
     98  public string $Style;
    9999
    100100  function __construct()
     
    126126  }
    127127
    128   function Show()
     128  function Show(): string
    129129  {
    130130    $Output = '<table class="'.$this->Style.'">';
     
    148148  }
    149149
    150   function GetOrderHeader()
     150  function GetOrderHeader(): string
    151151  {
    152152    if (array_key_exists('OrderCol', $_GET)) $_SESSION['OrderCol'] = $_GET['OrderCol'];
  • trunk/Packages/Common/UTF8.php

    r887 r888  
    526526  }
    527527
    528   function ToUTF8($String, $Charset = 'iso2')
     528  function ToUTF8(string $String, string $Charset = 'iso2'): string
    529529  {
    530530    $Result = '';
     
    540540  }
    541541
    542   function FromUTF8($String, $Charset = 'iso2')
     542  function FromUTF8(string $String, string $Charset = 'iso2'): string
    543543  {
    544544    $Result = '';
  • trunk/Packages/Common/Update.php

    r880 r888  
    33class UpdateManager
    44{
    5   var $Revision;
    6   var $Trace;
    7   var $VersionTable;
    8   /* @var Database */
    9   var $Database;
    10   var $InstallMethod;
     5  public int $Revision;
     6  public array $Trace;
     7  public string $VersionTable;
     8  public Database $Database;
     9  public string $InstallMethod;
    1110
    1211  function __construct()
     
    1918  }
    2019
    21   function GetDbVersion()
     20  function GetDbVersion(): ?int
    2221  {
    2322    $DbResult = $this->Database->select($this->VersionTable, '*', 'Id=1');
     
    2625  }
    2726
    28   function IsInstalled()
     27  function IsInstalled(): bool
    2928  {
    3029    $DbResult = $this->Database->query('SHOW TABLES LIKE "'.$this->VersionTable.'"');
     
    3231  }
    3332
    34   function IsUpToDate()
     33  function IsUpToDate(): bool
    3534  {
    3635    return $this->Revision <= $this->GetDbVersion();
    3736  }
    3837
    39   function Upgrade()
     38  function Upgrade(): string
    4039  {
    4140    $DbRevision = $this->GetDbVersion();
     
    4342    while ($this->Revision > $DbRevision)
    4443    {
     44      if (!array_key_exists($DbRevision, $this->Trace))
     45        die('Missing upgrade trace for revision '.$DbRevision);
    4546      $TraceItem = $this->Trace[$DbRevision];
    4647      $Output .= 'Aktualizace na verzi '.$TraceItem['Revision'].':<br/>';
     
    5758  }
    5859
    59   function Install()
     60  function Install(): void
    6061  {
    6162    $InstallMethod = $this->InstallMethod;
    6263    $InstallMethod($this);
    63     $this->Update();
    6464  }
    6565
    66   function Uninstall()
     66  function Uninstall(): void
    6767  {
    68 
    6968  }
    7069
    71   function InsertSampleData()
     70  function InsertSampleData(): void
    7271  {
    7372    $InstallMethod = $this->InsertSampleDataMethod;
     
    7574  }
    7675
    77   function Execute($Query)
     76  function Execute(string $Query): DatabaseResult
    7877  {
    7978    echo($Query.';<br/>');
  • trunk/ReadMe.txt

    r881 r888  
    61618) AoWoW download
    6262
    63 Download AoWoW from repository http://wowpreklad.zdechov.net/svn/wowpreklad/aowow
     63Download AoWoW from repository https://svn.zdechov.net/wowpreklad/aowow
    6464as subdirectory to directory of wowpreklad. Process according instructions in
    6565file ReadMe.txt at the same directory.
  • trunk/alert.php

    r880 r888  
    66class PageAlert extends Page
    77{
    8   function Show()
     8  function Show(): string
    99  {
    1010    $this->RawPage = true;
  • trunk/includes/Global.php

    r880 r888  
    2222class TempPage extends Page
    2323{
    24   function Show()
     24  function Show(): string
    2525  {
    2626    global $TempPageContent;
  • trunk/includes/PageEdit.php

    r880 r888  
    1919  }
    2020
    21   function Show()
     21  function Show(): string
    2222  {
    2323    $Output = '';
     
    2626      if ($_GET['action'] == 'add') $Output .= $this->AddItem();
    2727      else if ($_GET['action'] == 'view') $Output .= $this->ViewItem();
    28       else if ($_GET['action'] == 'edit') $Output .= $this->ModifyItem();
    29       else if ($_GET['action'] == 'remove') $Output .= $this->RemoveItem();
     28      //else if ($_GET['action'] == 'edit') $Output .= $this->ModifyItem();
     29      //else if ($_GET['action'] == 'remove') $Output .= $this->RemoveItem();
    3030      else if ($_GET['action'] == 'delete') $Output .= $this->DeleteItem();
    3131      else $Output .= ShowMessage(T('Unknown action'), MESSAGE_CRITICAL);
  • trunk/locale/cs.php

    r867 r888  
    33class LocaleTextcs extends LocaleText
    44{
    5   function Load()
     5  function Load(): void
    66  {
    77    $this->Code = 'cs';
  • trunk/locale/en.php

    r843 r888  
    33class LocaleTexten extends LocaleText
    44{
    5   function Load()
     5  function Load(): void
    66  {
    77    $this->Code = 'en';
Note: See TracChangeset for help on using the changeset viewer.