From bdd03e33dd658120f39ecd6ac5dd9692093e117f Mon Sep 17 00:00:00 2001 From: bdaloukas Date: Tue, 30 May 2017 18:36:18 +0300 Subject: [PATCH] Fix: PHP coding style problems --- backup/moodle2/restore_game_stepslib.php | 2 + bookquiz/play.php | 64 +++--- cross/cross_class.php | 2 + cross/crossdb_class.php | 2 + cross/play.php | 258 +++++++++++------------ cryptex/cryptexdb_class.php | 2 + db/access.php | 2 + exporthtml_hangman.php | 2 + exporthtml_millionaire.php | 2 + exporthtml_snakes.php | 2 + exportjavame.php | 2 + headergame.php | 2 + index.php | 2 +- lib.php | 27 +-- locallib.php | 4 +- mod_form.php | 2 +- pagelib.php | 2 + print.php | 2 +- report/overview/report.php | 2 + showanswers.php | 2 +- showattempts.php | 2 +- snakes/createboard.php | 2 + snakes/play.php | 10 +- sudoku/class.Sudoku.php | 4 +- sudoku/play.php | 27 ++- sudoku/sdd/class.logfile.php | 2 + 26 files changed, 221 insertions(+), 211 deletions(-) diff --git a/backup/moodle2/restore_game_stepslib.php b/backup/moodle2/restore_game_stepslib.php index 46e8903..b3480ed 100644 --- a/backup/moodle2/restore_game_stepslib.php +++ b/backup/moodle2/restore_game_stepslib.php @@ -20,6 +20,8 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die(); + /** * Define all the restore steps that will be used by the restore_game_activity_task */ diff --git a/bookquiz/play.php b/bookquiz/play.php index 665f725..0196da5 100644 --- a/bookquiz/play.php +++ b/bookquiz/play.php @@ -172,33 +172,33 @@ function game_bookquiz_play( $id, $game, $attempt, $bookquiz, $chapterid, $conte } } -?> - - - - - - - - - - - - + +
- - - - - -
-
- box_start('generalbox'); - echo $toc; - echo $OUTPUT->box_end(); - ?> - - + + + + + + + + + + + + - -
+ + + + + +
+
+ box_start('generalbox'); + echo $toc; + echo $OUTPUT->box_end(); + ?> + + box_start('generalbox'); $content = ''; if (!$book->customtitles) { @@ -227,12 +227,12 @@ function game_bookquiz_play( $id, $game, $attempt, $bookquiz, $chapterid, $conte echo $OUTPUT->box_end(); // Lower navigation. echo '

'.$chnavigation.'

'; -?> -
+ ?> +
-param3 != 0) { game_bookquiz_showquestions( $id, $questionid, $chapter->id, $nextid, $scoreattempt, $game, $context); diff --git a/cross/cross_class.php b/cross/cross_class.php index 8d3ea6e..557ce01 100644 --- a/cross/cross_class.php +++ b/cross/cross_class.php @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +defined('MOODLE_INTERNAL') || die(); + /* Crossing Words for Codewalkers PHP Coding Contest of July 2002 diff --git a/cross/crossdb_class.php b/cross/crossdb_class.php index 614f3cd..86932ad 100644 --- a/cross/crossdb_class.php +++ b/cross/crossdb_class.php @@ -16,6 +16,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +defined('MOODLE_INTERNAL') || die(); + /** * This class is a cross that can load and save to a table * diff --git a/cross/play.php b/cross/play.php index 9fd1e5a..61e4591 100644 --- a/cross/play.php +++ b/cross/play.php @@ -280,34 +280,34 @@ margin-top: 1em; '; - } else { - echo ''; - } +if ($print) { + echo ''; +} else { + echo ''; +} - if ($game->toptext != '') { - echo $game->toptext.'
'; - } +if ($game->toptext != '') { + echo $game->toptext.'
'; +} ?>

- This interactive crossword puzzle requires JavaScript and a reasonably recent web browser, such as Internet Explorer 5.5 - or later, Netscape 7, Mozilla, Firefox, or Safari. If you have disabled web page scripting, please re-enable it and refresh - the page. + This interactive crossword puzzle requires JavaScript and a reasonably recent web browser, such as Internet Explorer 5.5 + or later, Netscape 7, Mozilla, Firefox, or Safari. If you have disabled web page scripting, please re-enable it and refresh + the page.

param3 == 2) { - echo "\r\n"; - game_cross_show_welcome( $game); - echo "\r\n"; - echo "\r\n"; - } +if ($game->param3 == 2) { + echo "\r\n"; + game_cross_show_welcome( $game); + echo "\r\n"; + echo "\r\n"; +} ?> @@ -333,138 +333,125 @@ var CrosswordFinished, Initialized; // Check the user's browser and then initialize the puzzle. if (document.getElementById("waitmessage") != null) { - document.getElementById("waitmessage").innerHTML = ""; - - // Current game variables - CurrentWord = -1; - PrevWordHorizontal = false; - + document.getElementById("waitmessage").innerHTML = ""; + + // Current game variables + CurrentWord = -1; + PrevWordHorizontal = false; + + OnlyCheckOnce = false; - OnlyCheckOnce = false; - - // Create the cell-to-word arrays. - TableAcrossWord = new Array(CrosswordWidth); - for (var x = 0; x < CrosswordWidth; x++) + // Create the cell-to-word arrays. + TableAcrossWord = new Array(CrosswordWidth); + for (var x = 0; x < CrosswordWidth; x++) TableAcrossWord[x] = new Array(CrosswordHeight); - TableDownWord = new Array(CrosswordWidth); - for (var x = 0; x < CrosswordWidth; x++){ - TableDownWord[x] = new Array(CrosswordHeight); - } + TableDownWord = new Array(CrosswordWidth); + for (var x = 0; x < CrosswordWidth; x++){ + TableDownWord[x] = new Array(CrosswordHeight); + } - GuessLeter = new Array(CrosswordWidth); - for (var x = 0; x < CrosswordWidth; x++) - { - GuessLeter[x] = new Array(CrosswordHeight); - for (var y = 0; y < CrosswordHeight; y++) - { - GuessLeter[ x][ y] = "_"; - } - } + GuessLeter = new Array(CrosswordWidth); + for (var x = 0; x < CrosswordWidth; x++) { + GuessLeter[x] = new Array(CrosswordHeight); + for (var y = 0; y < CrosswordHeight; y++) { + GuessLeter[ x][ y] = "_"; + } + } - solu = new Array(CrosswordWidth); - for (var x = 0; x < CrosswordWidth; x++) - { - solu[x] = new Array(CrosswordHeight); - for (var y = 0; y < CrosswordHeight; y++) - { - solu[ x][ y] = ""; - } - } + solu = new Array(CrosswordWidth); + for (var x = 0; x < CrosswordWidth; x++) { + solu[x] = new Array(CrosswordHeight); + for (var y = 0; y < CrosswordHeight; y++) { + solu[ x][ y] = ""; + } + } - for (var y = 0; y < CrosswordHeight; y++) - for (var x = 0; x < CrosswordWidth; x++) - { - TableAcrossWord[x][y] = -1; - TableDownWord[x][y] = -1; - } - - // First, add the horizontal words to the puzzle. - for (var i = 0; i <= LastHorizontalWord; i++) - { - x = WordX[i]; - y = WordY[i]; - s = Guess[ i]; - so = Solutions[ i]; - for (var j = 0; j < WordLength[i]; j++) - { - TableAcrossWord[x + j][y] = i; - if( j < s.length) - c = s.substr( j, 1); - else - c = ''; - GuessLeter[ x+ j][ y] = c; - if( j < so.length) - c = so.substr( j, 1); - else - c = ''; - solu[ x+j][ y] = c; - } + for (var y = 0; y < CrosswordHeight; y++) { + for (var x = 0; x < CrosswordWidth; x++) { + TableAcrossWord[x][y] = -1; + TableDownWord[x][y] = -1; + } } + // First, add the horizontal words to the puzzle. + for (var i = 0; i <= LastHorizontalWord; i++) { + x = WordX[i]; + y = WordY[i]; + s = Guess[ i]; + so = Solutions[ i]; + for (var j = 0; j < WordLength[i]; j++) { + TableAcrossWord[x + j][y] = i; + if( j < s.length) + c = s.substr( j, 1); + else + c = ''; + GuessLeter[ x+ j][ y] = c; + if( j < so.length) + c = so.substr( j, 1); + else + c = ''; + solu[ x+j][ y] = c; + } + } - // Second, add the vertical words to the puzzle. - for (var i = LastHorizontalWord + 1; i < Words; i++) - { - x = WordX[i]; - y = WordY[i]; - s = Guess[ i]; - so = Solutions[ i]; - for (var j = 0; j < WordLength[i]; j++) - { - TableDownWord[x][y + j] = i; - if( j < s.length) - c = s.substr( j, 1); - else - c = ''; - GuessLeter[ x][ y+j] = c; - if( j < so.length) - c = so.substr( j, 1); - else - c = ''; - solu[ x][ y+j] = c; - } - } + // Second, add the vertical words to the puzzle. + for (var i = LastHorizontalWord + 1; i < Words; i++) { + x = WordX[i]; + y = WordY[i]; + s = Guess[ i]; + so = Solutions[ i]; + for (var j = 0; j < WordLength[i]; j++) { + TableDownWord[x][y + j] = i; + if( j < s.length) + c = s.substr( j, 1); + else + c = ''; + GuessLeter[ x][ y+j] = c; + if( j < so.length) + c = so.substr( j, 1); + else + c = ''; + solu[ x][ y+j] = c; + } + } - document.writeln(""); - for (var x = 0; x < CrosswordWidth; x++) - { - document.write(""); //col numbers - } + document.writeln(""); + for (var x = 0; x < CrosswordWidth; x++) { + document.write(""); //col numbers + } - // Now, insert the row HTML into the table. - for (var y = 0; y < CrosswordHeight; y++) - { - document.writeln(""); - document.write(""); //line numbers - for (var x = 0; x < CrosswordWidth; x++) - { - if (TableAcrossWord[x][y] >= 0 || TableDownWord[x][y] >= 0) - { + // Now, insert the row HTML into the table. + for (var y = 0; y < CrosswordHeight; y++) { + document.writeln(""); + document.write(""); //line numbers + for (var x = 0; x < CrosswordWidth; x++) { + if (TableAcrossWord[x][y] >= 0 || TableDownWord[x][y] >= 0) { var s; s = ""); - }else - document.write(""); //empty cell - } - document.writeln(""); - } + if( solu[x][y] != '') + document.write( solu[x][y]); + else if( GuessLeter[x][y]== "_") + document.write( " "); + else + document.write( GuessLeter[x][y]); + + document.write(""); + } else { + document.write(""); //empty cell + } + } + document.writeln(""); + } - // Finally, show the crossword and hide the wait message. - Initialized = true; - document.getElementById("waitmessage").style.display = "none"; - document.getElementById("crossword").style.display = "block"; + // Finally, show the crossword and hide the wait message. + Initialized = true; + document.getElementById("waitmessage").style.display = "none"; + document.getElementById("crossword").style.display = "block"; } // ---------- @@ -815,10 +802,8 @@ function OnPrint() } - @@ -988,7 +973,6 @@ function CheckHtmlClick()
 
 
" + (x+1) + "
" + (x+1) + "
" + (y+1)+"
" + (y+1)+" "; document.write( s); - if( solu[x][y] != '') - document.write( solu[x][y]); - else if( GuessLeter[x][y]== "_") - document.write( " "); - else - document.write( GuessLeter[x][y]); - - document.write("
- '; @@ -1067,7 +1051,6 @@ function CheckHtmlClick() ?> -

- . +defined('MOODLE_INTERNAL') || die(); + class CryptexDB extends CrossDB { public function savecryptex( $game, &$crossm, $crossd, $id, $letters) { global $USER; diff --git a/db/access.php b/db/access.php index 97e5eec..76fe84a 100644 --- a/db/access.php +++ b/db/access.php @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +defined('MOODLE_INTERNAL') || die(); + /** * Capability definitions for the game module. * diff --git a/exporthtml_hangman.php b/exporthtml_hangman.php index 977ae14..58cea1d 100644 --- a/exporthtml_hangman.php +++ b/exporthtml_hangman.php @@ -21,6 +21,8 @@ * @package game **/ +defined('MOODLE_INTERNAL') || die(); + ?> -
  @@ -1146,18 +1128,14 @@ function game_cross_show_welcome1() {   - - - -
- -
+ + + +
@@ -109,7 +111,7 @@ function game_snakes_play( $id, $game, $attempt, $snakes, $context) { game_snakes_showdice( $snakes, $board); } ?> -
wwwroot.'/mod/game/attempt.php?action=sudokucheckn&id='.$id; ?> - - + function OnCheck( pos) { + s = window.prompt( "", ""); + + if (s < "1") + return; + if (s > "9") + return; + + window.location.href = "&pos=" + pos + "&num=" + s; + } + +timefinish) { diff --git a/sudoku/sdd/class.logfile.php b/sudoku/sdd/class.logfile.php index 7f1f1f2..29a2c61 100644 --- a/sudoku/sdd/class.logfile.php +++ b/sudoku/sdd/class.logfile.php @@ -28,6 +28,8 @@ * Initial version created/ */ +defined('MOODLE_INTERNAL') || die(); + require_once('SDD/class.SDD.php'); class logfile extends SDD {