コード例 #1
0
function prereq_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $new_prereq_url = admin_url() . "admin.php?page=prereq_new_setting";
    $edit_prereq_url = admin_url() . "admin.php?page=prereq_edit_setting";
    $pano_id = null;
    if (isset($_GET['pano_id']) && is_numeric($_GET['pano_id'])) {
        $pano_id = $_GET['pano_id'];
    }
    $prereqs = get_pano_prereq($pano_id);
    ?>
    <link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
    <h2>Create a new prereq!</h2>
    <hr>
    <?php 
    if (isset($_GET['settings-saved'])) {
        ?>
        <div class="updated"><p>Settings updated successfully.</p></div>
    <?php 
    }
    ?>
    <table class="ui table segment">
      <tr>
        <th>Prereq Points</th>
        <th>Prereq Domain</th>
        <th>Prereq Info</th>
        <th>Prereq Item Qty</th>
        <th>Edit</th>
        <th>Delete</th>
      </tr>
      <?php 
    foreach ($prereqs as $prereq) {
        ?>

            <?php 
        $domain = get_domain($prereq->prereq_domain_id);
        ?>

            <tr>
                <td><?php 
        echo $prereq->prereq_pts;
        ?>
</td>
                <td><?php 
        echo $domain->name;
        ?>
</td>
                <td><?php 
        echo $prereq->prereq_desc;
        ?>
</td>
                <td><?php 
        echo count(get_prereq_items($prereq->id));
        ?>
</td>
                <td><a class="ui blue icon button" href="<?php 
        echo $edit_prereq_url;
        ?>
&id=<?php 
        echo $prereq->id;
        ?>
" style="padding: 7px">Edit</a></td>
                <td>
                    <form method="post" action="admin-post.php" id="delete_prereq_form<?php 
        echo $prereq->id;
        ?>
">
                        <!-- pano processing hook -->
                        <input type="hidden" name="action" value="delete_prereq" />
                        <input type="hidden" name="pano_id" value="<?php 
        echo $pano_id;
        ?>
" />
                        <input type="hidden" name="prereq_id" value="<?php 
        echo $prereq->id;
        ?>
" />

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

        <?php 
    }
    ?>
    </table>
    <a class="ui blue icon button" href="<?php 
    echo $new_prereq_url;
    ?>
&pano_id=<?php 
    echo $pano_id;
    ?>
" style="padding: 7px">New Prereq</a>
    </div>

    <script>
        jQuery(document).ready(function(){
        });
    </script>

<?php 
}
コード例 #2
0
function get_pano_prereqs($pano_id)
{
    $prereq = get_pano_prereq($pano_id);
    return $prereq;
}
コード例 #3
0
 function build_prereqs()
 {
     return $this->prereqs = get_pano_prereq($this->id);
 }
コード例 #4
0
function prereq_edit_settings_page()
{
    $semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
    $domains = get_domains();
    $items = get_items();
    $item_types = get_item_types();
    $prereq = null;
    $prereq_id = null;
    if (isset($_GET['pano_id']) && is_numeric($_GET['pano_id'])) {
        $prereq = get_pano_prereq($_GET['pano_id']);
        $prereq_id = $prereq->id;
    }
    $prereq_items = get_prereq_items($prereq_id);
    $selected_items = array();
    foreach ($prereq_items as $selected_item) {
        array_push($selected_items, $selected_item->item_id);
    }
    ?>
<link rel="stylesheet" type="text/css" href="<?php 
    echo $semantic;
    ?>
"/>
<h2>Edit your Prereqs!</h2>
<hr>

<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_prereq" />
  <input type="hidden" name="id" value="<?php 
    echo $prereq->id;
    ?>
" />
  <input type="hidden" name="pano_id" value="<?php 
    echo $prereq->pano_id;
    ?>
" />
  <div class="ui form segment new_prereq_form">
    <div class="ui form">
      <div class="field">
        <label for="prereq_pts">Prereq Points</label>
        <input type="number" name="prereq_pts" id="prereq_pts" placeholder="100" value="<?php 
    echo $prereq->prereq_pts;
    ?>
"required />
      </div>
    </div>
    <input type="hidden" name="prereq_domain_id" value="NA" />
    <div class="ui form">
      <div class="field">
        <label for="prereq_desc">Prereq Info</label>
        <textarea name="prereq_desc" id="prereq_desc" required ><?php 
    echo $prereq->prereq_desc;
    ?>
</textarea>
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label for="item_type">Filter by Item Type</label>
        <select name="item_type" id="item_type" class="ui dropdown">
          <option value="NA">All items</option>
          <?php 
    foreach ($item_types as $item_type) {
        ?>
          <option value="<?php 
        echo $item_type->id;
        ?>
"><?php 
        echo $item_type->name;
        ?>
</option>
          <?php 
    }
    ?>
        </select>
      </div>
    </div>
    <div class="ui form">
      <div class="field">
        <label>Items<span id="item_limit"> - maximum of 5 items</span></label>
        <ul>
          <?php 
    foreach ($items as $item) {
        ?>
            <?php 
        if (in_array($item->id, $selected_items)) {
            ?>
            <li class="games_form item <?php 
            echo $item->type_id;
            ?>
">
              <input type="checkbox" id="<?php 
            echo $item->id;
            ?>
" name="items[]" value="<?php 
            echo $item->id;
            ?>
" checked>
              <label for="<?php 
            echo $item->id;
            ?>
"><?php 
            echo $item->name;
            ?>
</label>
            </li>
            <?php 
        } else {
            ?>
            <li class="games_form item <?php 
            echo $item->type_id;
            ?>
">
              <input type="checkbox" id="<?php 
            echo $item->id;
            ?>
" name="items[]" value="<?php 
            echo $item->id;
            ?>
">
              <label for="<?php 
            echo $item->id;
            ?>
"><?php 
            echo $item->name;
            ?>
</label>
            </li>
            <?php 
        }
        ?>
          <?php 
    }
    ?>
        </ul>
      </div>
    </div>
    <?php 
    submit_button();
    ?>
  </div>
</form>
<script type="text/javascript">
  // Hiding error message
  jQuery('#item_limit').hide();

  // Event listener
  jQuery('#item_type').change(function(){
    filterTypes();
  });
  jQuery(':checkbox').change(function(){
    restrictItems();
  });
  jQuery('#form').submit(function(e){
    if(!restrictItems()){
      e.preventDefault();
    }
  });

  // Filters items based on user selection of item type.
  function filterTypes(){
    if(jQuery('#item_type').val() == 'NA'){
      jQuery('.item').each(function(){
        jQuery(this).show();
      });
    } else {
      var typeId = jQuery('#item_type').val();
      jQuery('.item').each(function(){
        jQuery(this).hide();
      });
      jQuery('.item').each(function(){
        jQuery('.' + typeId).each(function(){
          jQuery(this).show();
        });
      });
    }
  }

  // Displays a message if user picks more than [qty] items.
  // Prevents form submission if user picks more than [qty] items.
  function restrictItems(){
    var qty = 5;
    var allowSend = false;
    if(jQuery(':checkbox:checked').length > qty){
      jQuery('#item_limit').show();
      jQuery('#item_limit').css({'color': 'red', 'font-weight': 'bold'});
      allowSend = false;
    } else {
      jQuery('#item_limit').hide();
      allowSend = true;
    }
    return allowSend;
  }
</script>
<?php 
}
コード例 #5
0
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 
}
コード例 #6
0
<?php

require_once '../../../../wp-config.php';
require_once '../../../../wp-includes/wp-db.php';
require_once '../../../../wp-includes/pluggable.php';
$semantic = WP_PLUGIN_URL . '/panomanager/css/semantic.css';
$pano_id = $_GET['pano_id'];
$prereq = get_pano_prereq($pano_id);
$currency = get_points_symbol();
$items = get_prereq_items($prereq->id);
$user_id = get_current_user_id();
$items_size = sizeof($items);
?>


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
    <link rel="stylesheet" type="text/css" href="<?php 
echo $semantic;
?>
"/>
</head>
<body>
<h1>Pano Requirements</h1>
<p><?php 
echo "To access this pano you need:";
?>
</p>