本文整理汇总了PHP中Agent::languages方法的典型用法代码示例。如果您正苦于以下问题:PHP Agent::languages方法的具体用法?PHP Agent::languages怎么用?PHP Agent::languages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Agent
的用法示例。
在下文中一共展示了Agent::languages方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_languages
/**
* Tests Agent::languages()
*
* @test
*/
public function test_languages()
{
$expected = array("en-us", "en", "nl-be", "nl");
$output = Agent::languages();
$this->assertEquals($expected, $output);
}
示例2: fromBrowser
private function fromBrowser()
{
if (!$this->language) {
$matches = array_intersect($this->settings->languages(), Agent::languages());
if (count($matches)) {
$this->language = $matches[0];
}
}
return $this;
}
示例3: getUiLanguageFromSession
public function getUiLanguageFromSession()
{
$setLanguage = \Session::get('ui_language', \Config::get('app.locale'));
if (\Config::get('paperwork.userAgentLanguage')) {
$uaLanguages = \Agent::languages();
foreach ($uaLanguages as $uaLanguage) {
if (PaperworkHelpers::hasUiLanguage($uaLanguage)) {
$setLanguage = $uaLanguage;
break;
}
}
}
return $setLanguage;
}
示例4: action_view
public static function action_view($short_url)
{
if (is_object($short_url) === false) {
$short_url = Model_Url::query()->where('short_url', $short_url)->get_one();
}
$short_url->hits = $short_url->hits + 1;
$short_url->save();
if (empty($short_url) === false) {
$results = Controller_Url::check_loop($short_url);
$data['url'] = $results['url'];
$data['iframe'] = $results['iframe'];
if (isset($results['image']) === true) {
$data['image'] = $results['image'];
}
if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) {
$ip = $_SERVER["HTTP_CF_CONNECTING_IP"];
} else {
$ip = Input::real_ip();
}
$country = Model_Url_Stats_Country::query()->where('start_ip', '<=', ip2long($ip))->where('end_ip', '>=', ip2long($ip))->get_one();
if (empty($country) === false) {
$country = $country->country;
} else {
$country = 'N/A';
}
$lang = Agent::languages();
// Insert Some Stats
$stats = Model_Url_Stat::forge(array('url_id' => $short_url->id, 'ip' => $ip, 'country' => $country, 'referer' => Input::referrer(), 'language' => serialize($lang)));
$stats->save();
return new Response(View::Forge('url/redirect', $data));
} else {
Session::set('error', 'We couldn\'t');
Response::Redirect(Uri::Base());
}
}