/** * @Clips\Model({"partner"}) * @Clips\Form("admin/partner/edit") */ public function edit_form() { $data = $this->post(); $partners = $this->partner->load($data['id']); foreach (json_decode($partners->logo_path) as $k => $v) { $ks[] = $v->path; } $a = new \Pinet\Guoke\Controllers\Admin\FileUpload(); foreach ($_FILES['upload_file']['name'] as $k => $v) { if ($_FILES['upload_file']['name'][$k] == null) { $file_url = $ks; } else { $file_url[] = $a->upload_img($_FILES['upload_file']['size'][$k], $_FILES['upload_file']['tmp_name'][$k], $_FILES['upload_file']['name'][$k]); } } $paths = $file_url; foreach ($paths as $k => $v) { $paths[$k] = array('path' => $paths[$k]); } $data['company_name'] = $data['company_name']; $data['logo_path'] = json_encode($paths); unset($data['_clips_form']); $result = $this->partner->update((object) $data); if ($result) { return $this->redirect(\Clips\site_url("admin/partner/index")); } else { $this->error('Error in updating user.', 'update'); } }
/** * @Clips\Model({"banner","image"}) * @Clips\Form("admin/banner/edit") */ public function edit_form() { $data = $this->post(); $banners = $this->banner->load($data['id']); foreach (json_decode($banners->contents) as $k => $v) { foreach ($v->title as $key => $value) { foreach ($v->path as $key => $val) { $ks[] = $val; } } } $a = new \Pinet\Guoke\Controllers\Admin\FileUpload(); foreach ($_FILES['upload_file']['name'] as $k => $v) { if ($_FILES['upload_file']['name'][$k] == null) { $file_url = $ks; } else { $file_url[] = $a->upload_img($_FILES['upload_file']['size'][$k], $_FILES['upload_file']['tmp_name'][$k], $_FILES['upload_file']['name'][$k]); } } $titles = $data['title']; $paths = $file_url; foreach ($titles as $k => $v) { $titles[$k] = array('title' => $titles[$k]); } foreach ($paths as $k => $v) { $paths[$k] = array('path' => $paths[$k]); } $tempArr = array(); foreach ($titles as $k => $v) { $tempArr[$k] = $k; } foreach ($paths as $k => $v) { if (!array_key_exists($k, $tempArr[$k])) { $arr[$k]['title'] = array($titles[$k]['title']); $arr[$k]['path'] = array($paths[$k]['path']); } else { exit('sdf'); $arr[$k]['path'] = ''; } } $paths = $arr; $data['contents'] = json_encode($paths); $data['title'] = json_encode($data['title']); unset($data['_clips_form']); $result = $this->banner->update((object) $data); if ($result) { return $this->redirect(\Clips\site_url("admin/banner/index")); } else { $this->error('Error in updating user.', 'update'); } }