浏览代码

Moving tbl_change js into main/inc/lib/javascript

Julio Montoya 11 年之前
父节点
当前提交
3e14888d8f

+ 7 - 7
main/admin/calendar.php

@@ -100,7 +100,7 @@ if (!empty($_GET['sort']) and ($allow_individual_calendar_status=="show"))
 $htmlHeadXtra[] = to_javascript();
 
 // this loads the javascript that is needed for the date popup selection
-$htmlHeadXtra[] = "<script src=\"calendar_tbl_change.js\" type=\"text/javascript\" language=\"javascript\"></script>";
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/calendar/calendar_tbl_change.js" type="text/javascript" ></script>';
 
 // setting the name of the tool
 $nameTools = get_lang('GlobalAgenda'); // language variable in trad4all.inc.php
@@ -124,7 +124,7 @@ $TABLEAGENDA 			= Database::get_main_table(TABLE_MAIN_SYSTEM_CALENDAR);
 $tbl_user       		= Database::get_main_table(TABLE_MAIN_USER);
 $tbl_courseUser 		= Database::get_main_table(TABLE_MAIN_COURSE_USER);
 
-/* 
+/*
   			ACCESS RIGHTS
 */
 // permission stuff - also used by loading from global in agenda.inc.php
@@ -185,12 +185,12 @@ echo '<div class="sort" style="float:right">';
 echo '</div>';
 if (api_is_allowed_to_edit(false,true)) {
 	switch ($_GET['action']) {
-		case "add":            
-            if ($_POST['submit_event']) {		        
+		case "add":
+            if ($_POST['submit_event']) {
 			    $event_start    = (int) $_POST['fyear'].'-'.(int) $_POST['fmonth'].'-'.(int) $_POST['fday'].' '.(int) $_POST['fhour'].':'.(int) $_POST['fminute'].':00';
                 $event_stop     = (int) $_POST['end_fyear'].'-'.(int) $_POST['end_fmonth'].'-'.(int) $_POST['end_fday'].' '.(int) $_POST['end_fhour'].':'.(int) $_POST['end_fminute'].':00';
-                
-				$id = agenda_add_item($_POST['title'],$_POST['content'],$event_start,$event_stop);           
+
+				$id = agenda_add_item($_POST['title'],$_POST['content'],$event_start,$event_stop);
 				display_agenda_items();
 			} else {
 				show_add_form();
@@ -200,7 +200,7 @@ if (api_is_allowed_to_edit(false,true)) {
 		case "edit":
 			if( ! (api_is_course_coach() && !api_is_element_in_the_session(TOOL_AGENDA, intval($_REQUEST['id']) ) ) )
 			{ // a coach can only delete an element belonging to his session
-				if ($_POST['submit_event']) {		
+				if ($_POST['submit_event']) {
 			        $my_id_attach = (int)$_REQUEST['id_attach'];
 					$my_file_comment = Database::escape_string($_REQUEST['file_comment']);
 					store_edited_agenda_item($my_id_attach,$my_file_comment);

+ 3 - 7
main/admin/calendar_view.php

@@ -90,8 +90,10 @@ table.calendar .monthyear a:hover
 	background-color: #ffff00;
 }
 </style>
+
+<script src=<?php echo api_get_path(WEB_LIBRARY_PATH).'javascript/calendar/calendar_tbl_change.js'; ?>" type="text/javascript" ></script>
+
 <script type="text/javascript">
-<!--
     /* added 2004-06-10 by Michael Keck
      *       we need this for Backwards-Compatibility and resolving problems
      *       with non DOM browsers, which may have problems with css 2 (like NC 4)
@@ -120,11 +122,6 @@ table.calendar .monthyear a:hover
             }
         } // end if... else if...
     } // end if
-//-->
-</script>
-<script type="text/javascript" src="calendar_tbl_change.js"></script>
-<script type="text/javascript">
-<!--
 var month_names = new Array(
 <?php
 foreach($MonthsLong as $index => $month)
@@ -141,7 +138,6 @@ foreach($DaysShort as $index => $day)
 }
 ?>
 "");
-//-->
 </script>
 </head>
 <body onLoad="initCalendar();">

+ 2 - 2
main/blog/blog.php

@@ -194,7 +194,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'view_post')
 /*
 	DISPLAY
 */
-$htmlHeadXtra[] = '<script src="tbl_change.js" type="text/javascript"></script>';
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/calendar/tbl_change.js"></script>';
 
 // Set bredcrumb
 switch ($current_page)
@@ -478,4 +478,4 @@ switch ($current_page) {
 </table>
 <?php
 // Display the footer
-Display::display_footer();
+Display::display_footer();

+ 1 - 1
main/blog/calendar.php

@@ -110,7 +110,7 @@ table.calendar .monthyear a:hover
     } // end if
 //-->
 </script>
-<script type="text/javascript" src="tbl_change.js"></script>
+<script src="<?php echo api_get_path(WEB_LIBRARY_PATH).'javascript/calendar/tbl_change.js'; ?>"></script>
 <script type="text/javascript">
 <!--
 var month_names = new Array(

+ 10 - 11
main/calendar/agenda.inc.php

@@ -2497,16 +2497,18 @@ function show_add_form($id = '', $type = null)
 {
     $showImg = Display::return_icon('div_show.gif');
     $hideImg = Display::return_icon('div_hide.gif');
-
-    global $MonthsLong;
+    $MonthsLong = api_get_months_long();
     $htmlHeadXtra[] = to_javascript();
     // the default values for the forms
-    if (isset($_GET['originalresource']) && $_GET['originalresource'] !== 'no') {
+    //if (isset(!$_GET['originalresource']) && $_GET['originalresource'] !== 'no') {
+    if (!isset($_GET['originalresource'])) {
         $day = date('d');
         $month = date('m');
         $year = date('Y');
         $hours = 9;
         $minutes = '00';
+        $title = null;
+        $content = null;
 
         $end_day = date('d');
         $end_month = date('m');
@@ -2538,6 +2540,8 @@ function show_add_form($id = '', $type = null)
         $repeat = $form_elements['repeat'];
     }
 
+
+
     //	switching the send to all/send to groups/send to users
     if (isset($_POST['To']) && $_POST['To']) {
         $day = $_POST['fday'];
@@ -2622,15 +2626,12 @@ function show_add_form($id = '', $type = null)
     $origin = isset($_GET['origin']) ? Security::remove_XSS($_GET['origin']) : null;
     $course_url = empty($course_info) ? null : api_get_cidreq();
     ?>
-
-<!-- START OF THE FORM  -->
-
     <form class="form-horizontal" enctype="multipart/form-data"  action="<?php echo api_get_self().'?type='.Security::remove_XSS($type).'&origin='.$origin.'&'.$course_url."&sort=asc&toolgroup=".api_get_group_id().'&action='.Security::remove_XSS($_GET['action']); ?>" method="post" name="new_calendar_item">
         <input type="hidden" name="id" value="<?php if (isset($id)) echo $id; ?>" />
         <input type="hidden" name="action" value="<?php if (isset($_GET['action'])) echo $_GET['action']; ?>" />
         <input type="hidden" name="id_attach" value="<?php echo isset($_REQUEST['id_attach']) ? intval($_REQUEST['id_attach']) : null; ?>" />
-<input type="hidden" name="sort" value="asc"/>
-<input type="hidden" name="submit_event" value="ok"/>
+        <input type="hidden" name="sort" value="asc"/>
+        <input type="hidden" name="submit_event" value="ok"/>
     <?php
     // The form title
     if (isset($id) AND $id <> '') {
@@ -2655,8 +2656,6 @@ function show_add_form($id = '', $type = null)
 							</div>
 						</div>';
 
-
-
     // selecting the users / groups
     $group_id = api_get_group_id();
     if (empty($id)) {
@@ -2672,7 +2671,7 @@ function show_add_form($id = '', $type = null)
         show_to_form($to);
         echo '</div>
 				</div>';
-    }
+        }
     }
 
     // start date and time

+ 1 - 1
main/calendar/agenda.php

@@ -122,7 +122,7 @@ $htmlHeadXtra[] = to_javascript();
 $htmlHeadXtra[] = user_group_filter_javascript();
 
 // this loads the javascript that is needed for the date popup selection
-$htmlHeadXtra[] = "<script src=\"tbl_change.js\" type=\"text/javascript\" language=\"javascript\"></script>";
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/calendar/tbl_change.js" type="text/javascript" ></script>';
 
 // setting the name of the tool
 $nameTools = get_lang('Agenda'); // language variable in trad4all.inc.php

+ 1 - 2
main/calendar/allagendas.php

@@ -49,7 +49,6 @@ if (!empty ($course_path)) {
 	$interbreadcrumb[] = array ('url' => api_get_path(WEB_COURSE_PATH).urlencode($course_path).'/index.php', 'name' => Security::remove_XSS($_GET['courseCode']));
 }
 // this loads the javascript that is needed for the date popup selection
-//$htmlHeadXtra[] = "<script src=\"tbl_change.js\" type=\"text/javascript\" language=\"javascript\"></script>";
 
 // showing the header
 Display::display_header(get_lang('MyAgenda'));
@@ -381,4 +380,4 @@ if (isset ($_user['user_id'])) {
 	}
 }
 echo "</td></tr></table>";
-Display :: display_footer();
+Display :: display_footer();

+ 1 - 1
main/calendar/calendar.php

@@ -95,7 +95,7 @@ table.calendar td
     } // end if
 /* ]]> */
 </script>
-<script type="text/javascript" src="tbl_change.js"></script>
+<script src="<?php echo api_get_path(WEB_LIBRARY_PATH).'javascript/calendar/tbl_change.js'; ?>"></script>
 <script type="text/javascript">
 /* <![CDATA[ */
 var month_names = new Array(

+ 2 - 1
main/calendar/myagenda.php

@@ -29,7 +29,8 @@ if (!empty ($course_path)) {
 }
 // this loads the javascript that is needed for the date popup selection
 $htmlHeadXtra[] = to_javascript();
-$htmlHeadXtra[] = "<script src=\"tbl_change.js\" type=\"text/javascript\" language=\"javascript\"></script>";
+$htmlHeadXtra[] = '<script src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/calendar/tbl_change.js" type="text/javascript" ></script>';
+
 $htmlHeadXtra[] = "<script>
 $(function() {
     $(\".dialog\").dialog(\"destroy\");

+ 3 - 3
main/inc/ajax/agenda.ajax.php

@@ -3,7 +3,7 @@
 /**
  * Responses to AJAX calls
  */
-$type = isset($_REQUEST['type']) && in_array($_REQUEST['type'], array('personal', 'course', 'admin')) ? $_REQUEST['type'] : 'personal';
+$type = isset($_GET['type']) && in_array($_GET['type'], array('personal', 'course', 'admin')) ? $_GET['type'] : 'personal';
 
 if ($type == 'personal') {
     $cidReset = true; // fixes #5162
@@ -14,7 +14,7 @@ require_once '../global.inc.php';
 require_once api_get_path(SYS_CODE_PATH).'calendar/agenda.inc.php';
 require_once api_get_path(SYS_CODE_PATH).'calendar/myagenda.inc.php';
 
-$action = isset($_REQUEST['a']) ? $_REQUEST['a'] : null;
+$action = isset($_GET['a']) ? $_GET['a'] : null;
 
 if ($type == 'course') {
     api_protect_course_script(true);
@@ -80,7 +80,7 @@ switch ($action) {
             $uid = intval($user_id);
         }
         */
-        $events = $agenda->get_events($_REQUEST['start'], $_REQUEST['end'], api_get_course_int_id(), $group_id, $user_id);
+        $events = $agenda->get_events($_GET['start'], $_GET['end'], api_get_course_int_id(), $group_id, $user_id);
         echo $events;
         break;
     case 'get_user_agenda':

+ 2 - 2
main/inc/lib/formvalidator/Element/calendar_popup.php

@@ -103,7 +103,7 @@ table.calendar td a div:hover
 	background-color: #ffff00;
 }
 
-table.calendar .monthyear a {	
+table.calendar .monthyear a {
 	text-align: center;
 	/* color: #ffffff; */
 }
@@ -147,7 +147,7 @@ table.calendar .monthyear a:hover
     } // end if
 /* ]]> */
 </script>
-<script type="text/javascript" src="tbl_change.js.php"></script>
+<script src="<?php echo api_get_path(WEB_LIBRARY_PATH).'javascript/calendar/tbl_change.js'; ?>"></script>
 <script type="text/javascript">
 /* <![CDATA[ */
 var month_names = new Array(

+ 16 - 16
main/calendar/tbl_change.js → main/inc/lib/javascript/calendar/calendar_tbl_change.js

@@ -13,13 +13,13 @@ var clock_set = 0;
  * @param   string      field name
  */
 function openCalendar(form, field) {
-    window.open("./calendar.php", "calendar", "width=260,height=250,status=no,toolbar=no");
-	day = eval("document." + form + "." + field + "day.options["+ "document." + form + "." + field + "day.selectedIndex].value");
+    window.open("./calendar_view.php", "calendar", "width=260,height=250,status=no");
+    day = eval("document." + form + "." + field + "day.options["+ "document." + form + "." + field + "day.selectedIndex].value");
     month = eval("document." + form + "." + field + "month.options["+ "document." + form + "." + field + "month.selectedIndex].value");
-   	month = month-1;
+    month = month-1;
     year = eval("document." + form + "." + field + "year.options["+ "document." + form + "." + field + "year.selectedIndex].value");
-	formName = form;
-	fieldName =field;
+    formName = form;
+    fieldName =field;
 }
 
 /**
@@ -58,9 +58,9 @@ function formatNum4(i) {
  */
 function initCalendar() {
     if (!year && !month && !day) {
-		day = window.opener.day;
-		month = window.opener.month;
-		year  = window.opener.year;
+        day = window.opener.day;
+        month = window.opener.month;
+        year  = window.opener.year;
         if (isNaN(year) || isNaN(month) || isNaN(day) || day == 0) {
             dt      = new Date();
             year    = dt.getFullYear();
@@ -147,13 +147,13 @@ function initCalendar() {
  * @param   string     date text
  */
 function returnDate(d,m,y) {
-	cmd = "window.opener.document."+window.opener.formName+"."+window.opener.fieldName+"day.selectedIndex = "+(d-1);
-	eval(cmd);
-	cmd = "window.opener.document."+window.opener.formName+"."+window.opener.fieldName+"month.selectedIndex = "+m;
-	eval(cmd);
-	date = new Date();
-	year = date.getFullYear()-1;
-	cmd = "window.opener.document."+window.opener.formName+"."+window.opener.fieldName+"year.selectedIndex = "+(y-year);
-	eval(cmd);
+    cmd = "window.opener.document."+window.opener.formName+"."+window.opener.fieldName+"day.selectedIndex = "+(d-1);
+    eval(cmd);
+    cmd = "window.opener.document."+window.opener.formName+"."+window.opener.fieldName+"month.selectedIndex = "+m;
+    eval(cmd);
+    date = new Date();
+    year = date.getFullYear()-1;
+    cmd = "window.opener.document."+window.opener.formName+"."+window.opener.fieldName+"year.selectedIndex = "+(y-year);
+    eval(cmd);
     window.close();
 }

+ 0 - 0
main/blog/tbl_change.js → main/inc/lib/javascript/calendar/tbl_change.js