<?php

	class qa_html_theme_layer extends qa_html_theme_base {


		function footerlinks() {
			qa_html_theme_base::footerlinks();
			if( qa_opt('lang_switch_enable') && $this->template !== 'admin' ) {
				if (qa_clicked('lang_switch_save')) {
					setcookie('user_lang', qa_post_text('user_lang'), 0, '/', QA_COOKIE_DOMAIN);
					qa_redirect(qa_request());
				}

				require_once QA_INCLUDE_DIR.'king-app/admin.php';
				
				$this->output('<li ><div data-toggle="modal" data-target="#langsmodal" role="button" style="border: 1px solid #f2f5f8;text-align: center;border-radius: 14px;margin: 0 6px;font-size: 13px;height: 40px;padding:0 10px;line-height: 40px;cursor:pointer;"><i class="fa-solid fa-language"></i> '.qa_opt('lang_switch_title').'</div></li>');
				$this->output( '<div id="langsmodal" class="king-modal-login">' );
				$this->output( '<div class="king-modal-content">' );
				$fields = array();
				$langs = qa_admin_language_options();
				foreach ($langs as $key => $value) {
					$langsoptions[$key] = $value;
				}
				$ok = null;

				$defaultlang = isset($_COOKIE['user_lang']) ? $_COOKIE['user_lang'] : qa_opt('site_language');

				$fields[] = array(
					'label' => qa_opt('lang_switch_title'),
					'type' => 'select-radio',
					'options' => $langsoptions,
					'value'   => $langsoptions[$defaultlang],
					'tags' => 'NAME="user_lang"',
				);

				$langs['form'] = array(
					'tags'    => 'name="langss" method="post" action="' . qa_self_html() . '"',
					'style' => 'tall',
					'fields' => $fields,
					'buttons' => array(
						array(
							'label' => 'Save',
							'tags' => 'NAME="lang_switch_save"',
						)
					),
				);
				$this->form($langs['form']);
				$this->output('</div>');
				$this->output('</div>');
			}
		}


	}

