XOOPS模組開發
###############################################################################
# 產生 nav.html
###############################################################################
function write_Nav_html() {
global $ugmKind, $DIRNAME;
//---- 過濾資料 -------------------------*/
$myts = &MyTextSanitizer::getInstance();
# ----得到陣列 ----------------------------
$ofsn = 0;
$level = 1;
$nav_arr = $ugmKind->get_use_theme_nav_html($ofsn, $level);
$nav_body_html = "";
#第1層
foreach ($nav_arr as $nav) {
$target = $nav['target'] ? " target='_blank'" : "";
$url = $nav['url'] ? $myts->addSlashes($nav['url']) : "#";
$title = $nav['title'] ? $myts->addSlashes($nav['title']) : "";
$nav_body_html .= " <li><a class='page-scroll' href='{$url}' {$target}>{$title}</a></li>\n";
}
/*
*/
$nav_html .= "<nav id='mainNav' class='navbar navbar-default navbar-fixed-top <{if \$xoops_dirname != \"system\"}>affix<{/if}>'>\n";
$nav_html .= " <div class='container'>\n";
$nav_html .= " <!-- Brand and toggle get grouped for better mobile display -->\n";
$nav_html .= " <div class='navbar-header'>\n";
$nav_html .= " <button type='button' class='navbar-toggle collapsed' data-toggle='collapse' data-target='#bs-example-navbar-collapse-1'>\n";
$nav_html .= " <span class='sr-only'>Toggle navigation</span> Menu <i class='fa fa-bars'></i>\n";
$nav_html .= " </button>\n";
$nav_html .= " <a class='navbar-brand page-scroll' href='#page-top'><{\$xoops_sitename}></a>\n";
$nav_html .= " </div>\n";
$nav_html .= " <!-- Collect the nav links, forms, and other content for toggling -->\n";
$nav_html .= " <div class='collapse navbar-collapse' id='bs-example-navbar-collapse-1'>\n";
$nav_html .= " <ul class='nav navbar-nav navbar-right'>\n";
$nav_html .= $nav_body_html;
$nav_html .= " </ul>\n";
$nav_html .= " </div>\n";
$nav_html .= " <!-- /.navbar-collapse -->\n";
$nav_html .= " </div>\n";
$nav_html .= " <!-- /.container-fluid -->\n";
$nav_html .= "</nav>\n";
$file_name = "creative_nav.html";
#---- 檢查資料夾
mk_dir(XOOPS_ROOT_PATH . "/uploads/{$DIRNAME}/tpl");
$file = XOOPS_ROOT_PATH . "/uploads/{$DIRNAME}/tpl/" . $file_name;
$f = fopen($file, 'w'); //以寫入方式開啟文件
fwrite($f, $nav_html); //將新的資料寫入到原始的文件中
fclose($f);
}