aboutsummaryrefslogtreecommitdiff
path: root/mod/translation_editor/views/default/translation_editor/plugin_list.php
blob: b48b94fbf96d78aaff5f38bfb402a553cc7b7e7c (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
<?php 
	$plugins = $vars["plugins"];
	$current_language = $vars["current_language"];
	
	if(!empty($plugins)){
		$total = 0;
		$exists = 0; 
		$custom = 0;
		
		$list .= "<table id='translation_editor_plugin_list' class='elgg-table' title=\"" . elgg_echo("translation_editor:plugin_list:title") . "\">";
		$list .= "<tr>";
		$list .= "<th class='first_col'>" . elgg_echo("translation_editor:plugin_list:plugin") . "</th>";
		$list .= "<th>" . elgg_echo("translation_editor:plugin_list:total") . "</th>";
		$list .= "<th>" . elgg_echo("translation_editor:plugin_list:exists") . "</th>";
		$list .= "<th>" . elgg_echo("translation_editor:plugin_list:custom") . "</th>";
		$list .= "<th>" . elgg_echo("translation_editor:plugin_list:percentage") . "</th>";
		$list .= "<th>&nbsp;</th>";
		$list .= "</tr>";
		
		foreach($plugins as $plugin_name => $plugin_stats){
			
			$url = $vars["url"] . "translation_editor/" . $current_language . "/" . $plugin_name;
			
			$total += $plugin_stats["total"];
			$exists += $plugin_stats["exists"];
			$custom += $plugin_stats["custom"];
			
			if(!empty($plugin_stats["total"])){
				$percentage = round(($plugin_stats["exists"] / $plugin_stats["total"]) * 100);
			} else {
				$percentage = 100;
			}
			
			$complete_class = "";
			
			if($percentage == 100){
				$complete_class = " class='translation_editor_translation_complete'";
			} elseif($percentage == 0){
				$complete_class = " class='translation_editor_translation_needed'";
			}
			
			$list .= "<tr>";
			$list .= "<td class='first_col'><a href='" . $url . "'>" . $plugin_name . "</a></td>";
			$list .= "<td>" . $plugin_stats["total"] . "</td>";
			$list .= "<td>" . $plugin_stats["exists"] . "</td>";
			
			if($plugin_stats["custom"] > 0){
				$list .= "<td>" . $plugin_stats["custom"] . "</td>";
			} else {
				$list .= "<td>&nbsp;</td>";
			}
			
			$list .= "<td" . $complete_class . ">" . $percentage . "%</td>";
			
			if($plugin_stats["custom"] > 0){
				$merge_url = $vars["url"] . "action/translation_editor/merge?current_language=" . $current_language . "&plugin=" . $plugin_name;
				
				$list .= "<td>";
				$list .= elgg_view("output/url", array("href" => $merge_url, "is_action" => true, "title" => elgg_echo("translation_editor:plugin_list:merge"), "text" => elgg_view_icon("download")));
				if(elgg_is_admin_logged_in()){
					$delete_url = $vars["url"] . "action/translation_editor/delete?current_language=" . $current_language . "&plugin=" . $plugin_name;
					
					$list .= elgg_view("output/confirmlink", array("href" => $delete_url, "title" => elgg_echo("delete"), "text" => elgg_view_icon("delete-alt")));
				}
				$list .= "</td>";
			} else {
				$list .= "<td>&nbsp;</td>";
			}
			$list .= "</tr>";
		}
		
		$list .= "<tr class='translation_editor_plugin_list_total_row'>";
		$list .= "<td>&nbsp;</td>";
		$list .= "<td>" . $total . "</td>";
		$list .= "<td>" . $exists . "</td>";
		$list .= "<td>" . $custom . "</td>";
		$list .= "<td>" . round(($exists / $total) * 100, 2) . "%</td>";
		$list .= "<td>&nbsp;</td>";
		$list .= "</tr>";
		
		$list .= "</table>";
		
		echo $list;
	}