コード例 #1
0
<?php

/**
 * Created by IntelliJ IDEA.
 * User: Tyler
 * Date: 8/7/2015
 * Time: 7:02 PM
 */
require_once "../SQLUtil.php";
require_once "../objects/ArgumentOption.php";
$json = null;
$args = ArgumentOption::getAllArgumentOptions();
if ($args != false) {
    $json = array('data' => $args);
} else {
    $json = "Error getting all arguments.";
}
echo json_encode($json);
コード例 #2
0
 public function getCommandList()
 {
     $commandStructure = array();
     $commands = Command::getAllCommands();
     $arguments = Argument::getAllArguments();
     $commandOptions = CommandOption::getAllCommandOptions();
     $argumentOptions = ArgumentOption::getAllArgumentOptions();
     foreach ($commands as $cmd) {
         $tier1Args = array();
         $tier2Args = array();
         //            $tier3Args = array();
         $cmdOpts = array();
         $argOpts = array();
         foreach ($arguments as $arg) {
             if ($arg["command_name"] == $cmd["name"]) {
                 foreach ($argumentOptions as $argOpt) {
                     if ($argOpt["argument_id"] == $arg["argument_id"]) {
                         array_push($argOpts, array("option_id" => $argOpt["argument_option_id"], "option" => $argOpt["argument_option_name"], "option_short" => $argOpt["argument_option_short_name"], "argument_id" => $argOpt["argument_id"]));
                     }
                 }
                 if ($arg["requires_option"] == 0) {
                     $needsOp = false;
                 } else {
                     $needsOp = true;
                 }
                 if ($arg["argument_tier"] == 1) {
                     array_push($tier1Args, array("argument_id" => $arg["argument_id"], "argument" => $arg["argument_name"], "command_name" => $arg["command_name"], "has_child" => $arg["requires_argument_child"] == '0' ? false : true, "options" => $argOpts, "requires_option" => $needsOp, "user_defined" => $arg["user_defined"] == '0' ? false : true, "tier" => 1));
                 } else {
                     if ($arg["argument_tier"] == 2) {
                         array_push($tier2Args, array("argument_id" => $arg["argument_id"], "argument" => $arg["argument_name"], "argument_parent_id" => $arg["argument_parent"], "has_child" => $arg["requires_argument_child"] == '0' ? false : true, "options" => $argOpts, "requires_option" => $needsOp, "user_defined" => $arg["user_defined"] == '0' ? false : true, "tier" => 2));
                     }
                 }
                 //                    else if($arg["argument_tier"] == 3)
                 //                    {
                 //                        array_push($tier3Args, array(
                 //                            "argument_id" => $arg["argument_id"],
                 //                            "argument" => $arg["argument_name"],
                 //                            "argument_parent_id" => $arg["argument_parent"],
                 //                            "argument_parent" => $arg["command_name"],
                 //                            "has_child" => $arg["requires_argument_child"] == '0' ? false : true,
                 //                            "options" => $argOpts,
                 //                            "requires_option" => $needsOp
                 //                        ));
                 //                    }
                 $argOpts = array();
             }
         }
         foreach ($commandOptions as $cmdOpt) {
             if ($cmdOpt["command_name"] == $cmd["name"]) {
                 array_push($cmdOpts, array("option_id" => $cmdOpt["command_option_id"], "option" => $cmdOpt["command_option_name"], "option_short" => $cmdOpt["command_option_short_name"]));
             }
         }
         if ($cmd["requires_option"] == 0) {
             $needsOp = false;
         } else {
             $needsOp = true;
         }
         array_push($commandStructure, array("command_id" => $cmd["id"], "command" => $cmd["name"], "tier1_arguments" => $tier1Args, "tier2_arguments" => $tier2Args, "options" => $cmdOpts, "requires_option" => $needsOp));
     }
     return $commandStructure;
 }