# HG changeset patch # User Matti Hamalainen # Date 1416606397 -7200 # Node ID f4b99fed50b4b0742c54da89e05edf86a5fc8195 # Parent 18f88945d5f1bbf18764b8f7b8efa6d409ff9298 Use the formatting functionality added to stChkRequestItem*(). diff -r 18f88945d5f1 -r f4b99fed50b4 admajax.php --- a/admajax.php Fri Nov 21 23:45:22 2014 +0200 +++ b/admajax.php Fri Nov 21 23:46:37 2014 +0200 @@ -21,12 +21,12 @@ $res = TRUE; stChkRequestItemFail("name", $fake, $res, - array(CHK_ISGT, VT_STR, 0, "Compo name too short"), - array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_NAME, "Compo name too long.")); + array(CHK_ISGT, VT_STR, 0, "Compo name is empty."), + array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_NAME, "Compo name too long (%1 chars, must be less than %2).")); stChkRequestItemFail("description", $fake, $res, - array(CHK_ISGT, VT_STR, 10, "Compo description too short"), - array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_DESC, "Compo description too long.")); + array(CHK_ISGT, VT_STR, 10, "Compo description too short (%1 chars, must be more than %2)"), + array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_DESC, "Compo description too long (%1 chars, must be less than %2).")); // Not a full check? if (!$full) @@ -47,7 +47,7 @@ array(CHK_RANGE, VT_INT, array(EPREV_NONE, EPREV_AUDIO), "Invalid preview type value.")); stChkRequestItemFail("cpath", $fake, $res, - array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_PATH, "Compo file path too long.")); + array(CHK_LTEQ, VT_STR, SET_LEN_COMPO_PATH, "Compo file path too long (%1 chars, must be less than %2).")); break; } @@ -64,12 +64,12 @@ // Things common for all compo types stChkRequestItemFail("name", $fake, $res, - array(CHK_ISGT, VT_STR, 0, "Name too short."), - array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NAME, "Name too long.")); + array(CHK_ISGT, VT_STR, 0, "Name is empty."), + array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NAME, "Name too long (%1 chars, must be less than %2).")); stChkRequestItemFail("notes", $fake, $res, array(CHK_TYPE, VT_TEXT, "Invalid data."), - array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NOTES, "Entry notes too long.")); + array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_NOTES, "Entry notes are too long (%1 chars, must be less than %2).")); // Check based on compo type switch ($ctype) @@ -80,15 +80,15 @@ stChkRequestItemFail("author", $fake, $res, array(CHK_ISGT, VT_STR, 0, "Author name not set."), - array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_AUTHOR, "Entry author too long.")); + array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_AUTHOR, "Entry author too long (%1 chars, must be less than %2).")); stChkRequestItemFail("filename", $fake, $res, array(CHK_TYPE, VT_TEXT, "Invalid data."), - array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_FILENAME, "Entry filename too long.")); + array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_FILENAME, "Entry filename too long (%1 chars, must be less than %2).")); stChkRequestItemFail("info", $fake, $res, array(CHK_TYPE, VT_TEXT, "Invalid data."), - array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_INFO, "Entry info too long.")); + array(CHK_LTEQ, VT_STR, SET_LEN_ENTRY_INFO, "Entry info text too long (%1 chars, must be less than %2).")); if ($full) { @@ -100,13 +100,13 @@ case COMPO_POINTS: stChkRequestItemFail("evalue", $fake, $res, - array(CHK_TYPE, VT_INT, "Invalid points, must be a integer.")); + array(CHK_TYPE, VT_INT, "Invalid points value, must be a valid integer.")); break; case COMPO_ASSIGN: stChkRequestItemFail("evalue", $fake, $res, - array(CHK_TYPE, VT_INT, "Invalid position, must be a integer."), - array(CHK_GTEQ, VT_INT, 1, "Invalid position, must be > 0.")); + array(CHK_TYPE, VT_INT, "Invalid position, must be a valid integer."), + array(CHK_GTEQ, VT_INT, 1, "Invalid position, must be >= %2.")); break; } @@ -120,15 +120,15 @@ stChkRequestItemFail("text", $fake, $res, array(CHK_ISGT, VT_STR, 0, "News text too short."), - array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TEXT, "News text too long.")); + array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TEXT, "News text too long (%1 chars, must be less than %2).")); stChkRequestItemFail("author", $fake, $res, - array(CHK_ISGT, VT_STR, 0, "News author name too short."), - array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_AUTHOR, "News author name too long.")); + array(CHK_ISGT, VT_STR, 0, "News author name not set."), + array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_AUTHOR, "News author name too long (%1 chars, must be less than %2).")); stChkRequestItemFail("title", $fake, $res, - array(CHK_ISGT, VT_STR, 0, "News title too short."), - array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TITLE, "News title too long.")); + array(CHK_ISGT, VT_STR, 0, "News title not set."), + array(CHK_LTEQ, VT_STR, SET_LEN_NEWS_TITLE, "News title too long (%1 chars. must be less than %2).")); return $res; }