<?php

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

use modul_application\ESPCMS_ArticleTypeDB;
use inc_application\link\ArticleLink;

class lib_subtype {

	public static function call_subtype($parameter, $filename = 'subtype', $outHTML = null) {
		$espcms_lib_template = espcms_web_template();
		$espcms_lib_template->libfile = true;
		$para = espcms_array_getvalue($parameter);
		$mid = $para['mid'] && espcms_ismatches($para['mid']) ? $para['mid'] : 0;
		$sid = $para['sid'] && espcms_ismatches($para['sid']) ? $para['sid'] : 0;
		$lng = espcms_lancode();
		$sublist = ESPCMS_ArticleTypeDB::get_document_subjectlist_list($lng, $sid, $mid);
		$espcms_lib_template->into('para', $para);
		$espcms_lib_template->into('array', $sublist);
		if (!empty($outHTML)) {
			$output = $espcms_lib_template->fetch(null, null, $outHTML);
		} else {
			$output = $espcms_lib_template->fetch('lib/' . $filename);
		}
		return $output;
	}

	public static function find_subtype($sid = 0, $return_key = 'subjectname') {
		if (!espcms_ismatches($sid) || !$sid) {
			return false;
		}
		$read = ESPCMS_ArticleTypeDB::get_article_subjectlist_view($sid);
		if (!$read) {
			return false;
		}
		$read['link'] = ArticleLink::subtype_link($read);
		$read['purview_link'] = ArticleLink::doc_js_link('subpuv', $read);
		return $read[$return_key];
	}

}
