Changeset 577 for trunk/action.php


Ignore:
Timestamp:
Sep 11, 2013, 10:37:54 PM (11 years ago)
Author:
chronos
Message:
  • Modified: Moved some code from global to system file. System class is now serving as main application class. Now old files which still use ShowPage function need system initialization with $InitSystem = true; before global.php inclusion.
  • Modified: Get rid of some global reference to $System, $Config and $User variables.
  • Modified: Search result functionality moved to application module from action.php file.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/action.php

    r569 r577  
    11<?php
    22
     3$InitSystem = true;
    34include_once('includes/global.php');
    4 
    5 function Search()
    6 {
    7   global $System, $TranslationTree, $Config;
    8  
    9   if(array_key_exists('search', $_GET)) $Search = $_GET['search'];
    10   else if(array_key_exists('search', $_POST)) $Search = $_POST['search'];
    11   else $Search = '';
    12 
    13   $Output = '<table class="BaseTable"><tr><th>Skupina</th><th>Výsledků</th></tr>';
    14   foreach($TranslationTree as $Group)
    15   {
    16     $Table = $Group['TablePrefix'];
    17  
    18     $sql = 'SELECT COUNT(*) FROM `'.$Table.'` WHERE '.
    19     ' (`ID` LIKE "%'.$Search.'%")'.
    20     ' OR (`Entry` LIKE "%'.$Search.'%")';
    21     foreach($Group['Items'] as $Item)
    22     {
    23       if($Item['Column'] != '') $sql .= ' OR `'.$Item['Column'].'` LIKE "%'.$Search.'%"';
    24     }
    25     $DbResult = $System->Database->query($sql);
    26     $Line = $DbResult->fetch_row();
    27     $Output .= '<tr><td><a href="TranslationList.php?group='.$Group['Id'].'&amp;user=0&amp;state=0&amp;text='.$Search.'&amp;entry=">'.$Group['Name'].'</a></td><td>'.$Line[0].'</td></tr>';
    28   }
    29  
    30   $DbResult = $System->Database->query('SELECT count(*) FROM `User` WHERE `Name` LIKE "%'.$Search.'%"');
    31   $Line = $DbResult->fetch_row();
    32   $Output .= '<tr><td><a href="userlist.php?search='.$Search.'">Uživatelé</a></td><td>'.$Line[0].'</td></tr>';
    33  
    34   $DbResult = $System->Database->query('SELECT count(*) FROM `Team` WHERE `Name` LIKE "%'.$Search.'%" OR `Description` LIKE "%'.$Search.'%"');
    35   $Line = $DbResult->fetch_row();
    36   $Output .= '<tr><td><a href="team/?search='.$Search.'">Týmy</a></td><td>'.$Line[0].'</td></tr>';
    37  
    38   $DbResult = $System->Database->query('SELECT count(*) FROM `CzWoWPackageVersion` WHERE `Text` LIKE "%'.$Search.'%"');
    39   $Line = $DbResult->fetch_row();
    40   $Output .= '<tr><td><a href="download.php?addon">Čeština pro klienta</a></td><td>'.$Line[0].'</td></tr>';
    41   $Output .= '<tr><td><a href="aowow/?search='.$Search.'">Vyhledávací databáze AoWoW</a></td></tr>';
    42  
    43   $DbResult = $System->Database->query('SELECT count(*) FROM `Dictionary` WHERE (`Text` LIKE "%'.$Search.'%" OR `Description` LIKE "%'.$Search.'%") AND `Language` = '.$Config['OriginalLanguage']);
    44   $Line = $DbResult->fetch_row();
    45   $Output .= '<tr><td><a href="dictionary/?search='.$Search.'">Slovníček</a></td><td>'.$Line[0].'</td></tr>';
    46  
    47   $Output .= '</table>';
    48   return($Output);
    49 }
    505
    516function DatabaseKit()
     
    190145if(array_key_exists('action', $_GET)) $Action = $_GET['action'];
    191146
    192 if($Action == 'search') $Output = Search();
    193147else if($Action == 'dbkit') $Output = DatabaseKit();
    194148else $Output = ShowMessage('Nebyla zadána žádná akce.', MESSAGE_CRITICAL);
Note: See TracChangeset for help on using the changeset viewer.