comparison develop/models/_extractapp_func.php @ 6:63e08b98032f

rewrite extraction interface into PHP MVC architecture. (Although js hasn't been rewritten into MVC, it's fitted into the current PHP MVC architecture.) - The root of the new PHP MVC is at 'develop/'. - extraction interface is called "Extractapp" with several action, eg TaggingText, EditWordlist, EditTaglist, ExportTable.
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Thu, 05 Feb 2015 16:07:53 +0100
parents
children da10158c6d0a
comparison
equal deleted inserted replaced
5:cbbb7ef22394 6:63e08b98032f
1 <?php
2 $func = $_POST['func'];
3 $data_path = "../data/"; // get the current file path, which is getcwd(), and concatenate with "/data/"
4
5
6 switch ($func) {
7 case 'SmartRegexLoad':
8 SmartRegexLoad();
9 break;
10 case 'SmartRegexSave':
11 SmartRegexSave();
12 break;
13
14 default:
15 SmartRegexLoad();
16 break;
17 }
18
19
20 function SmartRegexLoad() {
21 global $data_path;
22 $returnArray = array();
23 $files1 = scandir($data_path."regex_files");
24 foreach ( $files1 as $file ) {
25 if ( $file != "." && $file != ".." && $file != ".DS_Store") {
26 $returnArray[preg_replace("/\.txt/", "", $file)] = file_get_contents( $data_path."regex_files/".$file );
27 }
28 }
29 echo json_encode($returnArray);
30 }
31
32
33 function SmartRegexSave() {
34 if ($_POST['text']){
35 /*
36 $date = date('Y_m_d_H_i_s', time());
37 if ( file_exists("regex_files/".$_POST['filename'].".txt") ) {
38 $oldFile = file_get_contents("regex_files/".$_POST['filename'].".txt");
39 file_put_contents("regex_files/".$_POST['filename']."_".$date.".txt", $oldFile);
40 }
41 */
42 global $data_path;
43 if (get_magic_quotes_gpc()) {
44 $require = stripslashes($_POST['text']);
45 } else {
46 $require = $_POST['text'];
47 }
48
49 file_put_contents( $data_path."regex_files/".$_POST['filename'].".txt", $require);
50 }
51 }
52
53
54 ?>