/** * action: LIST */ public function action_list() { $type = $this->request->query('type'); $site = $type == 'page' ? __('Page') : __('Email'); $locale = $this->request->query('locale_select') ? $this->request->query('locale_select') : NULL; // validation active Breadcrumbs::add(Breadcrumb::factory()->set_title($site)); $this->template->title = __('contents'); if (Model_Content::get_contents($type, $locale)->count() != 0) { $contents = Model_Content::get_contents($type, $locale); } else { Alert::set(Alert::INFO, __('You dont have any ') . $type . ' for ' . $locale . '!'); $contents = Model_Content::get_contents($type, 'en_UK'); } $ll = DB::select(DB::expr('DISTINCT (locale)'))->from('content')->where('type', '=', $type)->order_by('locale')->as_object()->cached()->execute(); $l_locale = array('' => ''); foreach ($ll as $key => $l) { $l_locale[$l->locale] = $l->locale; } $this->template->content = View::factory('oc-panel/pages/content/list', array('contents' => $contents, 'type' => $type, 'locale_list' => $l_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'); } }
public static function copy($from_locale, $to_locale, $type) { //get the contents for type locale $contents = Model_Content::get_contents($type, $to_locale); //only if theres no existent content if (count($contents) == 0) { $prefix = Database::instance()->table_prefix(); $query = "INSERT INTO " . $prefix . "content (locale,`order`,title,seotitle,description,from_email,type,status)\n SELECT '" . $to_locale . "',`order`,title,seotitle,description,from_email,type,status\n FROM " . $prefix . "content\n WHERE type='" . $type . "' AND locale='" . $from_locale . "'"; try { DB::query(Database::DELETE, $query)->execute(); } catch (Exception $e) { Alert::set(Alert::ERROR, $e->getMessage()); } return TRUE; } return FALSE; }