Example #1
0
 /**
  * @brief 错误或者成功输出
  *
  * @param string $status
  * @param stirng $url
  * @param string $msg
  * @param string $method
  * @param array $params
  *
  * @return string
  */
 public function splash($status = 'success', $url = null, $msg = null, $ajax = true)
 {
     $status = $status == 'failed' ? 'error' : $status;
     //如果需要返回则ajax
     if ($ajax == true || request::ajax()) {
         return response::json(array($status => true, 'message' => $msg, 'redirect' => $url));
     }
     if ($url && !$msg) {
         //如果有url地址但是没有信息输出则直接跳转
         return redirect::to($url);
     }
 }
Example #2
0
 public function handle($request, Clousure $next)
 {
     $routeAs = route::currentRouteName();
     $currentPermission = shopAuth::getSellerPermission();
     //$currentPermission = false 表示为店主不用判断权限
     //获取当前用户的路由权限
     if ($currentPermission && !in_array($routeAs, $currentPermission)) {
         if (request::ajax()) {
             return response::json(array('error' => true, 'message' => '无操作权限'));
         } else {
             return redirect::action('topshop_ctl_index@nopermission');
         }
     }
     return $next($request);
 }
Example #3
0
 public function splash($status = 'success', $url = null, $msg = null, $ajax = false)
 {
     $status = $status == 'failed' ? 'error' : $status;
     //如果需要返回则ajax
     if ($ajax == true || request::ajax()) {
         return response::json(array($status => true, 'message' => $msg, 'redirect' => $url));
     }
     if ($url && !$msg) {
         //如果有url地址但是没有信息输出则直接跳转
         return redirect::action($url);
     }
     $this->setLayoutFlag('splash');
     $pagedata['msg'] = $msg;
     return $this->page('topm/splash/error.html', $pagedata);
 }
Example #4
0
 function location_to()
 {
     //echo request::url(). '#'.$_SERVER['QUERY_STRING'];
     if (request::ajax() != true) {
         header('Location: ' . request::url() . '#' . $_SERVER['QUERY_STRING']);
     }
 }
Example #5
0
 protected function ajax()
 {
     return request::ajax() || request::wantsJson();
 }
 public function create(request $request)
 {
     if ($request->ajax()) {
     }
 }
Example #7
0
    function main()
    {
        if (isset($this->detail_pages)) {
            foreach ((array) $this->detail_pages as $k => $detail_func) {
                $str_detail_order = 'detail_' . $detail_func[1] . '_order';
                if (isset($detail_func[0]->{$str_detail_order}) && $detail_func[0]->{$str_detail_order}) {
                    switch ($detail_func[0]->{$str_detail_order}) {
                        case COLUMN_IN_HEAD:
                            $tmp = $this->detail_pages[$k];
                            unset($this->detail_pages[$k]);
                            $this->detail_pages = array_reverse($this->detail_pages);
                            $this->detail_pages[$k] = $tmp;
                            $this->detail_pages = array_reverse($this->detail_pages);
                            break;
                        case COLUMN_IN_TAIL:
                            $tmp = $this->detail_pages[$k];
                            unset($this->detail_pages[$k]);
                            $this->detail_pages[$k] = $tmp;
                            break;
                    }
                }
            }
        }
        if (request::ajax() && $_GET['singlepage'] != 'true') {
            //$_SERVER['HTTP_X_REQUESTED_WITH'] == 'XMLHttpRequest';
            if (isset($this->detail_pages)) {
                $tab_header = '<div class="tabs-wrap finder-tabs-wrap"><div class="tabs-items clearfix"><ul>';
                foreach ($this->detail_pages as $k => $detail_func) {
                    if ($k == $_GET['finderview']) {
                        $tab_header .= '<li class="tab current" item-id="' . $_GET['id'] . '" url="' . $this->url . '&action=detail&finderview=' . $k . '"><span>';
                        $tab_header .= $detail_func[0]->{$detail_func}[1];
                        $detail_html = $detail_func[0]->{$detail_func}[1]($_GET['id']);
                    } else {
                        //if($_GET['view'])unset($_GET['view']);
                        $tab_action = $this->url . '&action=detail&finderview=' . $k;
                        $tab_header .= '<li class="tab"><span>';
                        $tab_header .= '<a target="{update:\'finder-detail-' . $this->name . '\'}" href="' . $tab_action . '">' . $detail_func[0]->{$detail_func}[1] . '</a>';
                    }
                    $tab_header .= '</span></li>';
                }
                $tab_header .= '</ul></div>' . '<div class="scroll-handle l"><span>&laquo;</span></div>' . '<div class="scroll-handle r"><span>&raquo;</span></div></div>';
            }
            $output = '';
            if (count($this->detail_pages) > 1) {
                $output = $tab_header;
            }
            return $output . $detail_html;
        } else {
            if (request::ajax() && $_GET['singlepage'] == 'true') {
                foreach ($this->detail_pages as $k => $detail_func) {
                    if ($_GET['finderview'] == $k) {
                        $html = $detail_func[0]->{$detail_func}[1]($_GET['id']);
                        $label = $detail_func[0]->{$detail_func}[1];
                        echo <<<EOF
<h3>{$label}</h3>
{$html}
EOF;
                        exit;
                    }
                }
            } else {
                foreach ($this->detail_pages as $k => $detail_func) {
                    $detail_html = $detail_func[0]->{$detail_func}[1]($_GET['id']);
                    $pagedata['_detail_func'][$k] = array('label' => $detail_func[0]->{$detail_func}[1], 'html' => $detail_html);
                }
                return $this->controller->singlepage('desktop/common/detail-in-one.html', $pagedata);
            }
        }
    }
Example #8
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     //dd("Eliminado".$id);
     $user = User::findOrFail($id);
     $message = $user->fullName . ' has been delete';
     $user->delete();
     if (request::ajax()) {
         return response()->json(['message' => $message]);
     }
     //User::destroy($id);
     Session::flash('message', $message);
     return redirect()->route('admin.users.index');
 }