:::

1. XoopsModules\Tadtools\Utility 工具集

use XoopsModules\Tadtools\Utility;

Utility 工具集是把之前 tadtools/function.php 所有常用的函式,都物件化而已。

  1. 常用 XOOPS表單安全檢查(配合表單token 使用)
    Utility::xoops_security_check()

     

  2. 常用 將陣列列出(除錯用,取代die(var_dump($arr))
    Utility::dd($array = [])

     

  3. 常用 建立目錄
    Utility::mk_dir($dir = '')

     

  4. 常用 自訂錯誤訊息
    Utility::web_error($sql, $file = '', $line = '', $force = false)

     

  5. 常用 細部權限判斷
    Utility::power_chk($perm_name = '', $perm_itemid = '', $module_id = '', $trueifadmin = true)

     

  6. 常用 亂數字串($format =[ 'ALL', 'CHAR', 'NUMBER'])
    Utility::randStr($len = 6, $format = 'ALL')

     

  7. 常用 取得分頁工具
    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);

     

  8. 常用 取得模組工具列($forcetrue時,$interface_menu 無論有無內容,都會呈現工具列)
    Utility::toolbar_bootstrap($interface_menu = [], $force = false)

     

  9. 一般 刪除目錄
    Utility::delete_directory($dirname)

     

     

  10. 一般 拷貝目錄
    Utility::full_copy($source = '', $target = '')

     

  11. 一般 路徑導覽,需搭配 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;
    }
    

     

  12. 一般 設定頁面 meta 給FB、Line 等網站使用
    Utility::setup_meta($title = '', $content = '', $image = '')

     

  13. 一般 產生HTML5頁面語法
    Utility::html5($content = '', $ui = false, $bootstrap = true, $bootstrap_version = 3, $use_jquery = true, $container = 'container', $title = 'XOOPS', $head_code = '')

     

  14. 一般 將文字中的網址轉為連結
    Utility::autolink(&$text, $target = '_blank', $nofollow = true)

     

  15. 一般 產生QR Code
    Utility::mk_qrcode($url)

     

  16. 一般 把字串換成群組(例如將「1,2,3」轉成「管理員<br>會員<br>訪客」)
    Utility::txt_to_group_name($groupid_txt = '', $default_txt = '', $syb = '<br>')

     

  17. 一般 載入 jquery.js
    Utility::get_jquery($ui = false, $mode = '', $theme = 'base')

     

  18. 少用 加入 jquery-migrate($mode="return"時傳回語法)
    Utility::add_migrate($mode = "")

     

  19. 少用 版本判斷($type = ['xoops', 'php'])
    Utility::get_version($type = 'xoops', $ver = '')

     

  20. 少用 改檔名
    Utility::rename_win($oldfile, $newfile)

     

  21. 少用 解決 basename 抓不到中文檔名的問題
    Utility::get_basename($filename)

     

  22. 少用 載入 bootstrap,目前僅後台用得到
    Utility::get_bootstrap($mode = '')

     

  23. 少用 自動取得網址(輕鬆架的 mainfile.php用)
    Utility::get_xoops_url()

     

  24. 少用 自動取得實體位置(輕鬆架的 mainfile.php用)
    Utility::get_xoops_path()

     

  25. 少用 推文工具
    Utility::push_url($enable = 1, $css = 'width:auto;margin:10px;float:right;')

     

  26. 少用 facebook的留言
    Utility::facebook_comments($facebook_comments_width = 600, $modules = '', $page = '', $col_name = '', $col_sn = '')

     

  27. 少用 單選回復原始資料函數
    Utility::chk($DBV = null, $NEED_V = '', $defaul = '', $return = "checked='checked'")

     

  28. 少用 複選回復原始資料函數
    Utility::chk2($default_array = '', $NEED_V = '', $default = 0)

     

  29. 少用 取得所有群組陣列
    Utility::get_all_groups()

     

  30. 少用 輸出為UTF8
    Utility::to_utf8($buffer = '')

     

  31. 少用 判斷字串是否為utf8
    Utility::is_utf8($str)

     

  32. 少用 自動轉換編碼 ($OS_or_Web 為 Web 時,代表將系統的編碼轉成和網站用編碼一致)
    Utility::auto_charset($str = '', $OS_or_Web = 'web')

     

  33. 少用 刪除整個目錄
    Utility::rrmdir($path)

     

  34. 少用 $interface_menu 的內容做成json檔,放在 /uploads/menu_模組.txt
    Utility::make_menu_json($interface_menu = [], $moduleName = '')

     

  35. 少用 取得 tadtools 的偏好設定
    Utility::TadToolsXoopsModuleConfig()

     

  36. 少用 偵測是否為行動裝置
    Utility::mobile_device_detect($iphone = true, $ipad = true, $android = true, $opera = true, $blackberry = true, $palm = true, $windows = true, $mobileredirect = false, $desktopredirect = false)

:::

搜尋

QR Code 區塊

https%3A%2F%2Fwww.tad0616.net%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbsn%3D15%26tbdsn%3D1710

書籍目錄

展開 | 闔起

線上使用者

27人線上 (4人在瀏覽線上書籍)

會員: 0

訪客: 27

更多…