Project

General

Profile

« Previous | Next » 

Revision b3119a61

Added by Phil Davis over 8 years ago

get_service_status_icon fix description_state format

If "description_state" is requested here, there are too many "%s" substitutions in the string for sprintf().

Also, to help translators, number all the "%s" substitutions. Then translators can rearrange the text and variable order if they need to.

I removed the commented-out get_service_control_GET_links() while I am here, because it also contained sprintf() strings that had multiple "%s" substitutions. So I had found it when searching for lines containing multiple "%s". Might as well remove it "in the next version" as the comment says.

View differences:

src/etc/inc/service-utils.inc
482 482
	if ($title == "state") {
483 483
		$output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"{$statustext}\"></i>{$spacer}";
484 484
	} elseif ($title == "service_state") {
485
		$output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext("%s Service is %s"), $service["name"], $statustext) . "\"></i>{$spacer}";
485
		$output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext('%1$s Service is %2$s'), $service["name"], $statustext) . "\"></i>{$spacer}";
486 486
	} elseif ($title == "description_state") {
487
		$output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext("%s, %s Service is %s"), $service["description"], $statustext) . "\"></i>{$spacer}";
487
		$output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext('%1$s Service is %2$s'), $service["description"], $statustext) . "\"></i>{$spacer}";
488 488
	} elseif ($title == "description_service_state") {
489
		$output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext("%s, %s Service is %s"), $service["description"], $service["name"], $statustext) . "\"></i>{$spacer}";
489
		$output = "<i class=\"{$text_class} {$fa_class} {$fa_size}\" title=\"" . sprintf(gettext('%1$s, %2$s Service is %3$s'), $service["description"], $service["name"], $statustext) . "\"></i>{$spacer}";
490 490
	}
491 491

  
492 492
	$spacer = ($withtext) ? " " : "";
......
501 501
	return $output;
502 502
}
503 503

  
504
/* This function is no longer required since services now use the POST method via JavaScript
505
   Commenting out for now. It should be removed in the next version
506

  
507
// This version proved GET formatted links
508
function get_service_control_GET_links($service, $addname = false) {
509
	global $g;
510
	$output = "";
511
	$stitle = ($addname) ? $service['name'] . " " : "";
512

  
513
	switch ($service['name']) {
514
		case "openvpn":
515
			$link = '<a title="%s" href="status_services.php?mode=%s&amp;service='.$service['name'] . '&amp;vpnmode=' . $service['mode'] . '&amp;id=' . $service['vpnid'] . '">';
516
		break;
517
		case "captiveportal":
518
			$link = '<a title="%s" href="status_services.php?mode=%s&amp;service=' . $service['name'] . '&amp;zone=' . $service['zone'] . '">';
519
		break;
520
		default:
521
			$link = '<a title="%s" href="/status_services.php?mode=%s&amp;service=' . $service['name'] . '">';
522
	}
523

  
524
	if (get_service_status($service)) {
525
		switch ($service['name']) {
526
			case "openvpn":
527
				$output .= "<a href=\"status_services.php?mode=restartservice&amp;service={$service['name']}&amp;vpnmode={$service['mode']}&amp;id={$service['vpnid']}\">";
528
				break;
529
			case "captiveportal":
530
				$output .= "<a href=\"status_services.php?mode=restartservice&amp;service={$service['name']}&amp;zone={$service['zone']}\">";
531
				break;
532
			default:
533
				$output .= "<a href=\"/status_services.php?mode=restartservice&amp;service={$service['name']}\">";
534
		}
535
		$output .= "<i class=\"fa fa-repeat\" title=\"" . sprintf(gettext("Restart %sService"), $stitle) . "\"></i></a>\n";
536
		switch ($service['name']) {
537
			case "openvpn":
538
				$output .= "<a href=\"status_services.php?mode=stopservice&amp;service={$service['name']}&amp;vpnmode={$service['mode']}&amp;id={$service['vpnid']}\">";
539
				break;
540
			case "captiveportal":
541
				$output .= "<a href=\"status_services.php?mode=stopservice&amp;service={$service['name']}&amp;zone={$service['zone']}\">";
542
				break;
543
			default:
544
				$output .= "<a href=\"/status_services.php?mode=stopservice&amp;service={$service['name']}\">";
545
		}
546
		$output .= "<i class=\"fa fa-stop-circle-o\" title=\"" . sprintf(gettext("Stop %sService"), $stitle) . "\"></i></a>";
547
	} else {
548
		$service_enabled = is_service_enabled($service['name']);
549

  
550
		if ($service['name'] == 'openvpn' || $service['name'] == 'captiveportal' || $service_enabled) {
551
			$output .= sprintf($link, sprintf(gettext("Start %sService"), $stitle), 'startservice');
552
			$output .= '<i class="fa fa-play-circle"></i></a> ';
553
		}
554
	}
555

  
556
	return $output;
557
}
558
*/
559

  
560 504
function get_service_control_links($service, $addname = false) {
561 505
	global $g;
562 506
	$output = "";

Also available in: Unified diff