Beispiel #1
0
function main_f()
{
    if (isset($_SERVER['HTTP_REFERER'])) {
        $ar = get_words($_SERVER['HTTP_REFERER']);
        connect();
        if (count($ar) > 0) {
            foreach (array_reverse($ar, true) as $key => $val) {
                $sres = sql("select picture, name from ln_product where name like '%" . $key . "%' and picture is not null order by rating desc limit 0,1");
                if ($ar_res = mysql_fetch_assoc($sres)) {
                    //write_log($key);
                    get_picture($ar_res['picture']);
                    break;
                }
            }
        }
        disconnect();
    }
}
Beispiel #2
0
function detect_lang($text)
{
    $languages = array();
    if ($dh = opendir("stop/")) {
        while (($file = readdir($dh)) !== false) {
            if (!is_dir("stop/" . $file) && $file != "." && $file != "..") {
                $languages[] = $file;
            }
        }
    }
    $stop_words = array();
    foreach ($languages as $language) {
        $gestor = @fopen("stop/{$language}", "r");
        if ($gestor) {
            while (($buffer = fgets($gestor, 4096)) !== false) {
                if (!isset($stop_words[$language])) {
                    $stop_words[$language] = $buffer;
                } else {
                    $stop_words[$language] .= " {$buffer}";
                }
            }
        }
    }
    $scores = array();
    $words = get_words($text);
    foreach ($words as $word) {
        //echo "$word<br>";
        foreach ($languages as $language) {
            if (strpos($stop_words[$language], $word) !== FALSE) {
                $scores[$language] += 1;
            }
        }
    }
    arsort($scores);
    //print_r($scores);
    return key($scores);
}
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 
}
Beispiel #4
0
function get_cartoon($id)
{
    global $mysql_hostname;
    global $mysql_user;
    global $mysql_password;
    global $mysql_database;
    global $original_tags;
    global $imagepath;
    $output = array();
    // array of associations to return
    $sql = "SELECT `wp_product_list`.image, `wp_product_list`.description, `wp_product_list`.name, `wp_product_list`.additional_description, `wp_product_brands`.`name` AS brand FROM `wp_product_list`, `wp_product_files`, `wp_product_brands` WHERE  `wp_product_list`.`file` = `wp_product_files`.`id` AND `wp_product_brands`.`id` = `wp_product_list`.`brand` AND `wp_product_list`.`id` = " . $id . " LIMIT 1";
    $link = mysql_connect($mysql_hostname, $mysql_user, $mysql_password);
    mysql_set_charset('utf8', $link);
    $result = mysql_query($sql);
    if (!$result) {
        die('Invalid query: ' . mysql_error());
    }
    $product = mysql_fetch_array($result);
    $original_tags = $product['additional_description'];
    $imagepath = "<img src='http://cartoonbank.ru/wp-content/plugins/wp-shopping-cart/product_images/" . $product['image'] . "'>";
    $_tags = nl2br(stripslashes($product['additional_description']));
    $_tags_array = explode(',', $_tags);
    foreach ($_tags_array as $key => $value) {
        $word = urlencode(trim($value));
        $out = get_words($word);
        // download array of associations
        if (count($out) > 36) {
            $out = array_slice($out, 37, 25);
            // trancate array to meaningfil words
            $output = array_merge($output, $out);
            // merge all association arrays
        }
    }
    //pokazh ($output);
    //unique
    $output = array_unique($output);
    return $output;
}
function word_settings_page()
{
    $words = get_words();
    $categories = get_word_categories();
    $domains = get_domains();
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $new_word_url = admin_url() . "admin.php?page=new_word_settings";
    $edit_word_url = admin_url() . "admin.php?page=edit_word_settings";
    ?>

    <!-- style sheet so our admin page looks nice -->
    <link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
    <p>Manage your words!</p>
    <hr>

    <?php 
    if (isset($_GET['settings-saved'])) {
        ?>
        <div class="updated"><p>Settings updated successfully.</p></div>
    <?php 
    }
    ?>

    <h2>Vocabulary</h2>

    <div class="ui form">
        <div class="field">
            <label for="filter">Filter the words 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>

    <table id="wordTable" class="ui table segment tablesorter">
        <thead>
        <tr>
            <th>Name</th>
            <th>Description</th>
            <th>Points</th>
            <th>Image</th>
            <th>Audio</th>
            <th>Edit</th>
            <th>Delete</th>
        </tr>
        </thead>

        <tbody>
        <?php 
    foreach ($words as $word) {
        ?>
            <?php 
        $current_word = build_words($word->id);
        ?>
            <tr>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><?php 
        echo $current_word->get_word();
        ?>
</td>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><?php 
        echo $current_word->get_description();
        ?>
</td>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><?php 
        echo $current_word->get_points();
        ?>
</td>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><?php 
        echo $current_word->get_image();
        ?>
</td>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><?php 
        echo $current_word->get_audio();
        ?>
</td>

                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
"><a class="ui blue icon button" href="<?php 
        echo $edit_word_url;
        ?>
&id=<?php 
        echo $current_word->get_id();
        ?>
" style="padding: 7px">Edit</a></td>
                <td class="dom_option cat_option dom<?php 
        echo $word->domain_id;
        ?>
 cat<?php 
        echo $word->word_category_id;
        ?>
">
                    <form method="post" action="admin-post.php" id="delete_word_form<?php 
        echo $current_word->get_id();
        ?>
">
                        <!-- word processing hook -->
                        <input type="hidden" name="action" value="delete_word" />
                        <input type="hidden" name="word_id" value="<?php 
        echo $current_word->get_id();
        ?>
" />

                        <input type="submit" class="ui blue icon button" value="Delete" style="padding: 7px" >
                    </form>
                </td>
            </tr>

        <?php 
    }
    ?>
        </tbody>
    </table>
    <a class="ui blue icon button" href="<?php 
    echo $new_word_url;
    ?>
" style="padding: 7px">New Word</a>

    <script>
        jQuery(document).ready(function(){
            jQuery("#wordTable").tablesorter();
        })

        jQuery("#category_id").change(function(){
            filter_words();
        });

        jQuery("#domain_id").change(function(){
            filter_words();
        });

        function validation()
        {

        }

        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 
}
Beispiel #6
0
	#jq-books h3{margin:0 0 .2em 0}
	#home-content-wrapper #jq-books h3 a{font-size:1em;color:black;}
	#home-content-wrapper #jq-books a.jq-buyNow{font-size:1em;color:white;display:block;background:url(http://static.jquery.com/files/rocker/images/btn_blueSheen.gif) 50% repeat-x;text-decoration:none;color:#fff;font-weight:bold;padding:.2em .8em;float:left;margin-top:.2em;}
	
	</style>

 
 </head>

 <body>

 <script>
	$(function() {
        <?php 
echo "var availableTags = [";
echo get_words();
echo "];";
?>
		
		$( "#tags" ).autocomplete({
			source: availableTags
		});
	});
	</script>

<?php 
function get_words()
{
    $url = 'http://cartoonbank.ru/ales/wordassociations/emotionslist.html';
    $contents = file_get_contents($url);
    $tag = "a";
Beispiel #7
0
    echo "<h3>" . $result[$i]["word"] . " " . "" . "(" . $pos["pos"] . ")" . "</h3>";
    echo "<div>";
    echo "<p>";
    echo $def["def"];
    echo "</p>";
    echo "</div>";
}
?>
  </div>

  </div>
  
    <div id ="z" class = "display">
	<div class="accordion">
	<?php 
$result = get_words("z");
$size = sizeof($result);
for ($i = 0; $i < $size; $i++) {
    //get row where definiton id = word foreign key
    $def = get_definition($result[$i]["did"]);
    //get corresponding pos to the defintion foreign key
    $pos = print_pos($def["pos"]);
    echo "<h3>" . $result[$i]["word"] . " " . "" . "(" . $pos["pos"] . ")" . "</h3>";
    echo "<div>";
    echo "<p>";
    echo $def["def"];
    echo "</p>";
    echo "</div>";
}
?>
  </div>
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 
}
<?php

include 'db_funtions.php';
echo 'Test';
$words = get_words();
echo "words";
//$game_words = get_all_game_words(1);
echo $words;
//echo $game_words;
//    compare_words(); // Return an array with words already on the game
//
//    create_inputs();
Beispiel #10
0
<?php

require_once 'incl/functions.php';
?>
<div>
<?php 
$result = get_words("a");
$size = sizeof($result);
for ($i = 0; $i < $size; $i++) {
    echo "<h3>" . $result[$i]["word"] . "</h3>";
    echo "<div>";
    echo "<p>";
    echo "hook";
    echo "</p>";
    echo "</div>";
}
?>
  </div>
Beispiel #11
0
function pb_add_comment($user_id)
{
    $current_date = date("F j, Y, g:i:s a");
    $comment = htmlify($_POST['comment']);
    $post_id = $_POST['post_id'];
    if (!isset($_POST['add_reveiw'])) {
        $post_owner = pb_table_data('pb_services', 'owner', "service_id='{$post_id}'");
    } else {
        $post_owner = pb_table_data('pb_post', 'user_id', "product_id='{$post_id}'");
    }
    if (pb_explicit($_POST['comment']) == 'true') {
        $status = 'flagged';
    } else {
        $status = 'open';
    }
    pb_notify($post_owner, $user_id, $post_id, 'Commented on', get_words($comment, 20), '/item?id=' . $post_id);
    return pb_db("INSERT INTO pb_comments (post_id, date, author, status, comment) VALUES ('{$post_id}', '{$current_date}','{$user_id}','{$status}', '{$comment}')");
}
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 
}
function new_hatplehgame_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $categories = get_word_categories();
    $domains = get_domains();
    $words = get_words();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create a new HatPlã game!</h2>
<hr>
<form method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <input type="hidden" name="action" value="create_new_hatgame" />
    <div class="ui form segment new_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" required />
     	 	</div>
	      </div>
	    </div>

        <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="word_image">Choose an image for winning the game: <b>(Preferably 120x120)</b></label>
	    		<input type="file" name="word_image" id="word_image" required/>
     	 	</div>
	      </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) {
        ?>
                <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 
    }
    ?>
            </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 new_flashcardgame_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $domains = get_domains();
    $categories = get_word_categories();
    $words = get_words();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create New Game!</h2>
<hr>
<style type="text/css">
	#domain_form{
	    display: none;
	    width: 80%;
	    margin: 0 auto;

	}
</style>
<form id="form" method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <input type="hidden" name="action" value="create_new_flashcard" />
    <div class="ui form segment new_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" 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" 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="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) {
        ?>
                <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 
    }
    ?>
            </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);
		});
	});

    function addForm() {
        document.getElementById("buttonDomain").style.display = "none";
        document.getElementById("domain_form").style.display = "block";
    }

    jQuery('#form').submit(function(e){
        user_selected_enough_words(e);
    });

    jQuery('#game_number_of_words').change(function(){
        document.getElementById("words_error").style.display = "none";
        document.getElementById("not_enough_words").style.display = "none";
    });

    jQuery("input:checkbox").change(function(){
       document.getElementById("words_error").style.display = "none";
       document.getElementById("not_enough_words").style.display = "none";
    });


    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";
        }

    }

    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 word_settings_page()
{
    $words = get_words();
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $new_word_url = admin_url() . "admin.php?page=new_word_settings";
    $edit_word_url = admin_url() . "admin.php?page=edit_word_settings";
    ?>

<!-- style sheet so our admin page looks nice -->
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<p>Manage your words fuuuuuuuu!</p>
<hr>

<?php 
    if (isset($_GET['settings-saved'])) {
        ?>
        <div class="updated"><p>Settings updated successfully.</p></div>
    <?php 
    }
    ?>

<!--<h2>Words</h2>-->
<!--<table id="wordTable" class="ui table segment tablesorter">-->
<!--    <thead>-->
<!--      <tr>-->
<!--        <th>Word FDP</th>-->
<!--        <th>Description</th>-->
<!--        <th>Image</th>-->
<!--        <th>Audio</th>-->
<!--        <th>Domain</th>-->
<!--        <th>Category</th>-->
<!--        <th>Edit</th>-->
<!--        <th>Delete</th>-->
<!--      </tr>-->
<!--    </thead>-->
<!---->
<!--    <tbody>-->
<!--        --><?php 
    //foreach ($words as $word):
    ?>
<!--        --><?php 
    //$current_word = build_word($word->word_id);
    ?>
<!--        <tr>-->
<!--            <td>--><?php 
    //echo $current_word->get_name()
    ?>
<!--</td>-->
<!--            <td>--><?php 
    //echo $current_word->get_description()
    ?>
<!--</td>-->
<!--            <td>--><?php 
    //echo $current_word->get_image()
    ?>
<!--</td>-->
<!--            <td>--><?php 
    //echo $current_word->get_audio()
    ?>
<!--</td>-->
<!--            <td>--><?php 
    //echo $current_word->get_domain_id()
    ?>
<!--</td>-->
<!--            <td>--><?php 
    //echo $current_word->get_word_category_id()
    ?>
<!--</td>-->
<!--            <td><a class="ui blue icon button" href="--><?php 
    //echo $edit_word_url
    ?>
<!--&id=--><?php 
    //echo $current_word->get_id()
    ?>
<!--" style="padding: 7px">Edit</a></td>-->
<!--            <td>-->
<!--                <form method="post" action="admin-post.php" id="delete_word_form--><?php 
    //echo $current_word->get_id()
    ?>
<!--">-->
<!--                    <!-- word processing hook -->-->
<!--                    <input type="hidden" name="action" value="delete_word" />-->
<!--                    <input type="hidden" name="word_id" value="--><?php 
    //echo $current_word->get_id()
    ?>
<!--" />-->
<!---->
<!--                    <input type="submit" class="ui blue icon button" value="Delete" style="padding: 7px" >-->
<!--                </form>-->
<!--            </td>-->
<!--        </tr>-->
<!--    --><?php 
    //endforeach;
    ?>
<!--    </tbody>-->
<!--</table>-->
<!--<a class="ui blue icon button" href="--><?php 
    //echo $new_word_url
    ?>
<!--" style="padding: 7px">New Word</a>-->


<h2>Panos</h2>
<table id="wordTable" class="ui table segment tablesorter">
    <thead>
      <tr>
          <th>Name</th>
          <th>Description</th>
          <th>Edit</th>
          <th>Delete</th>
      </tr>
    </thead>

    <tbody>
        <?php 
    foreach ($words as $word) {
        ?>

        <tr>
            <td><?php 
        echo $word->name;
        ?>
</td>
            <td><?php 
        echo $word->description;
        ?>
</td>
            <td><a class="ui blue icon button" href="<?php 
        echo $edit_word_url;
        ?>
&id=<?php 
        echo $word->word_id;
        ?>
" style="padding: 7px">Edit</a></td>
            <td>
                <form method="post" action="admin-post.php" id="delete_word_form<?php 
        echo $word->word_id;
        ?>
">
                    <!-- word processing hook -->
                    <input type="hidden" name="action" value="delete_word" />
                    <input type="hidden" name="word_id" value="<?php 
        echo $word->word_id;
        ?>
" />

                    <input type="submit" class="ui blue icon button" value="Delete" style="padding: 7px" >
                </form>
            </td>
        </tr>

    <?php 
    }
    ?>
    </tbody>
</table>
<a class="ui blue icon button" href="<?php 
    echo $new_word_url;
    ?>
" style="padding: 7px">New Pano</a>

<script>
    jQuery(document).ready(function(){
        jQuery("#wordTable").tablesorter();
    })
</script>

<?php 
}
Beispiel #16
0
require_once '_csv_common.php';
/**
 * POSTの格納
 * @var [type]
 */
foreach ($_POST as $key => $value) {
    $tmp = $value;
    ${$key} = $tmp;
}
$data_flg = false;
$day = $m . $d;
$new_data = array();
$filename = './data/' . $m . '.csv';
//csvと該当日の内容の取得
$data = get_csv($filename);
$words = get_words($data, $day);
//csvの走査
//日付既存の場合
foreach ($data as $key => $value) {
    if ($value[0] === $day) {
        $texts = str_replace(array("\r\n", "\r", "\n"), "\n", $texts);
        //改行コードの統一
        $value = explode("\n", $day . "\n" . $texts);
        $new_data[] = $value;
        $data_flg = true;
        continue;
    }
    $new_data[] = $value;
}
//日付新規の場合
if (!$data_flg) {
Beispiel #17
0
        get_words($sql, "pn_name", "3");
        $sql = "select * from pn_rx_preserve\n\t\twhere lower(pn_name) like " . db_escape("%{$q}%");
        get_words($sql, "pn_name", "3");
    }
    if (!$db) {
        mysql_select_db('eyedock_data', $conn);
        $sql = 'select l.name as lens_name 
		from 
		rgpLenses l 
		where l.name like ' . db_escape("%{$q}%") . ' order by lens_name asc';
        get_words($sql, 'lens_name', '4');
        $sql = 'select m.name as material_name 
		from 
		rgpMaterials m 
		where m.name like ' . db_escape("%{$q}%") . ' order by m.name asc';
        get_words($sql, 'material_name', '5');
    }
    if ($arr) {
        ksort($arr);
        /* Get rid of beginning and trailing non-alphanumeric characters */
        $_arr = array_values($arr);
        foreach ($_arr as $k => $v) {
            if (strpos($v, '|')) {
                list($tmp1, $tmp2) = explode('|', $v);
                while (preg_match('/^[^\\d\\w]/', $tmp1)) {
                    $tmp1 = preg_replace('/^[^\\d\\w]/', '', $tmp1);
                }
                while (preg_match('/[^\\d\\w]$/', $tmp1)) {
                    $tmp1 = preg_replace('/[^\\d\\w]$/', '', $tmp1);
                }
                $_arr[$k] = $tmp1 . '|' . $tmp2;
function new_spotgame_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/vocabulary-plugin/css/semantic.css';
    $decks = get_decks('flashcard');
    $deck_words = get_deck_words('');
    $domains = get_domains();
    $categories = get_word_categories();
    $words = get_words();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create New Game!</h2>
<hr>

<form id="form" method="post" enctype="multipart/form-data" action="<?php 
    echo get_admin_url() . 'admin-post.php';
    ?>
">
    <input type="hidden" name="action" value="create_new_spotgame" />
    <div class="ui form segment new_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">Create a question to display in the game: </label>
	    		<input name="game_name" id="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>Word to be guessed:</label>
	        <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) {
        ?>
                <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 
    }
    ?>
            </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);
		});
	});

    function addForm() {
        document.getElementById("buttonDomain").style.display = "none";
        document.getElementById("domain_form").style.display = "block";
    }

    jQuery('#form').submit(function(e){
        user_selected_enough_words(e);
    });

    jQuery('#game_number_of_words').change(function(){
        document.getElementById("words_error").style.display = "none";
        document.getElementById("not_enough_words").style.display = "none";
    });

    jQuery("input:checkbox").change(function(){
       document.getElementById("words_error").style.display = "none";
       document.getElementById("not_enough_words").style.display = "none";
    });


    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";
        }

    }

    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();

        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();


    }

//    function filter_words(){
//
//        var selected        = jQuery( "#category_id option:selected" ).val();
//        var checkboxes = jQuery("input:checkbox");
//
//        if(!(selected == "NA")){
//            jQuery("label").hide();
//            var category = ".cat" + selected;
//
//            jQuery(category).show();
//            jQuery("input:checkbox").hide();
//
//            var category_selected = "";
//
//            for(var k = 0; k < checkboxes.length; k++){
//                category_selected = "." + checkboxes[k].className;
//                if(category_selected != category){
//                   checkboxes[k].checked = false;
//                }
//            }
//        }else{
//            jQuery("label").show();
//            jQuery("input:checkbox").hide();
//        }
//
//    }


</script>
<?php 
}
Beispiel #19
0
    return $result;
}
// get a pick of numbers
function get_numbers($count)
{
    echo $cound;
    $possible = "0123456789";
    $result = substr(str_shuffle($possible), 0, $count);
    return $result;
}
// set up default response
$password = null;
$data = array('success' => false, 'result' => $password);
$settings = array('wordCount' => $_POST['wordCount'] ? (int) $_POST['wordCount'] : WORD_COUNT, 'numbersCount' => $_POST['numbersCount'], 'specialCharactersCount' => $_POST['specialCharactersCount'] ? (int) $_POST['specialCharactersCount'] : SPECIAL_CHARACTERS_COUNT, 'includeHyphens' => $_POST['includeHyphens'], 'caseSelection' => $_POST['caseSelection'] ? $_POST['caseSelection'] : CASE_SELECTION);
// get raw words picked based on setting
$words = get_words($settings['wordCount']);
// build special chars selection
if ($settings['specialCharactersCount']) {
    $specialChars = get_special_chars($settings['specialCharactersCount']);
} else {
    $specialChars = "";
}
// get random numbers
if ($settings['numbersCount']) {
    $numbers = get_numbers($settings['numbersCount']);
} else {
    $numbers = "";
}
// upper or lower case the words
$words = array_flip($words);
if ($settings['caseSelection'] == "lower") {