public function getCategoryContent($id) { if ($id) { $category = Object::find($id); return $category->content; } }
function anyEdit(Request $request) { $object = null; $edit = DataEdit::source(new Photo()); if ($edit->status == 'show') { $edit->link(url('/photo/note?noteable_id=' . $edit->model->id), 'notiz anlegen', 'BR'); } // Add Object reference if ($request->has('object_id')) { $object = Object::find($request->get('object_id')); if ($object instanceof Object) { $edit->model->object_id = $object->id; } else { throw new \Exception("Invalid call to create photo"); } } else { $object = $edit->model->object; } $edit->link(url('/object/edit?show=' . $object->id), 'abbrechen', 'TR')->back(); $edit->add('photo', 'Foto', 'image')->move(Object::BasePath . $object->id . '/photo/')->fit(1024, 1024)->preview(256, 256); $edit->add('dummy1', 'Standort', 'text')->insertValue($object ? $object : null)->updateValue($object ? $object : null)->showValue($object ? $object : null)->attributes(['readonly' => 'readonly']); return $edit->view('edit.photo', compact('edit')); }
function addImage($object, $destinationPath, $picture, $filename, $newfileName, $extension, $mimeType, $fieldName) { list($source_image_width, $source_image_height, $source_image_type) = getimagesize($destinationPath . $picture); $imageObjectInfo = array(); $imageObjectInfo['width'] = $source_image_width; $imageObjectInfo['height'] = $source_image_height; $imageObjectInfo['filePath'] = $filename; $imageObjectInfo['sizes'] = array(); if ($source_image_width > 1920) { //} || $source_image_height > 1080) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.' . $extension, 1920, 1080); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.' . $extension); rename($destinationPath . $newfileName . '-resized.' . $extension, $destinationPath . $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension); $imageInfo = array(); $imageInfo['fileName'] = $destinationPath . $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['large'] = $imageInfo; } if ($source_image_width > 1024) { // || $source_image_height > 768) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.' . $extension, 1024, 768); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.' . $extension); rename($destinationPath . $newfileName . '-resized.' . $extension, $destinationPath . $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['medium'] = $imageInfo; } if ($source_image_width > 350) { //|| $source_image_height > 350) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.' . $extension, 350, 350); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.' . $extension); rename($destinationPath . $newfileName . '-resized.' . $extension, $destinationPath . $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['small'] = $imageInfo; } if ($source_image_width > 300) { //|| $source_image_height > 350) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.' . $extension, 300, 300); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.' . $extension); rename($destinationPath . $newfileName . '-resized.' . $extension, $destinationPath . $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-' . $siw . 'x' . $sih . '.' . $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['thumbnail'] = $imageInfo; } // Save image object if ($imageObjectId = ObjectMeta::getValue($object->id, $fieldName)) { $imageObject = Object::find($imageObjectId); } if (empty($imageObject)) { $imageObject = new Object(); } $imageObject->author_id = Auth::user()->id; $imageObject->type = 'image'; $imageObject->name = $newfileName . '.' . $extension; $imageObject->title = $filename; $imageObject->status = 'inherit'; $imageObject->guid = $newfileName; $imageObject->save(); ObjectMeta::setValue($imageObject->id, '_file_path', $newfileName . '.' . $extension); ObjectMeta::setValue($imageObject->id, '_image_info', serialize($imageObjectInfo)); ObjectMeta::setValue($object->id, $fieldName, $imageObject->id); return $imageObject; }
/** * Remove the specified resource from storage. * * @param $id * @return Response */ public function postDelete(DeleteRequest $request, $id) { $object = Object::find($id); $object->delete(); return redirect('admin/categories')->with('message', 'Category deleted successfully'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function postEdit(ObjectRequest $request, $id) { $object = Object::find($id); //$object->name = $request->name; $object->title = $request->title; $object->content = $request->content; $excerpt = strip_tags($request->content); $excerpt = preg_replace('/\\s+/', ' ', $excerpt); $object->excerpt = $excerpt; $object->save(); // if ($objecttype = Object::where('type', 'object_type') // ->where('name', '_object_type_' . $object['type'] ) // ->first() ) { // // if ( $fields = Object::getFields( $objecttype['id'] )->get() ) { // foreach ( $fields as $field ) { // if ( $fieldInfo = unserialize( $field['meta_value'] ) ) { // $value = Input::get($fieldInfo['id']); // // echo $value; // } // } // } // } //print_r(array_keys($_POST)); //abort(500, 'sadfds'); $fields = Object::getFields($id)->get(); foreach ($fields as $field) { foreach (array_keys($_POST) as $key) { if (substr($key, 0, 7) == '_field_') { $value = $request->input($key); if ($value == 'on') { $value = 1; } $object->setValue($key, $value); } } } $promoted = $request->input('_field_french_speakers'); if (!empty($promoted)) { $object->setValue('_field_french_speakers', 1); } else { $object->setValue('_field_french_speakers', 0); } $promoted = $request->input('_field_promoted'); if (!empty($promoted)) { $object->setValue('_field_promoted', 1); } else { $object->setValue('_field_promoted', 0); } if ($request->hasFile('featuredImage')) { $file = $request->file('featuredImage'); $filename = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension(); $mimeType = $file->getMimeType(); $destinationPath = public_path() . '/uploads/'; $newfileName = sha1($filename . time()); $picture = $newfileName . '.' . $extension; $request->file('featuredImage')->move($destinationPath, $picture); if ($imageObject = addImage($object, $destinationPath, $picture, $filename, $newfileName, $extension, $mimeType, '_featured_image')) { } } if ($request->hasFile('contentImage')) { $file = $request->file('contentImage'); $filename = $file->getClientOriginalName(); $extension = $file->getClientOriginalExtension(); $mimeType = $file->getMimeType(); $destinationPath = public_path() . '/uploads/'; $newfileName = sha1($filename . time()); $picture = $newfileName . '.' . $extension; $request->file('contentImage')->move($destinationPath, $picture); if ($imageObject = addImage($object, $destinationPath, $picture, $filename, $newfileName, $extension, $mimeType, '_content_image')) { } } return redirect('admin/objects')->with('message', 'Type saved successfully'); }
public function getContent($id) { if ($id) { if ($object = Object::find($id)) { return $object->content; } } }
function anyEdit(Request $request) { $partner = null; $object = null; $edit = DataEdit::source(new Task()); if ($edit->status == 'create') { $edit->link(url('/task'), 'abbrechen', 'TR')->back(); } if ($edit->status == 'show') { $edit->link(url('/task/note?noteable_id=' . $edit->model->id), 'notiz anlegen', 'BR'); } if ($edit->status == 'modify') { $edit->link(url('/task/edit?delete=' . $edit->model->id), 'löschen', 'TR'); } // Add Partner reference if ($request->has('partner_id')) { $partner = Partner::find($request->get('partner_id')); if ($partner instanceof Partner) { $edit->model->partner_id = $partner->id; } } else { if ($request->has('object_id')) { $object = Object::find($request->get('object_id')); if ($object instanceof Object) { $edit->model->object_id = $object->id; $edit->model->partner_id = $object->partner_id; $partner = $object->partner; } } else { $partner = $edit->model->partner; $object = $edit->model->object; } } $edit->add('name', 'Aufgabe', 'text')->attributes(['class' => 'autofocus'])->rule('required'); $edit->add('assigned_to', 'Verantwortlich', 'select')->options([null => '-- Nicht zugeordnet --'] + User::lists("name", "id")); if ($edit->status == 'create') { $edit->add('note', 'Details', 'textarea'); } else { if ($edit->status == 'modify') { $edit->add('is_finished', 'Erledigt', 'checkbox'); } else { if ($edit->status == 'show') { // Display Partner $edit->add('dummy3', 'Erledigt', 'text')->showValue($edit->model->is_finished ? 'ja' : 'nein')->attributes(['readonly' => 'readonly']); } } } $begin_at = date('Y-m-d'); $edit->add('begin_at', 'Start', 'date')->format('Y-m-d')->insertValue($begin_at)->showValue($begin_at)->rule('required'); $finish_at = date('Y-m-d', strtotime('+1 week')); $edit->add('finish_at', 'Ende', 'date')->format('Y-m-d')->insertValue($finish_at)->showValue($finish_at)->rule('required'); $duration = $edit->model->duration; $edit->add('dummy4', 'Dauer', 'text')->showValue($duration)->attributes(['readonly' => 'readonly']); $duein = $edit->model->duein; $edit->add('dummy5', 'Fällig', 'text')->showValue($duein)->attributes(['readonly' => 'readonly']); // Display Partner $edit->add('dummy1', 'Partner', 'text')->insertValue($partner ? $partner : null)->updateValue($partner ? $partner : null)->showValue($partner ? $partner : null)->attributes(['readonly' => 'readonly']); // Display Object $edit->add('dummy2', 'Standort', 'text')->insertValue($object ? $object : null)->updateValue($object ? $object : null)->showValue($object ? $object : null)->attributes(['readonly' => 'readonly']); $edit->saved(function () use($edit) { // Create a note for details if ($edit->status == 'create') { $text = isset($edit->fields['note']) ? trim($edit->fields['note']->value) : ''; if (strlen($text) > 0) { $note = new Note(['text' => $text]); $edit->model->notes()->save($note); } } }); return $edit->view('task', compact('edit')); }
public function getExport($id) { if ($objectType = Object::find($id)) { if ($data = ObjectType::getFields($id)->get()) { $fields = array(); $fields[] = 'name'; $fields[] = 'title'; $fields[] = 'content'; $fields[] = 'occupation'; $fields[] = 'address'; $fields[] = 'french_speakers'; $fields[] = 'phone'; $fields[] = 'email'; foreach ($data as $field) { $fieldInfo = unserialize($field->meta_value); $fields[] = $fieldInfo['name']; } if ($format = Input::get('format')) { switch ($format) { case 'excel': Excel::create(str_replace('Object Type: ', '', $objectType['title']), function ($excel) use($objectType, $fields) { $excel->sheet(str_replace('Object Type: ', '', $objectType['title']), function ($sheet) use($fields) { $sheet->setOrientation('landscape'); $sheet->fromArray($fields); }); })->export('xls'); break; } } } } }
function addImage($object, $destinationPath, $picture, $filename, $newfileName, $extension, $mimeType, $fieldName) { list($source_image_width, $source_image_height, $source_image_type) = getimagesize($destinationPath . $picture); $imageObjectInfo = array(); $imageObjectInfo['width'] = $source_image_width; $imageObjectInfo['height'] = $source_image_height; $imageObjectInfo['fileName'] = $filename; $imageObjectInfo['filePath'] = $newfileName . '.' . $extension; $imageObjectInfo['sizes'] = array(); $x = autoCrop($destinationPath, $picture, $fieldName); if ($x !== false) { $round = (int) \App\ResizesTinypng::max('round') + 1; insertIntoTableResizes($round, getTheImageSize($picture, $fieldName), $destinationPath . 'cropped/' . getTheImageSize($picture, $fieldName), 0, 'N', 0, false); $results_table = selectByRoundNumber($round); if (!empty($results_table)) { foreach ($results_table as $res_row) { $result_array = array('id' => intval($res_row['id']), 'round' => intval($res_row['round']), 'filename' => $res_row['file_name'], 'path' => $res_row['path'], 'runTiny' => intval($res_row['run_tiny']), 'error' => $res_row['error'], 'timeTiny' => intval($res_row['time_tiny']), 'timeAdded' => intval($res_row['created_at'])); $row_obj = array_to_object($result_array); $error_message = "N"; //START >> tinify images $tmp_path = str_replace(getcwd() . '/', "", $row_obj->path); //GET SERVER PATH $save_path = str_replace($row_obj->filename, "", $tmp_path); //OVERRIDE CURRENT LOCATION $flag = tinifyImage($row_obj->path, $save_path); if ($flag === false) { if ($error_message == "N") { $error_message = "Y - Compression failed"; } else { $error_message .= " - Compression failed"; } } //END << tinify image //UPDATE DB updateTableResizes($row_obj->id, $row_obj->round, $row_obj->filename, $row_obj->path, 1, $error_message, time(), $row_obj->timeAdded); } } } /* if ($source_image_width > 1920) {//} || $source_image_height > 1080) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.'. $extension, 1920, 1080); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.'. $extension); rename( $destinationPath . $newfileName . '-resized.'. $extension, $destinationPath . $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension); $imageInfo = array(); $imageInfo['fileName'] = $destinationPath . $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['large'] = $imageInfo; } if ($source_image_width > 1024) { // || $source_image_height > 768) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.'. $extension, 1024, 768); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.'. $extension); rename( $destinationPath . $newfileName . '-resized.'. $extension, $destinationPath . $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['medium'] = $imageInfo; } if ($source_image_width > 350) {//|| $source_image_height > 350) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.'. $extension, 350, 350); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.'. $extension); rename( $destinationPath . $newfileName . '-resized.'. $extension, $destinationPath . $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['small'] = $imageInfo; } if ($source_image_width > 300) {//|| $source_image_height > 350) { Thumbnail::generate_image_thumbnail($destinationPath . $picture, $destinationPath . $newfileName . '-resized.'. $extension, 300, 300); list($siw, $sih, $sit) = getimagesize($destinationPath . $newfileName . '-resized.'. $extension); rename( $destinationPath . $newfileName . '-resized.'. $extension, $destinationPath . $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension); $imageInfo = array(); $imageInfo['fileName'] = $newfileName . '-'. $siw . 'x'. $sih . '.'. $extension; $imageInfo['width'] = $siw; $imageInfo['height'] = $sih; $imageInfo['mimeType'] = $mimeType; $imageObjectInfo['sizes']['thumbnail'] = $imageInfo; } */ // Save image object if ($imageObjectId = ObjectMeta::getValue($object->id, $fieldName)) { $imageObject = Object::find($imageObjectId); } if (empty($imageObject)) { $imageObject = new Object(); } $imageObject->author_id = Auth::user()->id; $imageObject->type = 'image'; $imageObject->name = $newfileName . '.' . $extension; $imageObject->title = $filename; $imageObject->status = 'inherit'; $imageObject->guid = $newfileName; $imageObject->save(); ObjectMeta::setValue($imageObject->id, '_file_path', $newfileName . '.' . $extension); ObjectMeta::setValue($imageObject->id, '_image_info', serialize($imageObjectInfo)); ObjectMeta::setValue($object->id, $fieldName, $imageObject->id); return $imageObject; }