/** * action: EDIT */ public function action_edit() { $id = $this->request->param('id'); $content = new Model_Content($id); $type = $content->type; $site = $type == 'page' ? __('Page') : __('Email'); Breadcrumbs::add(Breadcrumb::factory()->set_title(__('Edit') . ' ' . $site)); $locale = $content->locale; if ($content->loaded()) { $languages = i18n::get_languages(); $this->template->content = View::factory('oc-panel/pages/content/edit', array('cont' => $content, 'locale' => $languages)); if ($p = $this->request->post()) { foreach ($p as $name => $value) { if ($name != 'submit') { $content->{$name} = $value; } } // if status is not checked, it is not set as POST response $content->status = isset($p['status']) ? 1 : 0; //$content->seotitle = $content->gen_seotitle($this->request->post('title')); try { $content->save(); Cache::instance()->delete_all(); Alert::set(Alert::SUCCESS, $content->type . ' ' . __('is edited')); Request::current()->redirect(Route::url('oc-panel', array('controller' => 'content', 'action' => 'edit', 'id' => $content->id_content))); } catch (Exception $e) { Alert::set(Alert::ERROR, $e->getMessage()); } } } else { Alert::set(Alert::INFO, __('Faild to load content')); Request::current()->redirect(Route::url('oc-panel', array('controller' => 'content', 'action' => 'edit')) . '?type=' . $type . '&locale_select=' . $locale); } }
/** * saves the content in a specific order * @return void */ public function action_saveorder() { $this->auto_render = FALSE; $this->template = View::factory('js'); $locale = core::get('locale_select', core::config('i18n.locale')); if ($contents = Model_Content::get_contents(core::get('type'), $locale)) { $order = Core::get('order'); //using order they send us foreach ($order as $key => $value) { $c = new Model_Content($value); $c->order = $key; $c->save(); } Core::delete_cache(); $this->template->content = __('Saved'); } else { $this->template->content = __('Error'); } }