本文整理汇总了PHP中MY_Controller::getCurrentLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP MY_Controller::getCurrentLocale方法的具体用法?PHP MY_Controller::getCurrentLocale怎么用?PHP MY_Controller::getCurrentLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MY_Controller
的用法示例。
在下文中一共展示了MY_Controller::getCurrentLocale方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: language_switch_show
public function language_switch_show($widget = array())
{
if ($widget['settings'] == FALSE) {
$settings = $this->defaults;
} else {
$settings = $widget['settings'];
}
$current_address = '';
$current_address .= $this->uri->uri_string();
if ($this->input->server('QUERY_STRING')) {
$current_address .= '?' . $this->input->server('QUERY_STRING');
}
if ($this->uri->segment(1)) {
if (array_key_exists($this->uri->segment(1), $this->core->langs)) {
$current_address = substr_replace($current_address, '', 0, strlen($this->uri->segment(1)));
} else {
$current_address = '/' . $current_address;
}
}
$languages = $this->db->get('languages')->result_array();
foreach ($languages as $key => $lang) {
if ($lang['identif'] == MY_Controller::getCurrentLocale()) {
$languages[$key]['current'] = 1;
} else {
$languages[$key]['current'] = 0;
}
}
return $this->template->fetch('widgets/' . $widget['name'], array('languages' => $languages, 'current_address' => $current_address));
}
示例2: widget
/**
* Run widget
*
* @param string $name - widget name
* @param integer $cache - cache ttl in minutes
*/
function widget($name = FALSE, $cache = FALSE)
{
$ci =& get_instance();
$query = $ci->db->limit(1)->get_where('widgets', array('name' => $name));
if ($query->num_rows() == 1) {
$widget = $query->row_array();
} else {
log_message('error', 'Can\'t run widget <b>' . $name . '</b>');
}
if (($data = $ci->cache->fetch('widget' . $name, 'widgets')) != FALSE and $cache != FALSE) {
return $data;
} else {
$widget['settings'] = unserialize($widget['settings']);
switch ($widget['type']) {
case 'module':
$subpath = isset($widget['settings']['subpath']) ? $widget['settings']['subpath'] . '/' : '';
$result = $ci->load->module($widget['data'] . '/' . $subpath . $widget['data'] . '_widgets')->{$widget}['method']($widget);
break;
case 'html':
$locale = MY_Controller::getCurrentLocale();
$id = $widget['id'];
$sql = "select * from widget_i18n where locale = '{$locale}' and id = '{$id}'";
$w_i18 = $ci->db->query($sql)->row_array();
$result = $w_i18['data'];
break;
}
if ($cache != FALSE and is_integer($cache)) {
$ci->cache->store('widget' . $name, $result, $cache * 60, 'widgets');
}
return $result;
}
}
示例3: getDiscount
/**
* get all activ discount
* @return array discount
*/
public function getDiscount()
{
$locale = \MY_Controller::getCurrentLocale();
$time = time();
$sql = "select *, mod_shop_discounts.id as ids, mod_shop_discounts.id as id\n from mod_shop_discounts\n left join mod_shop_discounts_i18n on mod_shop_discounts_i18n.id = mod_shop_discounts.id and mod_shop_discounts_i18n.locale = '{$locale}'\n where (max_apply > count_apply \n or max_apply is null \n or (max_apply is null and count_apply is null)\n or (count_apply is null and max_apply > 0))\n and \n (date_begin < '{$time}' and date_end > '{$time}' \n or date_begin < '{$time}' and date_end is Null \n or date_begin is Null and date_end is Null\n or date_begin < '{$time}' and date_end = '0'\n or date_begin is null and date_end = '0')\n and \n active = 1";
return $this->db->query($sql)->result_array();
}
示例4: getMoFileName
function getMoFileName($domain)
{
if ($domain) {
if (isset($GLOBALS['MO_FILE_NAMES'][$domain])) {
return $GLOBALS['MO_FILE_NAMES'][$domain];
}
if (!defined('CUR_LOCALE')) {
$CI =& get_instance();
if (strstr($_SERVER['REQUEST_URI'], 'install')) {
$lang = $CI->config->item('language');
$locale = $lang ? $lang : 'ru_RU';
} else {
if (strstr(uri_string(), 'admin')) {
$locale = $CI->config->item('language');
} else {
$currentLocale = MY_Controller::getCurrentLocale();
$language = $CI->db->where('identif', $currentLocale)->get('languages')->row_array();
$locale = $language['locale'];
}
}
define('CUR_LOCALE', $locale);
} else {
$locale = CUR_LOCALE;
}
$name = NULL;
switch ($domain) {
case 'main':
$searched = glob(correctUrl('./application/language/main/' . $locale) . '/' . $locale . '/LC_MESSAGES/main*.mo');
if (!empty($searched)) {
$name = str_replace('.mo', '', basename(array_pop($searched)));
}
break;
default:
if (strstr($domain, 'admin') && MAINSITE) {
$begin = MAINSITE;
} else {
$begin = '.';
}
//$locale = 'de_DE';
$module_path = correctUrl('./application/modules/' . $domain . '/language/' . $locale);
if (is_dir($module_path)) {
$searched = glob($module_path . '/' . $locale . '/LC_MESSAGES/' . $domain . '*.mo');
if (!empty($searched)) {
$name = str_replace('.mo', '', basename(array_pop($searched)));
}
} elseif (file_exists(TEMPLATES_PATH . $domain)) {
$searched = glob(TEMPLATES_PATH . $domain . '/language/' . $domain . '/' . $locale . '/LC_MESSAGES/' . $domain . '*.mo');
if (!empty($searched)) {
$name = str_replace('.mo', '', basename(array_pop($searched)));
}
}
break;
}
$GLOBALS['MO_FILE_NAMES'] = $GLOBALS['MO_FILE_NAMES'] ? $GLOBALS['MO_FILE_NAMES'] : array();
$GLOBALS['MO_FILE_NAMES'][$domain] = $name;
return $name;
}
return FALSE;
}
示例5: autoload
/**
* Autoload method.
*
* @return void
*/
public function autoload()
{
$url = ltrim(str_replace('/' . MY_Controller::getCurrentLocale() . '/', '', $this->input->server('REQUEST_URI')), '/');
//locale fix
$row = $this->db->where('trash_url', $url)->or_where('trash_url', $this->uri->uri_string())->get('trash')->row();
if ($row != null) {
$row->trash_redirect_type != '404' or $this->core->error_404();
redirect($row->trash_redirect, 'location', $row->trash_type);
}
}
示例6: getPaternSettings
public function getPaternSettings($patern_name)
{
$locale = \MY_Controller::getCurrentLocale();
$query = $this->db->select('*, mod_email_paterns.id as id')->join('mod_email_paterns_i18n', "mod_email_paterns_i18n.id = mod_email_paterns.id and mod_email_paterns_i18n.locale = '{$locale}'", 'left')->where('mod_email_paterns.name', $patern_name)->get('mod_email_paterns');
if ($query) {
return $query->row_array();
} else {
return '';
}
}
示例7: print_product
/**
* Print Product
* @param int $id
* @param int $var
*/
public function print_product($id, $var)
{
if (!$this->no_install) {
return false;
}
$product = SProductsQuery::create()->joinWithI18n(MY_Controller::getCurrentLocale())->findPk($id);
$variant = SProductVariantsQuery::create()->joinWithI18n(MY_Controller::getCurrentLocale())->findPk($var);
\CMSFactory\assetManager::create()->registerStyleWithoutTemplate('style');
\CMSFactory\assetManager::create()->setData(array('product' => $product, 'variant' => $variant))->render('print_product', TRUE);
}
示例8: get_one_banner
public function get_one_banner($id, $locale)
{
if (!$locale) {
$locale = MY_Controller::getCurrentLocale();
}
$banner = $this->db->query("select * from mod_banner inner join mod_banner_i18n on mod_banner.id = mod_banner_i18n.id where locale = '{$locale}' and mod_banner.id = '{$id}'")->result_array();
if (count($banner) == 0) {
return FALSE;
}
return $banner[0];
}
示例9: getWidgetTitle
function getWidgetTitle($name)
{
$ci =& get_instance();
$locale = MY_Controller::getCurrentLocale();
$query = $ci->db->join('widget_i18n', 'widget_i18n.id=widgets.id AND locale="' . $locale . '"', 'left')->get_where('widgets', array('name' => $name));
if ($query->num_rows() == 1) {
$widget = $query->row_array();
return $widget['title'];
} else {
log_message('error', 'Can\'t run widget <b>' . $name . '</b>');
}
return '';
}
示例10: getSettings
public function getSettings()
{
$settings = getSettings();
if (strstr($_SERVER['HTTP_REFERER'], 'admin')) {
$langs = $this->config->item('languages');
$language = $this->config->item('language');
$locale = $langs[$language][0];
} else {
$locale = MY_Controller::getCurrentLocale();
}
$settings['curLocale'] = $locale;
return json_encode($settings);
}
示例11: set_tpl_roles
function set_tpl_roles()
{
// roles
//$query = $this->db->get('shop_rbac_roles');
$locale = MY_Controller::getCurrentLocale();
$this->db->select("shop_rbac_roles.*", FALSE);
$this->db->select("shop_rbac_roles_i18n.alt_name", FALSE);
$this->db->where('locale', $locale);
$this->db->join("shop_rbac_roles_i18n", "shop_rbac_roles_i18n.id = shop_rbac_roles.id");
$role = $this->db->get('shop_rbac_roles')->result_array();
//$this->template->assign('roles', $query->result_array());
$this->template->assign('roles', $role);
// roles
}
示例12: __construct
/**
* Setting class variables
* @param string $locale locale to intiate class with
*/
public function __construct($locale = NULL)
{
if ($this->useLocales == TRUE) {
$this->locale = !is_null($locale) ? $locale : MY_Controller::getCurrentLocale();
}
$locales_ = CI::$APP->db->select('identif,id')->get('languages')->result_array();
foreach ($locales_ as $row) {
$this->locales[$row['id']] = $row['identif'];
}
// getting data from DB
$result = CI::$APP->db->select('siteinfo')->get('settings')->row_array();
$siteinfo = @unserialize($result['siteinfo']);
if (is_array($siteinfo)) {
$this->siteinfo = $siteinfo;
} else {
// throw new Exception();
}
}
示例13: media_url
function media_url($url = '')
{
$CI =& get_instance();
/* @var $config CI_Config */
$config = $CI->config;
if (is_array($url)) {
$url = implode('/', $url);
}
$index_page = $config->slash_item('index_page');
if ($index_page === '/') {
$index_page = '';
}
if ($CI->uri->segment(1) == MY_Controller::getCurrentLocale()) {
$return = rtrim($config->slash_item('base_url'), MY_Controller::getCurrentLocale() . '/') . '/' . $index_page . preg_replace("|^/*(.+?)/*\$|", "\\1", $url);
} else {
$return = $config->slash_item('base_url') . $index_page . preg_replace("|^/*(.+?)/*\$|", "\\1", $url);
}
return $return;
}
示例14: index
public function index()
{
$success = FALSE;
$this->load->library('Form_validation');
$this->form_validation->set_error_delimiters(FALSE, FALSE);
$model = new SCallbacks();
if ($this->input->post()) {
$this->form_validation->set_message('required', $model->validationMessage('required'));
$this->form_validation->set_rules($model->rules());
if ($this->form_validation->run($this) !== FALSE) {
$theme = SCallbackThemesQuery::create()->orderByPosition()->findOne();
if ($theme) {
$model->setThemeId($theme->getId());
} else {
$model->setThemeId(0);
}
$model->fromArray($this->input->post());
$model->setDate(time());
$model->setStatusId(SCallbackStatusesQuery::create()->filterByIsDefault(TRUE)->findOne()->getId());
$model->save();
$info = array();
$info['userName'] = $model->getName();
$info['userPhone'] = $model->getPhone();
$info['dateCreated'] = $model->getDate();
$info['callbackStatus'] = $model->getSCallbackStatuses()->getText();
if ($theme) {
$info['callbackTheme'] = $model->getSCallbackThemes()->getText();
}
$info['userComment'] = $model->getComment();
$this->composeAndSendEmail($info);
$locale = \MY_Controller::getCurrentLocale();
$notif = $this->db->where('locale', $locale)->where('name', 'callback')->get('answer_notifications')->row();
$success = $notif->message;
/** Register event 'category:load' */
CMSFactory\Events::create()->raiseEvent(['model' => $model], 'Shop:callback');
echo json_encode(array('msg' => $success, 'status' => true, 'close' => true, 'refresh' => $this->input->post('refresh') ? $this->input->post('refresh') : FALSE, 'redirect' => $this->input->post('redirect') ? $this->input->post('redirect') : FALSE));
} else {
echo json_encode(array('msg' => validation_errors(), 'status' => false, 'validations' => array('Name' => form_error('Name'), 'Phone' => form_error('Phone'), 'Comment' => form_error('Comment'))));
}
} else {
echo json_encode(array('msg' => "Ошибка, не достаточно данных", 'status' => false));
}
}
示例15: get_all
function get_all($offset = 0, $row_count = 0)
{
$users_table = $this->_table;
$roles_table = $this->_roles_table;
if ($offset >= 0 and $row_count > 0) {
$locale = MY_Controller::getCurrentLocale();
$this->db->select("{$users_table}.*", FALSE);
$this->db->select("{$roles_table}.name AS role_name", FALSE);
$this->db->select("shop_rbac_roles_i18n.alt_name AS role_alt_name", FALSE);
$this->db->join($roles_table, "{$roles_table}.id = {$users_table}.role_id", "left");
$this->db->join("shop_rbac_roles_i18n", "shop_rbac_roles_i18n.id = shop_rbac_roles.id AND shop_rbac_roles_i18n.locale ='{$locale}'", "left");
//$this->db->where('shop_rbac_roles_i18n.locale', MY_Controller::getCurrentLocale());
$this->db->order_by("{$users_table}.id", "ASC");
$query = $this->db->get($this->_table, $row_count, $offset);
} else {
$query = $this->db->get($this->_table);
}
return $query;
}