Mercurial > hg > extraction-interface
view develop/classes/basemodel.php @ 14:ac77748bb813
- Load regex files based on current topic. Only show the regex in this topic.
To do that, it needs to lookup a table called 'topic_regex_relation' which has the relation of topic and regex filename in filesystem.
- Extractapp UI with some layout modification: button, popup window, responsive (by bootstrap now). It was just for quick prototyping.
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 19 Feb 2015 11:07:27 +0100 |
parents | cc36a20a68ab |
children | 04736430d961 |
line wrap: on
line source
<?php abstract class BaseModel { // protected $database; protected $systemNAME, $topic; // protected $lg_server_url = "http://141.14.239.226:8080/gazetteer-server/rest/text/"; protected $get_text_from_fileId_url = "http://141.14.239.226:8080/gazetteer-server/rest/text/getFileText?fileId="; protected $get_text_from_sectionId_url = "http://141.14.239.226:8080/gazetteer-server/rest/text/getSectionText?sectionId="; protected $save_to_LGService_url = "http://141.14.239.226:8080/gazetteer-server/rest/text/save"; protected $save_new_to_LGService_url = "http://141.14.239.226:8080/gazetteer-server/rest/text/saveNew"; public function __construct() { global $mysql_database, $mysql_server, $mysql_user, $mysql_password, $systemNAME; $this->systemNAME = $systemNAME; // $this->database = new PDO("mysql:host=localhost;dbname=test", "username", "password"); set_time_limit(0); ini_set('memory_limit', '-1'); $link_mysql = mysql_connect($mysql_server, $mysql_user, $mysql_password); mysql_query("SET NAMES utf8"); if (!$link_mysql) { die('Could not connect: ' . mysql_error()); } $db_selected = mysql_select_db($mysql_database, $link_mysql); if (!$db_selected) { die ('Can\'t use foo : ' . mysql_error()); } $this->topic = 1; // set the default topic to person (人物) } protected function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue; $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue); switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } protected function GetWordlist() { $query = sprintf("SELECT * FROM `wordlist` WHERE `systemName`='%s' ORDER BY `name` ASC", $this->systemNAME); $result = mysql_query($query); if (!$result){ return json_encode("Failed during selecting wordlist table.");; } return $result; } protected function GetSectionsByID($section_id) { $query = sprintf("SELECT * FROM `sections` WHERE `id`=\"%s\"", $section_id); $result = mysql_query($query); if (!$result){ echo json_encode("Failed during selecting sections table"); return; } return $result; } protected function GetTaglist() { $query = sprintf("SELECT * FROM `taglist` WHERE `systemName`='%s' ORDER BY `tag` ASC", $this->systemNAME); $result = mysql_query($query); if (!$result) { return json_encode("Failed during selecting taglist table."); } return $result; } protected function GetBooksByID($bookId) { $query = sprintf("SELECT * FROM `books` WHERE id=\"%s\"", $bookId); $result = mysql_query($query); if (!$result) { return json_encode("Failed during selecting books table."); } return $result; } protected function GetTopiclist() { $query = sprintf("SELECT * FROM `topics`"); $result = mysql_query($query); if (!$result) { return json_encode("Failed during selecting topics table."); } return $result; } protected function GetTopicByID($topic_id) { $query = sprintf("SELECT * FROM `topics` WHERE id=\"%s\"", $topic_id); $result = mysql_query($query); if (!$result) { return json_encode("Failed during selecting topics table."); } return $result; } } ?>