source: trunk/Modules/Translation/Translation.php@ 816

Last change on this file since 816 was 816, checked in by chronos, 10 years ago
  • Modified: Tabs converted to spaces.
  • Modified: Remove spaces from end of lines.
  • Added: Code format script.
File size: 3.3 KB
Line 
1<?php
2
3include_once(dirname(__FILE__).'/Comparison.php');
4include_once(dirname(__FILE__).'/Form.php');
5include_once(dirname(__FILE__).'/Save.php');
6include_once(dirname(__FILE__).'/TranslationList.php');
7include_once(dirname(__FILE__).'/Progress.php');
8include_once(dirname(__FILE__).'/LoadNames.php');
9
10class ModuleTranslation extends AppModule
11{
12 function __construct($System)
13 {
14 parent::__construct($System);
15 $this->Name = 'Translation';
16 $this->Version = '1.0';
17 $this->Creator = 'Chronos';
18 $this->License = 'GNU/GPL';
19 $this->Description = 'Translation of text items and groups from original language to other languages.';
20 $this->Dependencies = array('News');
21 }
22
23 function Start()
24 {
25 global $TranslationTree;
26
27 $this->System->RegisterPage('comparison.php', 'PageTranslationComparison');
28 $this->System->RegisterPage('form.php', 'PageTranslationForm');
29 $this->System->RegisterPage('save.php', 'PageTranslationSave');
30 $this->System->RegisterPage('progress', 'PageProgress');
31 $this->System->RegisterPage('TranslationList.php', 'PageTranslationList');
32 $this->System->RegisterPage('LoadNames.php', 'PageLoadNames');
33 $this->System->ModuleManager->Modules['News']->RegisterRSS(array('Title' => T('Last translations'),
34 'Channel' => 'translation', 'Callback' => array($this, 'ShowRSS'), 'Permission' => LICENCE_ANONYMOUS));
35 $this->System->RegisterMenuItem(array(
36 'Title' => T('Completion status'),
37 'Hint' => 'Stav dokončení překládů',
38 'Link' => $this->System->Link('/progress/'),
39 'Permission' => LICENCE_ANONYMOUS,
40 'Icon' => '',
41 ), 1);
42 if(array_key_exists('Search', $this->System->ModuleManager->Modules))
43 {
44 foreach($TranslationTree as $Group)
45 {
46 $Table = $Group['TablePrefix'];
47
48 $Columns = array('ID', 'Entry');
49 foreach($Group['Items'] as $Item)
50 {
51 if($Item['Column'] != '') $Columns[] = $Item['Column'];
52 }
53
54 $this->System->ModuleManager->Modules['Search']->RegisterSearch('group'.$Group['Id'],
55 sprintf(T('Translation group "%s"'), $Group['Name']), $Columns, '`'.$Table.'`', $this->System->Link('/TranslationList.php?group='.
56 $Group['Id'].'&amp;user=0&amp;state=0&amp;entry=&amp;text='));
57 }
58 }
59 }
60
61 function ShowRSS()
62 {
63 $Items = array();
64 $DbResult = $this->Database->query('SELECT UNIX_TIMESTAMP(`Date`) AS `Date`, `User`.`Name` AS `UserName`, `Text` FROM `Log` '.
65 'JOIN `User` ON `User`.`ID` = `Log`.`User` WHERE `Type` = 1 ORDER BY `Date` DESC LIMIT 100');
66 while($DbRow = $DbResult->fetch_assoc())
67 {
68 $Items[] = array
69 (
70 'Title' => strip_tags($DbRow['Text'].' ('.$DbRow['UserName'].')'),
71 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'),
72 'Description' => $DbRow['Text'],
73 'Time' => $DbRow['Date'],
74 );
75 }
76 $Output = GenerateRSS(array
77 (
78 'Title' => $this->System->Config['Web']['Title'].' - '.T('Last translations'),
79 'Link' => 'http://'.$this->System->Config['Web']['Host'].$this->System->Link('/'),
80 'Description' => $this->System->Config['Web']['Description'],
81 'WebmasterEmail' => $this->System->Config['Web']['AdminEmail'],
82 'Items' => $Items,
83 ));
84 return($Output);
85 }
86}
Note: See TracBrowser for help on using the repository browser.