made a copy
[atutor.git] / include / html / editor_tabs / edit.inc.php
1 <?php
2 /****************************************************************/
3 /* ATutor                                                                                                               */
4 /****************************************************************/
5 /* Copyright (c) 2002-2009                                                                              */
6 /* Adaptive Technology Resource Centre / University of Toronto  */
7 /* http://atutor.ca                                                                                             */
8 /*                                                              */
9 /* This program is free software. You can redistribute it and/or*/
10 /* modify it under the terms of the GNU General Public License  */
11 /* as published by the Free Software Foundation.                                */
12 /****************************************************************/
13 // $Id$
14
15 if (!defined('AT_INCLUDE_PATH')) { exit; }
16
17 ?>
18         <div class="row">
19                 <div class="required" title="<?php echo _AT('required_field'); ?>">*</div><label for="ctitle"><?php echo _AT('title');  ?></label><br />
20                 <input type="text" name="title" id="ctitle" size="70" class="formfield" value="<?php echo ContentManager::cleanOutput($_POST['title']); ?>" />
21         </div>
22         
23         <?php
24                 if ($content_row['content_path']) {
25                         echo '  <div class="row">'._AT('packaged_in').'<br />'.$content_row['content_path'].'</div>';
26                 }
27         ?>
28
29         <div class="row">
30                 <label for="edithead"><?php echo _AT('customized_head');  ?></label>
31                 <input type="button" name="edithead" id="edithead" value="<?php echo _AT('edit'); ?>" onclick="switch_head_editor()" class="button"/><br />
32                 <small>&middot; <?php echo _AT('customized_head_note'); ?></small>
33         </div>
34
35 <?php 
36 if (trim($_POST['head']) == '<br />') {
37         $_POST['head'] = '';
38 }
39 if ($do_check) {
40         $_POST['head'] = $stripslashes($_POST['head']);
41 }
42 ?>
43
44         <div class="row">
45                 <div id="headDiv" style="display:none">
46                         <input type="checkbox" name="use_customized_head" id="use_customized_head" value="1" <?php if ($_POST['use_customized_head']) { echo 'checked="checked"'; } ?> />
47                         <label for="use_customized_head"><?php echo _AT('use_customized_head'); ?></label><br />
48                         <label for="head"><?php echo _AT('customized_head'); ?></label><br /><textarea name="head" id="head" cols="" rows="10"><?php echo htmlspecialchars($_POST['head']); ?></textarea>       
49                 </div>
50         </div>
51
52         <div class="row">
53                 <?php echo _AT('formatting'); ?><br />
54  
55                 <input type="radio" name="formatting" value="0" id="text" <?php if ($_POST['formatting'] == 0) { echo 'checked="checked"'; } ?> onclick="javascript: document.form.setvisualbutton.disabled=true; switch_body_weblink(this.value);" />
56                 <label for="text"><?php echo _AT('plain_text'); ?></label>
57
58                 <input type="radio" name="formatting" value="1" id="html" <?php if ($_POST['formatting'] == 1 || $_POST['setvisual']) { echo 'checked="checked"'; } ?> onclick="javascript: document.form.setvisualbutton.disabled=false; switch_body_weblink(this.value);"/>
59
60                 <label for="html"><?php echo _AT('html'); ?></label>
61
62                 <input type="hidden" name="displayhead" value="<?php if ($_POST['displayhead']==1 || $_REQUEST['displayhead']==1 || $_GET['displayhead']==1) echo '1'; else echo '0'; ?>" />
63                 <input type="hidden" name="setvisual" value="<?php if ($_POST['setvisual']==1 || $_REQUEST['setvisual']==1 || $_GET['setvisual']==1) echo '1'; else echo '0'; ?>" />
64                 <input type="hidden" name="settext" value="<?php if ($_POST['settext']==1 || $_REQUEST['settext']==1 || $_GET['settext']==1) echo '1'; else echo '0'; ?>" />
65                 <input type="button" name="setvisualbutton" value="<?php echo _AT('switch_visual'); ?>" onclick="switch_body_editor()" class="button" />
66                 
67                 <input type="radio" name="formatting" value="2" id="weblink" <?php if ($_POST['formatting'] == 2) { echo 'checked="checked"'; } ?> onclick="javascript: document.form.setvisualbutton.disabled=true; switch_body_weblink(this.value);"/>
68                 <label for="weblink"><?php echo _AT('weblink'); ?></label>
69
70                 <script type="text/javascript" language="javascript">
71                 //<!--
72                         document.write(" <a href=\"#\" onclick=\"window.open('<?php echo AT_BASE_HREF; ?>tools/filemanager/index.php?framed=1<?php echo SEP; ?>popup=1<?php echo SEP; ?>cp=<?php echo $content_row['content_path']; ?>','newWin1','menubar=0,scrollbars=1,resizable=1,width=640,height=490'); return false;\"><?php echo _AT('open_file_manager'); ?> </a>");
73                 //-->
74                 </script>
75                 <noscript>
76                         <a href="<?php echo AT_BASE_HREF; ?>tools/filemanager/index.php?framed=1"><?php echo _AT('open_file_manager'); ?></a>
77                 </noscript>                     
78         </div>
79
80 <!-- ******** Tool Manager ******* -->
81 <div class="row">
82     <?php //TODO***************BOLOGNA******************REMOVE ME***********/
83     echo _AT('tools_manager').'<br/>';
84     $count = 0;
85     foreach($all_tools as $tool) {
86         if($tool['tool_file'] != '' && $tool['table'] != '') {
87             $sql_assoc = "SELECT * FROM ".TABLE_PREFIX.$tool['table']." WHERE content_id='$cid'";
88             $result_assoc = mysql_query($sql_assoc,$db);
89             if($num_row = mysql_num_rows($result_assoc)){
90                 $tool['style']='border:solid; border-color:#43addb';
91                 $tool['alt'] = $tool['title'].' added';
92             } else {
93                 $tool['style']='';
94                 $tool['alt'] = $tool['title'].' noen';
95             }
96
97             $count++; ?>
98             <script type="text/javascript" language="javascript">
99                 document.write(" <a href=\"#\" onclick=\"window.open('<?php echo AT_BASE_HREF; ?>tools/toolmanager/index.php?framed=1<?php echo SEP; ?>popup=1<?php echo SEP; ?>tool_file=<?php echo $tool['tool_file'].SEP;?>cid=<?php echo $cid;?>','newWin2','menubar=0,scrollbars=1,resizable=1,width=600,height=400'); return false;\"><img id=\"<?php echo $tool['title'];?>\" style=\"<?php echo $tool['style'];?>\" src='<?php echo $tool['img']; ?>' alt='<?php echo $tool['alt'];?>' title='<?php echo $tool['title'];?>' height='30' hspace='2' border='0'/></a>");
100             </script>
101         <?php }
102     }
103     if($count == 0){
104         echo '<em>'._AT('none_found').'</em>';
105     } ?>
106 </div>
107 <br/>
108 <!-- ****** end Tool Manager ***** -->
109
110
111         <div class="row">
112                 <label for="body_text"><?php echo _AT('body');  ?></label><br />
113
114 <?php 
115
116 // kludge #1548
117 if (trim($_POST['body_text']) == '<br />') {
118         $_POST['body_text'] = '';
119 }
120 if ($do_check) {
121         $_POST['body_text'] = $stripslashes($_POST['body_text']);
122 }
123
124 //check if this is a weblink.
125 $body_text_hidden = '';
126 $weblink_text_hidden = 'display:none;';
127 if ($_POST['formatting']==CONTENT_TYPE_WEBLINK) {
128         $_POST['weblink_text'] = $_POST['body_text'];
129         $_POST['body_text'] = '';
130         $body_text_hidden = 'display:none;';
131         $weblink_text_hidden = '';
132 }
133 ?>
134                 <textarea name="body_text" id="body_text" cols="" rows="20" style="<?php echo $body_text_hidden; ?>"><?php echo htmlspecialchars($_POST['body_text']); ?></textarea>    
135                 <input name="weblink_text" id="weblink_text" value="<?php echo ($_POST['weblink_text']!=''?htmlspecialchars($_POST['weblink_text']):'http://'); ?>" style="width:60%; <?php echo $weblink_text_hidden; ?>"/>
136         </div>
137         
138         <div class="row">
139                 <?php require(AT_INCLUDE_PATH.'html/editor_tabs/content_code_picker.inc.php'); ?>
140         </div>
141
142         <div class="row">
143                 <strong><?php echo _AT('or'); ?></strong> <label for="uploadedfile"><?php echo _AT('paste_file'); ?></label><br />
144                 <input type="file" name="uploadedfile_paste" id="uploadedfile" class="formfield" size="20" /> <input type="submit" name="submit_file" value="<?php echo _AT('upload'); ?>"  class="button" /><br />
145                 <small class="spacer">&middot;<?php echo _AT('html_only'); ?><br />
146                 &middot;<?php echo _AT('edit_after_upload'); ?></small>
147         </div>
148
149         <script type="text/javascript" language="javascript">
150         //<!--
151         function on_load()
152         {
153                 if (document.getElementById("text").checked)
154                         document.form.setvisualbutton.disabled = true;
155                         
156                 if (document.form.displayhead.value==1)
157                 {
158                         document.getElementById("headDiv").style.display = '';
159                         document.form.edithead.value = "<?php echo _AT('hide'); ?>"
160                 }
161                         
162                 if (document.form.setvisual.value==1)
163                 {
164                         tinyMCE.execCommand('mceAddControl', false, 'body_text');
165                         document.form.formatting[0].disabled = "disabled";
166                         document.form.setvisualbutton.value = "<?php echo _AT('switch_text'); ?>";
167                 }
168                 else
169                 {
170                         document.form.setvisualbutton.value = "<?php echo _AT('switch_visual'); ?>";
171                 }
172         }
173         
174         // show/hide "cusomized head" editor
175         function switch_head_editor()
176         {
177                 if (document.form.edithead.value=="<?php echo _AT('edit'); ?>")
178                 {
179                         document.form.edithead.value = "<?php echo _AT('hide'); ?>"
180                         document.getElementById("headDiv").style.display = "";
181                         document.form.displayhead.value=1;
182                 }
183                 else
184                 {
185                         document.form.edithead.value = "<?php echo _AT('edit'); ?>"
186                         document.getElementById("headDiv").style.display = "none";
187                         document.form.displayhead.value=0;
188                 }
189         }
190         
191         // switch between text, visual editor for "body text"
192         function switch_body_editor()
193         {
194                 if (document.form.setvisualbutton.value=="<?php echo _AT('switch_visual'); ?>")
195                 {
196                         tinyMCE.execCommand('mceAddControl', false, 'body_text');
197                         document.form.setvisual.value=1;
198                         document.form.settext.value=0;
199                         document.form.formatting[0].disabled = "disabled";
200                         document.form.setvisualbutton.value = "<?php echo _AT('switch_text'); ?>";
201                 }
202                 else
203                 {
204                         disable_visual_txt();
205                 }
206         }
207
208         //switch between weblinks.
209         function switch_body_weblink(formatting){
210                 if (formatting==2){
211                         if (document.form.setvisualbutton.value=="<?php echo _AT('switch_text'); ?>"){
212                                 //take out the visual editor
213                                 disable_visual_txt();
214                         }
215
216                         document.form.body_text.style.display = "none";
217                         document.form.weblink_text.style.display = "inline";
218                 } else {
219                         document.form.body_text.style.display = "inline";
220                         document.form.weblink_text.style.display = "none";
221                 }
222         }
223
224         //disabling the text box.
225         function disable_visual_txt(){
226                 tinyMCE.execCommand('mceRemoveControl', false, 'body_text');
227                 document.form.setvisual.value=0;
228                 document.form.settext.value=1;
229                 document.form.formatting[0].disabled = "";
230                 document.form.setvisualbutton.value = "<?php echo _AT('switch_visual'); ?>";
231         }
232
233         //-->
234         </script>