public function update($id, $args) { $langs = get_langs(); if ($this->valid($args, $this->rules())) { $page = $this->findItem($id); $page->image = get_path($args['image']); $page->post_status = $args['post_status']; $page->template = $args['template']; if (!$page->update()) { throw new ExcuteException('save_error', 'Không lưu được'); } $syncs = []; foreach ($langs as $lang) { $code = $args[$lang->code]; $page_title = $code['post_title']; $slug = $code['slug']; $slug = trim($slug) == '' ? toSlug($page_title) : toSlug($slug); $page_desc = ['post_title' => $page_title, 'slug' => $slug, 'post_content' => $code['post_content'], 'post_excerpt' => $code['post_excerpt']]; $syncs[$lang->id] = $page_desc; } $page->langs()->sync($syncs); } else { throw new ValidationException('Error Validation', 'Điền đầy đủ các thông tin!'); } }
protected function getAll($group_id) { $langs = get_langs(); $results = []; foreach ($langs as $lang) { $results[$lang->code] = DB::table($this->table)->join($this->tbdesc, $this->table . '.id', '=', $this->tbdesc . '.menu_id')->where($this->tbdesc . '.lang_id', $lang->id)->where($this->table . '.group_id', $group_id)->select($this->tbdesc . '.*', $this->table . '.*')->orderBy('order')->get(); } return $results; }
public function update($id, $request) { if ($this->valid($request->all(), $this->rules())) { foreach (get_langs() as $lang) { $datalang = $request->get($lang->code); $status = $this->model->where('status_id', $id)->where('lang_id', $lang->id)->first(); $status->name = $datalang['name']; $status->update(); } } else { throw new ValidateException($this->getError()); } }
public function update(Request $request) { $langs = get_langs(); foreach ($langs as $lang) { $datas = $request->input($lang->code); foreach ($datas as $key => $value) { $value = is_array($value) ? serialize($value) : $value; $args = ['lang_id' => $lang->id, 'key' => $key, 'value' => $value]; $cond = Setting::where('key', $key)->where('lang_id', $lang->id); if ($cond->count() > 0) { $cond->update(['value' => $value]); } else { $meta = new Setting(); $meta->lang_id = $lang->id; $meta->key = $key; $meta->value = $value; $meta->save(); } } } return redirect()->back()->with('Mess', 'Cập nhật thành công'); }
public function update($id, $args) { $langs = get_langs(); if ($this->valid($args, $this->rules())) { $web = $this->findItem($id); $web->image = $args['image']; $web->domain = $args['domain']; $web->color = $args['color']; $web->order = $args['order']; if (!$web->save()) { throw new NullException('Not save', $this->getError()); } $syncs = []; foreach ($langs as $lang) { $datacode = $args[$lang->code]; $web_desc = ['name' => $datacode['name'], 'slug' => toSlug($datacode['name']), 'description' => $datacode['description']]; $syncs[$lang->id] = $web_desc; } $web->langs()->sync($syncs); } else { throw new ValidationException('Vui lòng điền đầy đủ các trường!', $this->getError()); } }
function lang_select($onChange = False, $ConfigLang = '') { if (!$ConfigLang) { $ConfigLang = get_var('ConfigLang', array('POST', 'COOKIE')); } $select = '<select name="ConfigLang"' . ($onChange ? ' onChange="this.form.submit();"' : '') . '>' . "\n"; $languages = get_langs(); usort($languages, create_function('$a,$b', 'return strcmp(@$a[\'descr\'],@$b[\'descr\']);')); foreach ($languages as $data) { if ($data['available'] && !empty($data['lang'])) { $selected = ''; $short = substr($data['lang'], 0, 2); if ($short == $ConfigLang || empty($ConfigLang) && $short == substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)) { $selected = ' selected'; } $select .= '<option value="' . $data['lang'] . '"' . $selected . '>' . $data['descr'] . '</option>' . "\n"; } } $select .= '</select>' . "\n"; return $select; }
public function update($id, $request, $multilang = true) { if ($this->valid($request->all(), $this->rules())) { $country = $this->find($id); if ($request->has('parent')) { $country->parent = $request->get('parent'); } $country->status = $request->get('status'); if ($request->has('icon')) { $country->icon = $request->get('icon'); } if ($request->has('visa_1')) { $country->visa_1 = $request->get('visa_1'); } if ($request->has('visa_2')) { $country->visa_2 = $request->get('visa_2'); } $country->update(); $syncs = []; foreach (get_langs() as $lang) { $langdata = $request->get($lang->code); $name = $langdata['name']; $country_desc = ['name' => $name, 'slug' => toSlug($name)]; $syncs[$lang->id] = $country_desc; } $country->langs()->sync($syncs); } else { throw new ValidateException($this->getError()); } }
public function update($id, $request) { if ($this->valid($request->all(), $this->rules())) { $room = $this->find($id); $room->image = get_path($request->get('image')); $room->status = $request->get('status'); $room->type_id = $request->get('type_id'); $room->hotel_id = $request->get('hotel_id'); // $room->price = $request->get('price'); $room->num_adult = $request->get('num_adult'); $room->square = $request->get('square'); $room->room_view = $request->get('room_view'); $room->add_bed = $request->get('add_bed'); if ($request->has('image_ids')) { $room->images = serialize($request->get('image_ids')); } $room->price_1 = $request->get('price_1'); $room->price_2 = $request->get('price_2'); $room->price_3 = $request->get('price_3'); $room->point_1 = strtotime(str_replace('/', '-', $request->get('point_1'))); $room->point_2 = strtotime(str_replace('/', '-', $request->get('point_2'))); $room->update(); $sync_langs = []; foreach (get_langs() as $lang) { $datalang = $request->get($lang->code); $name = $datalang['name']; $room_desc = ['name' => $name, 'slug' => toSlug($name), 'content' => $datalang['content']]; $sync_langs[$lang->id] = $room_desc; } $room->langs()->sync($sync_langs); $room->convenients()->detach(); if ($request->has('cats')) { $room->convenients()->attach($request->get('cats')); } } else { throw new ValidateException($this->getError()); } }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { $langs = get_langs(); $data = $request->all(); DB::beginTransaction(); try { $tour = Tourcat::find($id); $level = 0; if ($data['parent'] == 0) { $parent_id = $this->ID_ROOT; } else { $parent_id = DB::table('tour_cat')->where('id', $data['parent'])->select('parent_id')->get(); $parent_id = $parent_id[0]->parent_id; if ($parent_id >= $this->ID_ROOT) { $i = 0; $st = '_' . number_format($parent_id, 0, '', ''); while (substr($st, $level * 2, 2) != '00') { $level++; } $level--; } } $child_offset = number_format(pow($this->ID_BASE, $this->ID_MAX_LEVEL - ($level + 1)), 0, '', ''); $next_level = number_format($parent_id + pow($this->ID_BASE, $this->ID_MAX_LEVEL - $level), 0, '', ''); $row_child = DB::table('tour_cat')->where('parent_id', '>', $parent_id)->where('parent_id', '<', $next_level)->get(); $new_id = number_format($parent_id + $child_offset, 0, '', ''); for ($i = 1; $i < $this->ID_BASE; $i++) { $found = false; if ($row_child) { foreach ($row_child as $row) { if ($row->parent_id == $new_id) { $found = true; break; } } } if ($found) { $new_id = number_format($new_id + $child_offset, 0, '', ''); } } $tour->parent_id = $new_id; $tour->user_id = auth()->user()->id; $tour->update(); $syncs = []; foreach ($langs as $lang) { $code = $request->input($lang->code); $slug = trim($code['slug']) == '' ? toSlug($code['name']) : toSlug($code['slug']); $tour_lang = ['name' => $code['name'], 'slug' => $slug]; $syncs[$lang->id] = $tour_lang; } $tour->langs()->sync($syncs); } catch (Exception $e) { DB::rollBack(); return redirect()->back()->withInput()->with('errorMess', 'Có lỗi xảy ra!'); } DB::commit(); return redirect()->route('admin.tour-cat.index')->with('Mess', 'Cập nhật thành công'); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($tour, Request $request) { $langs = get_langs(); $data = $request->all(); DB::beginTransaction(); try { $tour->value = $data['value']; $tour->choice = $data['choice']; $tour->option = $data['option']; // $tour->update(); $syncs = []; foreach ($langs as $lang) { $code = $request->input($lang->code); $name = $code['name']; $com_lang = ['name' => $name]; $syncs[$lang->id] = $com_lang; } $tour->langs()->sync($syncs); } catch (Exception $e) { DB::rollBack(); return redirect()->back()->withInput()->with('errorMess', 'Có lỗi xảy ra!'); } DB::commit(); return redirect()->route('admin.services.index')->with('Mess', 'Cập nhật thành công'); }
$smarty->setTemplateDir(System_Settings::getSmarty_template()); $smarty->setCompileDir(System_Settings::getSmarty_compile_dir()); $smarty->setCacheDir(System_Settings::getSmarty_cached_dir()); $smarty->debugging = System_Settings::getSmarty_debugging(); $smarty->caching = false; $smarty->cache_lifetime = 0; // Подключение функций. require_once DOC . 'functions/functions_list.php'; // Подключение функций для щаблонов require_once DOC . 'functions/smarty.functions.php'; $langs = array(); $langs_array = array(); // Список языков. if (defined('MULTILANG') && MULTILANG == 1) { // Получаем список доступных языков $langs = get_langs(); for ($i = 0; $i < count($langs); $i++) { $langs_array[$langs[$i]['alias']] = $langs[$i]['id']; } } // Определение текущего языка. if (Text::get_get('lang')) { // Поиск языка в массиве языков.. for ($i = 0; $i < count($langs); $i++) { if (Text::get_get('lang') == $langs[$i]['alias']) { // Назначение языка. $current_lang = Text::get_get('lang'); break; } } // Проверка языка.
public function update($id, $args) { $langs = get_langs(); $cat = $this->findItem($id); $cat->parent = $args['parent']; $cat->order = $args['order']; if (isset($args['image'])) { $cat->image = get_path($args['image']); } if (!$cat->update()) { throw new NullException('Not save', $this->getError()); } $syncs = []; foreach ($langs as $lang) { $datacode = $args[$lang->code]; $name = $datacode['name']; $slug = $datacode['slug']; $cat_desc = ['name' => $name, 'slug' => trim($slug) == '' ? toSlug($name) : toSlug($slug), 'description' => $datacode['desc']]; $syncs[$lang->id] = $cat_desc; } $cat->langs()->sync($syncs); }
public function __construct($model) { $this->model = $model; $this->langs = get_langs(); }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id, Request $request) { $hour_from = "10:00"; $langs = get_langs(); $data = $request->all(); DB::beginTransaction(); try { $tour = Tour::findOrFail($id); if ($data['start_date'] != null) { $time_from = $this->convert_datetime($data['start_date'], $hour_from); } else { $time_from = time(); } $tour->start_date = $time_from; $tour->start_id = $data['start'][0]; $tour->price_company = $data['price_company']; $tour->price = $data['price']; $tour->image_url = parse_url($data['image'])['path']; $tour->days = $data['days']; $tour->nights = $data['nights']; $tour->code = $data['code']; $tour->price_child = $data['price_child']; $tour->price_baby = $data['price_baby']; $tour->price_single = $data['price_single']; $tour->user_id = auth()->user()->id; // $tour->update(); $syncs = []; foreach ($langs as $lang) { $code = $request->input($lang->code); $name = $code['name']; $keyword = mb_strtolower($this->convertUnicode($name)); $com_lang = ['name' => $name, 'schedule' => $code['schedule'], 'detail' => $code['detail'], 'notice' => $code['notice'], 'desc' => $code['desc'], 'keyword' => $keyword]; $syncs[$lang->id] = $com_lang; } $tour->langs()->sync($syncs); if (isset($data['cats'])) { $tour->tour_cat()->sync($data['cats']); } if (isset($data['end'])) { $tour->tour_place()->sync($data['end']); } } catch (Exception $e) { DB::rollBack(); return redirect()->back()->withInput()->with('errorMess', 'Có lỗi xảy ra!'); } DB::commit(); return redirect()->route('admin.tours.index')->with('Mess', 'Cập nhật thành công'); }
public function update($id, $request) { $menu = $this->find($id); $menu->status = $request->get('status'); if ($request->has('parent')) { $menu->parent = $request->get('parent'); } $menu->icon = $request->get('icon'); $menu->type = $request->get('type'); $menu->type_id = $request->get('type_id'); $menu->update(); $syncs = []; if ($request->get('type') == 'custom') { foreach (get_langs() as $lang) { $datalang = $request->get($lang->code); $menu_desc = ['name' => $datalang['name'], 'link' => $datalang['link']]; $syncs[$lang->id] = $menu_desc; } } else { foreach (get_langs() as $lang) { $datalang = $request->get($lang->code); $type_id = $request->get('type_id'); switch ($request->get('type')) { case 'page': $pagerepo = new PageRepository(new Page()); $page = $pagerepo->get_with_lang($type_id, $lang->code); $link = get_path(route('page.show', ['id' => $type_id, 'slug' => $page->lang->slug])); $name = trim($datalang['name']) == '' ? $page->lang->name : $datalang['name']; break; case 'cat': $catrepo = new TaxRepository(new Tax()); $cat = $catrepo->get_with_lang($type_id, $lang->code); $link = get_path(route('cat.show', ['id' => $type_id, 'slug' => $cat->lang->slug])); $name = trim($datalang['name']) == '' ? $cat->lang->name : $datalang['name']; break; case 'services': $services = new ServicesRepository(new Service()); $ser = $services->get_with_lang($type_id, $lang->code); $link = get_path(route('services.show', ['id' => $type_id, 'slug' => $ser->lang->slug])); $name = trim($datalang['name']) == '' ? $ser->lang->name : $datalang['name']; break; default: $link = ''; $name = ''; break; } $menu_desc = ['name' => $name, 'link' => $link]; $syncs[$lang->id] = $menu_desc; } } $menu->langs()->sync($syncs); }
public function update($id, $args) { $langs = get_langs(); if ($this->valid($args, $this->rules())) { $menu = $this->findItem($id); $menu->group_id = $args['group_id']; $parent = $args['parent']; $menu->parent = $parent == '' ? 0 : $parent; $menu->status = $args['status']; $menu->order = $args['order']; $menu->open_type = $args['open_type']; $menu->icon = $args['icon']; $link_type = $args['link_type']; $link = $args['link']; $menu->type = $link_type; $menu->item_id = $link; if (!$menu->update()) { throw new NullException('Not save', $this->getError()); } $syncs = []; foreach ($langs as $lang) { $datacode = $args[$lang->code]; switch ($link_type) { case 'cat': $cat = Category::find($link)->langs()->where('code', $lang->code)->first(['cat_desc.slug']); $menu_link = get_path(route('cat.view', [$link, $cat->slug])); break; case 'post': $post = Post::find($link)->langs()->where('code', $lang->code)->first(['post_desc.slug']); $menu_link = get_path(route('post.view', [$link, $post->slug])); break; case 'page': $page = Post::find($link)->langs()->where('code', $lang->code)->first(['post_desc.slug']); $menu_link = get_path(route('page.view', [$link, $page->slug])); break; case 'custom': $menu_link = $link; break; default: $menu_link = ''; break; } $menu_desc = ['name' => $datacode['name'], 'link' => $menu_link]; $syncs[$lang->id] = $menu_desc; } $menu->langs()->sync($syncs); } else { throw new ValidationException('Vui lòng điền đầy đủ các trường!', $this->getError()); } }
public function update($id, $request) { if ($this->valid($request->all(), $this->rules())) { $hotel = $this->find($id); $hotel->image = get_path($request->get('image')); $hotel->status = $request->get('status'); $hotel->star = $request->get('star'); $hotel->province_id = $request->get('province_id'); $hotel->hotline = $request->get('hotline'); $hotel->phone = $request->get('phone'); $hotel->email = $request->get('email'); $hotel->fax = $request->get('fax'); $hotel->build_year = $request->get('build_year'); $hotel->num_floor = $request->get('num_floor'); $hotel->num_room = $request->get('num_room'); $hotel->time_arrival = $request->get('time_arrival'); $hotel->time_departure = $request->get('time_departure'); if ($request->has('image_ids')) { $hotel->images = serialize($request->get('image_ids')); } $hotel->update(); $sync_langs = []; foreach (get_langs() as $lang) { $datalang = $request->get($lang->code); $name = $datalang['name']; $slug = $datalang['slug']; $hotel_desc = ['name' => $name, 'slug' => trim($slug) == '' ? toSlug($name) : toSlug($slug), 'note' => $datalang['note'], 'rule' => $datalang['rule'], 'content' => $datalang['content'], 'address' => $datalang['address']]; $sync_langs[$lang->id] = $hotel_desc; } $hotel->langs()->sync($sync_langs); $hotel->convenients()->detach(); if ($request->has('cats')) { $hotel->convenients()->attach($request->get('cats')); } // $hotel->cats()->detach(); // if ($request->has('cats')) { // $hotel->cats()->attach($request->get('cats')); // } // if ($request->has('newtags')) { // $newtags = $request->get('newtags'); // foreach ($newtags as $tag) { // $newtag = new $this->tax; // $newtag->type = 'tag'; // $newtag->dfname = $tag; // $newtag->dfslug = toSlug($tag); // $newtag->save(); // $hotel->tags()->attach($newtag->id); // } // } // if ($request->has('availtags')) { // $hotel->tags()->attach($request->get('availtags')); // } } else { throw new ValidateException($this->getError()); } }
public function update($id, $request) { $page = $this->find($id); authorize_other('edit_pages', 'edit_others_pages', $page->author_id); if ($this->valid($request->all(), $this->rules())) { $page->image = get_path($request->get('image')); $page->status = $request->get('status'); $page->author_id = auth()->user()->id; if ($request->has('template')) { $page->template = $request->get('template'); } $page->update(); $sync_langs = []; foreach (get_langs() as $lang) { $datalang = $request->get($lang->code); $name = $datalang['name']; $slug = $datalang['slug']; $page_desc = ['name' => $name, 'slug' => trim($slug) == '' ? toSlug($name) : toSlug($slug), 'excerpt' => $datalang['excerpt'], 'content' => $datalang['content']]; $sync_langs[$lang->id] = $page_desc; } $page->langs()->sync($sync_langs); } else { throw new ValidateException($this->getError()); } }
public function update_option($request) { $valid = Validator::make($request->all(), ['key' => 'required']); if ($valid->fails()) { throw new ValidateException($valid->errors()); } $check = $request->get('haslang'); if ((int) $check == 1) { foreach (get_langs() as $lang) { return $this->option->where('key', $request->get('key'))->where('lang_id', $lang->id)->update(['value' => $request->get($lang->code)['value']]); } } else { return $this->option->where('key', $request->get('key'))->update(['value' => $request->get('value')]); } }
public function update($id, $request) { if ($this->valid($request->all())) { $slide = $this->find($id); $slide->link = $request->get('link'); $slide->image = get_path($request->get('image')); $slide->open_type = $request->get('open_type'); $slide->order = $request->get('order'); $slide->status = $request->get('status'); $slide->group_id = $request->get('group_id'); $slide->update(); $syncs = []; foreach (get_langs() as $lang) { $datalang = $request->get($lang->code); $slide_desc = ['name' => $datalang['name'], 'description' => $datalang['description']]; $syncs[$lang->id] = $slide_desc; } $slide->langs()->sync($syncs); } else { throw new ValidateException($this->getError()); } }
function step($is_submit) { $result = array('html' => render('step_start', array('langs' => get_langs(), 'lang' => LANG))); return $result; }
public function update($id, $request) { $post = $this->find($id); authorize_other('edit_posts', 'edit_others_posts', $post->author_id); if ($this->valid($request->all(), $this->rules())) { $post->image = get_path($request->get('image')); $post->status = $request->get('status'); $post->author_id = auth()->user()->id; $post->update(); $sync_langs = []; foreach (get_langs() as $lang) { $datalang = $request->get($lang->code); $name = $datalang['name']; $slug = $datalang['slug']; $post_desc = ['name' => $name, 'slug' => trim($slug) == '' ? toSlug($name) : toSlug($slug), 'excerpt' => $datalang['excerpt'], 'content' => $datalang['content']]; $sync_langs[$lang->id] = $post_desc; } $post->langs()->sync($sync_langs); $post->cats()->detach(); if ($request->has('cats')) { $post->cats()->attach($request->get('cats')); } if ($request->has('newtags')) { $newtags = $request->get('newtags'); foreach ($newtags as $tag) { $newtag = new $this->tax(); $newtag->type = 'tag'; $newtag->dfname = $tag; $newtag->dfslug = toSlug($tag); $newtag->save(); $post->tags()->attach($newtag->id); } } if ($request->has('availtags')) { $post->tags()->attach($request->get('availtags')); } } else { throw new ValidateException($this->getError()); } }
function get_lang_options($install_language) { $langs = get_langs(); foreach ($langs as $language) { $abrv_language = explode('-', $language); $option[] = '<option value="' . $language . '"' . ($language == $install_language ? ' selected="selected"' : null) . '>' . ucwords($abrv_language[0]) . '</option>'; } return "\n" . join("\n", $option); }
<?php session_start(); define('DS', DIRECTORY_SEPARATOR); define('PATH', dirname(__FILE__) . DS); define('DOC_ROOT', str_replace(DS, '/', realpath($_SERVER['DOCUMENT_ROOT']))); header("Content-type:text/html; charset=utf-8"); mb_internal_encoding('UTF-8'); date_default_timezone_set('UTC'); include PATH . 'functions.php'; $all_langs = get_langs(); $default_lang = 'en'; if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) { $user_lang = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)); if (in_array($user_lang, $all_langs)) { $default_lang = $user_lang; } } if (isset($_REQUEST['lang'])) { if (in_array($_REQUEST['lang'], $all_langs)) { $_SESSION['install']['lang'] = $_REQUEST['lang']; header('Location: ' . $_SERVER['SCRIPT_NAME']); die; } } $is_lang_selected = isset($_SESSION['install']['lang']); $lang = $is_lang_selected ? $_SESSION['install']['lang'] : $default_lang; define('LANG', $lang); include PATH . DS . 'languages' . DS . LANG . DS . "language.php"; $steps = array(array('id' => 'start', 'title' => LANG_STEP_START), array('id' => 'license', 'title' => LANG_STEP_LICENSE), array('id' => 'php', 'title' => LANG_STEP_PHP_CHECK), array('id' => 'paths', 'title' => LANG_STEP_PATHS), array('id' => 'database', 'title' => LANG_STEP_DATABASE), array('id' => 'site', 'title' => LANG_STEP_SITE), array('id' => 'admin', 'title' => LANG_STEP_ADMIN), array('id' => 'config', 'title' => LANG_STEP_CONFIG), array('id' => 'cron', 'title' => LANG_STEP_CRON), array('id' => 'finish', 'title' => LANG_STEP_FINISH)); $current_step = 0;
// Lang Section $setup_tpl->set_var('lang_step_text', lang('Step %1 - Language Management', 4)); $GLOBALS['phpgw_info']['setup']['stage']['lang'] = $GLOBALS['phpgw_setup']->detection->check_lang(); // begin DEBUG code //$GLOBALS['phpgw_info']['setup']['stage']['lang'] = 0; // end DEBUG code switch ($GLOBALS['phpgw_info']['setup']['stage']['lang']) { case 1: $setup_tpl->set_var('lang_status_img', $incomplete); $setup_tpl->set_var('lang_status_alt', 'not completed'); $btn_install_lang = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(lang('You do not have any languages installed. Please install one now <br>'), 'POST', 'lang.php', 'submit', lang('Install Language'), ''); $setup_tpl->set_var('lang_table_data', $btn_install_lang); break; case 10: $langs_list = array(); $languages = get_langs(); foreach ($GLOBALS['phpgw_info']['setup']['installed_langs'] as $key => $value) { $langs_list[] = isset($languages[$key]) ? $languages[$key]['descr'] : $value; } $setup_tpl->set_var('lang_status_img', $completed); $setup_tpl->set_var('lang_status_alt', 'completed'); $btn_manage_lang = $GLOBALS['phpgw_setup']->html->make_frm_btn_simple(lang('This stage is completed<br>') . lang('Currently installed languages: %1 <br>', implode(', ', $langs_list)), 'POST', 'lang.php', 'submit', lang('Manage Languages'), ''); // show system-charset and offer conversation include_once PHPGW_API_INC . '/class.translation_sql.inc.php'; $translation = new translation(); $btn_manage_lang .= lang('Current system-charset is %1, click %2here%3 to change it.', $translation->system_charset ? "'{$translation->system_charset}'" : lang('not set'), '<a href="system_charset.php">', '</a>'); $setup_tpl->set_var('lang_table_data', $btn_manage_lang); break; default: $setup_tpl->set_var('lang_status_img', $incomplete); $setup_tpl->set_var('lang_status_alt', lang('not completed'));
/** * Generate a select box of available languages * * @param bool $onChange javascript to trigger when selection changes (optional) * @returns string HTML snippet for select box */ function lang_select($onChange = '') { $ConfigLang = phpgw::get_var('ConfigLang', 'string', 'POST'); $select = '<select name="ConfigLang"' . ($onChange ? ' onChange="this.form.submit();"' : '') . '>' . "\n"; $languages = get_langs(); while (list($null, $data) = each($languages)) { if ($data['available'] && !empty($data['lang'])) { $selected = ''; $short = substr($data['lang'], 0, 2); if ($short == $ConfigLang || empty($ConfigLang) && $short == substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2)) { $selected = ' selected'; } $select .= '<option value="' . $data['lang'] . '"' . $selected . '>' . $data['descr'] . '</option>' . "\n"; } } $select .= '</select>' . "\n"; return $select; }
@else <h3>Không có kết quả nào!</h3> @endif <div class="addnew"> <a href="#newModal" data-toggle="collapse" class="btn btn-primary btn-addnew"><i class="fa fa-plus"></i> Thêm mới</a> <div class="collapse" id="newModal"> <h3 class="title" id="myModalLabel">Thêm mới</h3> {!! lang_tabs() !!} {!! Form::open(['method' => 'post', 'route'=>'admin.imagecat.store', 'class'=>'form-horizontal']) !!} <br /> <div class="tab-content"> <?php $i = 0; foreach (get_langs() as $key => $lang) { $code = $lang->code; $i++; ?> <div class="tab-pane fade <?php if ($i == 1) { echo 'in active'; } ?> " id="lang-{{$lang->code}}"> {!! fForm::groupText('Tên danh mục', $code.'[name]', null, ['required']) !!} {!! fForm::groupText('Đường dẫn tĩnh', $code.'[slug]', null) !!} </div> <?php } ?>
public function update($id, $args) { $langs = get_langs(); $post = $this->findItem($id); if (isset($args['image'])) { $post->image = get_path($args['image']); } if (isset($args['post_status'])) { $post->post_status = $args['post_status']; } if (!$post->update()) { throw new ExcuteException('save_error', 'Không lưu được'); } $post->cats()->detach(); if (isset($args['cats'])) { $post->cats()->attach($args['cats']); } if (isset($args['newtags'])) { $newtags = $args['newtags']; if ($newtags) { foreach ($newtags as $tag) { $newtag = new Category(); $newtag->type = 'tag'; $newtag->save(); $newtag->langs()->attach(default_lang_id(), ['name' => $tag, 'slug' => toSlug($tag)]); $post->cats()->attach($newtag->id); } } } if (isset($args['availtags'])) { $availtags = $args['availtags']; if ($availtags) { $post->cats()->attach($availtags); } } $syncs = []; foreach ($langs as $lang) { $code = $args[$lang->code]; if (isset($code['post_title'])) { $this->post_title = $code['post_title']; } if (isset($code['slug'])) { $this->slug = $code['slug']; } $slug = trim($this->slug) == '' ? toSlug($this->post_title) : toSlug($this->slug); if (isset($code['post_content'])) { $this->post_content = $code['post_content']; } if (isset($code['post_excerpt'])) { $this->post_excerpt = $code['post_excerpt']; } if (isset($code['custom'])) { $this->custom = $code['custom']; } $post_desc = ['post_title' => $this->post_title, 'slug' => $slug, 'post_content' => $this->post_content, 'post_excerpt' => $this->post_excerpt, 'custom' => $this->custom]; $syncs[$lang->id] = $post_desc; } $post->langs()->sync($syncs); }
public function update($id, $request, $multilang = true) { if ($this->valid($request->all(), $this->rules($multilang))) { $tax = $this->find($id); if ($request->has('parent')) { $tax->parent = $request->get('parent'); } $tax->status = $request->get('status'); if ($multilang) { $tax->update(); $syncs = []; foreach (get_langs() as $lang) { $langdata = $request->get($lang->code); $name = $langdata['name']; $slug = isset($langdata['slug']) ? $langdata['slug'] : ''; $tax_desc = ['name' => $name, 'slug' => trim($slug) == '' ? toSlug($name) : toSlug($slug)]; $syncs[$lang->id] = $tax_desc; } $tax->langs()->sync($syncs); } else { $name = $request->get('dfname'); $slug = $request->get('dfslug'); $tax->dfname = $name; $tax->dfslug = trim($slug) == '' ? toSlug($name) : toSlug($slug); $tax->update(); } } else { throw new ValidateException($this->getError()); } }
function lang_switch() { $langs = get_langs(); ?> <ul> <?php foreach ($langs as $lang) { ?> <li><a href=""><?php echo $lang->name; ?> </a></li> <?php } ?> </ul> <?php }