From 40b0d42dee76bc62517801aa746371a9ce2895a1 Mon Sep 17 00:00:00 2001 From: piernov Date: Wed, 4 May 2016 14:26:57 +0200 Subject: Now possible to add format to sendMessage() strings --- inc/messages.inc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/inc/messages.inc b/inc/messages.inc index 4938fa1..7b952b8 100644 --- a/inc/messages.inc +++ b/inc/messages.inc @@ -14,18 +14,19 @@ $messages = array( "gamesave_delete_success" => "Game save successfully removed from server", ); -function sendMessage($type, $msg) { +function sendMessage($type, $msg, $fmt = null) { global $messages; $text = $messages[$msg]; + if($fmt) $text = vsprintf($text, $fmt); echo json_encode(array($type => $text)); } -function sendError($msg) { - sendMessage("error", $msg); +function sendError($msg, $fmt = null) { + sendMessage("error", $msg, $fmt); } -function sendInfo($msg) { - sendMessage("info", $msg); +function sendInfo($msg, $fmt = null) { + sendMessage("info", $msg, $fmt); } ?> -- cgit v1.2.3-70-g09d2