2 /************************************************************************/
\r
4 /************************************************************************/
\r
5 /* Copyright (c) 2010 */
\r
6 /* Inclusive Design Institute */
\r
8 /* This program is free software. You can redistribute it and/or */
\r
9 /* modify it under the terms of the GNU General Public License */
\r
10 /* as published by the Free Software Foundation. */
\r
11 /************************************************************************/
\r
13 require ('include/json.inc.php');
\r
14 require (TR_INCLUDE_PATH.'header.inc.php');
\r
18 <form enctype="multipart/form-data" action='<?php echo $this->url; ?>' method="post" name="form" target="messageIFrame">
\r
20 <div class="input-form">
\r
21 <fieldset class="group_form"><legend class="group_form"><?php echo _AT('create_edit_update'); ?></legend>
\r
23 <iframe id="messageIFrame" name="messageIFrame" src='' style='width:1px;height:1px;border:0' onload="show_message()"></iframe>
\r
24 <div id="messageDIV"></div>
\r
25 <table class="form-data">
\r
27 <td colspan="2" align="left"><?php echo _AT('required_field_text') ;?></td>
\r
31 <th align="left" style="width: 25%">
\r
32 <span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="system_patch_id"><?php echo _AT('system_update_id'); ?>:</label><br />
\r
34 <td align="left"><input id="system_patch_id" name="system_patch_id" type="text" maxlength="100" size="30" value="<?php echo $this->patch_row['system_patch_id']; ?>" /></td>
\r
37 <tr><th align="left" colspan="2"><small>· <?php echo _AT('contain_only'); ?></small></th></tr>
\r
40 <th align="left"><span class="required" title="<?php echo _AT('required_field'); ?>">*</span><label for="transformable_version_to_apply"><?php echo _AT('transformable_version_to_apply'); ?>:</label></th>
\r
41 <td align="left"><input id="transformable_version_to_apply" name="transformable_version_to_apply" type="text" maxlength="100" size="30" value="<?php echo $this->patch_row['applied_version']; ?>" /></td>
\r
45 <th align="left"><label for="description"><?php echo _AT('description'); ?>:</label></th>
\r
46 <td align="left"><textarea id="description" name="description" cols="40" rows="4"><?php echo $this->patch_row['description']; ?></textarea></td>
\r
50 <th align="left"><label for="sql_statement"><?php echo _AT('sql_statement'); ?>:</label></th>
\r
51 <td align="left"><textarea id="sql_statement" name="sql_statement" cols="40" rows="8"><?php echo $this->patch_row['sql_statement']; ?></textarea></td>
\r
55 <h2><label for="dependent_patches"><?php echo _AT('dependent_updates'); ?></label></h2><br/>
\r
57 <table id="dependent_patches" class="data" rules="rows" style="width:50%">
\r
60 <th><label for="dependent_patch"><?php echo _AT('dependent_update_id'); ?></label></th>
\r
66 <td><input type="button" name="add_dependent_patch" value="<?php echo _AT('add_dependent_update'); ?>" onclick="add_dependent()" /></td>
\r
72 // when edit existing patch
\r
73 if (is_array($this->dependent_rows))
\r
75 $num_of_dependents = count($this->dependent_rows);
\r
76 foreach ($this->dependent_rows as $row_patch_dependent)
\r
80 <td><input id="dependent_patch" name="dependent_patch[]" value="<?php echo $row_patch_dependent['dependent_patch_id']; ?>" type="text" maxlength="100" size="100" style="max-width:100%; display:block" /></td>
\r
86 // when creating new patch
\r
87 if ($num_of_dependents == 0)
\r
91 <td><input id="dependent_patch" name="dependent_patch[]" type="text" maxlength="100" size="100" style="max-width:95%; display:block" /></td>
\r
100 <h2><label for="filesDiv"><?php echo _AT('files'); ?></label></h2>
\r
101 <small>· <?php echo _AT('relative_directory'); ?></small>
\r
103 <div id="filesDiv" class="row">
\r
106 <div class="row" style="float:left">
\r
107 <input type="button" name="add_a_file" value="<?php echo _AT('add_a_file'); ?>" onclick="add_file()" />
\r
113 <input type="submit" name="create" value=" <?php echo _AT('create_update'); ?> " accesskey="c" />
\r
114 <input type="submit" name="save" value=" <?php echo _AT('save'); ?> " accesskey="s" onclick="document.form.target=''; "/>
\r
115 <input type="button" name="cancel" value=" <?php echo _AT('cancel'); ?> " onclick="location.href='updater/myown_patches.php'" />
\r
122 <script language="JavaScript" type="text/javascript">
\r
125 myescape = function(/*string*/ str) {
\r
126 return str.replace(/(['"\.*+?^${}()|[\]\/\\])/g, "\\$1").replace(/\n/g, '\\n');
\r
129 function show_message()
\r
131 var messageDIV = document.getElementById("messageDIV");
\r
132 var i = document.getElementById("messageIFrame");
\r
134 if (i.contentDocument) {
\r
135 var d = i.contentDocument;
\r
136 } else if (i.contentWindow) {
\r
137 var d = i.contentWindow.document;
\r
139 var d = window.frames[id].document;
\r
141 messageDIV.innerHTML = d.body.innerHTML;
\r
144 function add_dependent() {
\r
145 var dependentPatchesTable = document.getElementById("dependent_patches").tBodies[0];
\r
146 var dependentPatch = dependentPatchesTable.rows[dependentPatchesTable.rows.length - 1].cloneNode(true);
\r
147 dependentPatchesTable.appendChild(dependentPatch);
\r
148 dependentPatch.cells[0].firstChild.value='';
\r
150 var dependents = document.form["dependent_patch[]"];
\r
151 dependents[dependents.length - 1].focus();
\r
152 // document.form['dependent_patch['+ pos +']'].focus();
\r
155 var num_of_files = 0;
\r
156 function add_file(filedata) {
\r
157 var newDiv = document.createElement("div");
\r
159 newDiv.innerHTML = ACTION_HTML_TEMPLATE.replace(/\{1\}/g, num_of_files);
\r
160 document.getElementById("filesDiv").appendChild(newDiv);
\r
162 document.form['rb_action[' +num_of_files +']'][0].focus();
\r
165 var srcElement = null;
\r
167 if(filedata.action=="add") {
\r
168 // set focus on radio button "add"
\r
169 document.form['rb_action[' +num_of_files +']'][0].checked = true;
\r
170 document.form['rb_action[' +num_of_files +']'][0].focus();
\r
173 srcElement = document.form['rb_action[' +num_of_files +']'][0];
\r
174 document.form['add_filename[' +num_of_files +']'].value = filedata.name;
\r
175 document.form['add_dir[' +num_of_files +']'].value = filedata.location;
\r
177 // set uploaded file
\r
178 if (filedata.uploaded_file != "")
\r
180 document.form['add_uploaded_file[' +num_of_files +']'].value = filedata.uploaded_file;
\r
181 var tables = newDiv.getElementsByTagName('TABLE');
\r
182 tables[0].rows[2].style.display=''; // display the row of uploaded file
\r
183 tables[0].rows[2].cells[1].innerHTML=filedata.uploaded_file; // display uploaded file name
\r
184 tables[0].rows[3].cells[0].innerHTML='<?php echo _AT("replace_file"); ?>'; // change label from "upload file" to "replace file"
\r
187 // set uploaded file
\r
188 } else if(filedata.action=="alter") {
\r
189 document.form['rb_action[' +num_of_files +']'][1].checked = true;
\r
190 document.form['rb_action[' +num_of_files +']'][1].focus();
\r
192 srcElement = document.form['rb_action[' +num_of_files +']'][1];
\r
193 document.form['alter_filename[' +num_of_files +']'].value = filedata.name;
\r
194 document.form['alter_dir[' +num_of_files +']'].value = filedata.location;
\r
195 document.form['alter_code_from[' +num_of_files +']'].value = filedata.code_from;
\r
196 document.form['alter_code_to[' +num_of_files +']'].value = filedata.code_to;
\r
197 } else if(filedata.action=="delete") {
\r
198 document.form['rb_action[' +num_of_files +']'][2].checked = true;
\r
199 document.form['rb_action[' +num_of_files +']'][2].focus();
\r
201 srcElement = document.form['rb_action[' +num_of_files +']'][2];
\r
202 document.form['delete_filename[' +num_of_files +']'].value = filedata.name;
\r
203 document.form['delete_dir[' +num_of_files +']'].value = filedata.location;
\r
204 } if(filedata.action=="overwrite") {
\r
205 document.form['rb_action[' +num_of_files +']'][3].checked = true;
\r
206 document.form['rb_action[' +num_of_files +']'][3].focus();
\r
208 srcElement = document.form['rb_action[' +num_of_files +']'][3];
\r
209 document.form['overwrite_filename[' +num_of_files +']'].value = filedata.name;
\r
210 document.form['overwrite_dir[' +num_of_files +']'].value = filedata.location;
\r
212 // set uploaded file
\r
213 if (filedata.uploaded_file != "")
\r
215 document.form['overwrite_uploaded_file[' +num_of_files +']'].value = filedata.uploaded_file;
\r
216 var tables = newDiv.getElementsByTagName('TABLE');
\r
217 tables[3].rows[2].style.display=''; // display the row of uploaded file
\r
218 tables[3].rows[2].cells[1].innerHTML=filedata.uploaded_file; // display uploaded file name
\r
219 tables[3].rows[3].cells[0].innerHTML='<?php echo _AT("replace_file"); ?>'; // change label from "upload file" to "replace file"
\r
224 show_content({srcElement:srcElement});
\r
230 function del_file(evt) {
\r
231 var target =(evt.srcElement)?evt.srcElement:evt.currentTarget;
\r
232 var div = target.parentNode.parentNode ;
\r
233 div.parentNode.removeChild(div);
\r
236 function show_content(evt) {
\r
237 var target =(evt.srcElement)?evt.srcElement:evt.currentTarget;
\r
238 var tables = target.parentNode.parentNode.getElementsByTagName('TABLE');
\r
239 tables[0].style.display='none';
\r
240 tables[1].style.display='none';
\r
241 tables[2].style.display='none';
\r
242 tables[3].style.display='none';
\r
243 if(target.value == 'add') tables[0].style.display='';
\r
244 if(target.value == 'alter') tables[1].style.display='';
\r
245 if(target.value == 'delete') tables[2].style.display='';
\r
246 if(target.value == 'overwrite') tables[3].style.display='';
\r
249 var ACTION_HTML_TEMPLATE = ' \
\r
250 <div style="border-width:thin; border-style:solid; padding: 5px 5px 5px 5px; margin:5px 5px 5px 5px"> \
\r
251 <div style="float:left">Action: \
\r
252 <input type="radio" name="rb_action[{1}]" value="add" id="add[{1}]" checked onclick="show_content(event);" /><label for="add[{1}]"><?php echo addslashes(_AT("add")); ?></label> \
\r
253 <input type="radio" name="rb_action[{1}]" value="alter" id="alter[{1}]" onclick="show_content(event);" /><label for="alter[{1}]"><?php echo addslashes(_AT("alter")); ?></label> \
\r
254 <input type="radio" name="rb_action[{1}]" value="delete" id="delete[{1}]" onclick="show_content(event);" /><label for="delete[{1}]"><?php echo addslashes(_AT("delete")); ?></label> \
\r
255 <input type="radio" name="rb_action[{1}]" value="overwrite" id="overwrite[{1}]" onclick="show_content(event);" /><label for="overwrite[{1}]"><?php echo addslashes(_AT("overwrite")); ?></label> \
\r
259 <table style="display:" width="95%"> \
\r
261 <td width="150px"><?php echo addslashes(_AT("file_name")); ?></td> \
\r
262 <td><input name="add_filename[{1}]" type="text" /></td> \
\r
265 <td><?php echo addslashes(_AT("directory")); ?></td> \
\r
266 <td><input name="add_dir[{1}]" type="text" /></td> \
\r
268 <tr style="display: none"> \
\r
269 <td><?php echo addslashes(_AT("file")); ?></td> \
\r
271 <td><INPUT TYPE="hidden" NAME="add_uploaded_file[{1}]" SIZE="40" style="max-width:95%" /></td> \
\r
274 <td><?php echo addslashes(_AT("upload_file")); ?></td> \
\r
275 <td><INPUT TYPE="file" NAME="add_upload_file[{1}]" SIZE="40" style="max-width:95%" /></td> \
\r
278 <table style="display: none" width="95%"> \
\r
280 <td width="150px"><?php echo addslashes(_AT("file_name")); ?></td> \
\r
281 <td><input name="alter_filename[{1}]" type="text" maxlength="100" size="100" /></td> \
\r
284 <td><?php echo addslashes(_AT("directory")); ?></td> \
\r
285 <td><input name="alter_dir[{1}]" type="text" maxlength="100" size="100" style="max-width:95%" /></td> \
\r
288 <td><?php echo addslashes(_AT("code_to_replace_from")); ?></td> \
\r
289 <td><textarea name="alter_code_from[{1}]" rows="5" cols="120" style="max-width:95%"></textarea></td> \
\r
292 <td><?php echo addslashes(_AT("code_to_replace_to")); ?></td> \
\r
293 <td><textarea name="alter_code_to[{1}]" rows="5" cols="120" style="max-width:95%"></textarea></td> \
\r
296 <table style="display: none" width="95%"> \
\r
298 <td width="150px"><?php echo addslashes(_AT("file_name")); ?></td> \
\r
299 <td><input name="delete_filename[{1}]" type="text" maxlength="100" size="100" /></td> \
\r
302 <td><?php echo addslashes(_AT("directory")); ?></td> \
\r
303 <td><input name="delete_dir[{1}]" type="text" maxlength="100" size="100" /></td> \
\r
306 <table style="display: none" width="95%"> \
\r
308 <td width="150px"><?php echo addslashes(_AT("file_name")); ?></td> \
\r
309 <td><input name="overwrite_filename[{1}]" type="text" /></td> \
\r
312 <td><?php echo addslashes(_AT("directory")); ?></td> \
\r
313 <td><input name="overwrite_dir[{1}]" type="text" maxlength="100" size="100" /></td> \
\r
315 <tr id="overwrite_uploaded_file" style="display:none"> \
\r
316 <td><?php echo addslashes(_AT("file")); ?></td> \
\r
318 <td><INPUT type="hidden" NAME="overwrite_uploaded_file[{1}]" SIZE="40" style="max-width:95%" /></td> \
\r
321 <td><?php echo addslashes(_AT("upload_file")); ?></td> \
\r
322 <td><INPUT TYPE="file" NAME="overwrite_upload_file[{1}]" SIZE="40" style="max-width:95%" /></td> \
\r
326 <div style="float:left"> \
\r
327 <input type="button" value="<?php echo addslashes(_AT("delete_this_file")); ?>" onclick="del_file(event)" /> \
\r
333 var patch_files = <?php echo json_encode_result($this->file_rows); ?>;
\r
335 window.onload = function() {
\r
336 for(var i=0; i < patch_files.length; i++) {
\r
337 add_file(patch_files[i]);
\r
343 <?php require (TR_INCLUDE_PATH.'footer.inc.php'); ?>
\r