function view_datatable() { $form_general = $this->createform('.options', 'general', true); $form_config = $this->createform('.options', 'config', true); $form_social = $this->createform('.options', 'social', true); $form_twitter = $this->createform('.options', 'twitter', true); $form_facebook = $this->createform('.options', 'facebook', true); $form_telegram = $this->createform('.options', 'telegram', true); $form_sms = $this->createform('.options', 'sms', true); $form_register = $this->createform('.options', 'account', true); // add languages item foreach (\lib\utility\option::languages() as $key => $value) { $form_config->config_defaultLang->child()->id('lang_' . $key)->value($key)->label($value); } // add sms items $form_sms->sms_name->child()->id('sms_kavenegar')->value('kavenegar_api')->label(T_('Kavenegar')); $tld_list = ['com', 'org', 'edu', 'net', 'ir']; foreach ($tld_list as $key => $tld) { $form_config->config_defaultTld->child()->id('config_tld_' . $tld)->value($tld)->label($tld); } // add content list to show for redirect foreach (\lib\utility\option::contentList(true) as $key => $value) { $form_register->account_redirect->child()->id('redirect_' . $key)->value($value)->label(T_($value)); } // give perm list and fill it in default register type $myPermList = $form_register->account_default; $myPermNames = \lib\utility\option::permList(); if (!$myPermNames) { $myPermNames = []; } $myPerm = 1; // if list of permission is more than 6 item show in select if (count($myPermNames) > 6) { $myPermList = $form_register->account_default->type('select'); } // get list of permissions foreach ($myPermNames as $key => $value) { if ($myPerm == $key) { $myPermList->child()->value($key)->label(T_($value))->elname(null)->pl(null)->attr('type', null)->id('perm_' . $key)->selected(); } else { $myPermList->child()->value($key)->label(T_($value))->elname(null)->pl(null)->attr('type', null)->id('perm_' . $key); } } // get the datatable of options $datatable = $this->model()->draw_options(); // $datatable['sms']['sms'] = null; // fill all forms used in options page if (isset($datatable['general'])) { $this->form_fill($form_general, $datatable['general']); } if (isset($datatable['config']['config'])) { $this->form_fill($form_config, $datatable['config']['config']); // add default tld to domain name if (isset($datatable['config']['config']['meta']['defaultTld'])) { $selectedTld = $datatable['config']['config']['meta']['defaultTld']; $form_config->config_domainName->attr('data-after', $selectedTld); } } if (isset($datatable['social'])) { $this->form_fill($form_social, $datatable['social']); } if (isset($datatable['social']['twitter'])) { $this->form_fill($form_twitter, $datatable['social']['twitter']); } if (isset($datatable['social']['facebook'])) { $this->form_fill($form_facebook, $datatable['social']['facebook']); } if (isset($datatable['social']['telegram'])) { $this->form_fill($form_telegram, $datatable['social']['telegram']); } if (isset($datatable['sms']['sms'])) { $this->form_fill($form_sms, $datatable['sms']['sms']); } if (isset($datatable['account']['account'])) { $this->form_fill($form_register, $datatable['account']['account']); } }
public static function detect_language() { /** * set default language to storage for next use */ // var_dump(\lib\utility\option::get('config', 'meta', 'defaultLanguage')); $default_lang = \lib\utility\option::get('config', 'meta', 'defaultLang'); if ($default_lang) { router::set_storage('defaultLanguage', $default_lang); } else { router::set_storage('defaultLanguage', 'en_US'); } // if current tld is ir or referrer from site with ir tld, // change language to fa_IR if (\lib\router::get_storage('language')) { $myLang = router::get_storage('language'); switch (Tld) { case 'ir': $myLang = "fa_IR"; break; default: break; } if (defined('MainService') && Tld !== 'dev') { // for example redirect ermile.ir to ermile.com/fa $myLang = substr($myLang, 0, 2); $myredirect = new \lib\redirector(); $myredirect->set_domain()->set_url($myLang)->redirect(); } else { // else show in that domain with fa langusage router::set_storage('language', $myLang); } } /** * Localized Language, defaults to English. * * Change this to localize Saloos. A corresponding MO file for the chosen * language must be installed to content/languages. For example, install * fa_IR.mo to content/languages and set LANGUAGE to 'fa_IR' to enable Persian * language support. */ router::set_storage('language', router::get_storage('defaultLanguage')); if (router::get_repository_name() === 'content') { // $mysub = router::get_sub_domain(); $mysub = router::get_url(0); $myList = \lib\utility\option::languages(); // check langlist with subdomain and if is equal set current language foreach ($myList as $key => $value) { $myLang = substr($key, 0, 2); if ($mysub === $myLang) { if (router::get_storage('defaultLanguage') === $key) { // redirect to homepage $myredirect = new \lib\redirector(); $myredirect->set_domain()->set_url()->redirect(); } else { router::set_storage('language', $key); // update base url router::$base .= '/' . router::get_url(0); router::remove_url($myLang); } } } } else { // change with get all times except on content or root, // because in root user must change language with subdomain if (isset($_GET["lang"])) { router::set_storage('language', $_GET["lang"]); } elseif (isset($_COOKIE["lang"])) { router::set_storage('language', $_COOKIE["lang"]); } // save language preference for future page requests setcookie('lang', router::get_storage('language'), time() + 30 * 24 * 60 * 60, '/', '.' . Service); } // check direction of language and set for rtl languages switch (router::get_storage('language')) { case 'fa_IR': case 'ar_SU': router::set_storage('direction', 'rtl'); break; default: router::set_storage('direction', 'ltr'); break; } return router::get_storage('language'); }
/** * [mvc_construct description] * @return [type] [description] */ public function mvc_construct() { array_push($this->twig_include_path, addons); // define default value for url $this->url->fakesub = $this->url('fakesub'); // the $_SERVER[REQUEST_URI] $this->url->full = $this->url('full'); // full url except get parameter with http[s] $this->url->path = $this->url('path'); // full path except parameter and domain name $this->url->breadcrumb = $this->url('breadcrumb'); // full path in array for using in breadcrumb $this->url->domain = $this->url('domain'); // domain name like 'ermile' $this->url->base = $this->url('base'); $this->url->tld = $this->url('tld'); // domain ltd like 'com' $this->url->raw = Service; // domain name except subdomain like 'ermile.com' $this->url->root = $this->url('root'); $this->url->static = $this->url->root . '/' . 'static/'; $this->url->protocol = Protocol; $this->url->account = $this->url('account'); $this->url->MainStatic = $this->url('MainService') . '/' . 'static/'; $this->url->MainSite = $this->url('MainSite'); $this->url->MainProtocol = $this->url('MainProtocol'); $this->url->SubDomain = SubDomain ? SubDomain . '.' : null; // return all parameters and clean it $this->url->param = \lib\utility::get(null, true); $this->url->all = $this->url->full . $this->url->param; $this->data->site['title'] = T_("Saloos"); $this->data->site['desc'] = T_("Another Project with Saloos"); $this->data->site['slogan'] = T_("Saloos is an artichokes for PHP programming!!"); $this->data->site['langlist'] = \lib\utility\option::languages(); $this->data->site['currentlang'] = \lib\define::get_language(); $this->data->site['defaultLang'] = \lib\define::get_language('default'); // if allow to use social then get social network account list if (\lib\utility\option::get('social', 'status')) { $this->data->social = \lib\utility\option::get('social', 'meta'); } $this->data->page['title'] = null; $this->data->page['desc'] = null; $this->data->page['special'] = null; $this->data->bodyclass = null; $this->data->module = $this->module(); $this->data->child = $this->child(); $this->data->login = $this->login('all'); $this->data->perm = $this->access(null, 'all'); $this->data->permContent = $this->access('all'); // define default value for global $this->global->title = null; $this->global->login = $this->login(); $this->global->lang = $this->data->site['currentlang']; $this->global->direction = \lib\define::get_language('direction'); $this->global->id = $this->url('path', '_'); // add special pages to display array to use without name $this->data->display['main'] = "content/main/layout.html"; $this->data->display['home'] = "content/home/display.html"; $this->data->display['account'] = "content_account/home/layout.html"; $this->data->display['cp'] = "content_cp/home/layout.html"; $this->data->display['pagination'] = "content_cp/templates/inc_pagination.html"; // add special pages to template array to use without name $this->data->template['header'] = 'content/template/header.html'; $this->data->template['sidebar'] = 'content/template/sidebar.html'; $this->data->template['footer'] = 'content/template/footer.html'; // define default value for include $this->include->newline = PHP_EOL; $this->include->css_main = false; $this->include->css_ermile = true; $this->include->js_main = true; $this->include->css = true; $this->include->js = true; $this->include->fontawesome = null; $this->include->datatable = null; $this->include->telinput = null; $this->include->lightbox = null; $this->include->editor = null; if (isset($this->controller->pagnation)) { $this->data->pagnation = $this->controller->pagnation_get(); } if (method_exists($this, '_construct')) { $this->_construct(); } if (isset($this->url->MainStatic) && $this->url->MainStatic) { $this->url->myStatic = $this->url->MainStatic; } elseif (isset($this->url->MainStatic)) { $this->url->myStatic = $this->url->static; } if (method_exists($this, 'options')) { $this->options(); } if (\lib\utility\option::get('config', 'meta', 'saveAsCookie')) { $mygetlist = \lib\utility::get(null, 'raw'); if ($mygetlist) { foreach ($mygetlist as $name => $value) { if ($name === 'ssid') { $_SESSION['ssid'] = $value; } elseif (!($name === 'dev' || $name === 'lang')) { \lib\utility\cookie::write($name, $value); } } // remove get parameter from url header('Location: ' . $this->url('full')); } } // check main ********************************************* CHECK FOR ONLY IN FIRST PAGE IN RIGHT PLACE // in all page like ajax request must be run if (AccountService === MainService) { $this->model()->checkMainAccount(); $this->controller()->checkSession(); } }