public function localisedField($object, $key) { $localisedKey = $key . StringUtil::startWithUpperCase($this->locale->getLang()); if (!empty($object[$localisedKey])) { return $object[$localisedKey]; } $localisedKey = $key . StringUtil::startWithUpperCase($this->locale->getDefaultLang()); return $object[$localisedKey]; }
public static function redirect($url = "") { if (StringUtil::isAbsoluteUrl($url)) { header("Location: " . $url); exit; } else { header("Location: " . Config::getBasePath() . trim($url, "/")); exit; } }
public static function getControllerClassName($routeData) { $controllerName = StringUtil::startWithUpperCase($routeData->getControllerName()) . 'Controller'; if (RouteData::isSystemRequest($routeData)) { return "\\ph\\phAdmin\\application\\controllers\\" . $controllerName; } else { if (RouteData::isUserRequest($routeData)) { return "\\application\\controllers\\" . $controllerName; } } return null; }
private static function getViewPathFromBasePath($routeData, $basePath) { $lowControllerName = StringUtil::startWithLowerCase($routeData->getControllerName()); $lowActionName = StringUtil::startWithLowerCase($routeData->getActionName()); $filePathWithActionName = $basePath . $lowControllerName . "/" . $lowActionName . "." . self::$VIEW_FILE_EXTENSION; if (file_exists($filePathWithActionName)) { return $filePathWithActionName; } $filePathWithoutActionName = $basePath . $lowControllerName . "." . self::$VIEW_FILE_EXTENSION; if (file_exists($filePathWithoutActionName)) { return $filePathWithoutActionName; } return null; }
public function url($url) { return StringUtil::isAbsoluteUrl($url) === true ? $url : Config::getBasePath() . $this->trimSlashes($url); }
private function convertExtracted2CamelCase($extractedList) { $res = []; foreach ($extractedList as $extractedObject) { $converted = []; foreach ($extractedObject as $key => $value) { $converted[StringUtil::underscore2Camel($key)] = $value; } $res[] = $converted; } return $res; }
private static function isSystemController($firstRouteToken) { return !empty($firstRouteToken) && StringUtil::equalIgnoreCase($firstRouteToken, Settings::SYSTEM_REQUEST_PREFIX); }
public function getDefaultLangCapitalised() { return StringUtil::startWithUpperCase($this->defaultLang); }
private function getPasswordValidationErrors($user) { $errors = []; if (Util::isEmpty($user['password'])) { $errors['User_EmptyPassword'] = 1; } else { if (!StringUtil::equal($user['password'], $user['password_confirm'])) { $errors['User_PasswordNotConfirmed'] = 1; } } return $errors; }