Changeset 861 for trunk/Application


Ignore:
Timestamp:
Jan 21, 2016, 3:20:48 PM (9 years ago)
Author:
chronos
Message:
  • Removed: Execute flag from PHP files in repo.
  • Modified: BaseView class separated to file View.php.
  • Added: Left and Right bar items are now registered from their modules using callbacks.
Location:
trunk/Application
Files:
2 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Application/Core.php

    • Property svn:executable deleted
    r860 r861  
    320320  }
    321321}
    322 
    323 class BaseView extends View
    324 {
    325   var $Title;
    326 
    327   function ShowLocaleSelector()
    328   {
    329     //$Output .= ' <form action="?setlocale" method="get">';
    330     $Output = ' <select onchange="window.location=this.value">';
    331     foreach($this->System->LocaleManager->Available as $Locale)
    332     {
    333       $Remaining = substr($_SERVER["REQUEST_URI"], strlen($this->System->Config['Web']['BaseURL']));
    334       if(substr($Remaining, 1, strlen($Locale['Code'].'/')) == $this->System->LocaleManager->LangCode.'/')
    335         $Remaining = substr($Remaining, strlen('/'.$Locale['Code']));
    336       if($Locale['Code'] == $this->System->LocaleManager->CurrentLocale->Texts->Code) $Selected = ' selected="selected"';
    337         else $Selected = '';
    338       $Remaining = $this->System->TranslateReverseURL($Remaining, $this->System->LocaleManager->LangCode);
    339 
    340       $URL = $this->System->LinkLocale($Remaining, $Locale['Code']);
    341       $Output .= '<option title="" value="'.$URL.'"'.$Selected.' onchange="this.form.submit()">'.$Locale['Title'].'</option>';
    342     }
    343     $Output .= '</select><noscript><span><input type="submit" value="Submit"/></span></noscript>';
    344 
    345     return($Output);
    346   }
    347 
    348   function ShowTopBar()
    349   {
    350     $Output = '<div class="Menu">';
    351     if(isset($this->System->User))
    352     {
    353       if(!$this->System->User->Licence(LICENCE_USER))
    354         $Output .= '<div class="advert">'.$this->System->Config['Web']['Advertisement'].'</div>';
    355     }
    356     $Output .= '<span class="MenuItem"></span><span class="MenuItem2">';
    357 
    358     // Show bars items
    359     $Bar = '';
    360     foreach($this->System->Bars['Top'] as $BarItem)
    361       $Bar .= call_user_func($BarItem);
    362       if(trim($Bar) != '') $Output .= $Bar;
    363       else $Output .= '&nbsp;';
    364 
    365     $Output .= $this->ShowLocaleSelector();
    366     //$Output .= '</form>';
    367     $Output .= '</span></div>';
    368     return($Output);
    369   }
    370 
    371   function ShowLoginBox()
    372   {
    373     $Output = '';
    374     if($this->System->User->Licence(LICENCE_USER))
    375     {
    376       // $Output .= 'Jste přihlášen jako: <b>'.$tUser->Id.'</b> <a href="index.php?Logout">Odhlásit</a>';
    377     } else
    378     {
    379       $Output .= '<strong>'.T('Login').':</strong>
    380       <form action="" method="post">
    381       <table>
    382       <tr>
    383       <td><input type="text" name="LoginUser" size="13" /></td>
    384       </tr>
    385       <tr>
    386       <td><input type="password" name="LoginPass" size="13" /></td>
    387       </tr>
    388       <tr>
    389       <th><input type="submit" value="'.T('Do login').'" /></th>
    390       </tr>
    391       </table>
    392       </form>';
    393     }
    394     return($Output);
    395   }
    396 
    397   function ShowSearchBox()
    398   {
    399     $Output = '<strong>'.T('Search').':</strong>'.
    400       '<form action="'.$this->System->Link('/search/').'" method="get"><div>'.
    401       '<table>'.
    402       '<tr>'.
    403       '<td><input type="text" name="text" size="13" /></td>'.
    404       '</tr>'.
    405       '<tr>'.
    406       '<th><input type="submit" value="'.T('Do search').'" /></th>'.
    407       '</tr>'.
    408       '</table></div>'.
    409       '</form>';
    410     return($Output);
    411   }
    412 
    413   function ShowMainMenu()
    414   {
    415     $Output = '<strong>'.T('Menu').':</strong>'.
    416       '<div class="verticalmenu"><ul>';
    417     foreach($this->System->Menu as $MenuItem)
    418       if(!isset($this->System->User) or $this->System->User->Licence($MenuItem['Permission']))
    419       {
    420         if(isset($MenuItem['Click'])) $OnClick = ' onclick="'.$MenuItem['Click'].'"';
    421         else $OnClick = '';
    422         if($MenuItem['Icon'] != '') $Icon = '<img src="'.$this->System->Link('/images/menu/'.$MenuItem['Icon']).'"/>';
    423         else $Icon = '';
    424         $Output .= '<li>'.$Icon.'<a class="verticalmenua" title="'.$MenuItem['Hint'].'" href="'.
    425           $MenuItem['Link'].'"'.$OnClick.'>'.$MenuItem['Title'].'</a></li>';
    426       }
    427       $Output .= '</ul></div>';
    428       return($Output);
    429   }
    430 
    431   function ShowTranslatedMenu()
    432   {
    433     $TranslationTree = $this->System->ModuleManager->Modules['Translation']->GetTranslationTree();
    434 
    435     $Output = '<strong>'.T('Translate groups').':</strong><br /><div id="TranslationMenu">';
    436     $DbResult = $this->System->Database->select('Group', '`Id`, `Name`', '1 ORDER BY `Name`');
    437     while($Group = $DbResult->fetch_assoc())
    438     {
    439       $Groups[T($Group['Name'])] = $Group;
    440     }
    441     ksort($Groups);
    442     foreach($Groups as $Group)
    443     {
    444       $Output .= '<div id="menuitem-group'.$Group['Id'].'" onmouseover="show(\'group'.$Group['Id'].'\')" onmouseout="hide(\'group'.$Group['Id'].'\')">'.
    445         '<a href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].
    446         '&amp;action=filter').'">'.str_replace(' ','&nbsp;', T($Group['Name'])).'</a></div>'.
    447         '<div id="group'.$Group['Id'].'" class="hidden-menu-item" onmouseover="show(\'group'.$Group['Id'].'\')" onmouseout="hide(\'group'.$Group['Id'].'\')">';
    448       $Output .= '&nbsp;<a title="Zde můžete začít překládat" href="'.
    449         $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=1&amp;user=0&amp;entry=&amp;text=').'">'.T('Untranslated').'</a><br />'.
    450         '&nbsp;<a title="Přeložené texty, můžete zde hlasovat, nebo opravovat překlady" href="'.
    451         $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=2&amp;user=0&amp;entry=&amp;text=').'">'.T('Translated').'</a><br />';
    452       if(isset($this->System->User) and $this->System->User->Licence(LICENCE_USER))
    453       {
    454         $Output .= '&nbsp;<a title="'.T('Unfinished translations').'" href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=3').'">'.T('Unfinished').'</a><br />'.
    455           '&nbsp;<a title="Všechny překlady, které jste přeložil" href="'.
    456           $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=1&amp;user='.
    457           $this->System->User->Id).'&amp;entry=&amp;text=">'.T('Own').'</a><br />';
    458       }
    459       $Output .= '&nbsp;<a title="'.T('Compose special filter').'" href="'.
    460         $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;action=filter').
    461         '">'.T('Filter').'</a><br />';
    462       $Output .= '</div>';
    463     }
    464     $Output .= '</div>';
    465     return($Output);
    466   }
    467 
    468   function ShowHeader()
    469   {
    470     $Output = ''.
    471     '<!DOCTYPE html>'.
    472     '<html>'.
    473     '<head>'.
    474     '<meta http-equiv="content-type" content="text/html; charset='.$this->System->Config['Web']['Charset'].'" />'.
    475     '<meta name="keywords" content="'.$this->System->Config['Web']['Keywords'].'" />'.
    476     '<meta name="description" content="'.$this->System->Config['Web']['Description'].'" />'.
    477     '<meta name="robots" content="all" />'.
    478     '<link rel="stylesheet" href="'.$this->System->Link('/style/style.css').'" type="text/css" media="all" />'.
    479     '<script type="text/javascript" src="'.$this->System->Link('/style/global.js').'"></script>'.
    480     '<link rel="shortcut icon" href="'.$this->System->Link('/images/favicon.ico').'" />';
    481     $Output .= $this->System->ModuleManager->Modules['News']->ShowRSSHeader();
    482     $Title = $this->System->Config['Web']['Title'];
    483     if($this->Title != '') $Title = $this->Title.' - '.$Title;
    484     $Output .= '<title>'.$Title.'</title>'.
    485     '<script src="'.$this->System->Link('/style/respond.js').'"></script>'.
    486     '</head><body>';
    487 
    488     $Output .= $this->ShowTopBar();
    489     $Output .= '<table class="page"><tr><td class="menu">';
    490     $Output .= $this->ShowMainMenu();
    491     $Output .= $this->System->ModuleManager->Modules['User']->ShowOnlineList();
    492     $Output .= '<br />';
    493     $Output .= $this->ShowSearchBox();
    494 
    495     $Output .= '</td><td id="border-left"></td><td class="content">';
    496     return($Output);
    497   }
    498 
    499   function ShowFooter()
    500   {
    501     global $ScriptStartTime, $Revision, $ReleaseTime, $Version;
    502 
    503     $ScriptGenerateDuration = round(GetMicrotime() - $ScriptStartTime, 2);
    504 
    505     $Output = '</td>';
    506     if($this->System->ModuleManager->ModulePresent('Translation'))
    507     {
    508       $Output .= '<td class="menu2">';
    509       $Output .= $this->ShowTranslatedMenu();
    510       $Output .= '</td>';
    511     }
    512     $Output .= '</tr><tr>'.
    513       '<td colspan="4" class="page-bottom">'.T('Version').': '.$Version.' '.T('Revision').': '.$Revision.' ('.HumanDate($ReleaseTime).')'.
    514       ' &nbsp; <a href="http://svn.zdechov.net/trac/wowpreklad/browser/trunk">'.T('Source code').'</a> &nbsp; '.
    515       '<a href="http://svn.zdechov.net/trac/wowpreklad/log/trunk?verbose=on">'.T('Changelog').'</a> &nbsp; '.
    516       $this->System->Config['Web']['WebCounter'];
    517 
    518     $Output .= '</td></tr>';
    519     if($this->System->Config['Web']['ShowRuntimeInfo'] == true)
    520       $Output .= '<tr><td colspan="3" style="text-align: center;">'.T('Generating duration').': '.
    521     $ScriptGenerateDuration.' s / '.ini_get('max_execution_time').' s &nbsp;&nbsp; '.T('Used memory').': '.
    522     HumanSize(memory_get_peak_usage(FALSE)).' / '.ini_get('memory_limit').'B &nbsp;&nbsp; <a href="http://validator.w3.org/check?uri='.
    523     htmlentities('http://'.$_SERVER['HTTP_HOST'].GetRequestURI().'?'.$_SERVER['QUERY_STRING']).'">HTML validator</a></td></tr>';
    524     $Output .= '</table>'.
    525       '</body>'.
    526       '</html>';
    527     return($Output);
    528   }
    529 
    530   function ShowPage($Content)
    531   {
    532     $Output = $this->ShowHeader().$Content.$this->ShowFooter();
    533     if($this->System->Config['Web']['FormatOutput'])
    534       $Output = $this->FormatOutput($Output);
    535     return($Output);
    536   }
    537 
    538   function FormatOutput($s)
    539   {
    540     $out = '';
    541     $nn = 0;
    542     $n = 0;
    543     while($s != '')
    544     {
    545       $start = strpos($s, '<');
    546       $end = strpos($s, '>');
    547       if($start != 0)
    548       {
    549         $end = $start - 1;
    550         $start = 0;
    551       }
    552       $line = trim(substr($s, $start, $end + 1));
    553       if(strlen($line) > 0)
    554         if($line[0] == '<')
    555         {
    556           if($s[$start + 1] == '/')
    557           {
    558             $n = $n - 2;
    559             $nn = $n;
    560           } else
    561           {
    562             if(strpos($line, ' ')) $cmd = substr($line, 1, strpos($line, ' ') - 1);
    563             else $cmd = substr($line, 1, strlen($line) - 2);
    564             //echo('['.$cmd.']');
    565             if(strpos($s, '</'.$cmd.'>')) $n = $n + 2;
    566           }
    567         }// else $line = '['.$line.']';
    568         //if($line != '') echo(htmlspecialchars(str_repeat(' ',$nn).$line."\n"));
    569         if($nn < 0) $nn = 0;
    570         if($line != '') $out .= (str_repeat(' ', $nn).$line."\n");
    571         $s = substr($s, $end + 1, strlen($s));
    572         $nn = $n;
    573     }
    574     return($out);
    575   }
    576 }
  • trunk/Application/DefaultConfig.php

    • Property svn:executable deleted
  • trunk/Application/Version.php

    r859 r861  
    77
    88$Version = '1.0-alfa';
    9 $Revision = 859; // Subversion revision
     9$Revision = 861; // Subversion revision
    1010$DatabaseRevision = 857; // Database structure revision
    1111$ReleaseTime = '2016-01-21';
Note: See TracChangeset for help on using the changeset viewer.