aboutsummaryrefslogtreecommitdiff
path: root/views/default/translation_editor/language_selector.php
blob: 89ebbf882cd652d60bf16616326d40f30a66f068 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
<?php 

	$languages = $vars["languages"];
	$current_language = $vars["current_language"];
	$plugin = $vars["plugin"];
	$disabled_languages = $vars["disabled_languages"];
	$site_language = $vars["site_language"];
	
	if(!empty($languages)){
		$list = "<table id='translation_editor_language_table' class='elgg-table' title='" . elgg_echo("translation_editor:language_selector:title") . "'>";
		$list .= "<tr>";
		$list .= "<th class='translation_editor_flag'>&nbsp;</th>";
		$list .= "<th>" . elgg_echo("translation_editor:language") . "</th>";
		if(elgg_is_admin_logged_in()){
			$list .= "<th class='translation_editor_enable'>" . elgg_echo("translation_editor:disabled") . "</th>";
		}
		$list .= "</tr>";
		
		foreach($languages as $language){
			$list .= "<tr>";
			
			// flag
			$lang_flag_file = "mod/translation_editor/_graphics/flags/" . $language . ".png";
	
			if(file_exists(elgg_get_root_path() . $lang_flag_file)){
				$list .= "<td class='translation_editor_flag'>"; 
				$list .= "<img src='" . $vars['url'] . $lang_flag_file . "' alt='" . elgg_echo($language)  . "' title='" . elgg_echo($language) . "'> ";
				$list .= "</td>";
			} else {
				$list .= "<td class='translation_editor_flag'>&nbsp;</td>";
			}
			
			// language
			$list .= "<td>";
			if($language != $current_language){
				$url = $vars["url"] . "translation_editor/" . $language . "/" . $plugin;
				
				if($language != "en"){
					$completeness = translation_editor_get_language_completeness($language); 
					$list .= "<a href='" . $url . "'>" . elgg_echo($language) . " (" . $completeness . "%)</a>";
					
					if(elgg_is_admin_logged_in() && $completeness == 0){
						$list .= elgg_view("output/confirmlink", array("href" => $vars["url"] . "action/translation_editor/delete_language?language=" . $language, "confirm" => elgg_echo("translation_editor:language_selector:remove_language:confirm"), "text" => elgg_view_icon("delete-alt")));
					}
				} else {
					$list .= "<a href='" . $url . "'>" . elgg_echo($language) . "</a>";
					
				}
			} else {
				if($language != "en"){
					$list .= elgg_echo($language) . " (" . translation_editor_get_language_completeness($language) . "%)";
				} else {
					$list .= elgg_echo($language);
				}
			}
			
			if($site_language == $language){
				$list .= "<span id='translation_editor_site_language'>" . elgg_echo("translation_editor:language_selector:site_language") . "</span>";
			}
			$list .= "</td>";
			
			// checkbox
			if(elgg_is_admin_logged_in()){
				$list .= "<td class='translation_editor_enable'>";
				if($language != "en"){
					$list .= "<input type='checkbox' name='disabled_languages[]' value='" . $language . "' onchange='translation_editor_disable_language();' ";
					if(in_array($language, $disabled_languages)){
						$list .= "checked='checked' ";
					}
					$list .= "/>";
				}
				$list .= "</td>";
			}
			
			$list .= "</tr>";
		}
		
		$list .= "</table>";
		
		echo $list;	
	}
	
	if(elgg_is_admin_logged_in()){
		// add a new language
		echo elgg_view("translation_editor/add_language");
	}	
	
	echo "<br />";