Ignore:
Timestamp:
Apr 7, 2020, 10:15:48 PM (4 years ago)
Author:
chronos
Message:
  • Modified: Improved code formatting.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Wiki/Wiki.php

    r843 r880  
    2222  {
    2323    $DbResult = $this->Database->select('WikiPage', '*', '`VisibleInMenu`=1');
    24     while($DbRow = $DbResult->fetch_assoc())
     24    while ($DbRow = $DbResult->fetch_assoc())
    2525    {
    2626      $this->System->RegisterPage($DbRow['NormalizedName'], 'PageWiki');
     
    4040  function Show()
    4141  {
    42     if(array_key_exists('Action', $_GET))
    43     {
    44       if($_GET['Action'] == 'Edit') $Output = $this->EditContent();
    45       else if($_GET['Action'] == 'EditSave') $Output = $this->SaveContent();
    46       else if($_GET['Action'] == 'History') $Output = $this->ShowHistory();
     42    if (array_key_exists('Action', $_GET))
     43    {
     44      if ($_GET['Action'] == 'Edit') $Output = $this->EditContent();
     45      else if ($_GET['Action'] == 'EditSave') $Output = $this->SaveContent();
     46      else if ($_GET['Action'] == 'History') $Output = $this->ShowHistory();
    4747      else $Output = $this->ShowContent();
    4848    } else $Output = $this->ShowContent();
    49     return($Output);
     49    return $Output;
    5050  }
    5151
     
    5454    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
    5555    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    56     if($DbResult->num_rows > 0)
     56    if ($DbResult->num_rows > 0)
    5757    {
    5858      $DbRow = $DbResult->fetch_assoc();
    59       if(array_key_exists('ver', $_GET))
     59      if (array_key_exists('ver', $_GET))
    6060      {
    6161        $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' AND Id='.$_GET['ver']*1);
    62         if($DbResult2->num_rows > 0)
     62        if ($DbResult2->num_rows > 0)
    6363        {
    6464          $DbRow2 = $DbResult2->fetch_assoc();
    6565          $Output = '<h3>Archív stránky '.$DbRow['Name'].' ('.HumanDateTime($DbRow2['Time']).')</h3>';
    6666          $Output .= $DbRow2['Content'];
    67           if($this->System->User->Licence(LICENCE_MODERATOR))
     67          if ($this->System->User->Licence(LICENCE_MODERATOR))
    6868            $Output .= '<div><a href="?Action=Edit">Upravit nejnovější</a> <a href="?Action=History">Historie</a></div>';
    6969        } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
     
    7171      {
    7272        $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1');
    73         if($DbResult2->num_rows > 0)
     73        if ($DbResult2->num_rows > 0)
    7474        {
    7575          $DbRow2 = $DbResult2->fetch_assoc();
    7676          $Output = '<h3>'.$DbRow['Name'].'</h3>';
    7777          $Output .= $DbRow2['Content'];
    78           if($this->System->User->Licence(LICENCE_MODERATOR))
     78          if ($this->System->User->Licence(LICENCE_MODERATOR))
    7979            $Output .= '<hr><div><a href="?Action=Edit">Upravit</a> <a href="?Action=History">Historie</a></div>';
    8080        } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    8181      }
    8282    } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    83     return($Output);
     83    return $Output;
    8484  }
    8585
    8686  function EditContent()
    8787  {
    88     if($this->System->User->Licence(LICENCE_MODERATOR))
     88    if ($this->System->User->Licence(LICENCE_MODERATOR))
    8989    {
    9090    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
    9191    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    92     if($DbResult->num_rows > 0)
     92    if ($DbResult->num_rows > 0)
    9393    {
    9494      $DbRow = $DbResult->fetch_assoc();
    9595      $Output = '<h3>Úprava '.$DbRow['Name'].'</h3>';
    9696      $DbResult2 = $this->Database->select('WikiPageContent', '*', 'Page='.$DbRow['Id'].' ORDER BY Time DESC LIMIT 1');
    97       if($DbResult2->num_rows > 0)
     97      if ($DbResult2->num_rows > 0)
    9898      {
    9999        $DbRow2 = $DbResult2->fetch_assoc();
     
    106106    } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    107107    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    108     return($Output);
     108    return $Output;
    109109  }
    110110
    111111  function SaveContent()
    112112  {
    113     if($this->System->User->Licence(LICENCE_MODERATOR))
     113    if ($this->System->User->Licence(LICENCE_MODERATOR))
    114114    {
    115115    $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
    116116    $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    117     if($DbResult->num_rows > 0)
     117    if ($DbResult->num_rows > 0)
    118118    {
    119119      $DbRow = $DbResult->fetch_assoc();
    120       if(array_key_exists('content', $_POST) and array_key_exists('save', $_POST))
     120      if (array_key_exists('content', $_POST) and array_key_exists('save', $_POST))
    121121      {
    122122        $DbResult2 = $this->Database->insert('WikiPageContent', array('Content' => stripslashes($_POST['content']),
     
    127127    } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    128128    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    129     return($Output);
     129    return $Output;
    130130  }
    131131
    132132  function ShowHistory()
    133133  {
    134     if($this->System->User->Licence(LICENCE_MODERATOR))
     134    if ($this->System->User->Licence(LICENCE_MODERATOR))
    135135    {
    136136      $PageName = $this->System->PathItems[count($this->System->PathItems) - 1];
    137137      $DbResult = $this->Database->select('WikiPage', 'Name, Id', 'NormalizedName="'.$PageName.'"');
    138       if($DbResult->num_rows > 0)
     138      if ($DbResult->num_rows > 0)
    139139      {
    140140        $DbRow = $DbResult->fetch_assoc();
     
    160160          ' FROM `WikiPageContent` WHERE Page='.
    161161          $DbRow['Id'].' '.$Order['SQL'].$PageList['SQLLimit']);
    162         while($PageContent = $DbResult2->fetch_assoc())
     162        while ($PageContent = $DbResult2->fetch_assoc())
    163163        {
    164164          $Output .= '<tr>'.
     
    173173      } else $Output = ShowMessage('Wiki stránka nenalezena', MESSAGE_CRITICAL);
    174174    } else $Output = ShowMessage(T('Access denied'), MESSAGE_CRITICAL);
    175     return($Output);
     175    return $Output;
    176176  }
    177177
     
    200200    $text = str_replace("\r\n", '<br/>', $text);
    201201    $text = '<p>'.$text.'</p>';
    202     return($text);
     202    return $text;
    203203  }
    204204}
Note: See TracChangeset for help on using the changeset viewer.