Bug-fix-patch4

# handling exception in while adding language
# Implemented Yajra in users list table
# custom filter and veiw option in users list table
This commit is contained in:
Manish Verma
2016-12-20 19:33:23 +05:30
parent 1f8cda3875
commit 78f6a13528
11 changed files with 220 additions and 98 deletions

View File

@@ -122,79 +122,84 @@ class LanguageController extends Controller
*/
public function postForm()
{
// getting all of the post data
$file = [
'File' => Input::file('File'),
'language-name' => Input::input('language-name'),
'iso-code' => Input::input('iso-code'),
];
try {
// getting all of the post data
$file = [
'File' => Input::file('File'),
'language-name' => Input::input('language-name'),
'iso-code' => Input::input('iso-code'),
];
// setting up rules
$rules = [
'File' => 'required|mimes:zip|max:30000',
'language-name' => 'required',
'iso-code' => 'required|max:2',
]; // and for max size
// doing the validation, passing post data, rules and the messages
$validator = Validator::make($file, $rules);
if ($validator->fails()) {
// setting up rules
$rules = [
'File' => 'required|mimes:zip|max:30000',
'language-name' => 'required',
'iso-code' => 'required|max:2',
]; // and for max size
// doing the validation, passing post data, rules and the messages
$validator = Validator::make($file, $rules);
if ($validator->fails()) {
// send back to the page with the input data and errors
return Redirect::back()->withInput()->withErrors($validator);
} else {
//Checking if package already exists or not in lang folder
$path = base_path('resources/lang');
if (in_array(strtolower(Input::get('iso-code')), scandir($path))) {
//sending back with error message
Session::flash('fails', Lang::get('lang.package_exist'));
Session::flash('link', 'change-language/'.strtolower(Input::get('iso-code')));
return Redirect::back()->withInput();
} elseif (!array_key_exists(strtolower(Input::get('iso-code')), Config::get('languages'))) {//Checking Valid ISO code form Languages.php
//sending back with error message
Session::flash('fails', Lang::get('lang.iso-code-error'));
return Redirect::back()->withInput();
// send back to the page with the input data and errors
return Redirect::back()->withInput()->withErrors($validator);
} else {
// checking file is valid.
if (Input::file('File')->isValid()) {
$name = Input::file('File')->getClientOriginalName(); //uploaded file's original name
$destinationPath = base_path('public/uploads/'); // defining uploading path
$extractpath = base_path('resources/lang').'/'.strtolower(Input::get('iso-code')); //defining extracting path
mkdir($extractpath); //creating directroy for extracting uploadd file
//mkdir($destinationPath);
Input::file('File')->move($destinationPath, $name); // uploading file to given path
\Zipper::make($destinationPath.'/'.$name)->extractTo($extractpath); //extracting file to give path
//check if Zip extract foldercontains any subfolder
$directories = File::directories($extractpath);
//$directories = glob($extractpath. '/*' , GLOB_ONLYDIR);
if (!empty($directories)) { //if extract folder contains subfolder
$success = File::deleteDirectory($extractpath); //remove extracted folder and it's subfolder from lang
//$success2 = File::delete($destinationPath.'/'.$name);
if ($success) {
//sending back with error message
Session::flash('fails', Lang::get('lang.zipp-error'));
Session::flash('link2', 'http://www.ladybirdweb.com/support/show/how-to-translate-faveo-into-multiple-languages');
//Checking if package already exists or not in lang folder
$path = base_path('resources/lang');
if (in_array(strtolower(Input::get('iso-code')), scandir($path))) {
return Redirect::back()->withInput();
//sending back with error message
Session::flash('fails', Lang::get('lang.package_exist'));
Session::flash('link', 'change-language/'.strtolower(Input::get('iso-code')));
return Redirect::back()->withInput();
} elseif (!array_key_exists(strtolower(Input::get('iso-code')), Config::get('languages'))) {//Checking Valid ISO code form Languages.php
//sending back with error message
Session::flash('fails', Lang::get('lang.iso-code-error'));
return Redirect::back()->withInput();
} else {
// checking file is valid.
if (Input::file('File')->isValid()) {
$name = Input::file('File')->getClientOriginalName(); //uploaded file's original name
$destinationPath = base_path('public/uploads/'); // defining uploading path
$extractpath = base_path('resources/lang').'/'.strtolower(Input::get('iso-code')); //defining extracting path
mkdir($extractpath); //creating directroy for extracting uploadd file
//mkdir($destinationPath);
Input::file('File')->move($destinationPath, $name); // uploading file to given path
\Zipper::make($destinationPath.'/'.$name)->extractTo($extractpath); //extracting file to give path
//check if Zip extract foldercontains any subfolder
$directories = File::directories($extractpath);
//$directories = glob($extractpath. '/*' , GLOB_ONLYDIR);
if (!empty($directories)) { //if extract folder contains subfolder
$success = File::deleteDirectory($extractpath); //remove extracted folder and it's subfolder from lang
//$success2 = File::delete($destinationPath.'/'.$name);
if ($success) {
//sending back with error message
Session::flash('fails', Lang::get('lang.zipp-error'));
Session::flash('link2', 'http://www.ladybirdweb.com/support/show/how-to-translate-faveo-into-multiple-languages');
return Redirect::back()->withInput();
}
} else {
// sending back with success message
Session::flash('success', Lang::get('lang.upload-success'));
Session::flash('link', 'change-language/'.strtolower(Input::get('iso-code')));
return Redirect::route('LanguageController');
}
} else {
// sending back with success message
Session::flash('success', Lang::get('lang.upload-success'));
Session::flash('link', 'change-language/'.strtolower(Input::get('iso-code')));
// sending back with error message.
Session::flash('fails', Lang::get('lang.file-error'));
return Redirect::route('LanguageController');
return Redirect::route('form');
}
} else {
// sending back with error message.
Session::flash('fails', Lang::get('lang.file-error'));
return Redirect::route('form');
}
}
} catch (\Exception $e) {
Session::flash('fails', $e->getMessage());
Redirect::back()->withInput();
}
}