MMC alpha ready
This commit is contained in:
@@ -184,18 +184,18 @@ class AUKController extends Controller
|
||||
*/
|
||||
public function load(Request $request)
|
||||
{
|
||||
Log::alert("In load");
|
||||
// Log::alert("In load");
|
||||
$project_id = $request->session()->get('project_id');
|
||||
|
||||
$i = 0;
|
||||
while ($request->input('auk_name_' . $i) !== null) {
|
||||
Log::alert("Loading " . $i);
|
||||
// Log::alert("Loading " . $i);
|
||||
$auk_name = $request->input('auk_name_' . $i);
|
||||
$auk_path = $request->input('auk_path_' . $i);
|
||||
$image_dir = $request->input('image_dir_' . $i);
|
||||
Log::alert("auk_name \"" . $auk_name . "\"");
|
||||
Log::alert("auk_path \"" . $auk_path . "\"");
|
||||
Log::alert("image_dir \"" . $image_dir . "\"");
|
||||
// Log::alert("auk_name \"" . $auk_name . "\"");
|
||||
// Log::alert("auk_path \"" . $auk_path . "\"");
|
||||
// Log::alert("image_dir \"" . $image_dir . "\"");
|
||||
|
||||
AUK::create([
|
||||
'project_id' => $project_id,
|
||||
|
||||
@@ -5,7 +5,9 @@ namespace App\Http\Controllers;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Models\Project;
|
||||
use App\Models\AUK;
|
||||
use App\Models\Document;
|
||||
use App\Models\MMC;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
|
||||
class MMCController extends Controller
|
||||
@@ -21,8 +23,7 @@ class MMCController extends Controller
|
||||
$project_id = $request->session()->get('project_id');
|
||||
$project = Project::find($project_id);
|
||||
$top_auks = $project->auks()->where('parent_id', 0)->get()->sortBy('auk_name');
|
||||
if(count($top_auks))
|
||||
{
|
||||
if (count($top_auks)) {
|
||||
$mmc = $top_auks[0]->mmcs;
|
||||
}
|
||||
return view('mmc.list', ['project' => $project, 'top_auks' => $top_auks]);
|
||||
@@ -136,61 +137,70 @@ class MMCController extends Controller
|
||||
$project_id = $request->session()->get('project_id');
|
||||
$project = Project::find($project_id);
|
||||
|
||||
|
||||
$auk = AUK::find($auk_id);
|
||||
$MMC = array();
|
||||
$total_size = 0;
|
||||
$total_count = 0;
|
||||
$MMC_PATH = $project->mmc_path;
|
||||
$MMC_PATH = $project->mmc_path . '/' . $auk->auk_path . '/' . $auk->image_dir;
|
||||
$mmc_dir = scandir($MMC_PATH);
|
||||
|
||||
|
||||
foreach ($mmc_dir as $entry) {
|
||||
$course_path = $MMC_PATH . '/' . $entry;
|
||||
if (is_dir($course_path)) {
|
||||
if (intval($entry) > 0 && intval($entry) < 99) {
|
||||
// $MMC[] = $entry;
|
||||
// echo ($entry . "\n");
|
||||
$mmc_course_dir = scandir($course_path);
|
||||
foreach ($mmc_course_dir as $course_entry) {
|
||||
// VVV Images VVV
|
||||
if (strcasecmp($course_entry, 'images') == 0) {
|
||||
$course_image_path = $course_path . '/' . $course_entry;
|
||||
if (is_dir($course_image_path)) {
|
||||
// echo ($course_image_path . "\n");
|
||||
$MMC[$entry]['image_dir'] = $course_entry;
|
||||
$course_images = scandir($course_image_path);
|
||||
foreach ($course_images as $image) {
|
||||
$image_file_path = $course_image_path . '/' . $image;
|
||||
if (is_file($image_file_path)) {
|
||||
if (strncmp($entry, $image, 2) == 0) {
|
||||
if (
|
||||
strcasecmp(substr($image, -3, 3), 'jpg') == 0 ||
|
||||
strcasecmp(substr($image, -3, 3), 'svg') == 0 ||
|
||||
strcasecmp(substr($image, -3, 3), 'swf') == 0
|
||||
) {
|
||||
// $MMC[$entry][] = $image;
|
||||
$tmp_array = array();
|
||||
$tmp_array['file'] = $image;
|
||||
$tmp_array['size'] = filesize($image_file_path);
|
||||
$tmp_array['mtime'] = filemtime($image_file_path);
|
||||
$tmp_array['atime'] = fileatime($image_file_path);
|
||||
foreach ($mmc_dir as $image) {
|
||||
$image_file_path = $MMC_PATH . '/' . $image;
|
||||
if (is_file($image_file_path)) {
|
||||
if (strncmp($auk->auk_path, $image, 2) == 0) {
|
||||
if (
|
||||
strcasecmp(substr($image, -3, 3), 'jpg') == 0 ||
|
||||
strcasecmp(substr($image, -3, 3), 'svg') == 0 ||
|
||||
strcasecmp(substr($image, -3, 3), 'swf') == 0
|
||||
) {
|
||||
$tmp_array = array();
|
||||
$tmp_array['filename'] = $image;
|
||||
$tmp_array['size'] = filesize($image_file_path);
|
||||
$tmp_array['mtime'] = filemtime($image_file_path);
|
||||
$tmp_array['atime'] = fileatime($image_file_path);
|
||||
|
||||
$MMC[$entry]['images'][] = $tmp_array;
|
||||
$MMC[] = $tmp_array;
|
||||
|
||||
$total_size += $tmp_array['size'];
|
||||
$total_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// ^^^ Images ^^^
|
||||
$total_size += $tmp_array['size'];
|
||||
$total_count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return view('mmc.scan', ['project' => $project, 'MMC' => $MMC]);
|
||||
return view('mmc.scan', ['project' => $project, 'AUK' => $auk, 'MMC' => $MMC]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load Images from file system
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function load(Request $request, $auk_id)
|
||||
{
|
||||
// Log::alert("In load");
|
||||
$project_id = $request->session()->get('project_id');
|
||||
|
||||
$i = 0;
|
||||
while ($request->input('filename_' . $i) !== null) {
|
||||
$filename = $request->input('filename_' . $i);
|
||||
$size = $request->input('size_' . $i);
|
||||
$mtime= $request->input('mtime_' . $i);
|
||||
// Log::alert("filename \"" . $filename . "\"");
|
||||
// Log::alert("size \"" . $size . "\"");
|
||||
// Log::alert("mtime \"" . $mtime . "\"");
|
||||
// $atime= $request->input('atime_' . $i);
|
||||
|
||||
MMC::create([
|
||||
'filename' => $filename,
|
||||
'size' => $size,
|
||||
'mtime' => $mtime,
|
||||
// 'atime' => $atime,
|
||||
])->auks()->attach($auk_id);
|
||||
$i++;
|
||||
}
|
||||
return redirect(route('mmc.index'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user