<?php
namespace inc_application\link;
use modul_application\ESPCMS_ArticleDB;
class ArticleLink {
public static function doc_link($read = array(), $isdyurl = false, $isrewrite = true, $lng = false) {
global $espcms_command;
if ($read['islink'] && espcms_isurl($read['link'])) {
$link = $read['link'];
} else {
if (!$espcms_command['IS_HTML'] && $read['ishtml'] <= 1 && !$isdyurl && $read['pageclass'] <= 1) {
$action_key[] = $read['filepath'] ? $read['filepath'] : ESPCMS_ArticleDB::update_article_filepath($read);
$link = espcms_url_html_out($action_key, false, false);
} else {
if ($espcms_command['IS_REWRITE'] && $isrewrite) {
$action_key[] = 'Article_Read_' . $read['did'];
$action_key[] = urlencode($read['title']);
$link = espcms_url_out($action_key, true);
} else {
$action_key['ac'] = 'Article';
$action_key['at'] = 'Read';
$action_key['did'] = $read['did'];
$link = espcms_url_out($action_key);
}
}
}
return $link;
}
public static function doc_js_link($linkcode = false, $read = array()) {
$link_array = array();
$action_key['ac'] = 'Article';
$action_key['at'] = 'GetClick';
$action_key['did'] = $read['did'];
$link_array['click'] = espcms_url_out($action_key);
$action_key['at'] = 'Readpuv';
$action_key['did'] = $read['did'];
$link_array['readpuv'] = espcms_url_out($action_key);
$action_key['at'] = 'Typepuv';
$action_key['tid'] = $read['tid'];
$link_array['typepuv'] = espcms_url_out($action_key);
$action_key['at'] = 'Subpuv';
$action_key['sid'] = $read['sid'];
$link_array['subpuv'] = espcms_url_out($action_key);
return $linkcode ? $link_array[$linkcode] : $link_array;
}
public static function type_link($read = array(), $pageid = 0) {
global $espcms_command;
if ($read['styleid'] == 3) {
if ($read['isline'] && espcms_isurl($read['typeurl'])) {
$link = $read['typeurl'];
}
if (!$read['isline'] && espcms_ismatches($read['gotoline']) && $read['gotoline']) {
$doc_read = ESPCMS_ArticleDB::get_article_read($read['gotoline']);
$link = self::doc_link($doc_read);
}
} else {
if (!$espcms_command['IS_HTML'] && $read['pageclass'] <= 1) {
$action_key[] = $read['dirname'];
$read['filenamestyle'] = !$read['filenamestyle'] ? '{tid}_{pageid}' : $read['filenamestyle'];
if (espcms_ismatches($pageid) && $pageid && $pageid > 1) {
$read['pageid'] = $pageid;
$action_key[] = get_htmlfilename($read['filenamestyle'], $read);
}
$link = $pageid > 1 ? espcms_url_html_out($action_key, false, false, true) : espcms_url_html_out($action_key);
} else {
if ($espcms_command['IS_REWRITE']) {
$action_key[] = espcms_ismatches($pageid) && $pageid ? 'Article_List_' . $read['tid'] . '_' . $pageid : 'Article_List_' . $read['tid'];
$action_key[] = urlencode($read['typename']);
$link = espcms_url_out($action_key, true);
} else {
$action_key['ac'] = 'Article';
$action_key['at'] = 'List';
$action_key['tid'] = $read['tid'];
if (espcms_ismatches($pageid) && $pageid) {
$action_key['pageid'] = $pageid;
}
$link = espcms_url_out($action_key);
}
}
}
return $link;
}
public static function subtype_link($read = array(), $pageid = 0) {
global $espcms_command;
if (!$espcms_command['IS_HTML'] && $read['ishtml'] <= 1) {
$action_key[] = $read['dirname'];
$read['filenamestyle'] = !$read['filenamestyle'] ? '{sid}_{pageid}' : $read['filenamestyle'];
if (espcms_ismatches($pageid) && $pageid && $pageid > 1) {
$read['pageid'] = $pageid;
$action_key[] = get_htmlfilename($read['filenamestyle'], $read);
}
$link = $pageid > 1 ? espcms_url_html_out($action_key, false, false, true) : espcms_url_html_out($action_key);
} else {
if ($espcms_command['IS_REWRITE']) {
$action_key[] = espcms_ismatches($pageid) && $pageid ? 'Article_SubList_' . $read['sid'] . '_' . $pageid : 'Article_SubList_' . $read['sid'];
$action_key[] = urlencode($read['subjectname']);
$link = espcms_url_out($action_key, true);
} else {
$action_key['ac'] = 'Article';
$action_key['at'] = 'SubList';
$action_key['sid'] = $read['sid'];
if (espcms_ismatches($pageid) && $pageid) {
$action_key['pageid'] = $pageid;
}
$link = espcms_url_out($action_key);
}
}
return $link;
}
public static function tags_link($read = array(), $pageid = 0) {
global $espcms_command;
if ($espcms_command['IS_REWRITE']) {
$action_key[] = espcms_ismatches($pageid) && $pageid ? 'Article_Tags' . '_' . $pageid : 'Article_Tags';
$action_key[] = urlencode($read['keywordname']);
$link = espcms_url_out($action_key, true);
} else {
$action_key['ac'] = 'Article';
$action_key['at'] = 'Tags';
if (espcms_ismatches($pageid) && $pageid) {
$action_key['pageid'] = $pageid;
}
$action_key['key'] = urlencode($read['keywordname']);
$link = espcms_url_out($action_key);
}
return $link;
}
public static function search_link($read = array(), $pageid = 0) {
$action_key['ac'] = 'Search';
$action_key['at'] = 'List';
$action_key['pageid'] = $pageid;
$action_key['mid'] = $read['mid'];
$action_key['tid'] = $read['tid'];
$action_key['keyword'] = urlencode($read['keyword']);
$action_key['keyname'] = urlencode($read['keyname']);
$action_key['attr_array'] = $read['attr_array'] && is_array($read['attr_array']) ? urlencode(serialize($read['attr_array'])) : '';
$link = espcms_url_out($action_key);
return $link;
}
}