Skip to content

Commit

Permalink
Merge pull request #93 from Ctrlpanel-gg/dev_no-encryption
Browse files Browse the repository at this point in the history
Dev no encryption
  • Loading branch information
1day2die authored May 3, 2023
2 parents 7d93d45 + a4b8020 commit 75af4c1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public function getOldValue(string $key)
// Always get the first value of the key.
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();

if (is_null($old_value)) {
return null;
}

// Handle the old values to return without it being a string in all cases.
if ($old_value->type === "string" || $old_value->type === "text") {
if (is_null($old_value->value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ public function getOldValue(string $key)
// Always get the first value of the key.
$old_value = DB::table('settings_old')->where('key', '=', $key)->get(['value', 'type'])->first();

if (is_null($old_value)) {
return null;
}

// Handle the old values to return without it being a string in all cases.
if ($old_value->type === "string" || $old_value->type === "text") {
if (is_null($old_value->value)) {
Expand Down
21 changes: 17 additions & 4 deletions app/Helpers/ExtensionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ public static function getAllExtensions()
foreach ($extensionNamespaces as $extensionNamespace) {
$extensions = array_merge($extensions, glob($extensionNamespace . '/*', GLOB_ONLYDIR));
}

// remove base path from every extension but keep app/Extensions/...
$extensions = array_map(fn ($item) => str_replace('/', '\\', str_replace(app_path() . '/', 'App/', $item)), $extensions);
$extensions = array_map(fn ($item) => str_replace(app_path() . '/', 'App/', $item), $extensions);

return $extensions;
}
Expand All @@ -33,7 +34,7 @@ public static function getAllExtensionsByNamespace(string $namespace)
{
$extensions = glob(app_path() . '/Extensions/' . $namespace . '/*', GLOB_ONLYDIR);
// remove base path from every extension but keep app/Extensions/...
$extensions = array_map(fn ($item) => str_replace('/', '\\', str_replace(app_path() . '/', 'App/', $item)), $extensions);
$extensions = array_map(fn ($item) => str_replace(app_path() . '/', 'App/', $item), $extensions);

return $extensions;
}
Expand All @@ -60,6 +61,9 @@ public static function getExtension(string $extensionName)
public static function getAllExtensionClasses()
{
$extensions = self::getAllExtensions();

// replace all slashes with backslashes
$extensions = array_map(fn ($item) => str_replace('/', '\\', $item), $extensions);
// add the ExtensionClass to the end of the namespace
$extensions = array_map(fn ($item) => $item . '\\' . basename($item) . 'Extension', $extensions);
// filter out non existing extension classes
Expand All @@ -76,6 +80,9 @@ public static function getAllExtensionClasses()
public static function getAllExtensionClassesByNamespace(string $namespace)
{
$extensions = self::getAllExtensionsByNamespace($namespace);

// replace all slashes with backslashes
$extensions = array_map(fn ($item) => str_replace('/', '\\', $item), $extensions);
// add the ExtensionClass to the end of the namespace
$extensions = array_map(fn ($item) => $item . '\\' . basename($item) . 'Extension', $extensions);
// filter out non existing extension classes
Expand Down Expand Up @@ -177,10 +184,13 @@ public static function getAllExtensionSettingsClasses()
{
$extensions = self::getAllExtensions();


$settings = [];
foreach ($extensions as $extension) {

$extensionName = basename($extension);

// replace all slashes with backslashes
$extension = str_replace('/', '\\', $extension);
$settingsClass = $extension . '\\' . $extensionName . 'Settings';
if (class_exists($settingsClass)) {
$settings[] = $settingsClass;
Expand All @@ -193,6 +203,9 @@ public static function getAllExtensionSettingsClasses()
public static function getExtensionSettings(string $extensionName)
{
$extension = self::getExtension($extensionName);
// replace all slashes with backslashes
$extension = str_replace('/', '\\', $extension);

$settingClass = $extension . '\\' . $extensionName . 'Settings';

if (class_exists($settingClass)) {
Expand All @@ -207,6 +220,6 @@ public static function getExtensionSettings(string $extensionName)
*/
private static function extensionNameToPath(string $extensionName)
{
return app_path() . '/' . str_replace('\\', '/', str_replace('App\\', '', $extensionName));
return app_path() . '/' . str_replace('App/', '', $extensionName);
}
}

0 comments on commit 75af4c1

Please sign in to comment.