function load_pano($pano_id) { $id = $pano_id; // Check if the user is aloud to see it if (check_user_progress($pano_id)) { // Make sure the pano exists before trying to load it $id = check_pano_id($pano_id); } else { //TODO I'd suggest to break the code here, return a error page with redirection. } $pano = build_pano($pano_id); $quest = build_quest($id); $javascript = build_pano_javascript($pano_id, $pano, $quest); return $javascript; }
function build_pano_xml($pano_id) { // Create the actual pano object from the database $pano = build_pano($pano_id); $quest = build_quest($pano->get_id()); // Get XML $main_xml = xml_middle_man($pano); // Create object $pano_xml_obj = build_simple_xml_obj($main_xml); // Fix reference links $fixed_xml_object = fix_references($pano_id, $pano_xml_obj); // Add the nodes $xmk_obj_with_nodes = add_pano_hotspots($fixed_xml_object, $quest, $pano_id); // turn object back into XML $new_xml = $xmk_obj_with_nodes->saveXML(); // Output XML spit_out_xml($new_xml); }
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 }