示例#1
0
 public function action_index()
 {
     \Fuel\Core\Module::load('basic');
     $val = \Validation::forge();
     $val->add_field('cat', 'Category', 'required|min_length[1]|max_length[20]');
     $id = \Input::post('id');
     $data = array('data' => array(), 'group' => array(), 'test' => array(), 'record' => array());
     if ($val->run()) {
         switch ($val->validated('cat')) {
             case 'group':
                 // get groups
                 $group = \Debugger\Model_Group::find($id);
                 $group_data = array('id' => $group->id, 'name' => $group->name, 'description' => $group->description, 'tests' => array());
                 array_push($data['group'], $group_data);
                 break;
             case 'test':
                 // get tests
                 $test = \Debugger\Model_Test::find($id);
                 $test_data = array('id' => $test->id, 'name' => $test->name, 'description' => $test->description, 'group_id' => $test->group_id, 'priority' => $test->priority, 'records' => array());
                 array_push($data['test'], $test_data);
                 break;
             case 'record':
                 // get records
                 $records = \Debugger\Model_Record::find($id);
                 $record_data = array('id' => $record->id, 'type' => $record->type, 'object' => $record->object, 'action' => $record->action, 'test_id' => $record->test_id);
                 array_push($data['record'], $record_data);
                 break;
             case 'all':
                 // get groups
                 $groups = \Debugger\Model_Group::find()->get();
                 foreach ($groups as $group) {
                     $group_data = array('id' => $group->id, 'name' => $group->name, 'description' => $group->description, 'tests' => array());
                     // get tests
                     $tests = \Debugger\Model_Test::find()->where('group_id', $group->id)->get();
                     foreach ($tests as $test) {
                         $test_data = array('id' => $test->id, 'name' => $test->name, 'description' => $test->description, 'priority' => $test->priority, 'group_id' => $test->group_id, 'records' => array());
                         // get records
                         $records = \Debugger\Model_Record::find()->where('test_id', $test->id)->get();
                         foreach ($records as $record) {
                             array_push($test_data['records'], array('id' => $record->id, 'type' => $record->type, 'object' => $record->object, 'action' => $record->action, 'test_id' => $record->test_id));
                         }
                         array_push($group_data['tests'], $test_data);
                     }
                     array_push($data['data'], $group_data);
                 }
                 break;
         }
     }
     echo json_encode($data);
 }
示例#2
0
 public function action_index()
 {
     if ($_POST) {
         $val = \Validation::forge();
         $val->add_field('id', 'Object id', 'required|min_length[1]|max_length[20]');
         $val->add_field('cat', 'Category', 'required|min_length[1]|max_length[20]');
         if ($val->run()) {
             $data = array('group' => array(), 'test' => array(), 'record' => array());
             $cat = $val->validated('cat');
             $id = $val->validated('id');
             switch ($cat) {
                 case 'group':
                     $group = \Debugger\Model_Group::find($id);
                     // find and delete all test
                     $tests = \Debugger\Model_Test::find()->where('group_id', $group->id);
                     foreach ($tests as $test) {
                         // find and delete all records
                         $records = \Debugger\Model_Record::find()->where('test_id', $test->id);
                         foreach ($records as $record) {
                             $record->delete();
                         }
                         $test->delete();
                     }
                     $group->delete();
                     echo json_encode(array("status" => "ok"));
                     break;
                 case 'test':
                     $test = \Debugger\Model_Test::find($id);
                     // find and delete all records
                     $records = \Debugger\Model_Record::find()->where('test_id', $test->id);
                     foreach ($records as $record) {
                         $record->delete();
                     }
                     $test->delete();
                     echo json_encode(array("status" => "ok"));
                     break;
                 case 'record':
                     $record = \Debugger\Model_Record::find($id);
                     $record->delete();
                     echo json_encode(array("status" => "ok"));
                     break;
                 case 'check':
                     $check = \Debugger\Model_Check::find($id);
                     $check->delete();
                     echo json_encode(array("status" => "ok"));
                     break;
             }
         }
     }
 }
示例#3
0
 public function getData()
 {
     $data = array('data' => array());
     // get groups
     $groups = \Debugger\Model_Group::find()->get();
     foreach ($groups as $group) {
         $group_data = array('id' => $group['id'], 'name' => $group['name'], 'description' => $group['description'], 'tests' => array());
         // get tests
         $tests = \Debugger\Model_Test::find()->where('group_id', $group->id)->get();
         foreach ($tests as $test) {
             $test_data = array('id' => $test->id, 'name' => $test->name, 'description' => $test->description, 'group_id' => $test->group_id, 'records' => array());
             // get records
             $records = \Debugger\Model_Record::find()->where('test_id', $test->id)->get();
             foreach ($records as $record) {
                 array_push($test_data['records'], array('id' => $record->id, 'type' => $record->type, 'object' => $record->object, 'action' => $record->action, 'test_id' => $record->test_id));
             }
             array_push($group_data['tests'], $test_data);
         }
         array_push($data['data'], $group_data);
     }
     return $data;
 }
示例#4
0
[
<?php 
$data = array();
foreach ($tests as $test) {
    $records = \Debugger\Model_Record::find()->where('test_id', $test->id)->get();
    $b = array('attr' => array('id' => 'test_' . $test->id, 'rel' => 'test'), 'data' => $test->name, 'state' => count($records) == 0 ? '' : 'closed');
    array_push($data, $b);
}
echo json_encode($data);
?>
]