Mercurial > hg > extraction-interface
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/develop/models/_extractapp_func.php Thu Feb 05 16:07:53 2015 +0100 @@ -0,0 +1,54 @@ +<?php +$func = $_POST['func']; +$data_path = "../data/"; // get the current file path, which is getcwd(), and concatenate with "/data/" + + +switch ($func) { + case 'SmartRegexLoad': + SmartRegexLoad(); + break; + case 'SmartRegexSave': + SmartRegexSave(); + break; + + default: + SmartRegexLoad(); + break; +} + + +function SmartRegexLoad() { + global $data_path; + $returnArray = array(); + $files1 = scandir($data_path."regex_files"); + foreach ( $files1 as $file ) { + if ( $file != "." && $file != ".." && $file != ".DS_Store") { + $returnArray[preg_replace("/\.txt/", "", $file)] = file_get_contents( $data_path."regex_files/".$file ); + } + } + echo json_encode($returnArray); +} + + +function SmartRegexSave() { + if ($_POST['text']){ + /* + $date = date('Y_m_d_H_i_s', time()); + if ( file_exists("regex_files/".$_POST['filename'].".txt") ) { + $oldFile = file_get_contents("regex_files/".$_POST['filename'].".txt"); + file_put_contents("regex_files/".$_POST['filename']."_".$date.".txt", $oldFile); + } + */ + global $data_path; + if (get_magic_quotes_gpc()) { + $require = stripslashes($_POST['text']); + } else { + $require = $_POST['text']; + } + + file_put_contents( $data_path."regex_files/".$_POST['filename'].".txt", $require); + } +} + + +?> \ No newline at end of file