Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Merge pull request #24 from crocodic-studio/5.2
Browse files Browse the repository at this point in the history
bug fixed controller namespace & improve
  • Loading branch information
fherryfherry authored Aug 24, 2016
2 parents 5d2063d + 8172001 commit fc51148
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 29 deletions.
22 changes: 10 additions & 12 deletions src/controllers/CBController.php
Original file line number Diff line number Diff line change
Expand Up @@ -800,15 +800,20 @@ public function validation() {
}
$name = $di['name'];
if(!$name) continue;
$array_input[$name] = implode('|',$ai);

if(@$di['validation']) {
$array_input[$name] = $di['validation'];
}else{
$array_input[$name] = implode('|',$ai);
}
}

$validator = Validator::make(Request::all(),$array_input);

if ($validator->fails())
{
$message = $validator->messages();
$res = redirect()->back()->with("errors",$message);
$res = redirect()->back()->with("errors",$message)->withInput();
\Session::driver()->save();
$res->send();
exit();
Expand Down Expand Up @@ -1142,16 +1147,9 @@ public function init_setting() {

public function mainpath($path='') {
$path = ($path)?"/$path":"";
$current_modul_url = str_replace("\crocodicstudio\crudbooster\controllers\\","",strtok(Route::currentRouteAction(),'@') );
$current_modul_url = route($current_modul_url.'GetIndex');
$url = trim(str_replace(url('/'),'',$current_modul_url),'/');
if(strpos($url, '/add')) {
return substr($url, 0, strpos($url,'/add')).$path;
}elseif (strpos($url, '/edit')) {
return substr($url, 0, strpos($url,'/edit')).$path;
}else{
return $url.$path;
}
$controllername = str_replace(["\crocodicstudio\crudbooster\controllers\\","App\Http\Controllers\\"],"",strtok(Route::currentRouteAction(),'@') );
$route_url = route($controllername.'GetIndex');
return $route_url.$path;
}

public function get_cols() {
Expand Down
6 changes: 3 additions & 3 deletions src/controllers/ModulsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,10 @@ public function __construct() {
),"value"=>"fa fa-bars");


$this->form[] = array("label"=>"Route","name"=>"path","value"=>"admin/","jquery"=>"
$this->form[] = array("label"=>"Route","name"=>"path","jquery"=>"
$('#table_name').change(function() {
var v = $(this).val();
$('#path').val('admin/'+v);
$('#path').val(v);
})
");
$this->form[] = array("label"=>"Controller","name"=>"controller","type"=>"text","placeholder"=>"Auto Generated");
Expand Down Expand Up @@ -125,7 +125,7 @@ public function __construct() {

function hook_after_delete($id) {
$modul = DB::table('cms_moduls')->where('id',$id)->first();
@unlink(base_path('app/Http/Controllers/'.$modul->controller.'.php'));
@unlink(base_path('app/Http/Controllers/Admin'.$modul->controller.'.php'));
}

public function getFindLastSorting($id_moduls_group) {
Expand Down
4 changes: 2 additions & 2 deletions src/database/seeds/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public function run()
['id'=>11,'created_at'=>date('Y-m-d H:i:s'),'name'=>'favicon','content'=>'','content_input_type'=>'upload','dataenum'=>NULL,'helper'=>NULL],
['id'=>12,'created_at'=>date('Y-m-d H:i:s'),'name'=>'api_debug_mode','content'=>'true','content_input_type'=>'select','dataenum'=>'true,false','helper'=>NULL],
['id'=>13,'created_at'=>date('Y-m-d H:i:s'),'name'=>'google_api_key','content'=>'','content_input_type'=>'upload','dataenum'=>NULL,'helper'=>NULL],
['id'=>14,'created_at'=>date('Y-m-d H:i:s'),'name'=>'register_email_confirmation','content'=>'','content_input_type'=>'upload','dataenum'=>NULL,'helper'=>'Input message about email confirmation here, use alias [link_confirmation] to include the link.'],
['id'=>15,'created_at'=>date('Y-m-d H:i:s'),'name'=>'register_email_welcome','content'=>'','content_input_type'=>'upload','dataenum'=>NULL,'helper'=>"You can input message after registration is success. Then the message will be send to registrant. use [name] as user 's name, use [email] as user's email"]
['id'=>14,'created_at'=>date('Y-m-d H:i:s'),'name'=>'register_email_confirmation','content'=>'','content_input_type'=>'wysiwyg','dataenum'=>NULL,'helper'=>'Input message about email confirmation here, use alias [link_confirmation] to include the link.'],
['id'=>15,'created_at'=>date('Y-m-d H:i:s'),'name'=>'register_email_welcome','content'=>'','content_input_type'=>'wysiwyg','dataenum'=>NULL,'helper'=>"You can input message after registration is success. Then the message will be send to registrant. use [name] as user 's name, use [email] as user's email"]
]);
}
}
Expand Down
22 changes: 18 additions & 4 deletions src/helpers/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ function generate_controller($table,$name='') {

$path = base_path("app/Http/Controllers/");

if(file_exists($path.'Admin'.$controllername.'.php') || file_exists($path.'ControllerMaster/Admin'.$controllername.'.php')) {
if(file_exists($path.'Admin'.$controllername.'.php')) {
return 'Admin'.$controllername;
exit;
}
Expand All @@ -306,7 +306,7 @@ function generate_controller($table,$name='') {
use Cache;
use Validator;
class Admin'.$controllername.' extends Controller {
class Admin'.$controllername.' extends \crocodicstudio\crudbooster\controllers\CBController {
public function __construct() {
$this->table = "'.$table.'";
Expand Down Expand Up @@ -403,7 +403,7 @@ public function __construct() {

if(in_array($field, $password_candidate)) {
$type = 'password';
$add_attr = ', "help"=>"Please keep empty if you did not change the password"';
$add_attr = ', "help"=>"Please leave empty if you did not change the password"';
}


Expand All @@ -420,7 +420,7 @@ public function __construct() {
$add_attr .= ',"googlemaps"=>true';
}

$php .= "\t\t".'$this->form[] = array("label"=>"'.$label.'","name"=>"'.$field.'","type"=>"'.$type.'" '.$datatable.' '.$add_attr.' );'."\n";
$php .= "\t\t".'$this->form[] = array("label"=>"'.$label.'","name"=>"'.$field.'","type"=>"'.$type.'","required"=>true '.$datatable.' '.$add_attr.' );'."\n";
}

$php .= '
Expand Down Expand Up @@ -1001,6 +1001,20 @@ function get_method() {
return $method;
}

/*
| --------------------------------------------------------------------------------------------------------------
| To get main path url
| --------------------------------------------------------------------------------------------------------------
| will be return url get index of current
|
*/
function mainpath($path=NULL) {
$path = ($path)?"/$path":"";
$controllername = str_replace(["\crocodicstudio\crudbooster\controllers\\","App\Http\Controllers\\"],"",strtok(Route::currentRouteAction(),'@') );
$route_url = route($controllername.'GetIndex');
return $route_url.$path;
}

/*
| --------------------------------------------------------------------------------------------------------------
| To log activity
Expand Down
3 changes: 2 additions & 1 deletion src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@

});

Route::group(['middleware'=>['web','\crocodicstudio\crudbooster\middlewares\CBBackend'],'prefix'=>config('crudbooster.ADMIN_PATH')], function () {
// ROUTER FOR OWN CONTROLLER FROM CB
Route::group(['middleware'=>['web','\crocodicstudio\crudbooster\middlewares\CBBackend'],'prefix'=>config('crudbooster.ADMIN_PATH'),'namespace'=>'App\Http\Controllers'], function () {

try{
$master_controller = glob(__DIR__.'/controllers/*.php');
Expand Down
2 changes: 1 addition & 1 deletion src/views/default/actionmenu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
})
show_alert_floating('Please wait whilte delete selected...');
$.post("{{route($current_controller.'PostDeleteSelected')}}",{id:checks},function(resp) {
$.post("{{ mainpath('deleted-selected') }}",{id:checks},function(resp) {
show_alert_floating('Delete selected successfully !');
hide_alert_floating();
$(".btn-reload-table").click();
Expand Down
5 changes: 1 addition & 4 deletions src/views/default/form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,7 @@
<h3 class="box-title">{{ (Request::get('detail'))?str_replace(array("Add Data","Edit Data"),"Detail Data",$page_title):$page_title }}</h3>
<div class="box-tools">
@if($button_cancel)<a href='{{url($dashboard)."?".urldecode(http_build_query(@$_GET)) }}' class='btn btn-default'>Cancel</a>@endif
@if( ($priv->is_create || $priv->is_edit) && count($forms)!=0)
@if($priv->is_create && $button_addmore == TRUE) <button title='Save Data' class='btn btn-success addmore' type='button'><i class='fa fa-save'></i> Save & Add More</button>@endif
@if($button_save)<button title='Save Data' class='btn btn-success btn-form-save' onclick="$('#form').submit()" type='button'><i class='fa fa-save'></i> Save</button>@endif
@endif

</div>
</div>

Expand Down
7 changes: 5 additions & 2 deletions src/views/default/form_body.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@
@$value = (isset($form['value']))?$form['value']:'';
@$value = (isset($row->{$name}))?$row->{$name}:$value;
$old = old($name);
$value = ($old)?:$value;
if( ($parent_field && $name == $parent_field) && !isset($form['visible']) ) continue;
if(isset($form['onlyfor'])) {
Expand Down Expand Up @@ -656,11 +659,11 @@ function setupClickListener(id, types) {
$('#{{$name}}').change(function() {
console.log('{{$name}} changed');
$('#{{$form['sub_select']}}').html('<option value="">Tunggu sebentar...</option>');
$('#{{$form['sub_select']}}').html('<option value="">Please wait...</option>');
var parid = $(this).val();
$.get('{{url("admin/$tab/find-data")}}?parid='+parid+'&parfield={{$name}}&limit=500',function(resp) {
$('#{{$form['sub_select']}}').empty();
$('#{{$form['sub_select']}}').html("<option value=''>** Pilih Salah Satu</option>");
$('#{{$form['sub_select']}}').html("<option value=''>** Please Select Data</option>");
$.each(resp.items,function(i,obj) {
var selected = (val && val == obj.id)?'selected':'';
$('#{{$form['sub_select']}}').append('<option '+selected+' value=\"'+obj.id+'\">'+obj.text+'</option>');
Expand Down

0 comments on commit fc51148

Please sign in to comment.