$value) { $GLOBALS['em_nativeplaces'][$key] = $value; } $cachefile = DEDESTATIC.'/enums/infotype.json'; $data = json_decode(file_get_contents($cachefile)); foreach ($data as $key => $value) { $GLOBALS['em_infotypes'][$key] = $value; } function is_str_float($value){ return ((int)$value != $value) ; } function lib_infolink(&$ctag, &$refObj) { global $dsql, $nativeplace, $infotype, $hasSetEnumJs, $cfg_cmspath, $cfg_mainsite, $em_nativeplaces, $em_infotypes; //属性处理 //$attlist="row|12,titlelen|30"; //FillAttsDefault($ctag->CAttribute->Items,$attlist); //extract($ctag->CAttribute->Items, EXTR_SKIP); $cmspath = ((empty($cfg_cmspath) || !preg_match("#\/$#", $cfg_cmspath)) ? $cfg_cmspath.'/' : $cfg_cmspath); $baseurl = preg_replace("#\/$#", '', $cfg_mainsite).$cmspath; $smalltypes = ''; if (!empty($refObj->TypeLink->TypeInfos['smalltypes'])) { $smalltypes = explode(',', $refObj->TypeLink->TypeInfos['smalltypes']); } if (empty($refObj->Fields['typeid'])) { $row = $dsql->GetOne("SELECT id FROM `#@__arctype` WHERE channeltype='-8' And reid = '0' "); $typeid = (is_array($row) ? $row['id'] : 0); } else { $typeid = $refObj->Fields['typeid']; } $innerText = trim($ctag->GetInnerText()); if (empty($innerText)) $innerText = GetSysTemplets("info_link.htm"); $ctp = new DedeTagParse(); $ctp->SetNameSpace('field', '[', ']'); $ctp->LoadSource($innerText); $revalue = $seli = ''; $channelid = (empty($refObj->TypeLink->TypeInfos['channeltype']) ? -8 : $refObj->TypeLink->TypeInfos['channeltype']); $fields = array( 'nativeplace' => '', 'infotype' => '', 'typeid' => $typeid, 'channelid' => $channelid, 'linkallplace' => '', 'linkalltype' => '' ); $fields['nativeplace'] = $fields['infotype'] = ''; $fields['linkallplace'] = "不限"; $fields['linkalltype'] = "不限"; //地区链接 if (empty($nativeplace)) { foreach ($em_nativeplaces as $eid => $em) { if ($eid % 500 != 0) continue; $fields['nativeplace'] .= " {$em}\r\n"; } } else { $sontype = (($nativeplace % 500 != 0) ? $nativeplace : 0); //子集 $toptype = (($nativeplace % 500 == 0) ? (int)$nativeplace : (int)($nativeplace - ($nativeplace % 500))); //顶级联动分类 $fields['nativeplace'] = " {$em_nativeplaces[$toptype]} -"; if ($nativeplace % 500 == 0) { //1级分类 foreach ($em_nativeplaces as $eid => $em) { if ($eid < $toptype + 1 || $eid > $toptype + 499) continue; if (is_str_float($eid)) continue; //仅显示2级 if ($eid == $nativeplace) { $fields['nativeplace'] .= " {$em}\r\n"; } else { $fields['nativeplace'] .= " {$em}\r\n"; } } } else if (!is_str_float($nativeplace)) { //2级分类 $fields['nativeplace'] .= " {$em_nativeplaces[$sontype]}"; $i = 0; $ff = ""; foreach ($em_nativeplaces as $eid => $em) { if ($eid < $sontype + 1 && $eid > $sontype) { if (is_str_float($eid)) { $i++; } if ($eid === $nativeplace) { $ff .= " {$em}\r\n"; } else { $ff .= " {$em}\r\n"; } } } if ($i > 0) $fields['nativeplace'] .= " - "; $fields['nativeplace'] .= $ff; } else { //3级分类 $t = intval($nativeplace); $fields['nativeplace'] .= " {$em_nativeplaces[$t]} -"; foreach ($em_nativeplaces as $eid => $em) { if ($eid < $t + 1 && $eid > $t) { if ($eid === $nativeplace) { $fields['nativeplace'] .= " {$em}\r\n"; } else { $fields['nativeplace'] .= " {$em}\r\n"; } } } } } //小分类链接 if (empty($infotype) || !is_array($smalltypes)) { foreach ($em_infotypes as $eid => $em) { if (!is_array($smalltypes) || $eid % 500 != 0) continue; if (is_array($smalltypes) && !in_array($eid, $smalltypes)) continue; if ($eid == $infotype) { $fields['infotype'] .= " {$em}\r\n"; } else { $fields['infotype'] .= " {$em}\r\n"; } } } else { $sontype = (($infotype % 500 != 0) ? $infotype : 0); $toptype = (($infotype % 500 == 0) ? (int)$infotype : (int)($infotype - ($infotype % 500))); $fields['infotype'] = "{$em_infotypes[$toptype]} - "; if ($infotype % 500 == 0) { //1级分类 foreach ($em_infotypes as $eid => $em) { if ($eid < $toptype + 1 || $eid > $toptype + 499) continue; if (is_str_float($eid)) continue; //仅显示2级 if ($eid == $infotype) { $fields['infotype'] .= " {$em}\r\n"; } else { $fields['infotype'] .= " {$em}\r\n"; } } } else if (!is_str_float($infotype)) { //2级分类 $fields['infotype'] .= " {$em_infotypes[$sontype]}"; $i = 0; $ff = ""; foreach ($em_infotypes as $eid => $em) { if ($eid < $sontype + 1 && $eid > $sontype) { if (is_str_float($eid)) { $i++; } if ($eid === $infotype) { $ff .= " {$em}\r\n"; } else { $ff .= " {$em}\r\n"; } } } if ($i > 0) $fields['infotype'] .= " - "; $fields['infotype'] .= $ff; } else { //3级分类 $t = intval($infotype); $fields['infotype'] .= " {$em_infotypes[$t]} -"; foreach ($em_infotypes as $eid => $em) { if ($eid < $t + 1 && $eid > $t) { if ($eid === $infotype) { $fields['infotype'] .= " {$em}\r\n"; } else { $fields['infotype'] .= " {$em}\r\n"; } } } } } if (is_array($ctp->CTags)) { foreach ($ctp->CTags as $tagid => $ctag) { if (isset($fields[$ctag->GetName()])) { $ctp->Assign($tagid, $fields[$ctag->GetName()]); } } $revalue .= $ctp->GetResult(); } return $revalue; } ?>