diff --git a/config/database.php b/config/database.php index 73f0a6bb167d1186e641a5ece060a82466e3d18b..c207313d81bb8b9e60c661fdadca8739159b4dae 100644 --- a/config/database.php +++ b/config/database.php @@ -14,8 +14,8 @@ return array * boolean persistent use persistent connections? */ 'dsn' => 'mysql:host=127.0.0.1;dbname=mmcs_rating', - 'username' => 'mmcs_rating', - 'password' => 'Pefnesdy', + 'username' => 'root', + 'password' => '', 'persistent' => FALSE, 'options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8') ), diff --git a/media/js/task1.js b/media/js/task1.js new file mode 100644 index 0000000000000000000000000000000000000000..2db58c13738f70fa9be900fd533d78e25477b7ef --- /dev/null +++ b/media/js/task1.js @@ -0,0 +1,5 @@ +$(function () { +$('.btn').on('click', function() { + alert(1); +}); +}); \ No newline at end of file diff --git a/~dev_rating/application/bootstrap.php b/~dev_rating/application/bootstrap.php index a5ca469c961061a114d694aed5c703669a19c2ef..dd35f72e22b597757126f9f8daafbdc9fa44d3de 100644 --- a/~dev_rating/application/bootstrap.php +++ b/~dev_rating/application/bootstrap.php @@ -176,6 +176,13 @@ Route::set('sign:restore', 'remind/<token>') 'action' => 'restore', ]); +//Route::set('handler2', 'handler/task/get') +// ->defaults([ +// 'directory' => 'Handler', +// 'controller' => 'Task', +// 'action' => 'get', +// ]); + // --------------- Ajax features ---------------- Route::set('handler', 'handler/<controller>(/<action>(/<id>))') ->defaults([ @@ -280,3 +287,21 @@ Route::set('javaSessionProvider', 'java_authentication') 'controller' => 'JavaAuthentication', 'action' => 'authentication' ]); +Route::set('test', 'test') + ->defaults([ + 'directory' => 'Student', + 'controller' => 'test', + 'action' => 'go' + ]); +Route::set('task1', 'task1') + ->defaults([ + 'directory' => 'Student', + 'controller' => 'task1', + 'action' => 'go' + ]); + +Route::set('departments:main', 'departments(/<id>)', ['id' => '[0-9]+']) + ->defaults([ + 'controller' => 'Departments', // classes/Controller/Departments.php + 'id' => 1, + ]); diff --git a/~dev_rating/application/classes/Controller/Handler/Task.php b/~dev_rating/application/classes/Controller/Handler/Task.php new file mode 100644 index 0000000000000000000000000000000000000000..b58ba255bddf020ebbc3b215a6bd76cf29b36180 --- /dev/null +++ b/~dev_rating/application/classes/Controller/Handler/Task.php @@ -0,0 +1,17 @@ +<?php defined('SYSPATH') or die('No direct script access.'); + +class Controller_Handler_Task extends Controller_Handler +{ + + public function action_get() + { + $id = $this->post['id']; + $data = Model_Faculty::with($id); + $dep = $data->getDepartments(); + + $this->response->body(json_encode($dep)); + } + +} + + diff --git a/~dev_rating/application/classes/Controller/Student/Task1.php b/~dev_rating/application/classes/Controller/Student/Task1.php new file mode 100644 index 0000000000000000000000000000000000000000..05401c87edaf09db666571456bc5b4687db693d9 --- /dev/null +++ b/~dev_rating/application/classes/Controller/Student/Task1.php @@ -0,0 +1,19 @@ +<?php defined('SYSPATH') or die('No direct script access.'); + +class Controller_Student_Task1 extends Controller_Handler +{ + + public function action_go() + { + $data = Model_Faculty::with(1); + $dep = $data->getDepartments(); + $twig = Twig::factory('task1'); + $twig->set([ + "Departments" => $dep + ]); + $this->response->body($twig); + } + +} + + diff --git a/~dev_rating/application/views/task1.twig b/~dev_rating/application/views/task1.twig new file mode 100644 index 0000000000000000000000000000000000000000..a95c8760042e1cd2b973788a6f149ee66817a618 --- /dev/null +++ b/~dev_rating/application/views/task1.twig @@ -0,0 +1,23 @@ +<head> + {{ HTML.script('static/js/libs/jquery-1.11.1.min.js') |raw }} + {{ HTML.script('static/js/config.js')|raw }} + {{ HTML.script('static/js/task1.js')|raw }} + +</head> + +<body> + +<input type="text" size="1" name="num" min="1" max="10" value="1" class="textField"> +<form> + <input type="button" name="button" value="OK" class='btn'> +</form> + + +<select id="departments"> + {% for f in Departments %} + <option value="{{ f.ID }}"> + {{ f.Name }} + </option> + {% endfor %} +</select> +</body> \ No newline at end of file