<?php

/*
  PHP version 5
  Copyright (c) 2002-2018 ECISP.CN、EarcLink.COM
  警告：这不是一个免费的软件，请在许可范围内使用，请尊重知识产权，侵权必究，举报有奖
  作者：黄祥云 E-mail:6326420@qq.com  QQ:6326420 TEL:18665655030
 */

namespace inc_application\link;

class LngLink {

	public static function link_array($linkcode = false, $array = array()) {
		global $espcms_command;
		$link_array = array();

		$dir_name = $array['ispack'] && $array['packname'] ? $array['packname'] : $array['lng'];

		$link_url = $array['islink'] && $array['url'] ? $array['url'] . '/' : ESPCMS_URL;
		if ($espcms_command['HOME_LNG'] == $array['lng']) {
			$url = $link_url;
		} else {

			$url = !$espcms_command['IS_HTMLDIR'] || !$espcms_command['FILE_HTMLDIR'] ? $link_url . $dir_name . '/' : $link_url . $espcms_command['FILE_HTMLDIR'] . $dir_name . '/';
		}
		$link_array['view'] = $url;
		return $linkcode ? $link_array[$linkcode] : $link_array;
	}

	public static function wap_link_array($array = array()) {
		global $espcms_command;
		if ($espcms_command['IS_REWRITE']) {

			$action_key[] = 'lng_' . $array['lng'];
			$link = espcms_url_out($action_key, true);
		} else {
			$action_key['lng'] = $array['lng'];
			$link = espcms_url_out($action_key);
		}
		return $link;
	}

	public static function get_iswap_link($lng = false) {

		$action_key['ac'] = 'Wap';
		$action_key['at'] = 'JudgeWap';
		$action_key['lng'] = $lng;
		return espcms_url_out($action_key);
	}

}
