portal_diy.js 中的 spaceDiy 对象扩展函数
getdiy : function (type) {
if (type) {
var nav = $('controlnav').children;
for (var i in nav) {
if (nav[i].className == 'current') {
nav[i].className = '';
var contentid = 'content'+nav[i].id.replace('nav', '');
if ($(contentid)) $(contentid).style.display = 'none';
}
}
$('nav'+type).className = 'current';
if (type == 'start' || type == 'frame' ) {
$('content'+type).style.display = 'block';
return true;
}
var para = '&op='+type;
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
para += '&' + arguments[i] + '=' + arguments[++i];
}
}
var ajaxtarget = type == 'diy' ? 'diyimages' : '';
var x = new Ajax();
x.showId = ajaxtarget;
x.get('portal.php?mod=portalcp&ac=diy'+para+'&inajax=1&ajaxtarget='+ajaxtarget,function(s, x) {
if (s) {
if (typeof cpb_frame == 'object' && !BROWSER.ie) {delete cpb_frame;}
if (!$('content'+type)) {
var dom = document.createElement('div');
dom.id = 'content'+type;
$('controlcontent').appendChild(dom);
}
$('content'+type).innerHTML = s;
$('content'+type).style.display = 'block';
if (type == 'diy') {
spaceDiy.setCurrentDiy(spaceDiy.currentDiy);
if (spaceDiy.styleSheet.rules.length > 0) {
Util.show('recover_button');
}
}
var evaled = false;
if(s.indexOf('ajaxerror') != -1) {
evalscript(s);
evaled = true;
}
if(!evaled && (typeof ajaxerror == 'undefined' || !ajaxerror)) {
if(x.showId) {
ajaxupdateevents($(x.showId));
}
}
if(!evaled) evalscript(s);
}
});
}
}
'portal.php?mod=portalcp&ac=diy'+para+'&inajax=1&ajaxtarget='+ajaxtarget
以上语句即调取DIY模块信息的URL地址
对应的程序文件 source/include/portalcp/portalcp_diy.php
对应的模板文件 template/default/portal/portalcp_diy.htm
模板生成过程如下
<!--{if $op=='blockclass'}-->
<ul class="blocks content">
<li>自定义模块</li>
<!--{loop $_G['cache'][blockclass] $key $value}-->
<li class="module-$key">
<ul>
<!--{loop $value[subs] $skey $svalue}-->
<li class="module-$skey"><label onmousedown="drag.createObj (event,'block','$skey');" onmouseover="className='hover';" onmouseout="this.className='';">$svalue[name]</label></li>
<!--{/loop}-->
</ul>
</li>
<!--{/loop}-->
</ul>