diff options
author | piernov <piernov@piernov.org> | 2016-05-04 14:26:57 +0200 |
---|---|---|
committer | piernov <piernov@piernov.org> | 2016-05-04 14:26:57 +0200 |
commit | 40b0d42dee76bc62517801aa746371a9ce2895a1 (patch) | |
tree | bff87016f7dd875b1c7d793cfa5835c5fb233733 /inc/messages.inc | |
parent | 036d5a2e88232e966cfd0cc82277d5fba13e71ff (diff) | |
download | candybox-40b0d42dee76bc62517801aa746371a9ce2895a1.tar.gz candybox-40b0d42dee76bc62517801aa746371a9ce2895a1.tar.bz2 candybox-40b0d42dee76bc62517801aa746371a9ce2895a1.tar.xz candybox-40b0d42dee76bc62517801aa746371a9ce2895a1.zip |
Now possible to add format to sendMessage() strings
Diffstat (limited to 'inc/messages.inc')
-rw-r--r-- | inc/messages.inc | 11 |
1 files 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); } ?> |