/** * Default action with registration form. * * @access public * @return View * @since 1.0.0 * @version 2.1.0-dev */ public function actionDefault() { // if user is logged, redirect to main page if (UserModel::isLogged()) { Route::factory('home')->redirectTo(); } $this->setTitle(__('Register Your account')); $this->setKeywords(__('register account,login,email,password')); /* @var $oConfig ModelFormConfig */ $oConfig = ModelFormConfig::factory(); $oConfig->noReload(); $oConfig->setFieldsRestriction(['login', 'email', 'password']); $oUser = new UserModel(); $oModelForm = $oUser->form('register', $oConfig); /* @var $oModelForm \ModelForm\User */ $oForm = $oModelForm->generate(); // if form is submitted and is valid if ($oForm->isSubmittedAndValid()) { $this->sendActivationCode($oForm->get('password_confirm'), $oUser); $sMessage = __('Your account has been registered successfully. Activation link has been sent to your mailbox. Click it to make the final activation.'); Session::flash(Router::getCurrentUrl(), $sMessage); } // return registration View return View::factory('user/frontend/register')->bind('oForm', $oForm); }
/** * Default action for database updating. * * @access public * @return View * @since 2014-08-17 * @version 1.2.0-dev */ public function actionDefault() { $this->addToTitle('Database updating module'); // create update form $oForm = new Form('db_update'); $oForm->setSubmitValue(__('make update')); // check if update button has been clicked if ($oForm->isSubmittedAndValid()) { $sUpdateOutput = static::makeUpdateNoExec(); Cache::set($sUpdateOutput, 'output', 'dbupdate'); Session::flash(Router::getCurrentUrl(), __('Database updated successfully.')); } // return View return View::factory('db_update/backend/default')->bind('oForm', $oForm); }
/** @noinspection PhpMissingParentCallCommonInspection */ public function actionDefault() { // create pass recovery form $oForm = Form::factory('password_recovery'); $emailField = Form\Field\Text::factory('email', $oForm)->setRequired()->setLabel('E-mail'); $oForm->addField($emailField); $oForm->addField(Form\Field\Captcha::factory('captcha', $oForm)); // if form is valid if ($oForm->isSubmittedAndValid()) { $sEmail = $oForm->getField('email')->getValueFirst(); // find user with particular e-mail $query = DB::query('SELECT u FROM \\Model\\User u WHERE u.email = :email'); $query->param('email', $sEmail); $oResult = $query->single(); /* @var $oResult User */ if ($oResult instanceof User) { $this->sendRecoveryCode($oResult); $sMessage = __("Message has been sent on your e-mail address. Click on the link from it's content to recover password to your account."); Session::flash(Router::getCurrentUrl(), $sMessage); } } // return view return View::factory('user/frontend/recovery/default')->bind('oForm', $oForm); }
/** * Find active route in particular menu. * * @access private * @param array $routes * @param integer $parentKey * @param array $parent * @since 1.0.0-dev * @version 1.3.0-dev */ private function findActiveRoute(array &$routes, $parentKey = NULL, array $parent = []) { foreach ($routes as $i => &$route) { /* @var $route array */ /* @var $routeName string */ /* @var $routeParams array */ /* @var $activeRoutes array */ if (!isset($route['classes'])) { $route['classes'] = []; } $routeName = Helper\Arrays::get($route, 'route_name', NULL); $url = Helper\Arrays::get($route, 'url', NULL); $routeParams = Helper\Arrays::get($route, 'route_parameters', []); $activeRoutes = Helper\Arrays::get($route, 'active_routes', []); // $path = $url === NULL ? Route::factory($routeName)->path($routeParams) : $url; if ($routeName !== NULL) { $path = Route::factory($routeName)->path($routeParams); } else { $path = $url; } $path = str_replace(Router::getBase(), '', $path); $currentPath = Router::getCurrentUrl(); if (in_array(Router::getCurrentRouteName(), $activeRoutes)) { $route['classes'][] = ['current ' . $this->activeTrailClass]; } if ($parentKey !== NULL) { $route['parent_key'] = $parentKey; $route['parent'] = $parent; } if ($path === $currentPath) { $this->goBackAndSetActive($route); } if (isset($route['children']) && !empty($route['children'])) { $this->findActiveRoute($route['children'], $i, $routes); /* @var $oChildren View */ } } }
/** * Find active route in particular menu. * * @access private * @param array $aRoutes * @param integer $iParentKey * @param array $aParent * @since 1.2.0-dev * @version 1.2.0-dev */ private function findActiveRoute(array &$aRoutes, $iParentKey = NULL, array $aParent = []) { foreach ($aRoutes as $i => &$aRoute) { /* @var $aRoute array */ $oItem = $aRoute['object']; /* @var $oItem \Model\Menu\Item */ $sRouteName = $oItem->getRoute(); /* @var $sRouteName string */ $aRouteParams = $oItem->getRouteParams() !== NULL ? $oItem->getRouteParams() : []; /* @var $aRouteParams array */ $aActiveRoutes = $oItem->getActiveRoutes() !== NULL ? $oItem->getActiveRoutes() : []; /* @var $aRouteParams array */ $sPath = Route::factory($sRouteName)->path($aRouteParams); $sCurrentPath = Router::getCurrentUrl(); if (in_array(Router::getCurrentRouteName(), $aActiveRoutes)) { $aRoute['classes'] = 'current active_trail'; } elseif (!isset($aRoute['classes'])) { $aRoute['classes'] = NULL; } if ($iParentKey !== NULL) { $aRoute['parent_key'] = $iParentKey; $aRoute['parent'] = $aParent; } if ($sPath === $sCurrentPath) { $this->goBackAndSetActive($aRoute); } if (isset($aRoute['siblings']) && !empty($aRoute['siblings'])) { $this->findActiveRoute($aRoute['siblings'], $i, $aRoutes); /* @var $oChildren View */ } } }
/** * Change breadcrumbs and/or title of "delete entity" action. * * @access protected * @since 1.0.0-alpha * @version 1.0.0-alpha */ protected function alterBreadcrumbsTitleDelete() { $this->addToTitle(__('Delete item')); $this->addBreadCrumb(__('Delete item'), Router::getCurrentUrl()); }
/** * Get form action URL. * * @access public * @return string * @since 1.0.0-alpha * @version 1.0.0-alpha */ public function getAction() { if ($this->action === NULL) { $this->action = Router::getCurrentUrl(); } return $this->action; }
/** * Change breadcrumbs and/or title of "add entity" action. * * @access protected * @since 1.1.3-dev, 2015-08-20 * @version 1.2.0-dev */ protected function alterBreadcrumbsTitleAdd() { $this->addToTitle(__('Add menu item')); $this->addBreadCrumb(__('Add menu item'), Router::getCurrentUrl()); }