use XoopsModules\Tadtools\Utility;
Utility 工具集是把之前 tadtools/function.php 所有常用的函式,都物件化而已。
Utility::xoops_security_check()
die(var_dump($arr))
)
Utility::dd($array = [])
Utility::mk_dir($dir = '')
Utility::web_error($sql, $file = '', $line = '', $force = false)
Utility::power_chk($perm_name = '', $perm_itemid = '', $module_id = '', $trueifadmin = true)
Utility::randStr($len = 6, $format = 'ALL')
Utility::getPageBar($sql = '', $show_num = 20, $page_list = 10, $to_page = '', $url_other = '', $bootstrap = '3', $g2p_name = 'none')
常用範例
//Utility::getPageBar($原sql語法, 每頁顯示幾筆資料, 最多顯示幾個頁數選項);
$PageBar = Utility::getPageBar($sql, 20, 10);
$bar = $PageBar['bar'];
$sql = $PageBar['sql'];
$total = $PageBar['total'];
$xoopsTpl->assign('bar', $bar);
$xoopsTpl->assign('total', $total);
$force
為true
時,$interface_menu
無論有無內容,都會呈現工具列)
Utility::toolbar_bootstrap($interface_menu = [], $force = false)
Utility::delete_directory($dirname)
Utility::full_copy($source = '', $target = '')
get_模組_cate_path($分類編號)
;
Utility::tad_breadcrumb($cate_sn = '0', $cate_path_array = [], $url_page = 'index.php', $page_cate_name = 'csn', $cate_title_name = 'title', $last = '')
如:
//取得路徑
function get_cate_path($csn = "", $sub = false)
{
global $xoopsDB;
if (!$sub) {
$home['首頁'] = XOOPS_URL . "/modules/tadgallery/index.php";
} else {
$home = array();
}
$sql = "select title, of_csn from " . $xoopsDB->prefix("tad_gallery_cate") . " where csn='{$csn}'";
$result = $xoopsDB->query($sql) or redirect_header($_SERVER['PHP_SELF'], 3, mysql_error());
list($title, $of_csn) = $xoopsDB->fetchRow($result);
$opt_sub = (!empty($of_csn)) ? get_cate_path($of_csn, true) : "";
if (!empty($title)) {
$opt[$title] = XOOPS_URL . "/modules/tadgallery/index.php?csn=$csn";
}
if (is_array($opt_sub)) {
$path = array_merge($home, $opt_sub, $opt);
} elseif (is_array($opt)) {
$path = array_merge($home, $opt);
} else {
$path = $home;
}
return $path;
}
Utility::setup_meta($title = '', $content = '', $image = '')
Utility::html5($content = '', $ui = false, $bootstrap = true, $bootstrap_version = 3, $use_jquery = true, $container = 'container', $title = 'XOOPS', $head_code = '')
Utility::autolink(&$text, $target = '_blank', $nofollow = true)
Utility::mk_qrcode($url)
Utility::txt_to_group_name($groupid_txt = '', $default_txt = '', $syb = '<br>')
jquery.js
Utility::get_jquery($ui = false, $mode = '', $theme = 'base')
Utility::add_migrate($mode = "")
Utility::get_version($type = 'xoops', $ver = '')
Utility::rename_win($oldfile, $newfile)
Utility::get_basename($filename)
Utility::get_bootstrap($mode = '')
Utility::get_xoops_url()
Utility::get_xoops_path()
Utility::push_url($enable = 1, $css = 'width:auto;margin:10px;float:right;')
Utility::facebook_comments($facebook_comments_width = 600, $modules = '', $page = '', $col_name = '', $col_sn = '')
Utility::chk($DBV = null, $NEED_V = '', $defaul = '', $return = "checked='checked'")
Utility::chk2($default_array = '', $NEED_V = '', $default = 0)
Utility::get_all_groups()
Utility::to_utf8($buffer = '')
Utility::is_utf8($str)
Utility::auto_charset($str = '', $OS_or_Web = 'web')
Utility::rrmdir($path)
$interface_menu
的內容做成json檔,放在 /uploads/menu_模組.txt
Utility::make_menu_json($interface_menu = [], $moduleName = '')
Utility::TadToolsXoopsModuleConfig()
Utility::mobile_device_detect($iphone = true, $ipad = true, $android = true, $opera = true, $blackberry = true, $palm = true, $windows = true, $mobileredirect = false, $desktopredirect = false)