Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/controllers/Admin/BannersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public function addAction() {
$this->assets->collection('bottom-js')
->addJs('js/moment/moment.min.js')
->addJs('js/moment/ru.js')
->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js');
->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js')
->addJs('js/banners_edit_sizes.js');
$this->assets->collection('css')
->addCss('js/datetimepicker/css/bootstrap-datetimepicker.min.css');
$banner = new Banners();
Expand Down Expand Up @@ -123,7 +124,8 @@ public function editAction() {
$this->assets->collection('bottom-js')
->addJs('js/moment/moment.min.js')
->addJs('js/moment/ru.js')
->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js');
->addJs('js/datetimepicker/js/bootstrap-datetimepicker.js')
->addJs('js/banners_edit_sizes.js');
$this->assets->collection('css')
->addCss('js/datetimepicker/css/bootstrap-datetimepicker.min.css');
$id = $this->dispatcher->getParam('id');
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/Admin/ZonesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function addAction() {
$zone = new Zones();
if ($this->request->isPost())
{
if($zone->save($this->request->getPost(), array('name')))
if($zone->save($this->request->getPost(), array('name', 'width', 'height')))
{
$this->flashSession->success("Зона успешно создана");
return $this->response->redirect(array('for'=>'controller', 'controller'=>'zones'));
Expand Down Expand Up @@ -63,7 +63,7 @@ public function editAction() {
{
if ($this->request->isPost())
{
if($zone->save($this->request->getPost(), array('name')))
if($zone->save($this->request->getPost(), array('name', 'width', 'height')))
{
$this->flashSession->success("Зона отредактирована");
return $this->response->redirect(array('for'=>'controller', 'controller'=>'zones'));
Expand Down
6 changes: 4 additions & 2 deletions app/models/Zones.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

class Zones extends ModelBase
{
public $id, $name;
public $id, $name, $height, $width;
public $labels = array(
'name' => 'Имя'
'name' => 'Имя',
'height' => 'Высота',
'width' => 'Ширина'
);

public function initialize()
Expand Down
10 changes: 8 additions & 2 deletions app/views/admin/banners/edit.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,14 @@
$zones = \App\Models\Zones::find();
foreach($zones as $zone):?>
<div class="checkbox">
<label>
<?=$this->tag->checkField(array('zones[]', 'checked'=>in_array($zone->id, $checked_zones) ? 'checked' : null, 'value'=>$zone->id))?> <?=$zone->name?>
<label class="zone">
<?=$this->tag->checkField(array(
'zones[]',
'checked'=>in_array($zone->id, $checked_zones) ? 'checked' : null,
'value'=>$zone->id
))?> <?=$zone->name?>
(<i id="width"><?=$zone->width == '' ? '???' : $zone->width?></i>x<i id="height"><?=$zone->height == '' ? '???' : $zone->height?></i>)
<b class="status"></b>
</label>
</div>
<?php endforeach;?>
Expand Down
18 changes: 17 additions & 1 deletion app/views/admin/zones/edit.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,23 @@
<?=$this->tag->textField(array('name', 'value'=>$zone->name, 'class'=>'form-control'))?>
</div>
</div>

<div class="form-group">
<label class="control-label col-md-2" for="text">Размеры</label>
<div class="col-md-6">
<?=$this->tag->textField(array(
'width',
'value'=>$zone->width,
'class'=>'form-control',
'placeholder'=>'Ширина'
))?>
<?=$this->tag->textField(array(
'height',
'value'=>$zone->height,
'class'=>'form-control',
'placeholder'=>'Высота'
))?>
</div>
</div>
<div class="form-group">
<div class="col-md-8 col-md-offset-2">
<button type="submit" class="btn btn-primary">Сохранить</button>
Expand Down
4 changes: 3 additions & 1 deletion app/views/admin/zones/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>

<div class="row">
<div class="col-md-5">
<div class="col-md-12">
<div class="widget">
<div class="widget-head">
<div class="pull-left">Список</div>
Expand All @@ -22,6 +22,7 @@
<th>ID</th>
<th>Имя</th>
<th>Код инициализации зоны</th>
<th>Размеры</th>
<th>Действия</th>
</tr>
</thead>
Expand All @@ -33,6 +34,7 @@
<td>
<?=htmlspecialchars("<div id=\"banners_zone_{$zone->id}\"></div><script type=\"text/javascript\">new Banner(\"banners_zone_{$zone->id}\", {$zone->id});</script>");?>
</td>
<td><?=$zone->width == '' ? '???' : $zone->width?>x<?=$zone->height == '' ? '???' : $zone->height?></td>
<td>
<a class="btn btn-xs btn-default" href="<?=$this->url->get(array('for'=>'full', 'controller'=>'zones', 'action'=>'edit', 'id'=>$zone->id))?>"><i class="fa fa-pencil"></i></a>
<a class="btn btn-xs btn-danger" href="<?=$this->url->get(array('for'=>'full', 'controller'=>'zones', 'action'=>'delete', 'id'=>$zone->id))?>"><i class="fa fa-times"></i></a>
Expand Down
21 changes: 21 additions & 0 deletions public/js/banners_edit_sizes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
function init() {
var banner_w = Number($('input#width').val());
var banner_h = Number($('input#height').val());

$('.zone').each(function(){
var h = Number($(this).find('#height').text());
var w = Number($(this).find('#width').text());

if (w >= banner_w && h >= banner_h)
$(this).find('.status').text('входит в размер этой зоны');
else
$(this).find('.status').text('не входит в размер этой зоны');
});
}

$(document).ready(function(){
init();
$('input#width, input#height').change(function(){
init();
})
});
6 changes: 4 additions & 2 deletions sql_dump.sql
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,10 @@ CREATE TABLE IF NOT EXISTS `user_tokens` (
) ENGINE=InnoDB AUTO_INCREMENT=18 DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `zones` (
`id` int(10) unsigned NOT NULL,
`name` varchar(255) NOT NULL
`id` int(10) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`height` INT(11) NOT NULL,
`width` INT(11) NOT NULL
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;

CREATE TABLE IF NOT EXISTS `views` (
Expand Down