Beispiel #1
0
function list_tad_gallery($csn = "", $show_function = 1)
{
    global $xoopsDB, $xoopsModule, $xoopsModuleConfig, $xoopsTpl;
    $tadgallery = new tadgallery();
    $xoopsTpl->assign("jquery", get_jquery(true));
    $xoopsTpl->assign("csn", $csn);
    if (isset($_SESSION['gallery_list_mode']) and $_SESSION['gallery_list_mode'] == "good") {
        $mode_select = "<a href='main.php?op=chg_mode&mode=normal#gallery_top' class='btn btn-warning'>" . _MA_TADGAL_LIST_NORMAL . "</a>";
        $tadgallery->set_view_good(true);
        $cate_options = $cate_option = $link_to_cate = "";
    } else {
        $mode_select = "<a href='main.php?op=chg_mode&mode=good#gallery_top' class='btn btn-warning'>" . _MA_TADGAL_LIST_GOOD . "</a>";
        $tadgallery->set_view_good(false);
        $tadgallery->set_view_csn($csn);
        list_tad_gallery_cate_tree($csn);
        $cate = tadgallery::get_tad_gallery_cate($csn);
        $link_to_cate = !empty($csn) ? "<a href='../index.php?csn={$csn}' class='btn btn-info'>" . sprintf(_MA_TADGAL_LINK_TO_CATE, $cate['title']) . "</a>" : "";
    }
    $tag_select = tag_select("", "add_tag");
    $xoopsTpl->assign("cate_option", $cate_option);
    $xoopsTpl->assign("mode_select", $mode_select);
    $xoopsTpl->assign("link_to_cate", $link_to_cate);
    $xoopsTpl->assign("option", $cate_options);
    $xoopsTpl->assign("tag_select", $tag_select);
    $tadgallery->set_admin_mode(true);
    $tadgallery->get_photos();
}
Beispiel #2
0
function tad_gallery_form($sn = "")
{
    global $xoopsDB, $xoopsTpl;
    //抓取預設值
    if (!empty($sn)) {
        $DBV = tadgallery::get_tad_gallery($sn);
    } else {
        $DBV = array();
    }
    //預設值設定
    $sn = !isset($DBV['sn']) ? "" : $DBV['sn'];
    $title = !isset($DBV['title']) ? "" : $DBV['title'];
    $tag = !isset($DBV['tag']) ? "" : $DBV['tag'];
    $op = empty($sn) ? "insert_tad_gallery" : "update_tad_gallery";
    $xoopsTpl->assign('title', $title);
    $xoopsTpl->assign('op', $op);
    $xoopsTpl->assign('sn', $sn);
    $tag_select = tag_select($tag);
    $xoopsTpl->assign('tag_select', $tag_select);
}
Beispiel #3
0
function edit_photo($sn)
{
    global $upload_powers;
    $photo = tadgallery::get_tad_gallery($sn);
    $tag_select = tag_select($photo['tag']);
    $path = get_tadgallery_cate_path($photo['csn']);
    $patharr = array_keys($path);
    $make_option_js = "";
    foreach ($patharr as $k => $of_csn) {
        $j = $k + 1;
        $make_option_js .= "make_option('csn_menu','{$k}','{$of_csn}','{$patharr[$j]}');\n";
    }
    if ($_SESSION['bootstrap'] == '3') {
        $form_col = "\n        <div class='form-group'>\n          <label class='col-md-2 control-label'>" . _MD_TADGAL_CSN . "</label>\n          <div class='col-md-10'>\n            <select name='csn_menu[0]' id='csn_menu0' class='csn_menu'><option value=''></option></select>\n            <select name='csn_menu[1]' id='csn_menu1' class='csn_menu' style='display: none;'></select>\n            <select name='csn_menu[2]' id='csn_menu2' class='csn_menu' style='display: none;'></select>\n            <select name='csn_menu[3]' id='csn_menu3' class='csn_menu' style='display: none;'></select>\n            <select name='csn_menu[4]' id='csn_menu4' class='csn_menu' style='display: none;'></select>\n            <select name='csn_menu[5]' id='csn_menu5' class='csn_menu' style='display: none;'></select>\n            <select name='csn_menu[6]' id='csn_menu6' class='csn_menu' style='display: none;'></select>\n            <input type='text' name='new_csn' placeholder='" . _MD_TADGAL_NEW_CSN . "' class='csn_menu' style='width: 200px;'>\n          </div>\n        </div>\n\n        <div class='form-group'>\n          <label class='col-md-2 control-label'>" . _MD_TADGAL_TITLE . "</label>\n          <div class='col-md-10'>\n            <input class='form-control' type='text' name='title' value='{$photo['title']}' id='newTitle' placeholder='" . _MD_TADGAL_TITLE . "'>\n          </div>\n        </div>\n\n        <div class='form-group'>\n          <label class='col-md-2 control-label'>" . _MD_TADGAL_DESCRIPTION . "</label>\n          <div class='col-md-10'>\n            <textarea class='form-control' name='description' id='newDescription'>{$photo['description']}</textarea>\n          </div>\n        </div>\n\n        <div class='form-group'>\n          <label class='col-md-2 control-label'>" . _MD_TADGAL_TAG . "</label>\n          <div class='col-md-10'>\n            <input type='text' class='form-control' name='new_tag' id='new_tag' placeholder='" . _MD_TADGAL_TAG_TXT . "'>\n            {$tag_select}\n          </div>\n        </div>\n\n        <div class='form-group'>\n          <label class='col-md-2 control-label'></label>\n          <div class='col-md-10'>\n            <label class='checkbox-inline'>\n              <input type='checkbox' name='cover' value='small/{$photo['dir']}/{$photo['sn']}_s_{$photo['filename']}'>\n              " . _MD_TADGAL_AS_COVER . "\n            </label>\n\n            <input type='hidden' name='sn' value='{$photo['sn']}'>\n            <input type='hidden' name='op' value='update_tad_gallery'>\n            <button type='submit' class='btn btn-primary' id='sbtn'>" . _TAD_SAVE . "</button>\n          </div>\n        </div>\n        ";
    } else {
        $form_col = "\n        <div class='control-group'>\n          <label class='span2 control-label'>" . _MD_TADGAL_CSN . "</label>\n          <div class='controls controls-row'>\n            <select name='csn_menu[0]' id='csn_menu0' class='csn_menu'><option value=''></option></select>\n            <select name='csn_menu[1]' id='csn_menu1' class='csn_menu' style='display: none;'></select>\n            <select name='csn_menu[2]' id='csn_menu2' class='csn_menu' style='display: none;'></select>\n            <select name='csn_menu[3]' id='csn_menu3' class='csn_menu' style='display: none;'></select>\n            <select name='csn_menu[4]' id='csn_menu4' class='csn_menu' style='display: none;'></select>\n            <select name='csn_menu[5]' id='csn_menu5' class='csn_menu' style='display: none;'></select>\n            <select name='csn_menu[6]' id='csn_menu6' class='csn_menu' style='display: none;'></select>\n            <input type='text' name='new_csn' placeholder='" . _MD_TADGAL_NEW_CSN . "' class='csn_menu' style='width: 200px;'>\n          </div>\n        </div>\n\n        <div class='control-group'>\n          <label class='span2 control-label'>" . _MD_TADGAL_TITLE . "</label>\n          <div class='controls'>\n            <input type='text' class='span12' name='title' value='{$photo['title']}' id='newTitle' placeholder='" . _MD_TADGAL_TITLE . "'>\n          </div>\n        </div>\n\n        <div class='control-group'>\n          <label class='span2 control-label'>" . _MD_TADGAL_DESCRIPTION . "</label>\n          <div class='controls'>\n            <textarea name='description' class='span12' id='newDescription'>{$photo['description']}</textarea>\n          </div>\n        </div>\n\n        <div class='control-group'>\n          <label class='span2 control-label'>" . _MD_TADGAL_TAG . "</label>\n          <div class='controls'>\n            <input type='text' class='span12' name='new_tag' id='new_tag' placeholder='" . _MD_TADGAL_TAG_TXT . "'>\n            {$tag_select}\n          </div>\n        </div>\n\n        <div class='control-group'>\n          <label class='span2 control-label'></label>\n          <div class='controls controls-row'>\n            <label class='checkbox inline'>\n              <input type='checkbox' name='cover' value='small/{$photo['dir']}/{$photo['sn']}_s_{$photo['filename']}'>\n              " . _MD_TADGAL_AS_COVER . "\n            </label>\n            <input type='hidden' name='sn' value='{$photo['sn']}'>\n            <input type='hidden' name='op' value='update_tad_gallery'>\n            <button type='submit' class='btn btn-primary' id='sbtn'>" . _TAD_SAVE . "</button>\n          </div>\n        </div>";
    }
    $form = "\n    <script>\n      \$(function(){\n        {$make_option_js}\n\n        \$('#myForm').bind('submit', function() {\n          \$.ajax({\n            type : 'POST',\n            cache : false,\n            url : 'ajax.php',\n            data : \$(this).serializeArray(),\n            success: function(data) {\n              if(\$('#newTitle').val()!=''){\n                \$('#title{$sn}').parent().addClass('outline');\n                \$('#title{$sn}').text(\$('#newTitle').val());\n              }\n\n              if(\$('#newDescription').val()!=''){\n                \$('#description{$sn}').text(\$('#newDescription').val());\n                \$('#description{$sn}').addClass('photo_description');\n              }\n              \$.fancybox.close();\n              location.reload();\n            }\n          });\n          return false;\n        });\n      });\n\n      function make_option(menu_name , num , of_csn , def_csn){\n        \$('#'+menu_name+num).show();\n        \$.post('ajax_menu.php',  {'of_csn': of_csn , 'def_csn': def_csn} , function(data) {\n          \$('#'+menu_name+num).html(\"<option value=''>/</option>\"+data);\n        });\n\n        \$('.'+menu_name).change(function(){\n        var menu_id= \$(this).attr('id');\n        var len=menu_id.length-1;\n        var next_num = Number(menu_id.charAt(len))+1\n          var next_menu = menu_name + next_num;\n          \$.post('ajax_menu.php',  {'of_csn': \$('#'+menu_id).val()} , function(data) {\n            if(data==''){\n              \$('#'+next_menu).hide();\n            }else{\n              \$('#'+next_menu).show();\n              \$('#'+next_menu).html(\"<option value=''>/</option>\"+data);\n            }\n\n          });\n        });\n      }\n    </script>\n\n    <form method='post' id='myForm' style='width:800px;' class='form-horizontal' role='form'>\n      {$form_col}\n    </form>\n    ";
    return $form;
}