diff --git a/media/css/test.css b/media/css/test.css new file mode 100644 index 0000000000000000000000000000000000000000..3ffd17aebc0515b8036c2c0be26e46cf04e9950c --- /dev/null +++ b/media/css/test.css @@ -0,0 +1,3 @@ +p{ + color: #0000cc; +} \ No newline at end of file diff --git a/media/js/button.js b/media/js/button.js new file mode 100644 index 0000000000000000000000000000000000000000..734184e39c1ff68cc2c2189481b13d74946a7b59 --- /dev/null +++ b/media/js/button.js @@ -0,0 +1,13 @@ + +$(function () { + var button = $('#button'); + button.click(function () { + var num = ($('input').first().val()); + + // grade/~dev_rating + $.get(URLdir + '/departments/' + num, function (res) { + $('#container').html(res); + }); + }); + +}); \ No newline at end of file diff --git a/media/js/testik.js b/media/js/testik.js new file mode 100644 index 0000000000000000000000000000000000000000..5badcd44055701820a3380b6bc9c357561267e61 --- /dev/null +++ b/media/js/testik.js @@ -0,0 +1,11 @@ +/** + * Created by ami96_000 on 02.07.2015. + */ +$(function(){ + var faculty=$('#faculty'); + faculty.change(function () { + alert( + faculty.find('option:selected').val()); + }); + +}); \ No newline at end of file diff --git a/~dev_rating/application/bootstrap.php b/~dev_rating/application/bootstrap.php index f4552773a8f75b434235f006c6c0038b474474f6..0e176b17debd41ac68ad831df7b6bb1269c71902 100644 --- a/~dev_rating/application/bootstrap.php +++ b/~dev_rating/application/bootstrap.php @@ -280,3 +280,12 @@ Route::set('javaSessionProvider', 'java_authentication') 'controller' => 'JavaAuthentication', 'action' => 'authentication' ]); + +Route::set('departments:main', 'departments(/<id>)', ['id' => '[0-9]+']) + ->defaults([ + 'controller' => 'Departments', // classes/Controller/Departments.php + 'id' => 1, + ]); + +// bars.com/departments +// bars.com/departments/78 \ No newline at end of file diff --git a/~dev_rating/application/classes/Controller/Departments.php b/~dev_rating/application/classes/Controller/Departments.php new file mode 100644 index 0000000000000000000000000000000000000000..043968fa90241465426f92298efbe1039dbf98b3 --- /dev/null +++ b/~dev_rating/application/classes/Controller/Departments.php @@ -0,0 +1,16 @@ +<?php defined('SYSPATH') or die('No direct script access.'); + +class Controller_Departments extends Controller +{ + public function action_index() { + $id = (int) $this->request->param('id'); + + $name = $this->request->is_ajax() ? 'departments' : 'main_departments'; + + $twig = Twig::factory($name, [ + 'Departments' => Model_Faculty::with($id)->getDepartments() + ]); + + $this->response->body($twig); + } +} diff --git a/~dev_rating/application/views/departments.twig b/~dev_rating/application/views/departments.twig new file mode 100644 index 0000000000000000000000000000000000000000..c2fa9048365d1f910244f2f8bbace36c628aba42 --- /dev/null +++ b/~dev_rating/application/views/departments.twig @@ -0,0 +1,7 @@ +<ul> + {% for d in Departments %} + {% if d.Name != '' %} + <li value="{{ d.ID }}">{{ d.Name }}</li> + {% endif %} + {% endfor %} +</ul> \ No newline at end of file diff --git a/~dev_rating/application/views/main_departments.twig b/~dev_rating/application/views/main_departments.twig new file mode 100644 index 0000000000000000000000000000000000000000..253fc289434c041f7194954615ece43aa53e29cb --- /dev/null +++ b/~dev_rating/application/views/main_departments.twig @@ -0,0 +1,45 @@ +<html> +<head> + {{ HTML.script('static/js/libs/jquery-1.11.1.min.js') |raw }} + {{ HTML.script('static/js/button.js')|raw }} + {{ HTML.script('static/js/config.js')|raw }} +</head> +<body> + <p>Введите id факультета:</p> + + <input type="text" size="3" name="num" min="1" max="10" value="0"> + <button id="button">OK</button> + + <p>Список кафедр:</p> + + <div id="container"> + <ul> + {% for d in Departments %} + {% if d.Name != '' %} + <li value="{{ d.ID }}">{{ d.Name }}</li> + {% endif %} + {% endfor %} + </ul> + </div> +</body> +</html> + + +{#<select> + {% for f in Faculties %} + <option value="{{ f.ID }}"> + {{ f.Name }} + </option> + {% endfor %} +</select>#} +{# <select id="faculty"> + <option value="1">мимими</option> + <option value="2">урурру</option> + <option value="3" class="mytext">:3</option> + <option>ROOOOOAAAR</option> + </select> + +<p> + meow +</p> +<p class="mytext">ROAR</p>#} \ No newline at end of file