public function render()
 {
     $paragraph = new \Frame\Views\Paragraph();
     $paragraph->text('Incorrect username/password combination');
     $login = new \Work\Views\Login($this->data);
     $layout = new \Frame\Views\Layout(array(array($paragraph), array($login)));
     return $layout->render();
 }
Exemple #2
0
 public function render()
 {
     $paragraph = new \Frame\Views\Paragraph();
     $paragraph->text('Hello Frameworld!');
     $form = new \Frame\Views\Form('\\Work\\Controllers\\Main::welcome', 'welcome');
     $form->input('Name:', 'text', '', 'name');
     $form->input('Age:', 'text', '', 'age');
     $form->input('', 'submit', 'Submit', 'submit');
     $layout = new \Frame\Views\Layout(array(array($paragraph, 'welcome' => $form)));
     return $layout->render();
 }
Exemple #3
0
 public static function tests()
 {
     $tests = \Work\Models\Test::get();
     $rows = array();
     foreach ($tests as $test) {
         $test_inputs = \Work\Models\TestInput::where('test_id', '=', $test->test_id)->get();
         $data = array();
         foreach ($test_inputs as $test_input) {
             $input = \Work\Models\Input::where('input_id', '=', $test_input->input_id)->pluck('input');
             if (is_null($input)) {
                 throw new \Exception("No input found for {$test_input->test_input_id}");
             }
             $data[$input] = $test_input->input;
         }
         $controller = \Work\Models\Controller::where('controller_id', '=', $test->controller_id)->pluck('controller');
         list($class, $function) = explode('::', $controller);
         if ($data) {
             $result = $class::$function($data);
         } else {
             $result = $class::$function();
         }
         if ($test->result == $result) {
             $pass = '******';
         } else {
             $pass = '******';
         }
         $rows[] = array($controller, $test->result, $result, $pass);
     }
     $layout = new \Frame\Views\Layout($rows);
     return $layout->render();
 }
Exemple #4
0
    public function render()
    {
        $columns = array();
        $user_id = \Work\Models\User::where('session', '=', $_SESSION['frame_key'])->pluck('user_id');
        if (is_null($user_id)) {
            $user_id = 0;
        }
        foreach ($this->inputs as $input) {
            $id = \Frame\Key::get();
            if ($input['type'] == 'hidden') {
                if ($user_id) {
                    $store = \Work\Models\Store::where('user_id', '=', $user_id)->where('key', '=', $input['value'])->pluck('store_id');
                } else {
                    $store = \Work\Models\Store::where('key', '=', $input['value'])->pluck('store_id');
                }
                if (is_null($store)) {
                    $hidden = \Frame\Key::get();
                    \Work\Models\Store::create(array('user_id' => $user_id, 'key' => $hidden, 'value' => $input['value']));
                    $input['value'] = $hidden;
                }
            }
            $columns[] = array($input['label'], $this->build('input', '', array('id' => $id, 'name' => $id, 'type' => $input['type'], 'value' => $input['value'])));
            if (is_null($input['input'])) {
                continue;
            }
            $input_id = \Work\Models\Input::where('input', '=', $input['input'])->pluck('input_id');
            \Work\Models\Navigation::create(array('user_id' => $user_id, 'key' => $id, 'type' => 'input', 'navigation' => $input_id));
        }
        $layout = new \Frame\Views\Layout($columns);
        $key = \Frame\Key::get();
        $target_id = \Work\Models\Target::where('target', '=', $this->target)->pluck('target_id');
        if ($target_id) {
            $target = \Work\Models\Navigation::where('user_id', '=', $user_id)->where('type', '=', 'target')->where('navigation', '=', $target_id)->orderBy('navigation_id', 'desc')->pluck('key');
        } else {
            $navigation_id = \Work\Models\Navigation::where('type', '=', 'target')->where('key', '=', $this->target)->pluck('navigation_id');
            if ($navigation_id) {
                $target = $this->target;
            } else {
                $target = null;
            }
        }
        if (is_null($target)) {
            $id = $target = 'body';
        } else {
            $id = "#{$target}";
        }
        $form = $this->build('form', $layout->render(), array('id' => $key));
        $js = <<<JS
\$('#{$key}').submit(function(event) {
    event.preventDefault();
    var hidden = [];
    \$('{$id} [id]').each(function() {
        hidden.push(\$(this).attr('id'));
    });
    console.log(hidden);
    var ids = [];
    \$('body [id]').each(function() {
        if (\$.inArray(\$(this).attr('id'), hidden) >= 0) return true;
        ids.push(\$(this).attr('id'));
    });
    console.log(ids);
    \$.ajax({url: '', type: 'post', dataType: 'json', data: {key: '{$key}', form: \$(this).serializeArray(), target: '{$target}', clean: ids}}).success(function(json) {
        if (!json.status || json.status != 'COMPLETE' || !json.html) {
            var message = json.message || 'System error, check logs';
            alert(message);
            return false;
        }
        \$('{$id}').html(json.html);
    });
});
JS;
        $controller_id = \Work\Models\Controller::where('controller', '=', $this->controller)->pluck('controller_id');
        if (is_null($controller_id)) {
            throw new \Exception("{$this->controller} not found in controller table}");
        }
        \Work\Models\Navigation::create(array('user_id' => $user_id, 'key' => $key, 'type' => 'controller', 'navigation' => $controller_id));
        $script = $this->build('script', $js);
        return $form . $script;
    }