Пример #1
0
function tad_cal_full_calendar($options)
{
    global $xoopsUser, $xoopsTpl;
    $modhandler = xoops_gethandler('module');
    $xoopsModule =& $modhandler->getByDirname("tad_cal");
    $config_handler = xoops_gethandler('config');
    $module_id = $xoopsModule->getVar('mid');
    $xoopsModuleConfig =& $config_handler->getConfigsByCat(0, $module_id);
    if ($xoopsUser) {
        $isAdmin = $xoopsUser->isAdmin($module_id);
    } else {
        $isAdmin = false;
    }
    //引入TadTools的函式庫
    if (!file_exists(XOOPS_ROOT_PATH . "/modules/tadtools/tad_function.php")) {
        redirect_header("http://www.tad0616.net/modules/tad_uploader/index.php?of_cat_sn=50", 3, _TAD_NEED_TADTOOLS);
    }
    include_once XOOPS_ROOT_PATH . "/modules/tadtools/tad_function.php";
    include_once XOOPS_ROOT_PATH . "/modules/tad_cal/function_block.php";
    $jquery_path = get_jquery(true);
    //一般只要此行即可
    $block['jquery_path'] = $jquery_path;
    if (empty($xoopsModuleConfig['eventShowMode'])) {
        $xoopsModuleConfig['eventShowMode'] = 'eventClick';
    }
    if (empty($xoopsModuleConfig['eventTheme'])) {
        $xoopsModuleConfig['eventTheme'] = 'ui-tooltip-blue';
    }
    $style = make_style();
    if (empty($cate_sn)) {
        $cate_sn = 0;
    }
    $eventDrop = $del_js = "";
    if ($xoopsUser) {
        //先抓分類下拉選單
        $get_tad_cal_cate_menu_options = get_tad_cal_cate_menu_options($cate_sn);
        if ($isAdmin) {
            if (empty($get_tad_cal_cate_menu_options)) {
                $cate = _MB_TADCAL_NEW_CATE . _TAD_FOR . "<input name='new_cate_title' id='new_cate_title' value='" . _MB_TADCAL_NEW_CALENDAR . "'>";
            } else {
                $cate = _MB_TADCAL_CATE_SN . _TAD_FOR . "<select name='cate_sn' id='cate_sn' size=1 >{$get_tad_cal_cate_menu_options}</select>";
            }
            //快速新增功能
            $eventAdd = "selectable: true,\n      selectHelper: true,\n      select: function(start, end, allDay) {\n        var promptBox = \"" . _MB_TADCAL_TITLE . _TAD_FOR . "<input type='text' id='eventTitle' name='eventTitle' value='' /><br>{$cate}\";\n\n        function mycallbackform(v,m,f){\n          if(v != undefined){\n            calendar.fullCalendar('renderEvent',\n              {\n                title: f.eventTitle,\n                start: start,\n                end: end,\n                allDay: allDay\n              },\n              false // make the event 'stick'\n            );\n            \$.post('" . XOOPS_URL . "/modules/tad_cal/event.php', {op: 'insert_tad_cal_event', fc_start: start.getTime(), fc_end: end.getTime(), title: f.eventTitle, cate_sn: f.cate_sn, new_cate_title: f.new_cate_title},function(){\n              calendar.fullCalendar('refetchEvents');\n            });\n          }\n        }\n\n        function mysubmitfunc(v,m,f){\n          an = m.children('#eventTitle');\n\n          if(f.eventTitle == ''){\n            an.css('border','solid #ff0000 1px');\n            return false;\n          }\n          return true;\n        }\n\n        \$.prompt(promptBox,{\n          callback: mycallbackform,\n          submit: mysubmitfunc,\n          zIndex: 99999,\n          buttons: { Ok:true }\n        });\n        \$('#eventTitle').focus();\n\n        \$('#eventTitle').keypress(function(event) {\n          if (event.keyCode == '13') {\n             \$('#jqi_state0_buttonOk').click();\n           }\n        });\n        calendar.fullCalendar('unselect');\n      },\n      ";
            //拖曳搬移功能
            $eventDrop = "editable:true,\n      eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) {\n        var startTime=event.start.getTime();\n        \$.post('event.php', {op: 'ajax_update_date', dayDelta: dayDelta , minuteDelta: minuteDelta  , sn: event.id },function(data){\n          alert(data);\n        });\n      },\n      ";
        }
    }
    $block['eventDrop'] = $eventDrop;
    $block['eventAdd'] = $eventAdd;
    $block['style_css'] = $style['css'];
    $block['cate_sn'] = $cate_sn;
    $block['eventShowMode'] = $xoopsModuleConfig['eventShowMode'];
    $block['eventTheme'] = $xoopsModuleConfig['eventTheme'];
    $block['style_mark'] = $style['mark'];
    $block['my_counter'] = my_counter();
    $block['firstDay'] = $xoopsModuleConfig['cal_start'];
    return $block;
}
Пример #2
0
function fullcalendar($cate_sn = 0)
{
    global $xoopsUser, $xoopsModuleConfig, $isAdmin, $xoopsTpl;
    if (empty($xoopsModuleConfig['eventShowMode'])) {
        $xoopsModuleConfig['eventShowMode'] = 'eventClick';
    }
    if (empty($xoopsModuleConfig['eventTheme'])) {
        $xoopsModuleConfig['eventTheme'] = 'ui-tooltip-blue';
    }
    $style = make_style();
    if (empty($cate_sn)) {
        $cate_sn = 0;
    }
    $eventDrop = $del_js = $eventAdd = "";
    if ($xoopsUser) {
        //先抓分類下拉選單
        $get_tad_cal_cate_menu_options = get_tad_cal_cate_menu_options($cate_sn);
        if ($isAdmin) {
            if (empty($get_tad_cal_cate_menu_options)) {
                $cate = _MD_TADCAL_NEW_CATE . _TAD_FOR . "<input name='new_cate_title' id='new_cate_title' value='" . _MD_TADCAL_NEW_CALENDAR . "'>";
            } else {
                $cate = _MD_TADCAL_CATE_SN . _TAD_FOR . "<select name='cate_sn' id='cate_sn' size=1 >{$get_tad_cal_cate_menu_options}</select>";
            }
            //快速新增功能
            $eventAdd = "selectable: true,\n      selectHelper: true,\n      select: function(start, end, allDay) {\n        var promptBox = \"" . _MD_TADCAL_TITLE . _TAD_FOR . "<input type='text' id='eventTitle' name='eventTitle' value='' /><br>{$cate}\";\n\n        function mycallbackform(v,m,f){\n          if(v != undefined){\n\n            calendar.fullCalendar('renderEvent',\n              {\n                title: f.eventTitle,\n                start: start,\n                end: end,\n                allDay: allDay\n              },\n              false // make the event 'stick'\n            );\n\n\n            \$.post('event.php', {op: 'insert_tad_cal_event', fc_start: start.getTime(), fc_end: end.getTime(), title: f.eventTitle, cate_sn: f.cate_sn, new_cate_title: f.new_cate_title},function(){\n              calendar.fullCalendar('refetchEvents');\n            });\n          }\n        }\n\n        function mysubmitfunc(v,m,f){\n          an = m.children('#eventTitle');\n\n          if(f.eventTitle == ''){\n            an.css('border','solid #ff0000 1px');\n            return false;\n          }\n          return true;\n        }\n\n        \$.prompt(promptBox,{\n          callback: mycallbackform,\n          submit: mysubmitfunc,\n          zIndex: 99999,\n          buttons: { Ok:true }\n        });\n        \$('#eventTitle').focus();\n\n        \$('#eventTitle').keypress(function(event) {\n          if (event.keyCode == '13') {\n             \$('#jqi_state0_buttonOk').click();\n           }\n        });\n        calendar.fullCalendar('unselect');\n      },\n      ";
            //拖曳搬移功能
            $eventDrop = "editable:true,\n      eventDrop: function(event,dayDelta,minuteDelta,allDay,revertFunc) {\n        var startTime=event.start.getTime();\n        \$.post('event.php', {op: 'ajax_update_date', dayDelta: dayDelta , minuteDelta: minuteDelta  , sn: event.id },function(data){\n          alert(data);\n        });\n      },\n      ";
        }
    }
    $xoopsTpl->assign('eventDrop', $eventDrop);
    $xoopsTpl->assign('eventAdd', $eventAdd);
    $xoopsTpl->assign('style_css', $style['css']);
    $xoopsTpl->assign('cate_sn', $cate_sn);
    $xoopsTpl->assign('eventShowMode', $xoopsModuleConfig['eventShowMode']);
    $xoopsTpl->assign('eventTheme', $xoopsModuleConfig['eventTheme']);
    $xoopsTpl->assign('style_mark', $style['mark']);
    $xoopsTpl->assign('my_counter', my_counter());
    $xoopsTpl->assign('firstDay', $xoopsModuleConfig['cal_start']);
    $xoopsTpl->assign('cate', get_tad_cal_cate($cate_sn));
}