= 2) {
$items .= "
";
}
if ($status >= 1) {
$items .= "
";
}
$status = 1;
$items .= "
". $_REQUEST[main][$i]. "
". $_REQUEST[addr][$i]. "";
}
if ($_REQUEST[sub][$i]) {
if ($status >= 2) {
$items .= "
";
}
$status = 2;
$items .= "
". $_REQUEST[sub][$i]. "
". $_REQUEST[addr][$i]. "";
}
if ($_REQUEST[child][$i]) {
$status = 3;
$items .= "
". $_REQUEST[child][$i]. "
". $_REQUEST[addr][$i]. "
";
}
}
}
if ($status >= 2) {
$items .= "
";
}
if ($status >= 1) {
$items .= "
";
}
$xml =<<<_
$_REQUEST[nextIcon]
$_REQUEST[mainIcon]
$_REQUEST[subIcon]
$_REQUEST[childIcon]
$_REQUEST[theme]
$items
_;
file_put_contents("$System[datadir]/menu/apymenu.xml", $xml);
logregist("プルダウンメインメニューの編集");
}
if ($_REQUEST[action] != 'regist') {
header("Content-type:text/html; charset=utf-8");
$theme = $_REQUEST[theme];
echo <<<_
preview
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ページのタイトル</title>
<link type="text/css" href="/jquery/apymenu/$theme/menu.css" rel="stylesheet" />
<script type="text/javascript" src="/jquery/apymenu/$theme/menu.js"></script>
<script type="text/javascript" src="/jquery/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="/trycms/system.js"></script>
</head>
<body>
<div id="pulldownmenu"></div>
<script type="text/javascript">
getAjaxText('/trycms/apymenu.php?ajax=1', 'pulldownmenu', apymenu_initialize);
</script>
</body>
</html>
この例は15行目のAjaxで、13行目のdiv領域にメインメニューを挿入しています。
静的なhtmlファイルでSSIが使用可能な環境ではSSIで挿入が簡単です。
<!--#include virtual="/trycms/apymenu.php"-->
SSIの挿入では、上記タグをメニューを挿入したい位置に貼り付けるだけです。
javascriptのコードも同時に設定されますので、手動での設定は必要有りません。
(14行から16行は不要)
_;
exit;
}
}
if (is_file("$System[datadir]/menu/apymenu.xml")) {
$xml = simplexml_load_file("$System[datadir]/menu/apymenu.xml");
$mainCnt = count($xml->Items->main);
$i = 0;
foreach ($xml->Items->main as $mainobj) {
$main = ''; $sub = ''; $child = '';
$main = $xml->Items->main[$i]->title;
$action = $xml->Items->main[$i]->action;
if (isset($mainobj->sub)) {
$j = 0;
foreach ($xml->Items->main[$i]->sub as $subobj) {
$sub = $xml->Items->main[$i]->sub[$j]->title;
$action = $xml->Items->main[$i]->sub[$j]->action;
if (isset($xml->Items->main[$i]->sub[$j]->child)) {
$k = 0;
foreach ($xml->Items->main[$i]->sub[$j]->child as $childobj) {
$child = $xml->Items->main[$i]->sub[$j]->child[$k]->title;
$action = $xml->Items->main[$i]->sub[$j]->child[$k]->action;
$data[] = join("\t", array($main, $sub, $child, $action));
$main = ''; $sub = ''; $child = '';
$k++;
}
} else {
$data[] = join("\t", array($main, $sub, $child, $action));
$main = ''; $sub = ''; $child = '';
}
$j++;
}
} else {
$data[] = join("\t", array($main, $sub, $child, $action));
}
$i++;
}
}
!$xml->menuHeight && $xml->menuHeight = 55;
!$xml->fontSize && $xml->fontSize = 13;
$xml->menuBgcolor && $menuBgcolor = "#$xml->menuBgcolor";
$xml->menuColor && $menuColor = "#$xml->menuColor";
!$xml->theme && $xml->theme = "theme07";
$currentdir = "$_SERVER[DOCUMENT_ROOT]/jquery/apymenu";
if ($dh = opendir($currentdir)) {
while (($file = readdir($dh)) !== false) {
if (!preg_match("/^\./", $file) && filetype("$currentdir/$file") == "dir") {
$Themes[] = $file;
}
}
closedir($dh);
sort($Themes);
}
$doc .=<<<_
_;
$html .=<<<_
_;
$client = new window;
$client->name = 'client';
$client->width = '925px;';
$client->display = 'block';
$client->caption = "プルダウンメインメニュー";
$client->drag = false;
$client->resize = false;
$client->closebutton = true;
$client->closeFunc = '';
$client->smallbutton = true;
$client->height = '';
$client->border = false;
$client->bgcolor = '';
$client->statusbar = false;
$client->bgcolor = '';
$client->date = false;
$client->time = false;
$client->copy = false;
$client->body = $doc;
$html .= $client->show();
$javascript =<<<_
var previewwin;
var selectLine;
var imageField;
if (parent.mailform) {
$('#mailformbutton').css('display', 'block');
}
$('.selectColor').ColorPicker({
onSubmit: function(hsb, hex, rgb, el) {
$(el).val(hex);
$(el).css('backgroundColor', '#' + hex);
$(el).ColorPickerHide();
},
onBeforeShow: function () {
$(this).ColorPickerSetColor(this.value);
}})
.bind('keyup', function(){
$(this).ColorPickerSetColor(this.value);
});
$(function() {
$("#sortable").sortable();
/*$("#sortable").disableSelection();*/
});
function show_help() {
if ($('#help').css('display') == 'none') {
$('#help').css('display', 'block');
$('#help2').css('display', 'block');
document.getElementById('helpimg').src='images/help_open.png';
} else {
$('#help').css('display', 'none');
$('#help2').css('display', 'none');
document.getElementById('helpimg').src='images/help_close.png';
}
}
function gosubmit() {
with(document.clientform) {
target='';
action.value='regist';
submit();
}
}
function preview() {
document.getElementById('confirmdialog').innerHTML=
'\
 | \
\
最新のプレビューを表示すると自動的に現在の設定が保存されます。\
何も編集されていない場合は、[保存しない]を選択してください。\
保存すると編集履歴にも保存されます。 \
\
プレビューを表示しますか?\
| \
\
';
$(function() {
$('#confirmdialog').dialog({
title: '確認',
resizable: false,
width:400,
height:200,
modal: true,
buttons: {
保存する: function() {
$(this).dialog('close');
previewwin = window.open('', 'previewwin');
document.clientform.target='previewwin';
document.clientform.action.value='saveview';
$('#deleteButton').css('display', 'block');
document.clientform.submit();
previewwin.focus();
},
保存しない: function() {
$(this).dialog('close');
previewwin = window.open('', 'previewwin');
document.clientform.target='previewwin';
document.clientform.action.value='preview';
$('#deleteButton').css('display', 'block');
document.clientform.submit();
previewwin.focus();
},
キャンセル: function() {
$(this).dialog('close');
}
}
});
});
}
function selectContents(type,title) {
$('#popup').dialog('close');
getAjaxText('ajax.php?cmd='+type, 'ajaxdialog');
$(function() {
$('#ajaxdialog').dialog({
title: title,
resizable: false,
width:800,
modal: true,
show: 'blind',
hide: 'blind',
buttons: {
閉じる: function() {
$(this).dialog('close');
}
}
});
});
}
function setfilename(path) {
$('#addr'+selectLine).val(path);
}
function setimgfilename(path) {
$('#'+imageField).val(path);
}
function windowGoResize() {
var h = $(window).height();
document.getElementById('scroolBody').style.height=h-60+'px';
}
windowGoResize();
window.onresize=windowGoResize;
_;
?>