public function index() { if (!empty($_GET['nobg'])) { zbase_cookie_make('nobg', 1); } return $this->view(zbase_view_file('create.customize')); }
public function update() { $orderEntity = false; if ($this->isPost()) { $tableName = zbase_entity('custom_orders')->getTable(); $name = zbase_request_input('name', false); $orderId = zbase_request_input('order_id', false); $amount = zbase_request_input('amount', false); $validators = ['name' => 'required', 'amount' => 'required', 'order_id' => 'required|exists:' . $tableName . ',order_id,name,' . $name . ',total,' . number_format($amount, 2) . ',status,1', 'date' => 'required|date_format:Y-m-d|before:' . zbase_date_now()->addDay(), 'payment_center' => 'required', 'file' => 'required|image']; $messages = ['order_id.exists' => 'Order ID, Name and Amount don\'t match.', 'amount.required' => 'Enter the amount that you deposited or paid.', 'file.required' => 'Kindly upload your deposit or payment slip.', 'file.image' => 'The file you uploaded is not an image.']; $this->validate(zbase_request(), $validators, $messages); $folder = zbase_storage_path() . '/zivsluck/order/receipts/'; $newFilename = zbase_file_name_from_file($_FILES['file']['name'], $orderId, true); $newFilename = zbase_file_upload_image('file', $folder, $newFilename, 'png', [280, null]); if (file_exists($newFilename)) { $orderEntity = zbase_entity('custom_orders')->repository()->byId($orderId); $orderEntity->status = 2; $orderEntity->payment_merchant = zbase_request_input('payment_center', null); $orderEntity->paid_date_at = zbase_request_input('date', null); $orderEntity->payment_tracking_number = zbase_request_input('payment_tracking', null); $orderEntity->save(); $orderEntity->sendPaymentReceiptToShane(); } } zbase_view_pagetitle_set('Update Order'); return $this->view(zbase_view_file('order.update'), compact('orderEntity')); }
public function upload() { $image = false; $success = false; if ($this->isPost()) { if (!empty($_FILES['file'])) { $folder = zbase_storage_path() . '/zivsluck/site/images/'; $filename = md5($_FILES['file']['name'] . date('Y-m-d-H')); $newFilename = zbase_file_name_from_file($_FILES['file']['name'], $filename, true); if (!file_exists($folder . $filename . '.png')) { $newFilename = zbase_file_upload_image('file', $folder, $newFilename, 'png', []); if (file_exists($newFilename)) { $data = ['filename' => $filename]; $image = zbase_entity('images')->create($data); } } $image = zbase_entity('images')->repository()->by('filename', $filename)->first(); } else { $imagex = zbase_request_input('image', false); $delete = zbase_request_input('delete', false); if (!empty($imagex)) { $image = zbase_entity('images')->repository()->by('filename', $imagex)->first(); if (!empty($image)) { if (!empty($delete)) { unlink($folder = zbase_storage_path() . '/zivsluck/site/images/' . $image->name() . '.png'); $image->delete(); return 1; } $image->font = zbase_request_input('font', null); $image->material = zbase_request_input('material', null); $image->tags = zbase_request_input('tags', null); $image->save(); return 1; } return 0; } } } zbase_view_pagetitle_set('Images'); return $this->view(zbase_view_file('site.upload'), compact('image')); }
public function js() { return $this->view(zbase_view_file('page.js')); }
/** * SCripts when this content/view is displayed on innerContent via Ajax * * @param boolean $load Data is Loading else we are leaving the page, going back * @return void */ public function postPageOnInnerContentScript($tag = null) { if (!empty(zbase_request_input('_innercontent'))) { if (method_exists($this, 'pageOnInnerContentScript')) { $this->pageOnInnerContentScript($tag); } $postHtmlId = $this->postHtmlId(); $away = zbase_request_input('_innercontentaway', false); $tableRowId = zbase_request_input('_datatableRow', false); $innerContentId = zbase_request_input('_innerContentId', false); /** * Currently viewing the data */ $innerContentView = zbase_request_input('_innerContentView', false); if (empty($away)) { if (!empty($innerContentView)) { zbase()->json()->setVariable('_html_selector_replace', ['h3.page-title span.' . $this->postHtmlCommonId() => '<span class="' . $this->postHtmlCommonId() . '">' . zbase()->view()->title() . '<small>' . zbase()->view()->subTitle() . '</small></span>'], true); } else { if (!empty($tableRowId) && !empty($innerContentId)) { zbase()->json()->setVariable('_html_selector_remove', ['.' . $this->postHtmlCommonId() => ''], true); zbase()->json()->setVariable('_html_selector_append', ['.page-breadcrumb.breadcrumb' => '<li class="' . $this->postHtmlCommonId() . '"><i class="fa fa-angle-right"></i><a title="' . $this->postDisplayText() . '" href="#">' . $this->postDisplayText() . '</a></li>'], true); zbase()->json()->setVariable('_html_selector_append', ['h3.page-title' => '<span class="' . $this->postHtmlCommonId() . '">' . zbase()->view()->title() . '<small>' . zbase()->view()->subTitle() . '</small></span>'], true); zbase()->json()->setVariable('_html_selector_hide', ['.zbase-page-title' => ''], true); $script = 'jQuery(\'#' . $innerContentId . '\').closest(\'.zbase-widget-wrapper-datatable\').hide();jQuery(\'.breadcrumb li\').eq(2).find(\'a\').click(function(e){ e.preventDefault(); window.history.pushState(\'\',\'' . zbase()->view()->title() . '\',\'' . zbase_url_previous() . '\'); jQuery(\'#' . $innerContentId . '\').closest(\'.zbase-widget-wrapper-datatable\').show(); jQuery(\'#' . $innerContentId . '\').closest(\'.zbase-widget-wrapper-datatable\').siblings().remove(); jQuery(\'h3.page-title span.' . $this->postHtmlCommonId() . '\').remove(); jQuery(\'h3.page-title span.zbase-page-title\').show(); jQuery(\'.breadcrumb li.' . $this->postHtmlCommonId() . '\').remove(); })'; zbase()->json()->setVariable('_html_script', [$script], true); } } } else { $script = 'jQuery(\'#' . $innerContentId . '\').closest(\'.zbase-widget-wrapper-datatable\').show(); jQuery(\'#' . $innerContentId . '\').closest(\'.zbase-widget-wrapper-datatable\').siblings().remove(); jQuery(\'h3.page-title span.' . $this->postHtmlCommonId() . '\').remove(); jQuery(\'h3.page-title span.zbase-page-title\').show(); jQuery(\'.breadcrumb li.' . $this->postHtmlCommonId() . '\').remove();'; zbase()->json()->setVariable('_html_script', [$script], true); } } else { zbase()->json()->setVariable('_html_selector_replace', ['.page-breadcrumb.breadcrumb' => zbase_view_render(zbase_view_file('partial.breadcrumb', zbase_section()))], true); zbase()->json()->setVariable('_html_selector_html', ['.page-title' => zbase()->view()->title() . '<small>' . zbase()->view()->subTitle() . '</small>'], true); } }
/** * Display an error page * @param string|int $code * @param string $msg * @return string */ function zbase_view_error($code, $msg = null) { $common = [403, 404, 500, 503]; return \View::make(zbase_view_file('errors.' . (in_array($code, $common) ? $code : 500)), compact('msg', 'code')); }
public function index() { return $this->view(zbase_view_file('index.home')); }
/** * Render a view file * * zbase_view_render('index', []); * * @param string $file * @param array $params * @return \View */ function zbase_view_render($file, $params = []) { if (!empty($file)) { return view(zbase_view_file($file), $params)->render(); } }
/** * Login * @return */ public function login() { if (!$this->authEnabled()) { return $this->notfound('User authentication is disabled.'); } if ($this->isPost()) { return $this->postLogin(zbase_request()); } return $this->view(zbase_view_file('auth.login')); }
public function testzbase_view_file() { // Return the name $this->assertEquals('package::view.file', zbase_view_file('package::view.file')); }
public function index() { return $this->view(zbase_view_file('maintenance')); }
<?php /** * Routes configuration * * @link http://zbase.dennesabing.com * @author Dennes B Abing <*****@*****.**> * @license proprietary * @copyright Copyright (c) 2016 ClaremontDesign/MadLabs-Dx * @file routes.php * @project Zbase * @package config * */ return ['viewFile' => ['pageByViewFile' => ['view' => ['name' => zbase_view_file('index.viewfile'), 'enable' => true, 'page' => ['title' => 'Nodes', 'headTitle' => 'Nodes', 'subTitle' => 'Manage nodes', 'breadcrumbs' => [['label' => 'Nodes', 'link' => '#']]]], 'url' => '/view', 'enable' => true], 'controllerMethod' => ['controller' => ['name' => 'page', 'method' => 'index', 'enable' => true], 'url' => '/controller', 'enable' => false]]];
public function index() { return $this->view(zbase_view_file('promo.index')); }
public function controllerIndex() { if (!$this->getModule()->hasAccess()) { if (zbase_auth_has()) { return $this->unathorized(_zt('You don\'t have enough access to the resource.')); } else { return redirect()->to(zbase_url_from_route('login')); } } /** * Check for widgets */ $widgetsAction = $action = str_replace('.', '-', $this->getRouteParameter('action', 'index')); $requestMethod = zbase_request_method(); if (!empty($this->nodeName)) { $widgetsAction = $requestMethod . '-node-' . $this->nodeName . '-' . $action; $htmls = []; } $isAjax = zbase_request_is_ajax(); if ($isAjax) { $widgetsAction = (!empty($this->nodeName) ? $requestMethod . '-node-' . $this->nodeName . '-' : '') . 'json-' . $action; $htmls = []; } if ($this->getModule()->hasAction($requestMethod . '-' . $action)) { $widgetsAction = $requestMethod . '-' . $action; $action = $widgetsAction; $htmls = []; } $widgets = $this->getModule()->pageProperties($action)->widgetsByControllerAction($widgetsAction); if (count($widgets) == 1) { $firstWidget = collect($widgets)->first(); if ($firstWidget instanceof \Zbase\Widgets\WidgetInterface) { $firstWidget->pageProperties($widgetsAction); } } if (!is_array($widgets) && $widgets instanceof \Illuminate\Http\RedirectResponse) { return $widgets; } zbase()->json()->addVariable('_widget', $this->getModule()->id() . '_' . str_replace('-', '', $action)); if (zbase_is_dev()) { zbase()->json()->addVariable(__METHOD__, $widgetsAction); if (zbase_request_is_post()) { zbase()->json()->addVariable('_POST_PARAMETERS', zbase_request_inputs()); } zbase()->json()->addVariable('_ROUTE_PARAMETERS', zbase_route_inputs()); zbase()->json()->addVariable('_GET_PARAMETERS', zbase_request_query_inputs()); } // dd($this->getModule(), $widgetsAction, $widgets); if (empty($widgets)) { return zbase_abort(404); } foreach ($widgets as $widget) { if (!empty($this->nodeName)) { zbase()->json()->addVariable('node', ['prefix' => $this->getModule()->nodeNamespace(), 'name' => $this->nodeName, 'support' => 1]); $widget->setNodename($this->nodeName)->setNodeSupport(true); } if ($widget instanceof \Zbase\Widgets\ControllerInterface) { $v = $widget->validateWidget($action); if ($v instanceof \Illuminate\Contracts\Validation\Validator) { if ($isAjax) { zbase()->json()->addVariable('errors', $v->errors()->getMessages()); return new \Illuminate\Http\JsonResponse($v->errors()->getMessages(), 422); } else { return redirect()->to($this->getRedirectUrl())->withInput(zbase_request_inputs())->withErrors($v->errors()->getMessages()); } } $ret = $widget->controller($this->getRouteParameter('action', 'index')); if ($ret instanceof \Zbase\Exceptions\NotFoundHttpException) { return $this->notFound(); } if ($ret instanceof \Zbase\Exceptions\UnauthorizedException) { return $this->unathorized(); } if ($ret instanceof \Zbase\Exceptions\Exception) { return $this->error(); } if ($ret instanceof \Illuminate\Http\RedirectResponse) { if ($isAjax) { zbase()->json()->addVariable('redirect', $ret->getTargetUrl()); } else { return $ret; } } if (zbase_is_json()) { zbase_response_format_set('json'); $jsonIndexName = $widget->getWidgetPrefix(); if (zbase_is_angular()) { if ($widget instanceof \Zbase\Widgets\Type\Datatable) { $angularTemplate = zbase_angular_widget_datatable($this->getModule(), $widget); $jsonIndexName = $angularTemplate['serviceName']; } } if (zbase_is_dev()) { zbase()->json()->addVariable('$jsonIndexName', $jsonIndexName); } if (!$widget->isExporting()) { zbase()->json()->addVariable($jsonIndexName, $widget->toArray()); } } else { if ($isAjax) { $htmls[str_replace('-', '_', $widget->id())] = $widget->render(); } } $widget->pageProperties($widgetsAction); } } if (!empty($isAjax)) { zbase()->json()->addVariable('_widgets', 1); zbase()->json()->addVariable('html', $htmls); } else { return $this->view(zbase_view_file('module.index'), array('module' => $this->getModule(), 'widgets' => $widgets)); } }
</div> <!-- END PAGE HEADER--> <!-- BEGIN PAGE CONTENT--> <div class="row"> <div class="col-md-12 page-content-inner"> {!! zbase_alerts_render() !!} @yield('content') </div> </div> <!-- END PAGE CONTENT--> </div> </div> <!-- END CONTENT --> </div> <?php echo zbase_view_render(zbase_view_file('partial.footer', 'back')); ?> <?php } else { ?> {!! zbase_alerts_render() !!} @yield('content') <?php } ?> <?php echo zbase_view_render_body(); ?> </body> </html> <?php
public function renderException() { $request = zbase_request(); $e = $this; return response()->view(zbase_view_file('errors.' . $this->getStatusCode()), compact('request', 'e')); }
/** * Display the form to request a password reset link. * * @return \Illuminate\Http\Response */ public function getEmail() { return $this->view(zbase_view_file('auth.password.email')); }
echo $navigation->getNavigation(zbase_section()); } } ?> </ul> </div> <?php } ?> <!-- BEGIN TOP NAVIGATION MENU --> <ul class="nav navbar-nav pull-right"> <?php echo zbase_view_render(zbase_view_file('partial.notification-bar')); ?> <!-- BEGIN USER LOGIN DROPDOWN --> <?php if (zbase_auth_has()) { ?> <li class="dropdown user"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" data-hover="dropdown" data-close-others="true"> <img style="width:28px;" alt="" src="<?php echo zbase_auth_user()->avatarUrl(['w' => 30]); ?> "/> <span class="username"> <?php echo zbase_auth_user()->displayName();
/** * Create a route * @param string $name The Route Name * @param array $route The Route configuration * @return Response */ function zbase_route_response($name, $route) { if (!empty(zbase_is_maintenance())) { return zbase_response(view(zbase_view_file('maintenance'))); } $redirect = zbase_value_get($route, 'redirect', false); if (!empty($redirect)) { return redirect()->to($redirect); } $response = zbase_value_get($route, 'response', false); if (!empty($response)) { return $response; } /** * If we are using username in routes, * we have to check if the username exists in DB. * This is checked in zbase_route_username_get() * if the zbase_route_username_get() returns false, means * that the route is not a username or username didn't exists. * Here we check against all other Routes if the prefix is in our * list of routes, if not found, throw NotFoundHttpException */ $useUsernameRoute = zbase_route_username(); $usernameRoute = zbase_route_username_get(); $usernameRouteCheck = zbase_data_get($route, 'usernameRouteCheck', true); if (empty($usernameRouteCheck)) { /** * Will not check for username route */ $useUsernameRoute = false; } //if($usernameRoute === false && !empty($useUsernameRoute)) if ($name == 'index' && zbase_auth_has() && !empty($useUsernameRoute)) { return redirect()->to('/' . zbase_auth_real()->username); } if ($usernameRoute === false && !empty($useUsernameRoute)) { $uri = zbase_url_uri(); $adminKey = zbase_admin_key(); if (!empty($uri)) { $uriEx = explode('/', $uri); if (!empty($uriEx)) { foreach ($uriEx as $uriV) { if (!empty($uriV)) { /** * If it isn't an admin key, check it against given Routes */ if ($uriV !== $adminKey) { $routes = zbase_config_get('routes', []); if (!empty($routes)) { foreach ($routes as $rName => $r) { if (!empty($r['enable']) && !empty($r['url'])) { $urlEx = explode('/', $r['url']); if (!empty($urlEx)) { foreach ($urlEx as $urlExV) { if (!empty($urlExV)) { if ($uriV == $urlExV) { /** * Found it, valid URL */ $validUrlPrefix = true; } /** * Will deal only with the first not empty value so break it. */ break; } } } } if (!empty($validUrlPrefix)) { /** * Found it, break it */ $name = $rName; $route = $r; break; } } } } else { return redirect(zbase_url_from_route('home')); } /** * Will deal only with the first not empty value so break it. */ break; } } if (empty($validUrlPrefix)) { /** * Only if routeName is not the index */ if ($name != 'index') { // $response = new \Zbase\Exceptions\NotFoundHttpException(); // return $response->render(zbase_request(), $response); } } } } } $usernameRoutePrefix = zbase_route_username_prefix(); $originalRouteName = str_replace($usernameRoutePrefix, '', $name); zbase()->setCurrentRouteName($name); $guest = true; $authed = false; $guestOnly = false; $middleware = !empty($route['middleware']) ? $route['middleware'] : false; $backend = !empty($route['backend']) ? $route['backend'] : false; if ($name == 'password-reset' && zbase_auth_has()) { \Auth::guard()->logout(); return redirect(zbase_url_from_current()); } if (!empty($backend)) { // zbase_in_back(); } if (preg_match('/\\?usernameroute/', zbase_url_uri()) > 0 && !empty($useUsernameRoute) && zbase_auth_has()) { return redirect()->to('/' . zbase_auth_user()->username() . '/home'); } if (!empty($useUsernameRoute) && zbase_auth_has() && $usernameRoute != zbase_auth_user()->username()) { return redirect(zbase_url_from_route($originalRouteName, [$usernameRoutePrefix => zbase_auth_user()->username()])); } if (!empty($middleware)) { if (is_array($middleware)) { $access = isset($middleware['access']) ? $middleware['access'] : false; if (!empty($access) && is_array($access)) { if (!zbase_auth_has()) { zbase_session_set('__loginRedirect', zbase_url_from_current()); return redirect(zbase_url_from_route('login')); } if (zbase_auth_has() && !zbase_auth_is($access)) { return zbase_abort(401, ucfirst($access) . ' is needed to access the page.'); } } else { $guest = isset($middleware['guest']) ? $middleware['guest'] : false; $authed = isset($middleware['auth']) ? $middleware['auth'] : false; $adminAuthed = isset($middleware['admin']) ? $middleware['admin'] : false; if ($adminAuthed) { $authed = true; } $guestOnly = isset($middleware['guestOnly']) ? $middleware['guestOnly'] : false; } } } if (empty($access)) { if (!empty($backend)) { if (!empty($usernameRoute)) { /** * If user is loggedIn and this is admin side and this is not logIn page, * redirect to users dashboard. * User can only access his own dashboard via /{usernameroute?}/admin */ if (zbase_auth_has() && zbase_auth_is(zbase_route_username_minimum_access()) && zbase_is_back() && $usernameRoute != zbase_auth_user()->username()) { return redirect(zbase_url_from_route('admin', [$usernameRoutePrefix => zbase_auth_user()->username])); } if ((empty(zbase_auth_has()) || !zbase_auth_is('user')) && $name != $usernameRoutePrefix . 'admin.login') { zbase_session_set('__loginRedirect', zbase_url_from_current()); return redirect(zbase_url_from_route('admin.login')); } } else { if ((empty(zbase_auth_has()) || !zbase_auth_is('admin')) && $name != 'admin.login') { zbase_session_set('__loginRedirect', zbase_url_from_current()); return redirect(zbase_url_from_route('admin.login')); } } } else { if (!empty($guestOnly) && zbase_auth_has()) { return redirect(zbase_url_from_route('home')); } if (!empty($usernameRoute)) { if (!empty($authed) && !zbase_auth_has() && $name != $usernameRoutePrefix . 'login') { zbase_session_set('__loginRedirect', zbase_url_from_current()); return redirect(zbase_url_from_route('login')); } } else { if (!empty($authed) && !zbase_auth_has() && $name != 'login') { zbase_session_set('__loginRedirect', zbase_url_from_current()); return redirect(zbase_url_from_route('login')); } } } } $params = zbase_route_inputs(); $requestMethod = zbase_request_method(); $controller = !empty($route['controller']) ? $route['controller'] : null; $command = !empty($route['command']) ? $route['command'] : false; if (!empty($command) && $command instanceof \Closure) { $command(); exit; } if (!empty($controller) && !empty($controller['name']) && !empty($route['controller']['enable'])) { $controllerName = !empty($route['controller']['name']) ? $route['controller']['name'] : null; $controllerMethod = !empty($route['controller']['method'][$requestMethod]) ? $route['controller']['method'][$requestMethod] : (!empty($route['controller']['method']) ? $route['controller']['method'] : 'index'); if (!empty($controllerName)) { $controllerConfig = zbase_config_get('controller.class.' . $controllerName, null); if (!empty($controllerConfig) && !empty($controllerConfig['enable'])) { $controllerClass = zbase_controller_create_name(zbase_config_get('controller.class.' . $controllerName . '.name', Zbase\Http\Controllers\__FRAMEWORK__\PageController::class)); $controllerObject = zbase_object_factory($controllerClass, !empty($route['controller']['params']) ? $route['controller']['params'] : []); zbase()->setController($controllerObject->setName($controllerName)->setActionName($controllerMethod)->setRouteParameters($params)); zbase_view_page_details($route); return zbase_response($controllerObject->{$controllerMethod}()); } } } $view = !empty($route['view']) ? $route['view'] : null; if (!empty($view) && !empty($view['name']) && !empty($route['view']['enable'])) { zbase_view_page_details($route); if (!empty($route['view']['content'])) { $params['content'] = zbase_data_get($route['view']['content'], null); } if ($view['name'] == 'type.js') { zbase_response_format_set('javascript'); } return zbase_response(zbase_view_render(zbase_view_file($view['name']), $params)); } }