function edit_mission_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $panos = get_panos();
    $domains = get_domains();
    $mission = null;
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $mission = build_mission($_GET['id']);
    }
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Edit a quest!</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>Mission updated successfully.</p></div>
<?php 
    } elseif (isset($_GET['error'])) {
        ?>
    <div class="error"><p>Error updating mission.</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_mission" />
    <input type="hidden" name="mission_id" value="<?php 
    echo $mission->get_id();
    ?>
" />
    <input type="hidden" name="quest_id" id="quest_id" value="<?php 
    echo $mission->get_quest_id();
    ?>
" />
	    <div class="ui form">
	      <div class="field">
	        <label for="pano_id">Select a Pano</label>
	        <select name="pano_id" id="pano_id">
                 <?php 
    foreach ($panos as $pano) {
        ?>
					<option value="<?php 
        echo $pano->id;
        ?>
" data-quest-id="<?php 
        echo $pano->quest_id;
        ?>
" <?php 
        echo $pano->id === $mission->get_pano_id() ? "selected" : "";
        ?>
><?php 
        echo $pano->name;
        ?>
</option>
				 <?php 
    }
    ?>
            </select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="prereq_domain_id">Select a domain</label>
	        <select name="domain_id">
				 <option value="NA">...</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
					<option value="<?php 
        echo $domain->id;
        ?>
" <?php 
        echo $domain->id === $mission->get_domain_id() ? "selected" : "";
        ?>
><?php 
        echo $domain->name;
        ?>
</option>
				 <?php 
    }
    ?>
			</select>
	      </div>
	    </div>
    <div class="ui form segment new_pano_form">
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="misison_name">Mission Name</label>
	    		<input name="mission_name" id="name" placeholder="Fun Mission" value="<?php 
    echo $mission->get_name();
    ?>
" required />
     	 	</div>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="misison_description">Mission Info</label>
	        <textarea name="mission_description" required ><?php 
    echo $mission->get_description();
    ?>
</textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="mission_xml">Mission XML</label>
	        <textarea name="mission_xml" required ><?php 
    echo $mission->get_xml();
    ?>
</textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="mission_points">Assign Points</label>
	    		<input type="number" name="mission_points" id="mission_points" placeholder="100" value="<?php 
    echo $mission->get_points();
    ?>
" required />
     	 	</div>
	      </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);
		});
	});
</script>
<?php 
}
function new_quest_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $panos = get_panos();
    $domains = get_domains();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create a new pano!</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>
<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="create_new_quest" />
    <div class="ui form segment new_pano_form">
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="quest_name">Quest Name</label>
	    		<input name="quest_name" id="name" placeholder="Fun Quest" required />
     	 	</div>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="quest_description">Quest Description</label>
	        <textarea name="quest_description" required ></textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="pano_id">Select a Pano</label>
	        <select name="pano_id">
                 <?php 
    foreach ($panos as $pano) {
        ?>
                     <option value="<?php 
        echo $pano->id;
        ?>
"><?php 
        echo $pano->name;
        ?>
</option>
                 <?php 
    }
    ?>
            </select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="domain_id">Select a Domain</label>
	        <select name="domain_id">
                 <?php 
    foreach ($domains as $domain) {
        ?>
					<option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
				 <?php 
    }
    ?>
			</select>
	      </div>
	    </div>
	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>
<?php 
}
function pano_settings_page()
{
    $panos = get_panos();
    // Create urls
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $new_pano_url = admin_url() . "admin.php?page=new_pano_settings";
    $edit_pano_url = admin_url() . "admin.php?page=edit_pano_settings";
    ?>

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

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

<h2>Panos</h2>
<table id="panoTable" class="ui table segment tablesorter">
  <thead>
    <tr>
      <th>Pano Title</th>
      <th>Pano Info</th>
      <th>Prereq Points</th>
      <th>Edit</th>
      <th>Delete</th>
    </tr>
  </thead>
  <tbody>
    <?php 
    foreach ($panos as $pano) {
        ?>
    <?php 
        $prereq = get_pano_prereq($pano->id);
        ?>
    <tr>
      <td><?php 
        echo $pano->title;
        ?>
</td>
      <td><?php 
        echo $pano->description;
        ?>
</td>
      <td><?php 
        echo $prereq->prereq_pts;
        ?>
</td>
      <td><a class="ui blue icon button" href="<?php 
        echo $edit_pano_url;
        ?>
&id=<?php 
        echo $pano->pano_id;
        ?>
" style="padding: 7px">Edit</a></td>
      <td>
        <form method="post" action="admin-post.php" id="delete_pano_form<?php 
        echo $pano->pano_id;
        ?>
">
          <!-- pano processing hook -->
          <input type="hidden" name="action" value="delete_pano" />
          <input type="hidden" name="pano_id" value="<?php 
        echo $pano->pano_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_pano_url;
    ?>
" style="padding: 7px">New Pano</a>
<script>
jQuery(document).ready(function(){
  jQuery("#panoTable").tablesorter();
})
</script>

<?php 
}
function edit_quest_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $panos = get_panos();
    $domains = get_domains();
    $quest = null;
    if (isset($_GET['id']) && is_numeric($_GET['id'])) {
        $quest = build_quest($_GET['id']);
    }
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Edit a quest!</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>Quest updated successfully.</p></div>
<?php 
    } elseif (isset($_GET['error'])) {
        ?>
    <div class="error"><p>Error updating quest.</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_quest" />
    <input type="hidden" name="quest_id" value="<?php 
    echo $quest->get_id();
    ?>
" />
    <div class="ui form segment new_pano_form">
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="quest_name">Quest Name</label>
	    		<input name="quest_name" id="name" placeholder="Fun Quest" value="<?php 
    echo $quest->get_name();
    ?>
" required />
     	 	</div>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="quest_description">Quest Description</label>
	        <textarea name="quest_description" required ><?php 
    echo $quest->get_description();
    ?>
</textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="pano_id">Select a Pano</label>
	        <select name="pano_id">
                 <?php 
    foreach ($panos as $pano) {
        ?>
                    <option value="<?php 
        echo $pano->id;
        ?>
" <?php 
        echo $pano->id === $quest->get_pano_id() ? "selected" : "";
        ?>
><?php 
        echo $pano->name;
        ?>
</option>
                <?php 
    }
    ?>
            </select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="prereq_domain_id">Select a Domain</label>
	        <select name="prereq_domain_id">
                 <?php 
    foreach ($domains as $domain) {
        ?>
					 <option value="<?php 
        echo $domain->id;
        ?>
" <?php 
        echo $domain->id === $quest->get_domain_id() ? "selected" : "";
        ?>
><?php 
        echo $domain->name;
        ?>
</option>
				 <?php 
    }
    ?>
			</select>
	      </div>
	    </div>
	    <?php 
    submit_button();
    ?>
	</div>
</form>
</div>
<?php 
}
function new_mission_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $panos = get_panos();
    $domains = get_domains();
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Create a new pano!</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>
<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="create_new_mission" />
    <input type="hidden" name="quest_id" id="quest_id" value="<?php 
    echo $panos[0]->quest_id;
    ?>
" />
    <div class="ui form segment new_mission_form">
	    <div class="ui form">
	      <div class="field">
	        <label for="pano_id">Select a Pano</label>
	        <select id="pano_id" name="pano_id">
                 <?php 
    foreach ($panos as $pano) {
        ?>
					<option value="<?php 
        echo $pano->id;
        ?>
" data-quest-id="<?php 
        echo $pano->quest_id;
        ?>
"><?php 
        echo $pano->name;
        ?>
</option>
				 <?php 
    }
    ?>
            </select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="domain_id">Select a Domain</label>
	        <select name="domain_id">
				 <option value="NA">...</option>
                 <?php 
    foreach ($domains as $domain) {
        ?>
					<option value="<?php 
        echo $domain->id;
        ?>
"><?php 
        echo $domain->name;
        ?>
</option>
				 <?php 
    }
    ?>
			</select>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="mission_name">Mission Name</label>
	    		<input type="text" name="mission_name" id="name" placeholder="Fun Mission" required />
     	 	</div>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="mission_description">Mission Description</label>
	        <textarea name="mission_description" required ></textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	        <label for="mission_xml">Mission XML</label>
	        <textarea name="mission_xml" required ></textarea>
	      </div>
	    </div>
	    <div class="ui form">
	      <div class="field">
	      	<div class="ui left labeled icon input">
	        	<label for="mission_points">Assign Points</label>
	    		<input type="number" name="mission_points" id="mission_points" placeholder="100" required />
     	 	</div>
	      </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);
		});
	});
</script>
<?php 
}
Пример #6
0
function pano_hotspot_settings_page()
{
    $hotspots = get_hotspots();
    $panos = get_panos();
    $types = get_types();
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $hotspot_types = admin_url() . "admin.php?page=pano_hotspot_type_settings";
    $new_hotspot_url = admin_url() . "admin.php?page=new_hotspot_settings";
    $edit_hotspot_url = admin_url() . "admin.php?page=edit_hotspot_settings";
    $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;
    ?>
"/>
<hr>

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

<div>
    <h2>Hotspots</h2>
    <p>Filter hotspots by:</p>
    <label>Pano </label>
    <select id="pano_select">
        <option value="NA">Select a pano</option>
        <?php 
    foreach ($panos as $pano) {
        ?>
            <option value="<?php 
        echo $pano->id;
        ?>
"><?php 
        echo $pano->title;
        ?>
</option>
        <?php 
    }
    ?>
    </select>

    <label>Hotspot Type </label>
    <select id="type_select">
        <option value="NA">Select a type</option>
        <?php 
    foreach ($types as $type) {
        ?>
            <option value="<?php 
        echo $type->id;
        ?>
"><?php 
        echo $type->name;
        ?>
</option>
        <?php 
    }
    ?>
    </select>
</div>
<table id="hostpotTable" class="ui table segment tablesorter">
    <thead>
      <tr>
        <th>Pano</th>
        <th>Hotspot</th>
        <th>Menu Name</th>
        <th>Hotspot Info</th>
        <th>Points</th>
        <th>Attempts</th>
        <th>Type</th>
        <th>Edit</th>
        <th>Delete</th>
      </tr>
    </thead>

    <tbody>
        <?php 
    foreach ($hotspots as $hotspot) {
        ?>
            <?php 
        $current_hotspot = build_hotspot($hotspot->id);
        ?>
            <tr class="hotspot pano<?php 
        echo $hotspot->pano_id;
        ?>
 type<?php 
        echo $hotspot->type_id;
        ?>
">
                <td><?php 
        echo get_pano($hotspot->pano_id)->title;
        ?>
</td>
                <td><?php 
        echo $current_hotspot->get_name();
        ?>
</td>
                <td><?php 
        echo $current_hotspot->get_menu_name();
        ?>
</td>
                <td><?php 
        echo substr($current_hotspot->get_hotspot_info(), 0, 20) . "...";
        ?>
</td>
                <td><?php 
        echo $current_hotspot->get_points();
        ?>
</td>
                <td><?php 
        echo $current_hotspot->get_attempts();
        ?>
</td>
                <td><?php 
        echo $current_hotspot->get_type_name();
        ?>
</td>
                <td><a class="ui blue icon button" href="<?php 
        echo $edit_hotspot_url;
        ?>
&id=<?php 
        echo $current_hotspot->get_id();
        ?>
" style="padding: 7px">Edit</a></td>
                <td>
                    <form method="post" action="admin-post.php" id="delete_hotspot_form<?php 
        echo $current_hotspot->get_id();
        ?>
">
                        <!-- pano processing hook -->
                        <input type="hidden" name="action" value="delete_hotspot" />
                        <input type="hidden" name="hotspot_id" value="<?php 
        echo $current_hotspot->get_id();
        ?>
" />

                        <input type="submit" class="ui blue icon button" value="Delete" style="padding: 7px" >
                    </form>
                </td>
            </tr>
        <?php 
    }
    ?>
    </tbody>
</table>
<form method="POST" action="<?php 
    echo $pano_editor;
    ?>
&">
    <!-- word processing hook -->
    <input type="submit" class="ui blue icon button" value="Create Hotspot" style="padding: 7px;" />
</form>
<br/>

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


        jQuery("#pano_select").change( function() {
            filter_hotspots();
        });

        jQuery("#type_select").change( function(){
            filter_hotspots();
        });

        function filter_hotspots() {
            var pano = jQuery("#pano_select").prop("value");

            var type = jQuery("#type_select").prop("value");


            if (pano == "NA" && type == "NA") {
                jQuery(".hotspot").show();
            } else if (pano == "NA" && type != "NA") {
                jQuery(".hotspot").hide();
                jQuery(".type" + type).show();
            } else if (pano != "NA" && type == "NA") {
                jQuery(".hotspot").hide();
                jQuery(".pano" + pano).show();
            } else {
                jQuery(".hotspot").hide();
                jQuery(".pano" + pano + ".type" + type).show();
            }
        }
    })
</script>


<?php 
}