public function render($tpl_file = '') { if (sizeof($tpl_file) > 0) { $this->smarty_object = $tpl_file; } return $this->smarty_object->fetch(); }
public function findImages($search) { $user_id = \Registry::getCurrentUser()->iduser; $user = \Model\User::model()->findByPk($user_id); $criteria = new \DBCriteria(array('condition' => " description LIKE :match OR\n main_text LIKE :match OR\n title LIKE :match OR ", 'params' => array(':match' => "%{$search}%"))); $criteria->limit = $this->limit; $data = \Model\Pages::model()->with('idpageType')->findAll($criteria); $this->template->assign(['results' => $data, 'count_find' => count($data)]); }
/** * */ public function before() { $is_guest = \Registry::getCurrentUser()->isGuest(); // Дополнительные функции $this->InitEnvironment(); if (!Request::current()->is_ajax()) { // Add Google Font Assets::css('Google_Font', 'https://fonts.googleapis.com/css?family=Open+Sans:400,300,300italic,400italic,600,600italic,700,700italic&subset=latin,cyrillic-ext,cyrillic'); /*ADD google maps JS*/ Assets::js('google_maps_api', 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=true&libraries=drawing&places&geometry'); Assets::js('jQuery', 'https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js'); Assets::css('bootstrap', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', ['media' => 'screen']); Assets::js('bootstrap', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js'); //GMAP Plugin js Assets::js('cluster', base_UI . 'js/plugins/gmap/marker.js'); Assets::js('gmap', base_UI . 'js/plugins/gmap/gmaps.js'); /*Базовые стили шаблона*/ //Global Assets Assets::js('globalJS', base_UI . 'js/pages/global.js'); Assets::css('awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css'); Assets::css('stl', base_UI . 'css/style.css'); /*BootBox Js file*/ Assets::js('BootBox', base_UI . 'libs/BootBox/bootbox.js'); /*Login Js file*/ Assets::js('LoginJs', base_UI . 'js/Auth/login.js'); /*Register Js file*/ Assets::js('RegisterJs', base_UI . 'js/Auth/register.js'); //Zopim Helper js Assets::js('zopim', base_UI . 'js/index/zopim.js'); //MAP js Assets::js('map1', base_UI . 'js/map/map.js'); Assets::js('map2', base_UI . 'js/pages/map.js'); Assets::js('map3', base_UI . 'js/map/catalog.js'); $this->template = \smarty\View::init(); $this->renderULogin(); if (!$is_guest) { $access = new \Auth\Access(\Registry::getCurrentUser()->access_level); $user_id = \Registry::getCurrentUser()->iduser; $this->template->assign(['current_user' => \Registry::getCurrentUser(), 'isAdmin' => $access->get(\Auth\Access::User_Is_Admin), 'isModerator' => $access->get(\Auth\Access::User_Is_Moderator)]); } else { $this->template->assign(['current_user' => \Registry::getCurrentUser()]); } $this->template->assign(['localis' => $this->localis, 'local' => $this->i18n]); } else { $this->setJSONHeader(); // Mobile API if (!isset($_POST)) { $error = array('status' => 'error', 'message' => 'No Data', 'code' => '2'); echo json_encode($error); return; } /** @var $dbSession UserSession */ if ($_POST['token']) { $condition = (new \DBCriteria())->addColumnCondition(['token' => $_POST['token']])->addCondition('`expired`>=UNIX_TIMESTAMP(NOW())'); /** @var $dbSession UserSession */ $sessionData = UserSession::model()->with('user')->find($condition); \Registry::setCurrentUser($sessionData->user); } } }
/** * Loads the template [View] object. */ public function before() { parent::before(); if ($this->auto_render === TRUE) { // Load the template $this->smarty_object = View::factory($this->template); } }
/** * gets info from social network. If profile already linked to user authenticates, otherwise create new user instance * @throws \Kohana_Database_Exception */ public function action_uloginAuth() { $s = file_get_contents('http://ulogin.ru/token.php?token=' . $_POST['token'] . '&host=' . $_SERVER['HTTP_HOST']); $user = json_decode($s, true); if (strlen($user['error']) > 0) { $this->response->body($this->template->fetch('internal.tpl')); return; } $condition = (new \DBCriteria())->addColumnCondition(['uid' => $user['uid'], 'network' => $user['network']]); /** @var $ULogin \Model\ULogin */ $ULogin = \Model\ULogin::model()->with('user')->find($condition); if (null === $ULogin) { \Session::instance()->set('UloginData', $user); $user['bdate'] = date('Y-m-d', strtotime($user['bdate'])); $user_model = new User(); $user_model->login = $user['login']; $user_model->first_name = $user['first_name']; $user_model->email = $user['email']; $access_level = new \Auth\Access(); $access_level->set(\Auth\Access::User_Login); $user_model->access_level = $access_level->getValue(); if (!$user_model->save()) { throw new \Kohana_Database_Exception('Unable to save user model'); } $ULogin = new ULogin(); $ULogin->network = $user['network']; $ULogin->uid = $user['uid']; $ULogin->profile = $user['identity']; $ULogin->user_id = $user_model->id; if (!$ULogin->save()) { $this->response->body('Unable to save social network data'); } \Auth\Base::startSession($ULogin['user']); $this->redirect(\Route::get('pages')->uri(['controller' => 'Map', 'action' => 'Add'])); } else { \Auth\Base::startSession($ULogin['user']); $this->redirect(\Route::get('pages')->uri(['controller' => 'Map', 'action' => 'Add'])); } }
/** * */ public function before() { if (\Registry::getCurrentUser()->isGuest()) { if ($this->request->controller() != 'Main' && $this->request->action() != 'login') { #todo Fix it! if (!\Request::current()->is_ajax()) { \HTTP::redirect(\Route::get('SystemRoute')->uri(['controller' => 'Main', 'action' => 'login']), 302); } } } if (!Request::current()->is_ajax()) { // Add Google Font Assets::css('Google_Font', 'http://fonts.googleapis.com/css?family=Lato:100,300,400,700,300italic,400italic,700italic|Lustria'); Assets::js('jQuery', base_UI . 'libs/jquery-2.1.1.js'); Assets::css('bootstrap', 'http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css', ['media' => 'screen']); Assets::js('bootstrap', 'http:////netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js'); Assets::css('font-awesome', 'http://netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css', ['media' => 'screen']); /*Базовые стили шаблона*/ Assets::css('stl', base_UI . 'AdminLTE/css/style.css'); Assets::css('lightbox', base_UI . 'libs/lightbox/css/lightbox.css'); /*BootBox Js file*/ Assets::js('BootBox', base_UI . 'libs/BootBox/bootbox.js'); /*Login Js file*/ Assets::js('LoginJs', base_UI . 'js/Auth/login.js'); /*Register Js file*/ Assets::js('RegisterJs', base_UI . 'js/Auth/register.js'); //uLogin js Assets::js('uLogin', 'http://ulogin.ru/js/ulogin.js'); //Add notification plugin Assets::js('notification', base_UI . 'libs/bootstrap/msg/bootstrap-msg.js'); Assets::css('notification', base_UI . 'libs/bootstrap/msg/bootstrap-msg.css'); Assets::css('AdminLTE', base_UI . 'AdminLTE/css/AdminLTE.css'); Assets::js('AdminLTE_App', base_UI . 'AdminLTE/js/AdminLTE/app.js'); $this->template = \Smarty\View::init(); if (!Request::current()->is_ajax()) { $access = new \Auth\Access(\Registry::getCurrentUser()->access_level); $this->template->assign(['current_user' => \Registry::getCurrentUser(), 'isAdmin' => $access->get(\Auth\Access::User_Is_Admin), 'isModerator' => $access->get(\Auth\Access::User_Is_Moderator)]); } } }
public function action_transportCatalog() { $tplObj = \smarty\View::factory('catalog'); $page = $this->request->post('page'); $offset = $this->request->post('offset'); $is_pagination = $this->request->post('is_pagination'); $pagination = false; if ($is_pagination) { $data = \Model\TransportCompany::model()->count(); $p_factory = \Pagination::factory(array('total_items' => $data)); $tplObj->assign(['pagination' => $p_factory]); $pagination = $tplObj->fetch('catalog' . DS . 'pagination.tpl'); } $offset = $this->per_page * ($page - 1); if (Request::current()->is_ajax()) { $criteria = new \DBCriteria(); $criteria->limit = $this->per_page; $criteria->offset = $offset; $data = \Model\TransportCompany::model()->with(['companyAttacheds'])->findAll($criteria); $tplObj->assign(['data' => $data]); $this->response->body(json_encode(['pagination' => $pagination, 'content' => $tplObj->fetch('catalog' . DS . 'transport.tpl')])); } }
public function action_getPlaceInfo() { $id_place = $this->request->post('id'); if (Request::current()->is_ajax() && $id_place) { $criteria = new \DBCriteria(); $criteria->condition = ''; $data = \Model\PlacesInfo::model()->with(array('idplaces0' => array('select' => 'idplaces0.name', 'joinType' => 'INNER JOIN')))->findByAttributes(['idplaces' => $id_place]); $tplObj = \smarty\View::factory('places'); $tplObj->assign(['data' => $data]); $this->response->body(json_encode(['content' => $tplObj->fetch('places' . DS . 'place_info.tpl')])); } }
public function action_fullHistory() { if (Request::current()->is_ajax()) { $sender_id = \Registry::getCurrentUser()->id; $receiver_id = $this->request->post('receiver_id'); $session = $this->request->post('session'); $user_full_history = $this->userCustomHistory($sender_id, $receiver_id, $session); $tplObj = \smarty\View::factory('chat' . DS . 'history_ajax'); $tplObj->assign(['full_history' => $user_full_history, 'sender_id' => $sender_id]); $this->response->body($tplObj); return true; } }