public function defaultAction() { $model_and_view = new __ModelAndView('logon'); $request = __Client::getInstance()->getRequest(); //Check credentials: $login = $request->getParameter('login'); $password = $request->getParameter('password'); $user_identity = new __UsernameIdentity(); $user_identity->setUsername($login); $credentials = new __PasswordCredentials(); $credentials->setPassword($password); try { $result_logon = __AuthenticationManager::getInstance()->logon($user_identity, $credentials); } catch (__SecurityException $e) { $result_logon = false; $error_message = $e->getMessage(); } if ($result_logon == false) { //Now will include smarty as ORS template engine: if ($error_message == '') { $error_message = __ResourceManager::getInstance()->getResource('ERR_LOGON_ERROR')->getValue(); } $model_and_view->errorMsg = $error_message; } else { if ($request->getParameter('destination_page')) { $model_and_view->redirectPage = $request->GetParameter('destination_page'); } else { $model_and_view->redirectPage = __UriFactory::getInstance()->createUri()->setActionCode('index')->addParameter(__ApplicationContext::getInstance()->getPropertyContent('REQUEST_LION_ADMIN_AREA'), 1)->getUrl(); } } //Return the view code to use: return $model_and_view; }
public function defaultAction() { $model_and_view = new __ModelAndView('login'); $welcome_to_lion = __ResourceManager::getInstance()->getResource('WELCOME_TO_LION_LABEL')->setParameters(array(__ApplicationContext::getInstance()->getPropertyContent('APP_NAME')))->getValue(); $model_and_view->welcome_to_lion = $welcome_to_lion; return $model_and_view; }
public function headerAction() { $application_in_edition = __ResourceManager::getInstance()->getResource('APPLICATION_IN_EDITION')->setParameters(array('app_name' => __ContextManager::getInstance()->getApplicationContext()->getPropertyContent('APP_NAME'))); $model_and_view = new __ModelAndView('header'); $model_and_view->application_in_edition = $application_in_edition; if (__ApplicationContext::getInstance()->getPropertyContent('LION_ADMIN_AUTH_REQUIRED') == true) { $model_and_view->logout_access = true; } else { $model_and_view->logout_access = false; } return $model_and_view; }
public function getLocalizedMessage($language_iso_code) { if ($this->_resource_id != null) { $resource_manager = __ResourceManager::getInstance(); if ($resource_manager->hasResource($this->_resource_id, $language_iso_code)) { $return_value = __ResourceManager::getInstance()->getResource($this->_resource_id, $language_iso_code)->setParameters($this->_error_message_parameters)->getValue(); } else { $return_value = $this->_resource_id; } } else { $return_value = parent::getMessage(); } return $return_value; }
public function defaultAction() { $model_and_view = new __ModelAndView('notifier'); $url = basename(__UriFactory::getInstance()->createUri()->setController('index')->getUrl()); $parameters = array('default_url' => $url); $request = __ActionDispatcher::getInstance()->getRequest(); if ($request->hasParameter('notification_title')) { $notification_title = $request->getParameter('notification_title'); $model_and_view->notification_title = __ResourceManager::getInstance()->getResource($notification_title)->setParameters($parameters)->getValue(); } if ($request->hasParameter('notification_description')) { $notification_description = $request->getParameter('notification_description'); $model_and_view->notification_description = __ResourceManager::getInstance()->getResource($notification_description)->setParameters($parameters)->getValue(); } return $model_and_view; }
/** * Creates a new __LionException children instance (depending on the error_id parameter). * * @param string $error_id * @param mixed $parameters Error message parameters * @return __LionException */ public function &createException($error_id, $parameters = array()) { if (!is_array($parameters)) { $parameters = array($parameters); } if ($this->_error_table != null) { if (is_numeric($error_id)) { $error_code = $error_id; $error_id = $this->_error_table->getErrorId($error_code); } else { $error_code = $this->_error_table->getErrorCode($error_id); } if ($error_code != null) { $exception_class = $this->_error_table->getExceptionClass($error_code); $error_message = $this->_error_table->getErrorMessage($error_code, $parameters); $return_value = new $exception_class($error_message, $error_code); } else { $error_code = 0; if (__ResourceManager::getInstance()->hasResource($error_id)) { $error_message = __ResourceManager::getInstance()->getResource($error_id)->setParameters($parameters)->getValue(); } else { $error_message = $error_id; } $return_value = new __UnknowException($error_message, $error_code); } } else { $return_value = new __UnknowException($error_id, 0); } if ($return_value instanceof __LionException) { $return_value->setErrorMessageResourceId($error_id); $return_value->setErrorMessageParameters($parameters); if ($this->_error_table != null) { $return_value->setErrorTitle($this->_error_table->getErrorTitle($error_code)); } } return $return_value; }
protected function _getResourceToRender() { $return_value = null; if ($this->isAssigned('resource')) { $resource_to_load = $this->getAssignedVar('resource'); if ($this->_isValidResource($resource_to_load)) { if (file_exists($resource_to_load) && strpos(realpath($resource_to_load), APP_DIR) !== false) { $resource_content = file_get_contents($resource_to_load); } else { $resource_content = file_get_contents(LION_DIR . DIRECTORY_SEPARATOR . $resource_to_load); } $return_value = new __FileResource(); $return_value->setValue($resource_content); $return_value->setFileName($resource_to_load); } } else { if ($this->isAssigned('resource_id')) { $resource_id = $this->getAssignedVar('resource_id'); $return_value = __Resourcemanager::getInstance()->getResource($resource_id); __ResourceManager::getInstance()->removeResource($resource_id); } } return $return_value; }
/** * Returns an descriptive name for the error group that an error code belong to. * If the error code does not belong to any group, the ERR_GROUP_UNKNOW group will be used to retrieve the title. * * @param string $error_code The error code (i.e. 55710) * @return string A readable title for the error group that the error code belong to (i.e. 'Internal core error') */ public function getErrorTitle($error_code) { $group_id = $this->getErrorGroup($error_code); if ($group_id != null) { $return_value = __ResourceManager::getInstance()->getResource($group_id)->getValue(); } else { $return_value = __ResourceManager::getInstance()->getResource('ERR_GROUP_UNKNOW')->getvalue(); } return $return_value; }
protected function _doValidation(__IComponent &$component) { $this->_validation_result = true; if ($component instanceof __IValueHolder && $component->getEnabled() && $component->getVisible()) { $value = $component->getValue(); $trimmed_value = trim($value); $component_to_match = $this->getComponentToMatch(); //check file size (if applicable): $error_file_size = false; $max_file_size = $this->getMaxFileSize(); if ($max_file_size !== null) { if ($component instanceof __IUploaderComponent) { $size = $component->getSize(); if ($size !== null && $max_file_size < $size) { $error_file_size = true; } } else { throw __ExceptionFactory::getInstance()->createException('Can not validate file size on a non uploader component (not implementing the __IUploaderComponent): ' . get_class($component)); } } if ($error_file_size) { $component->setStatus(__IUploaderComponent::UPLOAD_STATUS_ERROR); $exceded_size = $size - $max_file_size; $this->setErrorMessage('Maximum file size (' . $this->_getPrintableSize($max_file_size) . ') exceded by ' . $this->_getPrintableSize($exceded_size)); $this->_validation_result = false; } else { if ($component_to_match instanceof __IValueHolder && trim($component_to_match->getValue()) !== $trimmed_value) { print "[" . trim($component_to_match->getValue()) . "] - [" . $trimmed_value . ']'; $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_FIELD_MUST_MATCH')->setParameters(array($component->getAlias(), $component_to_match->getAlias()))->getValue()); $this->_validation_result = false; } else { if (strlen($trimmed_value) == 0 && $this->getMandatory()) { $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_REQUIRED_FIELD')->setParameters(array($component->getAlias()))->getValue()); $this->_validation_result = false; } else { if ($this->getValidLength() != null && strlen($value) != $this->getValidLength()) { $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_INVALID_LENGTH')->setParameters(array($component->getAlias(), $this->getValidLength()))->getValue()); $this->_validation_result = false; } else { if ($this->getMinLength() != null && strlen($value) < $this->getMinLength()) { $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_TOO_SHORT_VALUE')->setParameters(array($component->getAlias(), $this->getMinLength()))->getValue()); $this->_validation_result = false; } else { if ($this->getMaxLength() != null && strlen($value) > $this->getMaxLength()) { $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_TOO_LONG_VALUE')->setParameters(array($component->getAlias(), $this->getMaxLength()))->getValue()); $this->_validation_result = false; } else { if (!empty($value) && $this->getPattern() != null && !preg_match("/" . $this->getPattern() . "/i", $value)) { $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_INVALID_VALUE')->setParameters(array($component->getAlias()))->getValue()); $this->_validation_result = false; } else { if ($this->getAcceptance() && !$value) { $this->setErrorMessage(__ResourceManager::getInstance()->getResource('ERR_MUST_BE_ACCEPTED')); $this->_validation_result = false; } else { if (!empty($value) && $this->getOnlyInteger() && !is_numeric($value)) { $this->setErrorMessage('Must be integer'); $this->_validation_result = false; } else { if (!empty($value) && $this->getSpecificNumber() !== null && $value != $this->getSpecificNumber()) { $this->setErrorMessage('Must be ' . $this->getSpecificNumber()); $this->_validation_result = false; } else { if (!empty($value) && $this->getMinimumNumber() !== null && $value < $this->getMinimumNumber()) { $this->setErrorMessage('Must not be less than ' . $this->getMinimumNumber()); $this->_validation_result = false; } else { if (!empty($value) && $this->getMaximumNumber() !== null && $value > $this->getMaximumNumber()) { $this->setErrorMessage('Must not be more than ' . $this->getMaximumNumber()); $this->_validation_result = false; } else { if (!empty($value) && $this->getAllowedExtensions() != null && !preg_match('/\\.(' . join('|', $this->getAllowedExtensions()) . ')$/i', $value)) { $component->setStatus(__IUploaderComponent::UPLOAD_STATUS_ERROR); $this->setErrorMessage('Invalid file type. Expected extensions: ' . join(', ', $this->getAllowedExtensions())); $this->_validation_result = false; } else { $event_handler = __EventHandlerManager::getInstance()->getEventHandler($this->_view_code); if ($event_handler->isEventHandled('validate', $this->_component)) { $ui_event = new __UIEvent('validate', array('validationRule' => $this->getId()), $component); if ($event_handler->handleEvent($ui_event) === false) { $this->_validation_result = false; } } } } } } } } } } } } } } } } if ($this->_validation_result == true) { $this->_error_message = null; } return $this->_validation_result; }
/** * Magic method representing the result of rendering the current resource * * @return string */ public function __toString() { $return_value = __ResourceManager::getInstance()->getResource($this->getKey())->setParameters($this->_parameters)->getValue(); return $return_value; }
protected function _getCreateCommand($id_command, $id_group, $href = NULL, $has_subitems = false) { if ($this->_component->I18nSupport === true) { $returnValue = "\ti" . md5($id_command) . " = dmbAPI_addCommand('" . $id_group . "_GRP', '" . __ResourceManager::getInstance()->getResource($id_command)->getValue() . "');\n"; } else { $returnValue = "\ti" . md5($id_command) . " = dmbAPI_addCommand('" . $id_group . "_GRP', '" . $id_command . "');\n"; } if ($href != NULL) { $returnValue .= "\tdmbAPI_setOnClick(i" . md5($id_command) . ", \"/" . $href . "\");\n"; } if ($has_subitems == true) { $img_arrow_normal = __UriFactory::getInstance()->createUri()->setRouteId('resource')->setParameters(array('resource' => '/images/arrows/menu_arrow_normal.gif'))->getUrl(); $img_arrow_over = __UriFactory::getInstance()->createUri()->setRouteId('resource')->setParameters(array('resource' => '/images/arrows/menu_arrow_over.gif'))->getUrl(); $returnValue .= "\tdmbAPI_setImageRightNormal(i" . md5($id_command) . ", '{$img_arrow_normal}', 4, 7);\n"; $returnValue .= "\tdmbAPI_setImageRightOver(i" . md5($id_command) . ", '{$img_arrow_over}', 4, 7);\n"; } return $returnValue; }
/** * Get a I18n {@link __Resource} * * @return __Resource */ public function &getResource($resource_id, $language_iso_code = null) { $return_value = null; $resource_manager = __ResourceManager::getContextInstance($this->_context_id); if ($resource_manager instanceof __ResourceManager) { $return_value = $resource_manager->getResource($resource_id, $language_iso_code); } return $return_value; }