annotate develop/models/_extractapp_func.php @ 12:e82ca7375e93

Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 16 Feb 2015 16:51:39 +0100
parents 54a235d43694
children cc36a20a68ab
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
1 <?php
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
2 $func = $_POST['func'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
3 $data_path = "../data/"; // get the current file path, which is getcwd(), and concatenate with "/data/"
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
4
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
5
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
6 switch ($func) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
7 case 'SmartRegexLoad':
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
8 SmartRegexLoad();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
9 break;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
10 case 'SmartRegexSave':
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
11 SmartRegexSave();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
12 break;
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
13
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
14 case 'SaveTextToLGService':
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
15 SaveTextToLGService();
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
16 break;
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
17
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
18 default:
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
19 SmartRegexLoad();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
20 break;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
21 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
22
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
23
12
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
24
e82ca7375e93 Integration with LocalGazetteerService (LGService), getting text from LGService and saving text to LGService. Adjust the control flow (controller).
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 10
diff changeset
25
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
26 function SmartRegexLoad() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
27 global $data_path;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
28 $returnArray = array();
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
29 $files1 = scandir($data_path."regex_files");
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
30 foreach ( $files1 as $file ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
31 if ( $file != "." && $file != ".." && $file != ".DS_Store") {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
32 $returnArray[preg_replace("/\.txt/", "", $file)] = file_get_contents( $data_path."regex_files/".$file );
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
33 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
34 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
35 echo json_encode($returnArray);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
36 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
37
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
38
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
39 function SmartRegexSave() {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
40 if ($_POST['text']){
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
41 /*
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
42 $date = date('Y_m_d_H_i_s', time());
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
43 if ( file_exists("regex_files/".$_POST['filename'].".txt") ) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
44 $oldFile = file_get_contents("regex_files/".$_POST['filename'].".txt");
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
45 file_put_contents("regex_files/".$_POST['filename']."_".$date.".txt", $oldFile);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
46 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
47 */
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
48 global $data_path;
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
49 if (get_magic_quotes_gpc()) {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
50 $require = stripslashes($_POST['text']);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
51 } else {
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
52 $require = $_POST['text'];
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
53 }
10
54a235d43694 add topic choosing in the TaggingText page
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents: 8
diff changeset
54
6
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
55 file_put_contents( $data_path."regex_files/".$_POST['filename'].".txt", $require);
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
56 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
57 }
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
58
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
59
63e08b98032f rewrite extraction interface into PHP MVC architecture.
Zoe Hong <zhong@mpiwg-berlin.mpg.de>
parents:
diff changeset
60 ?>