diff --git a/.gitignore b/.gitignore index 6d16498..827c319 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.idea/ -/app/config/config.ini \ No newline at end of file +/app/config/config.ini +public/content \ No newline at end of file diff --git a/app/controllers/Admin/ZonesController.php b/app/controllers/Admin/ZonesController.php index 3a0825c..e3f0019 100644 --- a/app/controllers/Admin/ZonesController.php +++ b/app/controllers/Admin/ZonesController.php @@ -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() { diff --git a/app/controllers/RotatorController.php b/app/controllers/RotatorController.php index 1dee3a7..0ff0a08 100644 --- a/app/controllers/RotatorController.php +++ b/app/controllers/RotatorController.php @@ -4,6 +4,7 @@ use App\Models\Banners; use App\Models\Views; +use App\Models\Zones; use Phalcon\Mvc\View; class RotatorController extends ControllerBase { @@ -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'); + 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) { @@ -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))); diff --git a/app/models/Zones.php b/app/models/Zones.php index 3b78532..e4cb90a 100644 --- a/app/models/Zones.php +++ b/app/models/Zones.php @@ -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; + } } diff --git a/app/views/admin/zones/index.phtml b/app/views/admin/zones/index.phtml index 49db605..44b382d 100644 --- a/app/views/admin/zones/index.phtml +++ b/app/views/admin/zones/index.phtml @@ -5,7 +5,7 @@