function edit_hatplehgame_settings_page() { $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css'; $game_id = filter_input(INPUT_POST, 'id'); $game = get_deck($game_id); $categories = get_word_categories(); $domains = get_domains(); $words = get_words(); if (isset($_GET['id']) && is_numeric($_GET['id'])) { $game = build_deck($_GET['id']); $deck_words = get_all_game_words_ids($_GET['id']); } $selected_words_ids = array(); for ($j = 0; $j < sizeof($deck_words); $j++) { $selected_words_ids[$j] = $deck_words[$j]->id; } ?> <link rel="stylesheet" type="text/css" href="<?php echo $semantic; ?> "/> <h2>Edit a Game!</h2> <hr> <?php if (isset($_GET['settings-saved'])) { ?> <div class="updated"><p>Game updated successfully.</p></div> <?php } elseif (isset($_GET['error'])) { ?> <div class="error"><p>Error updating game.</p></div> <?php } ?> <form method="post" enctype="multipart/form-data" action="<?php echo get_admin_url() . 'admin-post.php'; ?> "> <!-- pano processing hook --> <input type="hidden" name="action" value="edit_hatgame" /> <?php if (isset($_GET['action']) && $_GET['action'] == "edit") { $game_id_to_form = $game->get_id(); } elseif (isset($_GET['action']) && $_GET['action'] == "copy") { $game_id_to_form = "copy"; } ?> <input type="hidden" name="game_id" value="<?php echo $game_id_to_form; ?> "/> <div class="ui form segment edit_word_form"> <div class="ui form"> <div class="field"> <div class="ui left labeled icon input"> <label for="game_name">Game Name: </label> <input name="game_name" id="name" value="<?php echo $game->get_name(); ?> " required /> </div> </div> </div> <div class="ui form"> <div class="field"> <label for="word_image">Choose an image for winning the game: <b>(Preferably 120x120)</b></label> <img class="word_image" src="<?php echo content_url() . '/' . $game->get_image(); ?> " alt="Image"/> <input type="file" name="game_image" id="game_image" /> <input type="hidden" name="game_image" value="<?php echo $game->get_image(); ?> "/> </div> </div> <div class="ui form"> <div class="field"> <label for="filter">Filter by</label> <select name="domain_id" id="domain_id"> <option value="NA">Select a Domain</option> <?php foreach ($domains as $domain) { ?> <option value="<?php echo $domain->id; ?> "><?php echo $domain->name; ?> </option> <?php } ?> </select> <select name="category_id" id="category_id"> <option value="NA">Select a Category</option> <?php foreach ($categories as $category) { ?> <option value="<?php echo $category->id; ?> "><?php echo $category->name; ?> </option> <?php } ?> </select> </div> </div> <div class="ui form"> <div class="field"> <ul> <?php foreach ($words as $word) { ?> <?php if (in_array($word->id, $selected_words_ids)) { ?> <li class="games_form"> <input type="checkbox" id="<?php echo $word->id; ?> " class="dom<?php echo $word->domain_id; ?> cat<?php echo $word->word_category_id; ?> " name="words[]" value="<?php echo $word->id; ?> " checked> <label for="<?php echo $word->id; ?> " class="dom_option cat_option dom<?php echo $word->domain_id; ?> cat<?php echo $word->word_category_id; ?> "><?php echo $word->word; ?> </label> </li> <?php } else { ?> <li class="games_form"> <input type="checkbox" id="<?php echo $word->id; ?> " class="dom<?php echo $word->domain_id; ?> cat<?php echo $word->word_category_id; ?> " name="words[]" value="<?php echo $word->id; ?> "> <label for="<?php echo $word->id; ?> " class="dom_option cat_option dom<?php echo $word->domain_id; ?> cat<?php echo $word->word_category_id; ?> "><?php echo $word->word; ?> </label> </li> <?php } ?> <?php } ?> </ul> </div> </div> <?php submit_button(); ?> </div> </form> </div> <script> jQuery(document).ready(function(){ jQuery("#pano_id").change(function(){ var quest_id = jQuery("option:selected", this).attr("data-quest-id"); jQuery("#quest_id").val(quest_id); }); }); jQuery("#category_id").change(function(){ filter_words(); }); jQuery("#domain_id").change(function(){ filter_words(); }); function filter_words() { var cat_selected = jQuery( "#category_id option:selected" ).val(); var dom_selected = jQuery( "#domain_id option:selected" ).val(); jQuery(".cat_option").hide(); //jQuery("input:checkbox").hide(); if(cat_selected == "NA" && dom_selected == "NA") { jQuery(".cat_option").show(); } else if(cat_selected != "NA" && dom_selected == "NA") { jQuery(".cat_option").hide(); jQuery(".cat" + cat_selected).show(); } else if(cat_selected == "NA" && dom_selected != "NA") { jQuery(".cat_option").hide(); jQuery(".dom" + dom_selected).show(); } else { jQuery(".cat_option").hide(); jQuery(".dom" + dom_selected + ".cat" + cat_selected).show(); } jQuery("input:checkbox").hide(); } </script> <?php }
function spotgame_settings_page() { $games = get_decks("spotgame"); $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css'; $new_game_url = admin_url() . "admin.php?page=new_spotgame_settings"; $edit_game_url = admin_url() . "admin.php?page=edit_spotgame_settings&action=edit"; $copy_game_url = admin_url() . "admin.php?page=edit_spotgame_settings&action=copy"; $view_game_url = admin_url() . "admin.php?page=view_spotgame_settings"; //$pano_editor = WP_PLUGIN_URL . '../sample-page-edit'; $pano_editor = admin_url() . "admin.php?page=view_panos_settings"; ?> <!-- style sheet so our admin page looks nice --> <link rel="stylesheet" type="text/css" href="<?php echo $semantic; ?> "/> <link rel="stylesheet" type="text/css" href="../flashcard/js/featherlight/featherlight.min.css"/> <script type="text/javascript" src="../flashcard/js/featherlight/featherlight.min.js"></script> <script type="text/javascript" src="../flashcard/js/featherlight/featherlight-functions.js"></script> <hr> <?php if (isset($_GET['settings-saved'])) { ?> <div class="updated"><p>Settings updated successfully.</p></div> <?php } ?> <h2>Games</h2> <table id="gameTable" class="ui table segment tablesorter"> <thead> <tr> <th>Question</th> <th>Choosed Word</th> <th>Edit</th> <th>Copy</th> <th>Delete</th> <th>View</th> <th>Add HotSpot</th> </tr> </thead> <tbody> <?php foreach ($games as $game) { ?> <?php $current_game = build_deck($game->id); ?> <tr> <td><?php echo $current_game->get_name(); ?> </td> <td><?php echo $current_game->get_name(); ?> </td> <td><a class="ui blue icon button" href="<?php echo $edit_game_url; ?> &id=<?php echo $current_game->get_id(); ?> " style="padding: 7px">Edit</a></td> <td><a class="ui blue icon button" href="<?php echo $copy_game_url; ?> &id=<?php echo $current_game->get_id(); ?> " style="padding: 7px">Copy</a></td> <td> <form method="post" action="admin-post.php" id="delete_word_form<?php echo $current_game->get_id(); ?> "> <!-- word processing hook --> <input type="hidden" name="action" value="delete_deck" /> <input type="hidden" name="game_type" value="spotgame"> <input type="hidden" name="game_id" value="<?php echo $current_game->get_id(); ?> " /> <input type="hidden" name="deck_id" value="<?php echo $game->id; ?> " /> <input type="submit" class="ui blue icon button" value="Delete" style="padding: 7px" > </form> </td> <td> <form method="POST" action="<?php echo $view_game_url; ?> &"> <!-- word processing hook --> <input type="hidden" name="deck_id" value="<?php echo $game->id; ?> " /> <input type="submit" class="ui blue icon button" value="View" style="padding: 7px" > </form> </td> <td> <form method="POST" action="<?php echo $pano_editor; ?> &"> <!-- word processing hook --> <input type="hidden" name="game_id" value="<?php echo $game->id; ?> " /> <input type="submit" class="ui blue icon button" value="Create_Hotspot" style="padding: 7px" > </form> </td> </tr> <?php } ?> </tbody> </table> <a class="ui blue icon button" href="<?php echo $new_game_url; ?> " style="padding: 7px">New Game</a> <script> jQuery(document).ready(function(){ jQuery("#gameTable").tablesorter(); }) </script> <?php }
function edit_spotgame_settings_page() { $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css'; $game_id = filter_input(INPUT_POST, 'id'); $game = get_deck($game_id); $domains = get_domains(); $categories = get_word_categories(); $words = get_words(); $decks = get_decks('flashcard'); //Will be empty if it's a copy or //Will have the id if it's an update $game_id_to_form = ""; if (isset($_GET['id']) && is_numeric($_GET['id'])) { $game = build_deck($_GET['id']); $deck_words = get_number_of_words_for_game($_GET['id']); } $selected_words_ids = array($deck_words->number_of_words); //echo var_dump($selected_words_ids); // for($j = 0; $j < sizeof($deck_words); $j++){ // $selected_words_ids[$j] = $deck_words[$j]->id; // } ?> <link rel="stylesheet" type="text/css" href="<?php echo $semantic; ?> "/> <h2>Edit a Game!</h2> <hr> <?php if (isset($_GET['settings-saved'])) { ?> <div class="updated"><p>Game updated successfully.</p></div> <?php } elseif (isset($_GET['error'])) { ?> <div class="error"><p>Error updating game.</p></div> <?php } ?> <form id="form" method="post" enctype="multipart/form-data" action="<?php echo get_admin_url() . 'admin-post.php'; ?> "> <!-- pano processing hook --> <input type="hidden" name="action" value="edit_spotgame" /> <?php if (isset($_GET['action']) && $_GET['action'] == "edit") { $game_id_to_form = $game->get_id(); } elseif (isset($_GET['action']) && $_GET['action'] == "copy") { $game_id_to_form = "copy"; } ?> <input type="hidden" name="game_id" value="<?php echo $game_id_to_form; ?> "/> <div class="ui form segment edit_word_form"> <div class="ui form"> <div class="field"> <label>Choose a deck:</label> <select name="decks" id="deck_id"> <option value="NA">Select a Deck</option> <?php foreach ($decks as $deck) { ?> <option value="<?php echo $deck->id; ?> "><?php echo $deck->name; ?> </option> <?php } ?> </select> </div> </div> <div class="ui form"> <div class="field"> <div class="ui left labeled icon input"> <label for="game_name">Question that will display in the game: </label> <input name="game_name" id="name" value="<?php echo $game->get_name(); ?> " required /> </div> </div> </div> <p class="error" id="not_enough_words">* Select just one word</p> <div class="ui form"> <div class="field"> <label for="category_id">Filter by</label> <select name="domain_id" id="domain_id"> <option value="NA">Select a Domain</option> <?php foreach ($domains as $domain) { ?> <option value="<?php echo $domain->id; ?> "><?php echo $domain->name; ?> </option> <?php } ?> </select> <select name="category_id" id="category_id"> <option value="NA">Select a Category</option> <?php foreach ($categories as $category) { ?> <option value="<?php echo $category->id; ?> "><?php echo $category->name; ?> </option> <?php } ?> </select> </div> </div> <div class="ui form"> <div class="field"> <ul> <?php foreach ($words as $word) { ?> <?php if (in_array($word->id, $selected_words_ids)) { ?> <li class="games_form"> <input type="checkbox" id="<?php echo $word->id; ?> " class="dom<?php echo $word->domain_id; ?> cat<?php echo $word->word_category_id; ?> " name="words[]" value="<?php echo $word->id; ?> " checked> <label for="<?php echo $word->id; ?> " class="dom_option cat_option dom<?php echo $word->domain_id; ?> cat<?php echo $word->word_category_id; ?> " ><?php echo $word->word; ?> </label> </li> <?php } else { ?> <li class="games_form"> <input type="checkbox" id="<?php echo $word->id; ?> " class="dom<?php echo $word->domain_id; ?> cat<?php echo $word->word_category_id; ?> " name="words[]" value="<?php echo $word->id; ?> "> <label for="<?php echo $word->id; ?> " class="dom_option cat_option dom<?php echo $word->domain_id; ?> cat<?php echo $word->word_category_id; ?> " ><?php echo $word->word; ?> </label> </li> <?php } ?> <?php } ?> </ul> </div> </div> <?php submit_button(); ?> </div> </form> </div> <script> jQuery('#form').submit(function(e){ user_selected_enough_words(e); }); jQuery('#game_number_of_words').change(function(){ document.getElementById("words_error").style.display = "none"; }); jQuery("input:checkbox").change(function(){ document.getElementById("words_error").style.display = "none"; document.getElementById("not_enough_words").style.display = "none"; }); jQuery("#category_id").change(function(){ filter_words(); }); jQuery("#domain_id").change(function(){ filter_words(); }); function user_selected_enough_words(e){ var n = jQuery("input:checkbox:checked").length; var game_number_of_words = jQuery('#game_number_of_words').prop('value'); if(n > 1 || n < 1){ e.preventDefault(); document.getElementById("not_enough_words").style.display = "block"; document.getElementById("words_error").style.display = "none"; } else if(n < Number(game_number_of_words)){ e.preventDefault(); document.getElementById("words_error").style.display = "block"; document.getElementById("not_enough_words").style.display = "none"; }else{ document.getElementById("words_error").style.display = "none"; document.getElementById("not_enough_words").style.display = "none"; } } function filter_words() { var cat_selected = jQuery( "#category_id option:selected" ).val(); var dom_selected = jQuery( "#domain_id option:selected" ).val(); var checkboxes = jQuery("input:checkbox"); jQuery(".cat_option").hide(); //jQuery("input:checkbox").hide(); if(cat_selected == "NA" && dom_selected == "NA") { jQuery(".cat_option").show(); } else if(cat_selected != "NA" && dom_selected == "NA") { jQuery(".cat_option").hide(); jQuery(".cat" + cat_selected).show(); var category = "cat" + cat_selected; for(var k = 0; k < checkboxes.length; k++){ if(!checkboxes[k].classList.contains(category)){ checkboxes[k].checked = false; } } } else if(cat_selected == "NA" && dom_selected != "NA") { jQuery(".cat_option").hide(); jQuery(".dom" + dom_selected).show(); var domain = "dom" + dom_selected; for(var k = 0; k < checkboxes.length; k++){ if(!checkboxes[k].classList.contains(domain)){ checkboxes[k].checked = false; } } } else { jQuery(".cat_option").hide(); jQuery(".dom" + dom_selected + ".cat" + cat_selected).show(); var category = "cat" + cat_selected; for(var k = 0; k < checkboxes.length; k++){ if(!checkboxes[k].classList.contains(category)){ checkboxes[k].checked = false; } } var domain = "dom" + dom_selected; for(var k = 0; k < checkboxes.length; k++){ if(!checkboxes[k].classList.contains(domain)){ checkboxes[k].checked = false; } } } jQuery("input:checkbox").hide(); } </script> <?php }
function edit_flashcardgame_settings_page() { $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css'; $game_id = filter_input(INPUT_POST, 'id'); $game = get_deck($game_id); $domains = get_domains(); $categories = get_word_categories(); $words = get_words(); //Will be empty if it's a copy or //Will have the id if it's an update $game_id_to_form = ""; if (isset($_GET['id']) && is_numeric($_GET['id'])) { $game = build_deck($_GET['id']); $deck_words = get_all_game_words_ids($_GET['id']); } $selected_words_ids = array(); for ($j = 0; $j < sizeof($deck_words); $j++) { $selected_words_ids[$j] = $deck_words[$j]->id; } ?> <link rel="stylesheet" type="text/css" href="<?php echo $semantic; ?> "/> <h2>Edit a Game!</h2> <hr> <style type="text/css"> #wpfooter{ display: none; } #file_input { border: 1px solid #cccccc; padding: 5px; } .new_pano_form{ width:85%; margin: 0px auto; } </style> <?php if (isset($_GET['settings-saved'])) { ?> <div class="updated"><p>Game updated successfully.</p></div> <?php } elseif (isset($_GET['error'])) { ?> <div class="error"><p>Error updating game.</p></div> <?php } ?> <form id="form" method="post" enctype="multipart/form-data" action="<?php echo get_admin_url() . 'admin-post.php'; ?> "> <!-- pano processing hook --> <input type="hidden" name="action" value="edit_flashcard" /> <?php if (isset($_GET['action']) && $_GET['action'] == "edit") { $game_id_to_form = $game->get_id(); } elseif (isset($_GET['action']) && $_GET['action'] == "copy") { $game_id_to_form = "copy"; } ?> <input type="hidden" name="game_id" value="<?php echo $game_id_to_form; ?> "/> <div class="ui form segment edit_word_form"> <div class="ui form"> <div class="field"> <div class="ui left labeled icon input"> <label for="game_name">Game Name: </label> <input name="game_name" id="name" value="<?php echo $game->get_name(); ?> " required /> </div> </div> </div> <div class="ui form"> <div class="field"> <div class="ui left labeled icon input"> <label for="game_number_of_words">Defined number of words to be guessed: </label> <input name="game_number_of_words" id="game_number_of_words" value="<?php echo $game->get_number_of_words(); ?> " required /> </div> </div> </div> <p class="error" id="words_error">* Number of words in the game can not be lower than words selected</p> <p class="error" id="not_enough_words">* Must select at least 6 words</p> <div class="ui form"> <div class="field"> <label for="category_id">Filter by</label> <select name="category_id" id="category_id"> <option value="NA">Select a Category</option> <?php foreach ($categories as $category) { ?> <option value="<?php echo $category->id; ?> "><?php echo $category->name; ?> </option> <?php } ?> </select> </div> </div> <div class="ui form"> <div class="field"> <ul> <?php foreach ($words as $word) { ?> <?php if (in_array($word->id, $selected_words_ids)) { ?> <li class="games_form"> <input type="checkbox" id="<?php echo $word->id; ?> " class="cat<?php echo $word->word_category_id; ?> " name="words[]" value="<?php echo $word->id; ?> " checked> <label for="<?php echo $word->id; ?> " class="cat<?php echo $word->word_category_id; ?> "><?php echo $word->word; ?> </label> </li> <?php } else { ?> <li class="games_form"> <input type="checkbox" id="<?php echo $word->id; ?> " class="cat<?php echo $word->word_category_id; ?> " name="words[]" value="<?php echo $word->id; ?> "> <label for="<?php echo $word->id; ?> " class="cat<?php echo $word->word_category_id; ?> "><?php echo $word->word; ?> </label> </li> <?php } ?> <?php } ?> </ul> </div> </div> <?php submit_button(); ?> </div> </form> </div> <script> jQuery('#form').submit(function(e){ user_selected_enough_words(e); }); jQuery('#game_number_of_words').change(function(){ document.getElementById("words_error").style.display = "none"; }); jQuery("input:checkbox").change(function(){ document.getElementById("words_error").style.display = "none"; }); jQuery("#category_id").change(function(){ filter_words(); }); function user_selected_enough_words(e){ var n = jQuery("input:checkbox:checked").length; var game_number_of_words = jQuery('#game_number_of_words').prop('value'); if(n < 6){ e.preventDefault(); document.getElementById("not_enough_words").style.display = "block"; document.getElementById("words_error").style.display = "none"; } else if(n < Number(game_number_of_words)){ e.preventDefault(); document.getElementById("words_error").style.display = "block"; document.getElementById("not_enough_words").style.display = "none"; }else{ document.getElementById("words_error").style.display = "none"; document.getElementById("not_enough_words").style.display = "none"; } } function filter_words(){ var selected = jQuery( "#category_id option:selected" ).val(); //jQuery("input:checkbox").hide(); //jQuery("label").hide(); if(!(selected == "NA")){ jQuery("label").hide(); var category = ".cat" + selected; jQuery(category).show(); jQuery("input:checkbox").hide(); }else{ jQuery("label").show(); jQuery("input:checkbox").hide(); } } </script> <?php }