当前位置: 首页>>代码示例>>PHP>>正文


PHP Get::user_acceptlang方法代码示例

本文整理汇总了PHP中Get::user_acceptlang方法的典型用法代码示例。如果您正苦于以下问题:PHP Get::user_acceptlang方法的具体用法?PHP Get::user_acceptlang怎么用?PHP Get::user_acceptlang使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Get的用法示例。


在下文中一共展示了Get::user_acceptlang方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: updateRoomLog

    function updateRoomLog($roomid)
    {
        $xml_answer = false;
        $bw_code = Get::user_acceptlang();
        $request = '<?xml version="1.0" encoding="utf-8"?' . '>
		<ews type="10" lang="' . $bw_code . '">
			<clientcode>' . Get::sett('code_teleskill') . '</clientcode>
			<roomid>' . $roomid . '</roomid>
			<complete>1</complete>
			</ews>';
        $xml_answer = $this->_sendXmlRequest($request);
        if ($xml_answer === false || $xml_answer === '') {
            return array('errorcode' => -1, 'errormessage' => '', 'roomid' => '');
        }
        //Test Answer
        /*$xml_answer =	'<?xml version="1.0" encoding="utf-8"?'.'>'
        		 .'<ews>'
        		.'<errorcode>0</errorcode>'
        		.'<errormessage></errormessage>'
        		.'<sessions>'
        		.'<session sid="1" uid="1039" role="2" date="2008-09-30 11:00:13" duration="3565"/>'
        		.'<session sid="2" uid="1097" role="1" date="2008-09-30 11:05:54" duration="3254"/>'
        		.'<session sid="3" uid="1098" role="1" date="2008-09-30 11:01:18" duration="3148"/>'
        		.'<session sid="4" uid="1099" role="1" date="2008-09-30 11:07:25" duration="3297"/>'
        		.'</sessions>'
        		.'</ews>';*/
        $dom_answer = new DoceboDOMDocument();
        $dom_answer->loadXML(trim($xml_answer));
        $dlist_code = $dom_answer->getElementsByTagName('errorcode');
        $dlist_msg = $dom_answer->getElementsByTagName('errormessage');
        $dnode_code = $dlist_code->item(0);
        $dnode_msg = $dlist_msg->item(0);
        $e_code = $dnode_code->textContent;
        $e_msg = $dnode_msg->textContent;
        if ($e_code == 0) {
            $this->clearRoomLog($roomid);
            $dlist_sessions = $dom_answer->getElementsByTagName('session');
            if ($dlist_sessions->length > 0) {
                $array_element = array();
                for ($i = 0; $i < $dlist_sessions->length; $i++) {
                    $node = $dlist_sessions->item($i);
                    if ((int) $node->getAttribute('uid') != 0) {
                        $gmt = date('P', fromDatetimeToTimestamp($node->getAttribute('date')));
                        $gmt_split = explode(':', $gmt);
                        $gmt_offset = (int) $gmt_split[0];
                        if (isset($array_element[$node->getAttribute('uid')])) {
                            $array_element[$node->getAttribute('uid')]['duration'] += $node->getAttribute('duration');
                            $array_element[$node->getAttribute('uid')]['role'] = $node->getAttribute('role');
                            $array_element[$node->getAttribute('uid')]['access']++;
                        } else {
                            $array_element[$node->getAttribute('uid')]['role'] = $node->getAttribute('role');
                            $array_element[$node->getAttribute('uid')]['date'] = date('Y-m-d H:i:s', fromDatetimeToTimestamp($node->getAttribute('date')) + $gmt_offset * 3600);
                            $array_element[$node->getAttribute('uid')]['duration'] = $node->getAttribute('duration');
                            $array_element[$node->getAttribute('uid')]['access'] = 1;
                        }
                    }
                }
                $query = "INSERT INTO " . $GLOBALS['prefix_scs'] . "_teleskill_log (roomid, idUser, role, date, duration, access)" . " VALUES";
                $first = true;
                foreach ($array_element as $id_user => $values) {
                    if (!$first) {
                        $query .= ", ";
                    } else {
                        $first = false;
                    }
                    $query .= " ('" . $roomid . "',\r\n\t\t\t\t\t\t\t\t'" . (int) $id_user . "',\r\n\t\t\t\t\t\t\t\t'" . $values['role'] . "',\r\n\t\t\t\t\t\t\t\t'" . $values['date'] . "',\r\n\t\t\t\t\t\t\t\t'" . $values['duration'] . "',\r\n\t\t\t\t\t\t\t\t'" . $values['access'] . "')";
                }
                $result = sql_query($query);
                return $result;
            }
            return true;
        }
        return array('errorcode' => $e_code, 'errormessage' => $e_msg, 'roomid' => '');
    }
开发者ID:abhinay100,项目名称:forma_app,代码行数:74,代码来源:ConferenceTeleSkillPlugin.php

示例2: get

 /**
  * Return the current language, the following policy is followed
  * if a session preference is found, that one will be used, otherwise :
  * if the user is logged in we find and setup it's default language
  * if the user is anonymous we try to select the languagfe using the browser list of language preferences
  * if all of the previous fail we will use the default setted language
  * @return string
  */
 public static function get($reset = false)
 {
     if ($reset && isset($_SESSION['current_lang'])) {
         unset($_SESSION['current_lang']);
     }
     if (!isset($_SESSION['current_lang'])) {
         $_SESSION['current_lang'] = self::getDefault();
         // we if (!Get::cfg('demo_mode', false) && !Docebo::user()->isAnonymous()) {don't know which language we need
         if (!Get::cfg('demo_mode', false) && !Docebo::user()->isAnonymous()) {
             // load the language from the user setting
             $_SESSION['current_lang'] = Docebo::user()->preference->getLanguage();
         } else {
             // find the user language looking into the browser info
             $langadm = new LangAdm();
             $all_language = $langadm->getLangListNoStat();
             $browser_lang = Get::user_acceptlang(false);
             foreach ($browser_lang as $code) {
                 foreach ($all_language as $lang) {
                     if (strpos($lang->lang_browsercode, $code) !== false) {
                         $_SESSION['current_lang'] = $lang->lang_code;
                         return $_SESSION['current_lang'];
                     }
                 }
                 // end foreach
             }
             // end foreach
         }
     }
     return $_SESSION['current_lang'];
 }
开发者ID:abhinay100,项目名称:forma_app,代码行数:38,代码来源:lib.lang.php


注:本文中的Get::user_acceptlang方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。