function build_cache_diytemplatename() { $data = array(); $apps = array('portal', 'forum', 'group', 'home'); $nullname = lang('portalcp', 'diytemplate_name_null'); $scriptarr = $lostname = array(); foreach (C::t('common_diy_data')->range() as $datarow) { $datarow['name'] = $datarow['name'] ? $datarow['name'] : lang('portalcp', $datarow['targettplname'], '', ''); if (empty($datarow['name'])) { $lostname[$datarow['targettplname']] = $datarow['targettplname']; $datarow['name'] = $nullname; } $data[$datarow['targettplname']] = dhtmlspecialchars($datarow['name']); $curscript = substr($datarow['targettplname'], 0, strpos($datarow['targettplname'], '/')); if (in_array($curscript, $apps)) { $scriptarr[$curscript][$datarow['targettplname']] = true; } } if ($lostname) { require_once libfile('function/portalcp'); foreach (getdiytplnames($lostname) as $pre => $datas) { foreach ($datas as $id => $name) { $data[$pre . $id] = $name; } } } savecache('diytemplatename', $data); foreach ($scriptarr as $curscript => $value) { savecache('diytemplatename' . $curscript, $value); } }
} $multi = $initemdata ? '' : multi($count, $perpage, $page, $theurl); } } if ($blocks) { $losttpls = $alldata = array(); $bids = array_keys($blocks); if ($bids) { foreach (C::t('common_template_block')->fetch_all_by_bid($bids) as $value) { $alldata[] = $value; if (!isset($_G['cache']['diytemplatename'][$value['targettplname']])) { $losttpls[$value['targettplname']] = $value['targettplname']; } } if ($losttpls) { $lostnames = getdiytplnames($losttpls); foreach ($lostnames as $pre => $datas) { foreach ($datas as $id => $name) { $_G['cache']['diytemplatename'][$pre . $id] = $tpls[$pre . $id] = $name; } } } foreach ($alldata as $value) { $diyurl = block_getdiyurl($value['targettplname']); $diyurl = $diyurl['url']; $tplname = isset($_G['cache']['diytemplatename'][$value['targettplname']]) ? $_G['cache']['diytemplatename'][$value['targettplname']] : $value['targettplname']; if (!isset($tpls[$value['targettplname']])) { $tpls[$value['targettplname']] = $tplname; } $blocks[$value['bid']]['page'][$value['targettplname']] = $diyurl ? '<a href="' . $diyurl . '" target="_blank">' . $tplname . '</a>' : $tplname; }
function getdiytplname($targettplname, $tpldirectory) { $diydata = C::t('common_diy_data')->fetch($targettplname, $tpldirectory); $diytplname = $diydata ? $diydata['name'] : ''; if (empty($diytplname) && ($data = getdiytplnames(array($targettplname)))) { $diytplname = array_shift(array_shift($data)); } return $diytplname; }