PHP App::getRouter Examples

PHP App::getRouter - 30 examples found. These are the top rated real world PHP examples of App::getRouter extracted from open source projects. You can rate examples to help us improve the quality of examples.
 public function restore()
 {
     $params = App::getRouter()->getParams();
     if (strlen($params[0]) > 0) {
         $res = $this->model->getRestorePass($params[0]);
         if ($params[0] == $res[0]['hash']) {
             // если хеш в базе найден - показать страницу с восстановлением и грохнуть записи из таблицы хеша
             $this->model->delRestorePass($res[0]['email'], $res[0]['hash']);
             // тут удалим из базы мыло и хеш логина при подтверждении
             $data = $res[0]['id_user'];
             $this->data['restore'] = $data;
         }
     } else {
         // проверим ответ
         if (count($_POST)) {
             if (!is_null($_POST['password']) && !is_null($_POST['password1']) && $_POST['password'] == $_POST['password1']) {
                 // и если все получено ок
                 $data = $_POST;
                 $this->model->saveNewPass($data);
                 // записать новый пароль
                 Router::redirect('/');
             }
         }
     }
 }
 public function view()
 {
     $params = App::getRouter()->getParams();
     if (isset($params[0])) {
         $name = strtolower($params[0]);
         $this->data['project'] = $this->model->getByKoDescription($name);
     }
 }
Example #3
0
 function __construct($data = array())
 {
     $this->data = $data;
     $this->params = App::getRouter()->getParams();
     $this->params_get = App::getRouter()->getParamsGet();
     // adding global value accounts count to all controllers
     $this->data['account_count'] = (new Person())->getAccountCount();
 }
 public function view()
 {
     $params = App::getRouter()->getParams();
     if (isset($params[0])) {
         $id = strtolower($params[0]);
         $this->data['product'] = $this->model->getById($id);
     }
 }
Example #5
0
 public function admin_delete()
 {
     $params = App::getRouter()->getParams();
     if (isset($params[0])) {
         $this->model->eventDelete($params[0]);
         Router::redirect('/admin/events');
     }
 }
Example #6
0
 public function view()
 {
     $params = App::getRouter()->getParams();
     if (isset($params[0])) {
         $alias = strtolower($params[0]);
         $this->data['content'] = "Here will be a page with '{$alias}' alias";
     }
 }
Example #7
0
 public function viev()
 {
     $params = App::getRouter()->getParams();
     if (isset($params[0])) {
         $alias = strtolower($params[0]);
         echo "Here will be a page with '{$alias}' alias";
     }
 }
Example #8
0
 public function view()
 {
     $params = App::getRouter()->getParams();
     if (isset($params[0])) {
         $alias = strtolower($params[0]);
         $this->data['page'] = $this->model->getByAlias($alias);
     }
 }
Example #9
0
 public function admin_index()
 {
     if (Session::get('role') != 'admin') {
         Router::redirect('/');
     }
     $params = App::getRouter()->getParams();
     print_r($params);
     $this->data['pages'] = $this->model->getList($params[0]);
 }
 public function view()
 {
     $params = App::getRouter()->getParams();
     if (isset($params[0])) {
         $alias = strtolower($params[0]);
         $this->data['page'] = $this->model->getByAlias($alias);
     }
     $comments_model = new Comment();
     $this->data['comments'] = $comments_model->getByPageId($this->data['page']['id']);
 }
Example #11
0
 protected static function getDefaultViewPath()
 {
     $router = App::getRouter();
     if (!$router) {
         throw new Exception('Router was not found');
     }
     $controller_dir = $router->getController();
     $template_name = $router->getMethodPrefix() . $router->getAction() . '.php';
     return VIEWS_PATH . DS . $controller_dir . DS . $template_name;
 }
Example #12
0
 protected static function getDefaultViewPath()
 {
     $router = App::getRouter();
     if (!$router) {
         return false;
     }
     $controller_dir = $router->getController();
     $template_name = $router->getMethodPrefix() . $router->getAction() . '.html';
     return VIEWS_PATH . DS . $controller_dir . DS . $template_name;
 }
Example #13
0
 protected static function getDefaultViewPath()
 {
     $router = App::getRouter();
     if (!$router) {
         throw new Exception("Calling view without creating router object");
     }
     $controller_dir = $router->getController();
     $template_name = $router->getMethodPrefix() . $router->getAction() . ".html";
     return VIEWS_PATH . DS . $controller_dir . DS . $template_name;
 }
Example #14
0
 public function view()
 {
     $params = App::getRouter()->getParams();
     $this->data['excInfo'] = $this->model->getExcursionById($params[0]);
     if (isset($params[0]) && isset($this->data['excInfo'])) {
         $this->data['userInfo'] = $this->model->getUserInfo($this->data['excInfo']['user_id']);
     } else {
         Router::redirect('/');
     }
 }
Example #15
0
 public function __construct($data = array())
 {
     //session_start();
     if (isset($_SESSION['time']) && time() - $_SESSION['time'] > 3600) {
         session_destroy();
         Router::redirect('/');
         // session_start();
     }
     $_SESSION['time'] = time();
     $this->data = $data;
     $this->params = App::getRouter()->getParams();
 }
Example #16
0
 public function add()
 {
     $params = App::getRouter()->getParams();
     if (isset($params[0])) {
         $result = $this->model->add($_POST, $params[0]);
         if ($result) {
             Session::MessageSend(3, 'Ваш отзыв добавлен успешно.', '/users/reviews/' . $params[0]);
         } else {
             Session::MessageSend(1, 'Что-то пошлно не так, возможно вы не заполнили все поля.', '/users/reviews/' . $params[0]);
         }
     }
 }
 public function view()
 {
     $params = App::getRouter()->getParams();
     if (!empty($params)) {
         /*if (isset($params)) {*/
         /*var_dump($params);die;*/
         $alias = strtolower($params[0]);
         $this->data['page'] = $this->model->getByAlias($alias);
     } else {
         $this->data['content'] = "PAGE controller - method view! Default content here<br />";
     }
 }
 public function view()
 {
     $params = App::getRouter()->getParams();
     if (isset($params[0])) {
         $com = strtolower($params[0]);
         $this->data['good'] = $this->model->getByCompany($com);
     }
     if (isset($params[1])) {
         $mod = strtolower($params[1]);
         $this->data['good'] = $this->model->getByModel($mod);
     }
 }
Example #19
0
 public function delete()
 {
     $params = App::getRouter()->getParams();
     $this->data['message'] = $this->model->getUserMessage($params[0]);
     if (isset($params[0])) {
         if (Session::get('id') == $this->data['message']['user_id']) {
             $this->model->deleteUserMessage($params[0]);
             Session::MessageSend(3, 'Сообщение удалено.', '/users/messages/');
         } else {
             Router::redirect('/users/messages/');
         }
     }
 }
Example #20
0
 public function view()
 {
     $params = App::getRouter()->getParams();
     $alias = strtolower($params[0]);
     $this->data['city'] = $this->model->getByAlias($alias);
     $this->data['gidCount'] = $this->model->gidCountByCity($alias);
     $this->data['excCount'] = $this->model->excCountByCity($alias);
     if (isset($params[0]) && isset($this->data['city'])) {
         $this->data['gids'] = $this->model->getAllGidByCity($alias);
     } else {
         Router::redirect('/');
     }
 }
Example #21
0
 public function __construct($data = array())
 {
     //session_start();
     // определим время сессии и если оно больше 1 часа - то выбросить пользователя из системы.
     if (isset($_SESSION['time']) && time() - $_SESSION['time'] > 3600) {
         session_destroy();
         Router::redirect('/');
         exit;
         // session_start();
     }
     $_SESSION['time'] = time();
     $this->data = $data;
     $this->params = App::getRouter()->getParams();
 }
Example #22
0
 public static function getMainMenu()
 {
     self::$router = App::getRouter()->getRoute();
     self::$router = self::$router == 'default' ? '' : '/admin';
     $result = '';
     foreach (self::$items as $_item) {
         $class = '';
         if (App::getRouter()->getController() == $_item['active_class']) {
             $class = 'active';
         }
         $result .= '<li class="' . $class . '"><a href="' . self::$router . $_item['url'] . '">' . $_item['title'] . '</a></li>';
     }
     return $result;
 }
Example #23
0
 public function toy()
 {
     $category = array_shift(App::getRouter()->getParams());
     $method = next(App::getRouter()->getParams());
     //print_r($method); die;
     $this->data['toys'] = $this->model->getList($category);
     $this->data['latest tovar'] = $this->model->getLatestTovar();
     switch ($method) {
         case 'price0-9':
             $this->data['toys'] = $this->model->getSortPriceABC($category);
             break;
         case 'price9-0':
             $this->data['toys'] = $this->model->getSortPriceDESC($category);
             break;
         case 'boy':
             $this->data['toys'] = $this->model->getSortBOY($category);
             break;
         case 'girl':
             $this->data['toys'] = $this->model->getSortGIRL($category);
             break;
         case 'year1':
             $this->data['toys'] = $this->model->getSortYear1($category);
             break;
         case 'year1-2':
             $this->data['toys'] = $this->model->getSortYear1and2($category);
             break;
         case 'year2-3':
             $this->data['toys'] = $this->model->getSortYear2and3($category);
             break;
         case 'year3-5':
             $this->data['toys'] = $this->model->getSortYear3and5($category);
             break;
         case 'year5-7':
             $this->data['toys'] = $this->model->getSortYear5and7($category);
             break;
         case 'year7-11':
             $this->data['toys'] = $this->model->getSortYear7and11($category);
             break;
         case 'year11-16':
             $this->data['toys'] = $this->model->getSortYear11and16($category);
             break;
         case 'year16':
             $this->data['toys'] = $this->model->getSortYear16($category);
     }
 }
Example #24
0
 /**
  * 创建url
  *
  * @param string $url
  * @param array $params
  * @param boolean $absolute 是否绝对地址
  * @return string
  */
 public static function build($url, $params = array(), $absolute = false)
 {
     $mode = App::getConfig()->getURLMode();
     $request = Request::getInstance();
     $router = App::getRouter();
     $protocol = $request->getProtocol();
     $domain = $request->getHost();
     if ($url == '') {
         $url = '/' . $router;
     } elseif ($mode === 1) {
         $url = self::buildQuery($router, $url, $params);
     } elseif ($mode === 2) {
         $url = self::buildPathInfo($router, $url, $params);
     } elseif ($mode === 3) {
         $url = self::buildRewrite($url, $params);
     } else {
         $url = self::buildQuery($router, $url, $params);
     }
     if ($absolute) {
         return $protocol . '://' . $domain . $url;
     } else {
         return $url;
     }
 }
Example #25
0
 public function profile()
 {
     $params = App::getRouter()->getParams();
     if ($params[0] == null) {
         Router::redirect('/');
     }
     if (count($_POST)) {
         $hash = md5(Config::get('salt') . $_POST['password']);
         if ($_POST['password'] === $_POST['password2']) {
             $res_post = $_POST;
             $this->model->save($res_post);
         }
         Router::redirect('/');
     }
     if ($_POST['back']) {
         Router::redirect('/');
     }
     if (isset($this->params[0])) {
         $this->data['users'] = $this->model->getUsersById($this->params[0]);
     } else {
         Session::setFlash(__('Wrong_page_id', 'Wrong page id'));
         Router::redirect('/');
     }
 }
Example #26
0
 public function view()
 {
     $params = App::getRouter()->getParams();
     $this->data['posts'] = $this->model->getPost($params);
 }
 public function __construct($data = array())
 {
     $this->data = $data;
     $this->params = App::getRouter()->getParams();
 }
 public function admin_edit()
 {
     if (getId() == null) {
         Router::redirect('/');
     }
     if (!$_POST['back']) {
         $params = App::getRouter()->getParams();
         if ($params[0] == null || $params[1] == null) {
             Router::redirect('/');
         }
         $result = $this->model->getGood($params);
         $cur_goods = $result[0];
         if (($cur_goods['goods_active'] == 1 || (int) $cur_goods['goods_days_left'] > 0) && $cur_goods['goods_start_time'] < date('Y-m-d H:m:s', time())) {
             Session::setFlash(__('page_was_not_saved', 'Page was not saved'));
             Router::redirect('/admin/users/');
         } else {
             $this->data['mainlist'] = $result;
         }
     } else {
         if (getId() != null) {
             Router::redirect('/admin/users/');
         } else {
             Router::redirect('/admin/users/');
         }
     }
 }
Example #29
0
 public function reviews()
 {
     $params = App::getRouter()->getParams();
     if (isset($params[0])) {
         $this->data['user'] = $this->model->getUserInfo($params[0]);
         $this->data['reviews'] = $this->model->getUserReviews($params[0]);
     } else {
         Router::redirect($_SERVER['HTTP_REFERER']);
     }
 }
Example #30
0
 public function __construct($data = array())
 {
     $this->data;
     $this->params = App::getRouter()->getParams();
     //echo "<pre>"; print_r($this->params);echo "</pre>";
 }