Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
ef279be
+ API запрос для получения банера для мобильной версии
atnartur Aug 28, 2015
6fd5328
+ Функция для получения ссылки баннера для мобильных приложений
atnartur Aug 28, 2015
360c6fe
+ Вывод кода вставки баннера в мобильные приложения на странице просм…
atnartur Aug 28, 2015
85e810c
+ Скрипт для автоматического выделения данных в полях ввода
atnartur Aug 28, 2015
d3499de
Merge branch 'feat_apache_supporting' into feat_mobile_rotator
atnartur Aug 28, 2015
1ae5b00
! Увеличен размер блока со списком зон
atnartur Aug 28, 2015
4d818f0
- показ flash баннеров в версии ротатора для мобильных приложений
atnartur Aug 28, 2015
a1656f1
! Flash в rotator/get
atnartur Aug 30, 2015
baf5d18
+ Совмещены rotator/get и rotator/get_mobile
atnartur Aug 30, 2015
2ec31eb
= Изменено шифрование ключа для мобильных запросов
atnartur Aug 30, 2015
a931bc7
! rotator/get обращение к объекту SQL-запроса
atnartur Aug 30, 2015
7c365d6
+ .gitignore public/content
atnartur Aug 30, 2015
857f748
+ Защита мобильных запросов через secret key
atnartur Aug 30, 2015
29d5573
- секретный ключ в мобильных запросах
atnartur Sep 16, 2015
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/.idea/
/app/config/config.ini
/app/config/config.ini
public/content
2 changes: 2 additions & 0 deletions app/controllers/Admin/ZonesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public function indexAction() {
Tag::prependTitle('Зоны');
$this->view->title = "Зоны";
$this->view->zones = Zones::find();

$this->assets->collection('bottom-js')->addJs('js/zones.js');
}

public function addAction() {
Expand Down
21 changes: 16 additions & 5 deletions app/controllers/RotatorController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Models\Banners;
use App\Models\Views;
use App\Models\Zones;
use Phalcon\Mvc\View;

class RotatorController extends ControllerBase {
Expand All @@ -14,15 +15,25 @@ protected function initialize()

public function getAction() {
$url = $this->request->getQuery('url');
$banners = $this->modelsManager->createBuilder()

if($this->request->has('type'))
$type = $this->request->get('type');
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ты зачем мне Flash выпилил?!

else
$type = 'standart';

$banners_sql = $this->modelsManager->createBuilder()
->from(array('b'=>'App\Models\Banners'))
->innerJoin('App\Models\BannersZones', 'b.id = bz.banner_id AND bz.zone_id = ' . $this->request->getQuery('zone_id', 'int'), 'bz')
->andWhere('(end_date IS NULL OR end_date > ' . time() . ") AND (start_date IS NULL OR start_date <= " . time() . ") AND active = 1 AND archived = 0")
->groupBy('b.id')
->andWhere('(end_date IS NULL OR end_date > ' . time() . ") AND (start_date IS NULL OR start_date <= " . time() . ") AND active = 1 AND archived = 0");

if($type === 'mobile')
$banners_sql->andWhere('type <> "flash"');

$banners = $banners_sql->groupBy('b.id')
->getQuery()
->execute();

if(count($banners)) {

$existsNonzeroPriority = false;

$banners = $banners->filter(function($banner) use (&$existsNonzeroPriority, $url) {
Expand Down Expand Up @@ -83,7 +94,7 @@ public function get_jsAction() {
$this->response->setContentType('text/javascript');
$this->view->pick('rotator/js');
}

public function clickAction() {
$id = $this->dispatcher->getParam('id');
$banner = Banners::findFirst(array('id = :id:', 'bind'=>array('id'=>$id)));
Expand Down
4 changes: 4 additions & 0 deletions app/models/Zones.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ public function initialize()
array('alias' => 'banners')
);
}

function get_mobile_link(){
return 'http://' . $_SERVER['HTTP_HOST'] . '/rotator/get?type=mobile&zone_id=' . $this->id;
}
}
10 changes: 7 additions & 3 deletions 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 @@ -21,7 +21,8 @@
<tr>
<th>ID</th>
<th>Имя</th>
<th>Код инициализации зоны</th>
<th>Код для сайта</th>
<th>Ссылка для запроса с мобильных приложений</th>
<th>Действия</th>
</tr>
</thead>
Expand All @@ -31,7 +32,10 @@
<td><?=$zone->id?></td>
<td><a href="<?=$this->url->get(array('for'=>'full', 'controller'=>'zones', 'action'=>'edit', 'id'=>$zone->id))?>"><?=$zone->name?></a></td>
<td>
<?=htmlspecialchars("<div id=\"banners_zone_{$zone->id}\"></div><script type=\"text/javascript\">new Banner(\"banners_zone_{$zone->id}\", {$zone->id});</script>");?>
<input class="form-control self_selected" type="text" value="<?=htmlspecialchars("<div id=\"banners_zone_{$zone->id}\"></div><script type=\"text/javascript\">new Banner(\"banners_zone_{$zone->id}\", {$zone->id});</script>");?>">
</td>
<td>
<input class="form-control self_selected" type="text" value="<?=$zone->get_mobile_link()?>">
</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>
Expand Down
5 changes: 5 additions & 0 deletions public/js/zones.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
$(document).ready(function(){
$(".self_selected").click(function(){
$(this).select();
});
});