Changeset 635


Ignore:
Timestamp:
Jan 19, 2014, 9:36:28 PM (10 years ago)
Author:
chronos
Message:
  • Upraveno: Jednotka UTF8 přepracována na třídu. Převodní tabulka se takto bude inicializovat pouze pokud bude skutečně vytvořena instance třídy.
  • Přidáno: V jednotce Table implementována tabulka jako obecná třída.
  • Upraveno: Stránkování ve výpisech implementováno jako samostatná třída.
  • Upraveno: Titulek stránky s názvem stránky není třeba zobrazovat jelikož název stránky se zobrazuje v titulku prohlížeče.
Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r634 r635  
    11<?php
    22
    3 $Revision = 634; // Subversion revision
     3$Revision = 635; // Subversion revision
    44$DatabaseRevision = 633; // SQL structure revision
    55$ReleaseTime = strtotime('2014-01-19');
  • trunk/Common/Global.php

    r627 r635  
    1313include_once(dirname(__FILE__).'/Mail.php');
    1414include_once(dirname(__FILE__).'/Page.php');
     15include_once(dirname(__FILE__).'/Table.php');
    1516include_once(dirname(__FILE__).'/Form/Form.php');
    1617include_once(dirname(__FILE__).'/Config.php');
     
    136137}
    137138
     139class Pageing
     140{
     141        var $TotalCount;
     142        var $ItemPerPage;
     143        var $Around;
     144       
     145        function __construct()
     146        {
     147                global $System;
     148               
     149                $this->ItemPerPage = 5; //$System->Config['Web']['ItemsPerPage'];
     150                $this->Around = $System->Config['Web']['VisiblePagingItems'];
     151        }
     152       
     153  function Show()
     154  {
     155    $QueryItems = GetQueryStringArray($_SERVER['QUERY_STRING']);
     156 
     157    $Result = '';
     158    if(array_key_exists('all', $QueryItems))
     159    {
     160      $PageCount = 1;
     161      $ItemPerPage = $this->TotalCount;   
     162    } else
     163    {
     164      $ItemPerPage = $this->ItemPerPage;
     165      $Around = round($this->Around / 2);
     166      $PageCount = floor($this->TotalCount / $ItemPerPage) + 1;
     167    }
     168 
     169    if(!array_key_exists('Page', $_SESSION)) $_SESSION['Page'] = 0;
     170    if(array_key_exists('page', $_GET)) $_SESSION['Page'] = $_GET['page'] * 1;
     171    if($_SESSION['Page'] < 0) $_SESSION['Page'] = 0;
     172    if($_SESSION['Page'] >= $PageCount) $_SESSION['Page'] = $PageCount - 1;
     173    $CurrentPage = $_SESSION['Page']; 
     174       
     175    $Result .= 'Počet položek: <strong>'.$this->TotalCount.'</strong> &nbsp; Stránky: ';
     176 
     177    $Result = '';
     178    if($PageCount > 1)
     179    {
     180      if($CurrentPage > 0)
     181      {
     182        $QueryItems['page'] = 0;     
     183        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;&lt;</a> ';
     184        $QueryItems['page'] = ($CurrentPage - 1);
     185        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&lt;</a> ';
     186      }
     187      $PagesMax = $PageCount - 1;
     188      $PagesMin = 0;
     189      if($PagesMax > ($CurrentPage + $Around)) $PagesMax = $CurrentPage + $Around;
     190      if($PagesMin < ($CurrentPage - $Around))
     191      {
     192        $Result.= ' ... ';
     193        $PagesMin = $CurrentPage - $Around;
     194      }
     195      for($i = $PagesMin; $i <= $PagesMax; $i++)
     196      {
     197        if($i == $CurrentPage) $Result.= '<strong>'.($i + 1).'</strong> ';
     198        else {
     199         $QueryItems['page'] = $i;
     200         $Result .= '<a href="?'.SetQueryStringArray($QueryItems).'">'.($i + 1).'</a> ';
     201        }
     202      }
     203      if($PagesMax < ($PageCount - 1)) $Result .= ' ... ';
     204      if($CurrentPage < ($PageCount - 1))
     205      {
     206        $QueryItems['page'] = ($CurrentPage + 1);
     207        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&gt;</a> ';
     208        $QueryItems['page'] = ($PageCount - 1);
     209        $Result.= '<a href="?'.SetQueryStringArray($QueryItems).'">&gt;&gt;</a>';
     210      }
     211    }
     212    $QueryItems['all'] = '1';
     213    if($PageCount > 1) $Result.= ' <a href="?'.SetQueryStringArray($QueryItems).'">Vše</a>';
     214 
     215    $Result = '<div style="text-align: center">'.$Result.'</div>';
     216    $this->SQLLimit = ' LIMIT '.$CurrentPage * $ItemPerPage.', '.$ItemPerPage;
     217    $this->Page = $CurrentPage;
     218    return($Result);
     219  }
     220}
     221
    138222function GetPageList($TotalCount)
    139223{
  • trunk/Common/Page.php

    r634 r635  
    8585    if($this->BasicHTML == false)
    8686    {
    87       $Output .= '<div class="MainTitle">'.$Title.'</div>
    88       <div class="Navigation"><span class="MenuItem"><strong>Navigace :: </strong> '.$Navigation.'</span><div class="MenuItem2">';
     87      //$Output .= '<div class="MainTitle">'.$Title.'</div>';
     88      $Output .= '<div class="MainTitle"><span class="MenuItem"><strong>Navigace :: </strong> '.$Navigation.'</span><div class="MenuItem2">';
    8989        foreach($this->System->Bars['Top'] as $BarItem)
    9090        $Output .= call_user_func($BarItem);
  • trunk/Common/Setup/Setup.php

    r619 r635  
    207207   
    208208    $Output = '';
    209     $PageList = GetPageList(count($this->System->ModuleManager->Modules));
    210  
    211     $Output .= $PageList['Output'];
    212     $Output .= '<table class="WideTable" style="font-size: small;">';
    213      
    214     $TableColumns = array(
    215         array('Name' => 'Name', 'Title' => 'Jméno'),
    216         array('Name' => 'Creator', 'Title' => 'Tvůrce'),
    217         array('Name' => 'Version', 'Title' => 'Verze'),
    218         array('Name' => 'License', 'Title' => 'Licence'),
    219         array('Name' => 'Installed', 'Title' => 'Instalováno'),
    220         array('Name' => 'Enabled', 'Title' => 'Povoleno'),
    221         array('Name' => 'Description', 'Title' => 'Popis'),
    222         array('Name' => 'Dependencies', 'Title' => 'Závislosti'),
    223         array('Name' => '', 'Title' => 'Akce'),
    224     );
    225     $Order = GetOrderTableHeader($TableColumns, 'Name', 0);
    226     $Output .= $Order['Output'];
    227  
     209   
     210    $Pageing = new Pageing();
     211    $Pageing->TotalCount = count($this->System->ModuleManager->Modules);
     212    $Table = new Table();   
     213    $Table->SetColumns(array(
     214      array('Name' => 'Name', 'Title' => 'Jméno'),
     215      array('Name' => 'Creator', 'Title' => 'Tvůrce'),
     216      array('Name' => 'Version', 'Title' => 'Verze'),
     217      array('Name' => 'License', 'Title' => 'Licence'),
     218      array('Name' => 'Installed', 'Title' => 'Instalováno'),
     219      array('Name' => 'Enabled', 'Title' => 'Povoleno'),
     220      array('Name' => 'Description', 'Title' => 'Popis'),
     221      array('Name' => 'Dependencies', 'Title' => 'Závislosti'),
     222      array('Name' => '', 'Title' => 'Akce'),
     223    ));
    228224    foreach($this->System->ModuleManager->Modules as $Module)
    229225    {
     
    239235      } else $Actions .= ' <a href="?action=modules&amp;op=install&amp;name='.$Module->Name.'">Instalovat</a>';
    240236   
    241       $Output .= '<tr><td>'.$Module->Name.'</td>'.
    242           '<td>'.$Module->Creator.'</td>'.
    243           '<td>'.$Module->Version.'</td>'.
    244           '<td>'.$Module->License.'</td>'.
    245           '<td>'.$YesNo[$Module->Installed].'</td>'.
    246           '<td>'.$YesNo[$Module->Enabled].'</td>'.
    247           '<td>'.$Module->Description.'</td>'.
    248           '<td>'.$Dependencies.'</td>'.
    249           '<td>'.$Actions.'</td></tr>';
    250     }
    251     $Output .= '</table>';
    252     $Output .= $PageList['Output'];
     237      $Table->Cells[] = array($Module->Name,
     238        $Module->Creator, $Module->Version,
     239        $Module->License, $YesNo[$Module->Installed],
     240        $YesNo[$Module->Enabled], $Module->Description,
     241        $Dependencies, $Actions);
     242    }
     243    $Output .= $Pageing->Show();
     244    $Output .= $Table->Show();
     245    $Output .= $Pageing->Show();   
    253246    //$Output .= '<p><a href="?A=SaveToDb">Uložit do databáze</a></p>';
    254247    return($Output);
  • trunk/Common/UTF8.php

    r548 r635  
    3131*/
    3232
    33 $CharTable = array(
     33class Encoding
     34{
     35  function __construct()
     36  {
     37        $this->CharTable = array(
    3438  'iso2' => array(
    3539        0x80=>"\xc2\x80",
     
    520524  ),
    521525);
    522 
    523 
    524 function ToUTF8($String, $Charset = 'iso2')
    525 {
    526   global $CharTable;
    527 
    528   $Result = '';
    529   for($I = 0; $I < strlen($String); $I++)
     526  }
     527
     528  function ToUTF8($String, $Charset = 'iso2')
    530529  {
    531      if(ord($String[$I]) < 128) $Result .= $String[$I];
    532      else if(ord($String[$I]) > 127)
    533      {
    534        $Result .= $CharTable[$Charset][ord($String[$I])];
    535      }
     530    $Result = '';
     531    for($I = 0; $I < strlen($String); $I++)
     532    {
     533       if(ord($String[$I]) < 128) $Result .= $String[$I];
     534       else if(ord($String[$I]) > 127)
     535       {
     536         $Result .= $this->CharTable[$Charset][ord($String[$I])];
     537       }
     538    }
     539    return($Result);
    536540  }
    537   return($Result);
     541
     542  function FromUTF8($String, $Charset = 'iso2')
     543  {
     544    $Result = '';
     545    $UTFPrefix = '';
     546    for($I = 0; $I < strlen($String); $I++)
     547    {
     548      if(ord($String{$I}) & 0x80) // UTF control character
     549      {
     550        if(ord($String{$I}) & 0x40) // First
     551        {
     552          if($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
     553          $UTFPrefix = $String{$I};
     554        }
     555        else $UTFPrefix .= $String{$I}; // Next
     556      } else
     557      {
     558        if($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $this->CharTable[$Charset]));
     559        $UTFPrefix = '';
     560        $Result .= $String{$I};
     561      }
     562    }
     563    return($Result);
     564  }
    538565}
    539 
    540 function FromUTF8($String, $Charset = 'iso2')
    541 {
    542   global $CharTable;
    543 
    544   $Result = '';
    545   $UTFPrefix = '';
    546   for($I = 0; $I < strlen($String); $I++)
    547   {
    548     if(ord($String{$I}) & 0x80) // UTF control character
    549     {
    550       if(ord($String{$I}) & 0x40) // First
    551       {
    552        if($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $CharTable[$Charset]));
    553         $UTFPrefix = $String{$I};
    554       }
    555       else $UTFPrefix .= $String{$I}; // Next
    556     } else
    557     {
    558       if($UTFPrefix != '') $Result .= chr(array_search($UTFPrefix, $CharTable[$Charset]));
    559       $UTFPrefix = '';
    560       $Result .= $String{$I};
    561     }
    562   }
    563   return($Result);
    564 }
  • trunk/Modules/Finance/Bill.php

    r627 r635  
    2020  function HtmlToPdf($HtmlCode)
    2121  {
    22     $Output = shell_exec('echo "'.addslashes(FromUTF8($HtmlCode)).
     22        $Encoding = new Encoding();
     23    $Output = shell_exec('echo "'.addslashes($Encoding->FromUTF8($HtmlCode)).
    2324      '"|htmldoc --no-numbered --webpage --no-embedfonts --charset 8859-2 -t pdf -');
    2425    return($Output);
  • trunk/Modules/News/ImportObecHovezi.php

    r622 r635  
    4141
    4242/*
    43 //$Content = addslashes(ToUTF8(file_get_contents($SourceURL), 'win1250'));
     43//$Encoding = new Encoding();
     44//$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250'));
    4445$Content = file_get_contents($SourceURL);
    4546while(strpos($Content, $StartText) !== false)
  • trunk/Modules/News/ImportTvBeskyd.php

    r622 r635  
    1414$Author = 'Automat';
    1515
    16 //$Content = addslashes(ToUTF8(file_get_contents($SourceURL), 'win1250'));
     16//$Encoding = new Encoding();
     17//$Content = addslashes($Encoding->ToUTF8(file_get_contents($SourceURL), 'win1250'));
    1718$Content = file_get_contents($SourceURL);
    1819while(strpos($Content, $StartText) !== false)
Note: See TracChangeset for help on using the changeset viewer.