Professional CodeIgniter

(singke) #1

Chapter 9: Security and Performance


284


Here is the edit() function of the admin/colors controller:

function edit($id=0){
if ($this- > input- > post(‘name’)){
$this- > MColors- > updateColor();
$this- > session- > set_flashdata(‘message’,’Color updated’);
redirect(‘admin/colors/index’,’refresh’);
}else{
$data[‘title’] = “Edit Color”;
$data[‘main’] = ‘admin_colors_edit’;
$data[‘color’] = $this- > MColors- > getColor($id);
if (!count($data[‘color’])){
redirect(‘admin/colors/index’,’refresh’);
}
$this- > load- > vars($data);
$this- > load- > view(‘dashboard’);
}
}

Here is the edit() function of the admin/pages controller:

function edit($id=0){
if ($this- > input- > post(‘name’)){
$this- > MPages- > updatePage();
$this- > session- > set_flashdata(‘message’,’Page updated’);
redirect(‘admin/pages/index’,’refresh’);
}else{
$data[‘title’] = “Edit Page”;
$data[‘main’] = ‘admin_pages_edit’;
$data[‘page’] = $this- > MPages- > getPage($id);
if (!count($data[‘page’])){
redirect(‘admin/pages/index’,’refresh’);
}
$this- > load- > vars($data);
$this- > load- > view(‘dashboard’);
}
}

Here is the edit() function of the admin/products controller:

function edit($id=0){
if ($this- > input- > post(‘name’)){
$this- > MProducts- > updateProduct();
$this- > session- > set_flashdata(‘message’,’Product updated’);
redirect(‘admin/products/index’,’refresh’);
}else{
$data[‘title’] = “Edit Product”;
$data[‘main’] = ‘admin_product_edit’;
$data[‘product’] = $this- > MProducts- > getProduct($id);
$data[‘categories’] = $this- > MCats- > getCategoriesDropDown();
$data[‘assigned_colors’] = $this- > MProducts- > getAssignedColors($id);
$data[‘assigned_sizes’] = $this- > MProducts- > getAssignedSizes($id);
Free download pdf