/** * Check if we are searching * * @return boolean */ public function isSearching() { if (zbase_request_is_post() && zbase_is_json() && !empty(zbase_request_input($this->getWidgetPrefix('search_query')))) { return true; } return false; }
/** * Dx * * @link http://dennesabing.com * @author Dennes B Abing <*****@*****.**> * @license proprietary * @copyright Copyright (c) 2015 ClaremontDesign/MadLabs-Dx * @version 0.0.0.1 * @since Mar 8, 2016 10:37:59 AM * @file widget.php * @project Expression project.name is undefined on line 13, column 15 in Templates/Scripting/EmptyPHP.php. * @package Expression package is undefined on line 14, column 15 in Templates/Scripting/EmptyPHP.php. */ return ['type' => 'form', 'enable' => false, 'config' => ['nested' => true, 'elements' => ['header' => ['ui' => ['type' => 'component.pageHeader', 'id' => 'header', 'text' => 'Request to change password, enter your current password.']], 'password' => ['type' => 'password', 'id' => 'account_password', 'label' => 'Account Password', 'angular' => ['ngModel' => 'currentUser.accountPassword'], 'validations' => ['required' => ['enable' => function () { if (zbase_request_is_post()) { $tab = zbase_request_input('tab'); if ($tab == 'email' || $tab == 'password') { return true; } } return false; }, 'message' => 'Please enter your account password.'], 'accountPassword' => ['enable' => function () { if (zbase_request_is_post()) { $tab = zbase_request_input('tab'); if ($tab == 'email' || $tab == 'password') { return true; } } return false; }, 'message' => 'Account password don\'t match.']]]]]];
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)); } }
/** * Return the validation rules * @return array */ public function getValidationRules() { if (zbase_request_is_post()) { $currentTab = zbase_request_input('tab', false); if (!empty($this->_validationRules['_tab' . $currentTab])) { return $this->_validationRules['_tab' . $currentTab]; } } return $this->_validationRules; }
/** * Set Page Property * @param string $action The Controller Action * @param array $param some assoc array that can be replace to the string * @return void */ public function pageProperties($action) { $section = zbase_section(); if (zbase_request_is_post()) { $action = str_replace('post-', null, $action); } $title = $this->_v('controller.' . $section . '.action.' . $action . '.page.title', null); $headTitle = $this->_v('controller.' . $section . '.action.' . $action . '.page.headTitle', $title); $subTitle = $this->_v('controller.' . $section . '.action.' . $action . '.page.subTitle', null); $breadcrumbs = $this->_v('controller.' . $section . '.action.' . $action . '.page.breadcrumbs', $this->_v('controller.' . $section . '.action.index.page.breadcrumbs', [])); zbase_view_pagetitle_set($headTitle, $title, $subTitle); if (!empty($breadcrumbs)) { zbase_view_breadcrumb($breadcrumbs); } return $this; }
protected function validateApi() { if (!empty($this->apiConfiguration['params'])) { $notParams = []; if (!empty($this->apiConfiguration['notParams'])) { $notParams = $this->apiConfiguration['notParams']; } $inputs = zbase_route_inputs(); unset($inputs['username']); unset($inputs['key']); unset($inputs['format']); unset($inputs['module']); unset($inputs['object']); unset($inputs['method']); $rules = array(); $messages = array(); if (zbase_request_is_post()) { $inputs = zbase_request_inputs(); } foreach ($this->apiConfiguration['params'] as $paramName => $param) { $pRules = array(); if (!empty($param['validations'])) { foreach ($param['validations'] as $ruleName => $ruleConfig) { $enable = true; $rule = $ruleName; if (isset($ruleConfig['enable'])) { $enable = $ruleConfig['enable']; } if (!empty($enable)) { if (!empty($ruleConfig['text'])) { $rule = zbase_data_get($ruleConfig, 'text'); } $pRules[] = $rule; if (!empty($ruleConfig['message'])) { $messages[$paramName . '.' . $ruleName] = $ruleConfig['message']; } } } } if (!empty($pRules)) { $rules[$paramName] = implode('|', $pRules); } if (isset($inputs[$paramName])) { if (!empty($param['varname'])) { $this->params[$param['varname']] = $inputs[$paramName]; } else { $this->params[$paramName] = $inputs[$paramName]; } } } if (!empty($notParams)) { foreach ($notParams as $nParam) { if (isset($this->params[$nParam])) { unset($this->params[$nParam]); } } } $validator = \Validator::make($inputs, $rules, $messages); if ($validator->fails()) { foreach ($validator->errors()->all() as $msg) { $this->apiErrors[] = $msg; } return false; } } return true; }
<br /> <br /> <br /> MESSAGE: ------------------- <br /> <?php echo $message; } ?> <br /> <br /> <br /> --- DETAILS: <?php $error = 'Date: ' . zbase_date_now()->format('Y-m-d h:i:s A') . "<br />"; $error .= 'URL: ' . zbase_url_uri() . "<br />"; $error .= 'Is Posting: ' . (zbase_request_is_post() ? 'Yes' : 'No') . "<br />"; $error .= 'Is AJAX: ' . (zbase_request_is_ajax() ? 'Yes' : 'No') . "<br />"; $error .= 'Data: ' . json_encode(zbase_request_inputs()) . "<br />"; $error .= 'Routes: ' . json_encode(zbase_route_inputs()) . "<br />"; $error .= 'IP Address: ' . zbase_ip() . "<br /><br /"; if (zbase_auth_has()) { $user = zbase_auth_user(); $error .= 'User: '******' ' . $user->username() . '[' . $user->id() . ']' . "<br />"; } echo $error; ?> <?php echo zbase_view_render(zbase_view_file_contents('email.footer'));