Changeset 860 for trunk/includes


Ignore:
Timestamp:
Jan 21, 2016, 2:49:19 PM (9 years ago)
Author:
chronos
Message:
  • Modified: Now application modules are started according configuration file.
  • Added: Each module which want to show something in main page bars needs to register its callback.
Location:
trunk/includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/Global.php

    r859 r860  
    99include_once(dirname(__FILE__).'/../Application/Version.php');
    1010require_once(dirname(__FILE__).'/../HTML/BBCodeParser2.php');
    11 
    12 // Include application modules
    13 // TODO: Make modules configurable
    14 include_once(dirname(__FILE__).'/../Modules/Error/Error.php');
    15 include_once(dirname(__FILE__).'/../Modules/Log/Log.php');
    16 include_once(dirname(__FILE__).'/../Modules/Translation/Translation.php');
    17 include_once(dirname(__FILE__).'/../Modules/AoWoW/AoWoW.php');
    18 include_once(dirname(__FILE__).'/../Modules/Referrer/Referrer.php');
    19 include_once(dirname(__FILE__).'/../Modules/Team/Team.php');
    20 include_once(dirname(__FILE__).'/../Modules/User/User.php');
    21 include_once(dirname(__FILE__).'/../Modules/Dictionary/Dictionary.php');
    22 include_once(dirname(__FILE__).'/../Modules/Import/Import.php');
    23 include_once(dirname(__FILE__).'/../Modules/Export/Export.php');
    24 include_once(dirname(__FILE__).'/../Modules/Server/Server.php');
    25 include_once(dirname(__FILE__).'/../Modules/ClientVersion/ClientVersion.php');
    26 include_once(dirname(__FILE__).'/../Modules/ShoutBox/ShoutBox.php');
    27 include_once(dirname(__FILE__).'/../Modules/News/News.php');
    28 include_once(dirname(__FILE__).'/../Modules/Wiki/Wiki.php');
    29 include_once(dirname(__FILE__).'/../Modules/Search/Search.php');
    30 include_once(dirname(__FILE__).'/../Modules/FrontPage/FrontPage.php');
    31 include_once(dirname(__FILE__).'/../Modules/Download/Download.php');
    32 include_once(dirname(__FILE__).'/../Modules/Forum/Forum.php');
    33 include_once(dirname(__FILE__).'/../Modules/Redirection/Redirection.php');
    34 include_once(dirname(__FILE__).'/../Modules/Admin/Admin.php');
    35 include_once(dirname(__FILE__).'/../Modules/Info/Info.php');
    36 
    3711
    3812// Back compatibility, will be removed
  • trunk/includes/System.php

    r859 r860  
    1111  /* @var LocaleManager */
    1212  var $LocaleManager;
     13  var $Bars;
    1314
    1415  function __construct()
     
    2122    $this->OnPageNotFound = array();
    2223    $this->Pages = array();
     24    $this->Bars = array();
    2325  }
    2426
     
    2830
    2931    $this->Config = $Config;
    30     date_default_timezone_set($this->Config['Web']['Timezone']);
     32    if(isset($this->Config['Web']['Timezone']))
     33      date_default_timezone_set($this->Config['Web']['Timezone']);
    3134    mb_internal_encoding("UTF-8");
    3235
     
    7881       'Icon' => '',
    7982      ),
    80     */
     83
    8184      array(
    8285        'Title' => T('IRC chat'),
     
    8689        'Icon' => '',
    8790      ),
     91      */
    8892    );
    8993  }
     
    106110    foreach($_GET as $Index => $Item) $_GET[$Index] = addslashes($_GET[$Index]);
    107111
     112    $this->RegisterPageBar('Top');
     113    $this->RegisterPageBar('Left');
     114    $this->RegisterPageBar('Right');
    108115    $this->Init();
    109116
     
    116123      $this->ModuleManager->Start();
    117124    }
    118 
    119     // Initialize application modules
    120     $this->ModuleManager->RegisterModule(new ModuleError($this));
    121     $this->ModuleManager->Modules['Error']->ErrorHandler->ShowError = $this->Config['Web']['ShowPHPError'];
    122     $this->ModuleManager->RegisterModule(new ModuleLog($this));
    123     $this->ModuleManager->RegisterModule(new ModuleUser($this));
    124     $this->ModuleManager->RegisterModule(new ModuleAoWoW($this));
    125     $this->ModuleManager->RegisterModule(new ModuleReferrer($this));
    126     $this->ModuleManager->Modules['Referrer']->Excludes[] = $this->Config['Web']['Host'];
    127     $this->ModuleManager->RegisterModule(new ModuleTeam($this));
    128     $this->ModuleManager->RegisterModule(new ModuleDictionary($this));
    129     $this->ModuleManager->RegisterModule(new ModuleTranslation($this));
    130     $this->ModuleManager->RegisterModule(new ModuleImport($this));
    131     $this->ModuleManager->RegisterModule(new ModuleExport($this));
    132     $this->ModuleManager->RegisterModule(new ModuleServer($this));
    133     $this->ModuleManager->RegisterModule(new ModuleClientVersion($this));
    134     $this->ModuleManager->RegisterModule(new ModuleShoutBox($this));
    135     $this->ModuleManager->RegisterModule(new ModuleNews($this));
    136     $this->ModuleManager->RegisterModule(new ModuleWiki($this));
    137     $this->ModuleManager->RegisterModule(new ModuleSearch($this));
    138     $this->ModuleManager->RegisterModule(new ModuleFrontPage($this));
    139     $this->ModuleManager->RegisterModule(new ModuleDownload($this));
    140     $this->ModuleManager->RegisterModule(new ModuleForum($this));
    141     $this->ModuleManager->RegisterModule(new ModuleRedirection($this));
    142     $this->ModuleManager->RegisterModule(new ModuleAdmin($this));
    143     $this->ModuleManager->RegisterModule(new ModuleInfo($this));
    144     $this->ModuleManager->FileName = dirname(__FILE__).'/../Config/ModulesConfig.php';
    145     // TODO: Allow control from web which modules should be installed
    146     $this->ModuleManager->InstallAll();
    147     $this->ModuleManager->StartAll();
    148125
    149126    $this->BaseView = new BaseView($this);
     
    327304    echo($Output);
    328305  }
     306
     307  function RegisterPageBar($Name)
     308  {
     309    $this->Bars[$Name] = array();
     310  }
     311
     312  function UnregisterPageBar($Name)
     313  {
     314    unset($this->Bars[$Name]);
     315  }
     316
     317  function RegisterPageBarItem($BarName, $ItemName, $Callback)
     318  {
     319    $this->Bars[$BarName][$ItemName] = $Callback;
     320  }
    329321}
    330322
     
    357349  {
    358350    $Output = '<div class="Menu">';
    359     if(!$this->System->User->Licence(LICENCE_USER))
    360       $Output .= '<div class="advert">'.$this->System->Config['Web']['Advertisement'].'</div>';
     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    }
    361356    $Output .= '<span class="MenuItem"></span><span class="MenuItem2">';
    362     if($this->System->User->Licence(LICENCE_USER))
    363     {
    364       //$DbResult =$this->Database->query('SELECT `Id`, `Name` FROM `Team` WHERE `Id`='.$this->System->User->Team);
    365       //$Team = $DbResult->fetch_assoc();
    366       //$Output .= ''<span class="MenuItem">Moje překlady: <a href="">Dokončené</a> <a href="">Rozpracované</a> <a href="">Exporty</a> Tým: <a href="">'.$Team['name'].'</a></span>';
    367       $Output .= $this->System->User->Name.' <a href="'.$this->System->Link('/?action=logout').'">'.T('Logout').'</a>'.
    368           ' <a href="'.$this->System->Link('/user/?user='.$this->System->User->Id).'">'.T('My page').'</a>'.
    369           ' <a href="'.$this->System->Link('/options/').'">'.T('Options').'</a>'.
    370           ' <a title="Vámi přeložené texty" href="'.$this->System->Link('/TranslationList.php?user='.
    371           $this->System->User->Id.'&amp;group=0&amp;state=2&amp;text=&amp;entry=').'">'.T('Translated').'</a>'.
    372           ' <a title="Vaše rozpracované text" href="'.$this->System->Link('/TranslationList.php?user='.
    373           $this->System->User->Id.'&amp;group=0&amp;state=3&amp;text=&amp;entry=').'">'.T('Unfinished').'</a>'.
    374           ' <a title="Nikým nepřeložené texty" href="'.
    375           $this->System->Link('/TranslationList.php?user=0&amp;group=0&amp;state=1&amp;text=&amp;entry=').'">'.T('Untranslated').'</a>';
    376     } else
    377     {
    378       $Output .= '<a href="'.$this->System->Link('/login/').'">'.T('Login').'</a>&nbsp;'.
    379         '<a href="'.$this->System->Link('/registration/').'">'.T('Registration').'</a>';
    380     }
     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
    381365    $Output .= $this->ShowLocaleSelector();
    382366    //$Output .= '</form>';
     
    432416      '<div class="verticalmenu"><ul>';
    433417    foreach($this->System->Menu as $MenuItem)
    434       if($this->System->User->Licence($MenuItem['Permission']))
     418      if(!isset($this->System->User) or $this->System->User->Licence($MenuItem['Permission']))
    435419      {
    436420        if(isset($MenuItem['Click'])) $OnClick = ' onclick="'.$MenuItem['Click'].'"';
     
    466450        '&nbsp;<a title="Přeložené texty, můžete zde hlasovat, nebo opravovat překlady" href="'.
    467451        $this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=2&amp;user=0&amp;entry=&amp;text=').'">'.T('Translated').'</a><br />';
    468       if($this->System->User->Licence(LICENCE_USER))
     452      if(isset($this->System->User) and $this->System->User->Licence(LICENCE_USER))
    469453      {
    470454        $Output .= '&nbsp;<a title="'.T('Unfinished translations').'" href="'.$this->System->Link('/TranslationList.php?group='.$Group['Id'].'&amp;state=3').'">'.T('Unfinished').'</a><br />'.
Note: See TracChangeset for help on using the changeset viewer.