Skip to content
Snippets Groups Projects
Commit e17a9e95 authored by Turchin's avatar Turchin
Browse files

Completed test task #29

parent 1071f906
Branches
Tags
No related merge requests found
...@@ -14,8 +14,8 @@ return array ...@@ -14,8 +14,8 @@ return array
* boolean persistent use persistent connections? * boolean persistent use persistent connections?
*/ */
'dsn' => 'mysql:host=127.0.0.1;dbname=mmcs_rating', 'dsn' => 'mysql:host=127.0.0.1;dbname=mmcs_rating',
'username' => 'mmcs_rating', 'username' => 'root',
'password' => 'Pefnesdy', 'password' => '',
'persistent' => FALSE, 'persistent' => FALSE,
'options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8') 'options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')
), ),
......
$(function () {
$('.btn').on('click', function() {
alert(1);
});
});
\ No newline at end of file
...@@ -176,6 +176,13 @@ Route::set('sign:restore', 'remind/<token>') ...@@ -176,6 +176,13 @@ Route::set('sign:restore', 'remind/<token>')
'action' => 'restore', 'action' => 'restore',
]); ]);
//Route::set('handler2', 'handler/task/get')
// ->defaults([
// 'directory' => 'Handler',
// 'controller' => 'Task',
// 'action' => 'get',
// ]);
// --------------- Ajax features ---------------- // --------------- Ajax features ----------------
Route::set('handler', 'handler/<controller>(/<action>(/<id>))') Route::set('handler', 'handler/<controller>(/<action>(/<id>))')
->defaults([ ->defaults([
...@@ -280,3 +287,21 @@ Route::set('javaSessionProvider', 'java_authentication') ...@@ -280,3 +287,21 @@ Route::set('javaSessionProvider', 'java_authentication')
'controller' => 'JavaAuthentication', 'controller' => 'JavaAuthentication',
'action' => 'authentication' '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,
]);
<?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));
}
}
<?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);
}
}
<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
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment