Skip to content

Commit

Permalink
unwanted variables are removed
Browse files Browse the repository at this point in the history
  • Loading branch information
shunnmugam committed Nov 24, 2021
1 parent b48ce53 commit 4ea9750
Show file tree
Hide file tree
Showing 79 changed files with 1,099 additions and 1,297 deletions.
11 changes: 3 additions & 8 deletions src/CmsServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
namespace Ramesh\Cms;

use Illuminate\Support\ServiceProvider;

use Ramesh\Cms\Controller\CmsController;
use Cms;
use Ramesh\Cms\providers\ModuleServiceProvider;
use Ramesh\Cms\providers\CommandProvider;
use Illuminate\Support\Facades\Schema;
Expand Down Expand Up @@ -35,15 +33,14 @@ public function boot()
], 'config');

$this->publishes([
__DIR__.'/stubs/skin' => public_path('skin'),
__DIR__ . '/stubs/skin' => public_path('skin'),
], 'public');

$this->publishes([
__DIR__.'/stubs/cms' => base_path('cms'),
__DIR__ . '/stubs/cms' => base_path('cms'),
], 'public');

Schema::defaultStringLength(191);

}

/**
Expand All @@ -57,15 +54,13 @@ public function register()
return new CmsController();
});
$loader = require base_path() . '/vendor/autoload.php';
$loader->setPsr4('cms\\core\\',base_path('cms/core'));
$loader->setPsr4('cms\\core\\', base_path('cms/core'));
//$loader->setPsr4('cms\\',base_path('cms/theme1'));


$this->app->register(ModuleServiceProvider::class);
$this->app->register(CommandProvider::class);

include_once('Helper.php');

}

}
4 changes: 1 addition & 3 deletions src/Commands/CmsPublish.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
namespace Ramesh\Cms\Commands;

use Illuminate\Console\Command;
use Ramesh\Cms\CmsServiceProvider;
use Cms;
use App;

class CmsPublish extends Command
{
/**
Expand Down
36 changes: 14 additions & 22 deletions src/Commands/Seed.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@

use Illuminate\Console\Command;
use Cms;
use File;
use Illuminate\Support\Facades\File;

class Seed extends Command
{
/**
Expand Down Expand Up @@ -47,40 +48,33 @@ public function handle()

$class = $this->option('class');

if($module)
{
if($class) {
if ($module) {
if ($class) {
$this->call('db:seed', [
'--class' => Cms::getPath() . '\\' . $module . '\\Database\\seeds\\'.$class
'--class' => Cms::getPath() . '\\' . $module . '\\Database\\seeds\\' . $class
]);
}
else
{
$module_path = base_path().'/' . Cms::getPath() . '/' . Cms::getModulesPath() . '/'.Cms::getCurrentTheme().'/' . $module . '/Database/seeds';
} else {
$module_path = base_path() . '/' . Cms::getPath() . '/' . Cms::getModulesPath() . '/' . Cms::getCurrentTheme() . '/' . $module . '/Database/seeds';
$files = $this->getAllFileInFolder($module_path);
foreach ($files as $file) {
$class_name = preg_replace('/\..+$/', '', $file);
$this->call('db:seed', [
'--class' => Cms::getPath() . '\\' . $module . '\\Database\\seeds\\'.$class_name
'--class' => Cms::getPath() . '\\' . $module . '\\Database\\seeds\\' . $class_name
]);
}

}
}else
{
} else {
$cms = Cms::allModulesPath(false);
foreach ($cms as $module)
{
foreach ($cms as $module) {


if($class) {
if (File::exists(base_path().'/' . $module . '/Database/seeds/'.$class.'.php')) {
if ($class) {
if (File::exists(base_path() . '/' . $module . '/Database/seeds/' . $class . '.php')) {
$this->call('db:seed', [
'--class' => $module . '\\Database\\seeds\\' . $class
]);
}
}
else {
} else {

$files = $this->getAllFileInFolder(base_path() . '/' . $module . '/Database/seeds');
//print_r($files);
Expand All @@ -94,10 +88,9 @@ public function handle()
//echo 'hai';
}
}

}
}
//echo 'success';
//echo 'success';
}

protected function getAllFileInFolder($folder)
Expand All @@ -108,7 +101,6 @@ protected function getAllFileInFolder($folder)
foreach ($files as $file) {
$path[] = $file->getfileName();
}

}
return $path;
}
Expand Down
11 changes: 3 additions & 8 deletions src/Controller/ModuleController.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
namespace Ramesh\Cms\Controller;

namespace Ramesh\Cms\Controller;

class ModuleController extends CmsController
{
Expand All @@ -26,28 +26,26 @@ public function getName()
*/
public function getJson()
{

}
/*
* get module id
*/
public function getId()
{

}
/*
* get module path
*/
public function getPath()
{
return base_path().DIRECTORY_SEPARATOR.parent::getPath().DIRECTORY_SEPARATOR.parent::getModulesLocalPath().parent::getCurrentTheme().DIRECTORY_SEPARATOR.$this->name;
return base_path() . DIRECTORY_SEPARATOR . parent::getPath() . DIRECTORY_SEPARATOR . parent::getModulesLocalPath() . parent::getCurrentTheme() . DIRECTORY_SEPARATOR . $this->name;
}
/*
* get module core path
*/
public function getCorePath()
{
return base_path().DIRECTORY_SEPARATOR.parent::getPath().DIRECTORY_SEPARATOR.parent::getModulesCorePath().DIRECTORY_SEPARATOR.$this->name;
return base_path() . DIRECTORY_SEPARATOR . parent::getPath() . DIRECTORY_SEPARATOR . parent::getModulesCorePath() . DIRECTORY_SEPARATOR . $this->name;
}

/**********get configuration values*****************/
Expand All @@ -61,7 +59,4 @@ public function getModuleConfig()
{
return parent::getConfig()['module'];
}



}
7 changes: 1 addition & 6 deletions src/Controller/ModulesController.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php
namespace Ramesh\Cms\Controller;

namespace Ramesh\Cms\Controller;

class ModulesController extends CmsController
{


public function __construct()
{

}

/*
Expand All @@ -18,8 +17,4 @@ public function getName()
{
return $this->name;
}




}
36 changes: 11 additions & 25 deletions src/providers/ModuleServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@

use Illuminate\Support\ServiceProvider;
use Illuminate\Foundation\AliasLoader;


use Unisharp\Laravelfilemanager\LaravelFilemanagerServiceProvider;
use Intervention\Image\ImageServiceProvider;

use Cms;

class ModuleServiceProvider extends ServiceProvider
Expand All @@ -20,7 +15,6 @@ class ModuleServiceProvider extends ServiceProvider
*/
public function boot()
{

}

/**
Expand All @@ -32,17 +26,14 @@ public function register()
{
$this->registerLibrary();

if(!config('cms') || config('cms')=='')
{
if (!config('cms') || config('cms') == '') {
//first time
}
else{
} else {
$this->registerNamespace();

$this->registerComposerAutoload();
$this->registerHelpers();
}

}
/*
* register module providers
Expand All @@ -51,7 +42,7 @@ protected function registerProviders()
{
$res = Cms::allModuleProvider();
//print_r($res);exit;

foreach ($res as $key => $provider) {
$this->app->register($provider);
}
Expand All @@ -65,37 +56,33 @@ protected function registerComposerAutoload()
$loader = require base_path() . '/vendor/autoload.php';
$composers = Cms::allModulesComposer();
foreach ($composers as $composer) {
foreach($composer['autoload'] as $autoload) {
foreach ($composer['autoload'] as $autoload) {
foreach ($autoload as $key => $value)
$loader->setPsr4($key,base_path().DIRECTORY_SEPARATOR.$value);
$loader->setPsr4($key, base_path() . DIRECTORY_SEPARATOR . $value);
}
}


}
protected function registerNamespace()
{
$modules = Cms::allModules();
$loader = require base_path() . '/vendor/autoload.php';
foreach($modules as $module)
{
if($module['type']=='local')
{
$loader->setPsr4('cms\\'.$module['name'].'\\',$module['path']);
foreach ($modules as $module) {
if ($module['type'] == 'local') {
$loader->setPsr4('cms\\' . $module['name'] . '\\', $module['path']);
}
}

$this->registerProviders();
// exit;
// exit;
}
/*
* Register Helpers
*/
protected function registerHelpers()
{

foreach(Cms::allModulesHelpers() as $aliaas => $value) {
$this->app->booting(function () use($aliaas,$value) {
foreach (Cms::allModulesHelpers() as $aliaas => $value) {
$this->app->booting(function () use ($aliaas, $value) {
$loader = AliasLoader::getInstance();
$loader->alias($aliaas, $value);
});
Expand All @@ -112,6 +99,5 @@ protected function registerLibrary()

$loader = AliasLoader::getInstance();
$loader->alias('Image', \Intervention\Image\Facades\Image::class);

}
}
23 changes: 10 additions & 13 deletions src/stubs/cms/core/admin/Controllers/AdminAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace cms\core\admin\Controllers;

use User;
use Hash;
use Session;
use cms\core\user\helpers\User;
use Carbon\Carbon;
use Illuminate\Http\Request;

Expand Down Expand Up @@ -32,24 +30,24 @@ public function dologin(Request $request)
'password' => 'required',
]);

$user = User::check(['username'=>$request->username,'password'=>$request->password]);
$user = User::check(['username' => $request->username, 'password' => $request->password]);

if($user) {
$users = UserModel::where('username','=',$request->username)->first();
Session::put(['ACTIVE_USER' => strval($users->id)
,'ACTIVE_USERNAME' => $users->username,
if ($user) {
$users = UserModel::where('username', '=', $request->username)->first();
$request->session()->put([
'ACTIVE_USER' => strval($users->id), 'ACTIVE_USERNAME' => $users->username,
'ACTIVE_GROUP' => 'Super Admin',
'ACTIVE_EMAIL' => $users->email,
'ACTIVE_MOBILE' => $users->mobile,
'ACTIVE_USERIMAGE' => $users->images]);
'ACTIVE_USERIMAGE' => $users->images
]);
//change offline to online
$users->online = 1;
$users->ip = request()->ip();
$users->lastactive = Carbon::now();
$users->save();
return redirect()->route('backenddashboard');
}
else
} else
return redirect()->back()
->withInput($request->input())
->withErrors(['Wrong Information']);
Expand Down Expand Up @@ -78,8 +76,7 @@ public function logout(Request $request)

$request->session()->flush();

Session::flash("success","Logout Successfull");
$request->session()->flash("success", "Logout Successfull");
return redirect('administrator/login');
}

}
14 changes: 5 additions & 9 deletions src/stubs/cms/core/admin/Middleware/AdminAuth.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
namespace cms\core\admin\Middleware;

use Closure;
use Session;
use User;
use CGate;
use cms\core\gate\helpers\CGate;

class AdminAuth
{
/**
Expand All @@ -17,18 +16,15 @@ class AdminAuth
*/
public function handle($request, Closure $next)
{
if(!ctype_digit(Session::get('ACTIVE_USER')) || !filter_var(Session::get('ACTIVE_EMAIL'), FILTER_VALIDATE_EMAIL)){
if (!ctype_digit($request->session()->get('ACTIVE_USER')) || !filter_var($request->session()->get('ACTIVE_EMAIL'), FILTER_VALIDATE_EMAIL)) {
return redirect('administrator/login');

}
if(CGate::allows('Backend Access')!=true)
{
if (CGate::allows('Backend Access') != true) {
$request->session()->flush();
Session::flash("error","Access Denied");
$request->session()->flash("error", "Access Denied");
return redirect('administrator/login');
}

return $next($request);
}

}
Loading

0 comments on commit 4ea9750

Please sign in to comment.