Moving to GIT
This commit is contained in:
parent
7e1bf85deb
commit
a6843071c7
9
CHANGELOG
Normal file
9
CHANGELOG
Normal file
@ -0,0 +1,9 @@
|
||||
V 0.223, 19. Mar 2022
|
||||
---------------------
|
||||
New functionalities added:
|
||||
- browse by bibliographic type
|
||||
- provide language when adding a new entry (added by users)
|
||||
- option to add languages
|
||||
- detect if the record is already in the database and report that to the end user
|
||||
- by default, no results are shown in the browse section (instead of all shown which might have taken a long time)
|
||||
- extra instructions provided at the end of the "browse" subpage
|
51
README
Normal file
51
README
Normal file
@ -0,0 +1,51 @@
|
||||
##
|
||||
## READ THIS BEFORE ASKING QUESTIONS
|
||||
##
|
||||
|
||||
0: LICENSE, TERMS, SPECIAL REMARKS
|
||||
1: REQUIREMENTS
|
||||
2: DATABASE STRUCTURE
|
||||
3. CONFIGURATION
|
||||
3.2 FRONT-END
|
||||
|
||||
4. BACK_END PRECHECK
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
##
|
||||
##
|
||||
##
|
||||
0 LICENSE, TERMS, SPECIAL REMARKS
|
||||
|
||||
(add license, would prefer open type)
|
||||
|
||||
|
||||
|
||||
|
||||
2 DATABASE STRUCTURE
|
||||
|
||||
Most tables start with prefixes that denote their function.
|
||||
|
||||
- publications is the main table containing common publication data
|
||||
- p_* tables contain additional publication data for specific types
|
||||
- l_* tables for lists (entities) such as authors, publishers, languages,..
|
||||
- l_* tables also for parent (master) publication lists
|
||||
publication -> p_newspaperArticle -> l_newspaper
|
||||
publication->p->journalArticle -> l_journal
|
||||
|
||||
book chapter -> book is excemption as we also have book type:
|
||||
|
||||
publication->p_book
|
||||
publication->p_bookChapter->p_book
|
||||
|
||||
- dict_x_y store relationships between a and b
|
||||
|
||||
-
|
||||
|
||||
##
|
||||
##
|
||||
##
|
||||
3.2 CONFIGURATION: FRONT-END
|
||||
open index.php and set API_URL for the correct API URL (line 9)
|
7
TODO
Normal file
7
TODO
Normal file
@ -0,0 +1,7 @@
|
||||
FRONTEND:
|
||||
rewrites (nice urls, search for index.php or "?w")
|
||||
search results
|
||||
|
||||
|
||||
BACKEND:
|
||||
rewrites (nice urls)
|
238
api/README.api
Normal file
238
api/README.api
Normal file
@ -0,0 +1,238 @@
|
||||
ESS Bibliography API documentation
|
||||
Version: 0.1
|
||||
|
||||
Further Info: May Dousak (may.dousak@fdv.uni-lj.si)
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
1. GENERAL PRINCIPLES
|
||||
2. LIST OF CALLS
|
||||
--------------------------------------------------------------------------------
|
||||
1. GENERAL PRINCIPLES
|
||||
|
||||
1.1 SENDING REQUESTS
|
||||
|
||||
Your client should request queries using a POST parameter to:
|
||||
|
||||
a) API URL
|
||||
|
||||
default: https://bibliography.europeansocialsurvey.org/api
|
||||
|
||||
b) an appropriate command, passed as a POST variable w
|
||||
|
||||
c) (optional) parameters as additional POST variables
|
||||
|
||||
|
||||
1.2 RECEIVING RESPONSES
|
||||
|
||||
In case of success, data is received along with HTTP code 200 ("OK").
|
||||
|
||||
In case of wrong call, http code 400 ("Invalid request") is returned.
|
||||
|
||||
In case of error in server side appropriate HTTP response code along with
|
||||
text content is returned.
|
||||
|
||||
In essence: check the response codes before reporting bugs!
|
||||
|
||||
|
||||
|
||||
1.3 JQUERY CLIENT EXAMPLE
|
||||
|
||||
The following simple example requests the lists of countries and fills the
|
||||
according drop-down ("affiliation").
|
||||
|
||||
$.ajax ({
|
||||
method: "POST",
|
||||
url: API_URL,
|
||||
data: {
|
||||
w: 'list_countries'
|
||||
}
|
||||
})
|
||||
.done (function (msg) {
|
||||
if (msg == '') {
|
||||
console.log('No response received from API!');
|
||||
}
|
||||
else {
|
||||
$('#affiliation').html('<option value="0">Any</option>');
|
||||
|
||||
if (msg['status'] == "200") {
|
||||
msg['data'].forEach(function (item) {
|
||||
$('#affiliation').html( $('#affiliation').html() + '<option value="' + item['id'] + '">' + item['name'] + '</option>');
|
||||
});
|
||||
}
|
||||
else {
|
||||
console.log(msg);
|
||||
}
|
||||
}
|
||||
})
|
||||
.fail (function() {
|
||||
console.log('No response received from API!');
|
||||
});
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
2. LIST OF COMMANDS
|
||||
|
||||
|
||||
browse
|
||||
|
||||
Displays list of entries based on the browse data
|
||||
|
||||
Extra POST variables:
|
||||
(in progress. Please refer to classes/browse.php)
|
||||
|
||||
Response: json array of results.
|
||||
|
||||
|
||||
|
||||
browse2spreadsheet
|
||||
|
||||
Exports the current list of entries into a spreadsheet (CSV).
|
||||
|
||||
Extra POST variables:
|
||||
(in progress. Please refer to classes/browse.php)
|
||||
|
||||
Response: CSV file.
|
||||
|
||||
|
||||
|
||||
display_item
|
||||
|
||||
Displays details for the selected item (from search_suggestions)
|
||||
|
||||
Extra POST variables:
|
||||
id - id of the item
|
||||
|
||||
Response: array (
|
||||
name : item name
|
||||
label : item label
|
||||
block : block item resides in
|
||||
txt : item full text )
|
||||
|
||||
|
||||
doi
|
||||
|
||||
Fetches bibliographic data from DOI record. Please use sparingly as it
|
||||
connects to third-party servers (DOI) and we do not want to get blocked.
|
||||
|
||||
Extra post varialbes:
|
||||
doi : doi record
|
||||
|
||||
Response: array containing citation data.
|
||||
|
||||
|
||||
|
||||
item2spreadsheet
|
||||
|
||||
Exports item citations into a spreadsheet
|
||||
|
||||
Extra POST variables:
|
||||
id: item id
|
||||
|
||||
Response: CSV file.
|
||||
|
||||
|
||||
item_citations
|
||||
|
||||
Displays all the bibliographic entries "using" the selected item.
|
||||
|
||||
Extra POST variables:
|
||||
id: item id
|
||||
|
||||
Response: json list of entries using the given item.
|
||||
|
||||
|
||||
|
||||
list_countries
|
||||
|
||||
returns list of countries (for which there are bibliographic entries)
|
||||
you might want to use in a form for searching records.
|
||||
|
||||
Extra POST variables: none
|
||||
Response: array(country_id => country_name)
|
||||
|
||||
|
||||
list_items
|
||||
|
||||
returns list of ESS items you might want to use in a form for searching
|
||||
records.
|
||||
|
||||
Extra POST variables: none
|
||||
Response: array(item_id => item_name)
|
||||
|
||||
|
||||
list_journalField
|
||||
|
||||
returns list of journal fields you might want to use in a form for
|
||||
searching records.
|
||||
|
||||
Extra POST variables: none
|
||||
Response: array(journal_id => journal_name)
|
||||
|
||||
list_modules
|
||||
|
||||
returns list of ESS modules you might want to use in a form for
|
||||
searching records.
|
||||
|
||||
Extra POST variables: none
|
||||
Response: array(module_id => module_name)
|
||||
|
||||
|
||||
list_pubType
|
||||
|
||||
returns list of all publication types you might want to use in a form
|
||||
for searching records.
|
||||
|
||||
Extra POST variables: none
|
||||
Response: array(pubType_id => pubType_name)
|
||||
|
||||
|
||||
list_rounds
|
||||
|
||||
returns list of ESS rounds you might want to use in a form for
|
||||
searching records.
|
||||
|
||||
Extra POST variables: none
|
||||
Response: array(round_id => round_name)
|
||||
|
||||
|
||||
list_topics
|
||||
|
||||
returns list of ESS topics countries you might want to use in a form for
|
||||
searching records.
|
||||
|
||||
Extra POST variables: none
|
||||
Response: array(topic_id => topic_name)
|
||||
|
||||
|
||||
search
|
||||
|
||||
See search_suggestions.
|
||||
When fulltext is enabled, it will return list of all results.
|
||||
|
||||
|
||||
|
||||
search_suggestions
|
||||
|
||||
returns list of search suggestions for fulltext search.
|
||||
Currently, it only works on item search (need to update it to fulltext)
|
||||
|
||||
Extra POST variables:
|
||||
txt - fulltext to search for
|
||||
|
||||
Response: array (
|
||||
id : item ID
|
||||
name : item name
|
||||
label : item label
|
||||
block : block item resides in
|
||||
txt : item full text )
|
||||
|
||||
|
||||
total_items_published
|
||||
|
||||
Returns the number of records in the database.
|
||||
|
||||
Extra POST variables: none
|
||||
Response: number of bibliographic entries (integer).
|
||||
|
||||
|
200
api/api.php
Normal file
200
api/api.php
Normal file
@ -0,0 +1,200 @@
|
||||
<?php
|
||||
|
||||
$w = $_POST['w']??'';
|
||||
|
||||
//require ('../settings.php');
|
||||
require ('settings_api.php');
|
||||
|
||||
switch ($w) {
|
||||
|
||||
case 'search_suggestions':
|
||||
$search = new search();
|
||||
$results = $search->txtSearch(true);
|
||||
|
||||
response (200, "OK", $results);
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 'search':
|
||||
$search = new search();
|
||||
$results = $search->txtSearch(false);
|
||||
|
||||
response (200, "OK", $results);
|
||||
|
||||
break;
|
||||
|
||||
case 'total_records_published':
|
||||
$browse = new browse();
|
||||
$data = $browse->numRecords();
|
||||
|
||||
response (200, "OK", $data);
|
||||
|
||||
case 'search_query_text':
|
||||
$search = new search();
|
||||
$results = $search->queryText();
|
||||
|
||||
response (200, "OK", $results);
|
||||
|
||||
break;
|
||||
|
||||
case 'display_item':
|
||||
$item = new item();
|
||||
$data = $item->getData();
|
||||
|
||||
response (200, "OK", $data);
|
||||
|
||||
break;
|
||||
|
||||
case 'list_countries':
|
||||
$c = new country();
|
||||
$results = $c->listAll();
|
||||
|
||||
response (200, "OK", $results);
|
||||
|
||||
break;
|
||||
|
||||
case 'list_languages':
|
||||
$c = new language();
|
||||
$results = $c->listAll();
|
||||
|
||||
response (200, "OK", $results);
|
||||
|
||||
break;
|
||||
|
||||
case 'list_topics':
|
||||
$c = new topic();
|
||||
$results = $c->listAll();
|
||||
|
||||
response (200, "OK", $results);
|
||||
|
||||
break;
|
||||
|
||||
case 'list_items':
|
||||
$c = new item();
|
||||
$results = $c->listAll();
|
||||
|
||||
response (200, "OK", $results);
|
||||
|
||||
break;
|
||||
|
||||
case 'list_modules':
|
||||
$c = new module();
|
||||
$results = $c->listAll();
|
||||
|
||||
response (200, "OK", $results);
|
||||
|
||||
break;
|
||||
|
||||
case 'list_rounds':
|
||||
$c = new round();
|
||||
$results = $c->listAll();
|
||||
|
||||
response (200, "OK", $results);
|
||||
|
||||
break;
|
||||
|
||||
case 'list_journalField':
|
||||
$c = new journalField();
|
||||
$results = $c->listAll();
|
||||
|
||||
response (200, "OK", $results);
|
||||
|
||||
break;
|
||||
|
||||
case 'list_pubType':
|
||||
$c = new pubType();
|
||||
$results = $c->listAll();
|
||||
|
||||
response (200, "OK", $results);
|
||||
|
||||
break;
|
||||
|
||||
case 'browse':
|
||||
$browse = new browse();
|
||||
$data = $browse->getRecords();
|
||||
|
||||
response (200, "OK", $data);
|
||||
|
||||
break;
|
||||
|
||||
case 'browse2spreadsheet':
|
||||
$browse = new browse();
|
||||
$data = $browse->spreadsheet_export();
|
||||
|
||||
response (200, "OK", $data);
|
||||
|
||||
break;
|
||||
|
||||
case 'item_citations':
|
||||
$browse = new browse();
|
||||
$data = $browse->item_citations();
|
||||
|
||||
response (200, "OK", $data);
|
||||
|
||||
break;
|
||||
|
||||
case 'item2spreadsheet':
|
||||
$browse = new browse();
|
||||
$data = $browse->spreadsheet_item();
|
||||
|
||||
response (200, "OK", $data);
|
||||
|
||||
break;
|
||||
|
||||
case 'doi':
|
||||
$data = doi::fetchData($_POST['doi']);
|
||||
|
||||
response (200, "OK", $data);
|
||||
break;
|
||||
|
||||
case 'do_insert':
|
||||
$myData = filter_input(INPUT_POST, 'content', FILTER_SANITIZE_STRING);
|
||||
|
||||
$insert = new publish();
|
||||
$data = $insert->consider($myData);
|
||||
if ($data == "OK") {
|
||||
response (200, "OK", $data);
|
||||
}
|
||||
else {
|
||||
response (406, 'ERROR', $data);
|
||||
}
|
||||
|
||||
|
||||
default:
|
||||
|
||||
response (400, "Invalid Request", $_POST['w']);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function response($status,$status_message,$data)
|
||||
{
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
|
||||
header("Cache-Control: post-check=0, pre-check=0", false);
|
||||
header("Pragma: no-cache"); // HTTP/1.0
|
||||
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
||||
header("Content-Type:application/json");
|
||||
header("HTTP/1.1 ".$status);
|
||||
|
||||
$response['status']=$status;
|
||||
$response['status_message']=$status_message;
|
||||
$response['data']=str_replace (array ('{','}','[',']'), array ('','','',''), $data);
|
||||
$json_response = json_encode($response);
|
||||
echo $json_response;
|
||||
|
||||
|
||||
|
||||
if ($status!=200) {
|
||||
// mail or log
|
||||
}
|
||||
|
||||
die();
|
||||
|
||||
}
|
||||
|
||||
?>
|
62
api/settings_api.php
Normal file
62
api/settings_api.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
define ('SITE_PATH', '/var/www/biblio_backend/');
|
||||
define ("DEBUG", 1);
|
||||
define ("CONTACT", 'May at may.dousak @ fdv.uni-lj.si');
|
||||
define ("ERROR_LOG", SITE_PATH .'logs/err.log');
|
||||
define ('FILE_LINES_LIMIT', 10000);
|
||||
define ('FILE_LINES_SKIP', 0);
|
||||
define ('DOI_REQ_LIMIT', 10000);
|
||||
|
||||
|
||||
ini_set ('display_errors', DEBUG);
|
||||
ini_set ('error_reporting', DEBUG);
|
||||
|
||||
|
||||
$sql_host = 'r3';
|
||||
$sql_user = "biblio";
|
||||
$sql_pass = "biblio";
|
||||
$sql_db = "ess_biblio";
|
||||
|
||||
/*
|
||||
$sql_host = 'localhost';
|
||||
$sql_user = "biblio";
|
||||
$sql_pass = "biblio";
|
||||
$sql_db = "ess_2022";
|
||||
*/
|
||||
|
||||
// DATABASE STUFF
|
||||
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
try {
|
||||
$PDO = new PDO("mysql:host=" .$sql_host .";dbname=" .$sql_db .";charset=utf8", $sql_user, $sql_pass);
|
||||
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$PDO->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
die ('Cannot connect to the database! Error: ' .$ex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// autoload stuff (backend only)
|
||||
|
||||
function loadClass($class) {
|
||||
|
||||
if (is_file (SITE_PATH .'classes/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/' . $class .'.php';
|
||||
}
|
||||
else if (is_file (SITE_PATH .'classes/publications/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/publications/' . $class .'.php';
|
||||
}
|
||||
else if (is_file (SITE_PATH .'classes/lists/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/lists/' . $class .'.php';
|
||||
}
|
||||
}
|
||||
|
||||
spl_autoload_register('loadClass');
|
||||
|
||||
?>
|
63
api/settings_api.php.example
Normal file
63
api/settings_api.php.example
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
define ('SITE_PATH', '/var/www/biblio/');
|
||||
define ("DEBUG", 1);
|
||||
define ("CONTACT", 'May at may.dousak @ fdv.uni-lj.si');
|
||||
define ("ERROR_LOG", SITE_PATH .'logs/err.log');
|
||||
define ('FILE_LINES_LIMIT', 10000);
|
||||
define ('FILE_LINES_SKIP', 0);
|
||||
define ('DOI_REQ_LIMIT', 10000);
|
||||
|
||||
|
||||
ini_set ('display_errors', DEBUG);
|
||||
ini_set ('error_reporting', DEBUG);
|
||||
|
||||
/*
|
||||
$sql_host = 'r3';
|
||||
$sql_user = "biblio";
|
||||
$sql_pass = "biblio";
|
||||
$sql_db = "ess_biblio";
|
||||
*/
|
||||
|
||||
$sql_host = 'localhost';
|
||||
$sql_user = "biblio";
|
||||
$sql_pass = "biblio";
|
||||
$sql_db = "ess_2022";
|
||||
|
||||
|
||||
// DATABASE STUFF
|
||||
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
try {
|
||||
$PDO = new PDO("mysql:host=" .$sql_host .";dbname=" .$sql_db .";charset=utf8", $sql_user, $sql_pass);
|
||||
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$PDO->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
die ('Cannot connect to the database! Error: ' .$ex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// autoload stuff (backend only)
|
||||
|
||||
function loadClass($class) {
|
||||
|
||||
if (is_file (SITE_PATH .'classes/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/' . $class .'.php';
|
||||
}
|
||||
else if (is_file (SITE_PATH .'classes/publications/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/publications/' . $class .'.php';
|
||||
}
|
||||
else if (is_file (SITE_PATH .'classes/lists/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/lists/' . $class .'.php';
|
||||
}
|
||||
}
|
||||
|
||||
spl_autoload_register('loadClass');
|
||||
|
||||
?>
|
876
backups/ess_biblio_0.sql
Normal file
876
backups/ess_biblio_0.sql
Normal file
File diff suppressed because one or more lines are too long
876
backups/ess_biblio_1619437597.sql
Normal file
876
backups/ess_biblio_1619437597.sql
Normal file
File diff suppressed because one or more lines are too long
920
backups/ess_biblio_1619437608.sql
Normal file
920
backups/ess_biblio_1619437608.sql
Normal file
File diff suppressed because one or more lines are too long
876
backups/ess_biblio_1619437964.sql
Normal file
876
backups/ess_biblio_1619437964.sql
Normal file
File diff suppressed because one or more lines are too long
878
backups/ess_biblio_1619438777.sql
Normal file
878
backups/ess_biblio_1619438777.sql
Normal file
File diff suppressed because one or more lines are too long
861
backups/ess_biblio_1619439491.sql
Normal file
861
backups/ess_biblio_1619439491.sql
Normal file
File diff suppressed because one or more lines are too long
861
backups/ess_biblio_1619439833.sql
Normal file
861
backups/ess_biblio_1619439833.sql
Normal file
File diff suppressed because one or more lines are too long
0
backups/ess_biblio_1619682950.sqlcd
Normal file
0
backups/ess_biblio_1619682950.sqlcd
Normal file
866
backups/ess_biblio_1619682997.sql
Normal file
866
backups/ess_biblio_1619682997.sql
Normal file
File diff suppressed because one or more lines are too long
866
backups/ess_biblio_1619683009.sql
Normal file
866
backups/ess_biblio_1619683009.sql
Normal file
File diff suppressed because one or more lines are too long
866
backups/ess_biblio_1619683295.sql
Normal file
866
backups/ess_biblio_1619683295.sql
Normal file
File diff suppressed because one or more lines are too long
866
backups/ess_biblio_1619683315.sql
Normal file
866
backups/ess_biblio_1619683315.sql
Normal file
File diff suppressed because one or more lines are too long
866
backups/ess_biblio_1619683333.sql
Normal file
866
backups/ess_biblio_1619683333.sql
Normal file
File diff suppressed because one or more lines are too long
866
backups/ess_biblio_1619683414.sql
Normal file
866
backups/ess_biblio_1619683414.sql
Normal file
File diff suppressed because one or more lines are too long
949
backups/ess_biblio_1619695626.sql
Normal file
949
backups/ess_biblio_1619695626.sql
Normal file
File diff suppressed because one or more lines are too long
984
backups/ess_biblio_1619724175.sql
Normal file
984
backups/ess_biblio_1619724175.sql
Normal file
File diff suppressed because one or more lines are too long
984
backups/ess_biblio_1619762961.sql
Normal file
984
backups/ess_biblio_1619762961.sql
Normal file
File diff suppressed because one or more lines are too long
0
backups/ess_biblio_1647936260.sql
Normal file
0
backups/ess_biblio_1647936260.sql
Normal file
0
backups/ess_biblio_1647936265.sql
Normal file
0
backups/ess_biblio_1647936265.sql
Normal file
0
backups/ess_biblio_1647936290.sql
Normal file
0
backups/ess_biblio_1647936290.sql
Normal file
0
backups/ess_biblio_1647936295.sql
Normal file
0
backups/ess_biblio_1647936295.sql
Normal file
1129
backups/ess_biblio_1647936298.sql
Normal file
1129
backups/ess_biblio_1647936298.sql
Normal file
File diff suppressed because one or more lines are too long
1126
backups/ess_biblio_20210514.sql
Normal file
1126
backups/ess_biblio_20210514.sql
Normal file
File diff suppressed because one or more lines are too long
1111
backups/ess_biblio_r3_1620371614.sql
Normal file
1111
backups/ess_biblio_r3_1620371614.sql
Normal file
File diff suppressed because one or more lines are too long
920
backups/nsd_db_1619763548.sql
Normal file
920
backups/nsd_db_1619763548.sql
Normal file
File diff suppressed because one or more lines are too long
1058
classes/_import.php
Normal file
1058
classes/_import.php
Normal file
File diff suppressed because it is too large
Load Diff
170
classes/author.php
Normal file
170
classes/author.php
Normal file
@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of author
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
class author {
|
||||
//put your code here
|
||||
protected $PDO;
|
||||
|
||||
|
||||
private static function _cleanCitation (&$citation) {
|
||||
// make sure it is in form Surname, N. no leading/trailing whitespaces, no double whitespaces,...)
|
||||
// also remove dot (and add it again, later)
|
||||
$t = trim ($citation, " \n\r\t\v\0.");
|
||||
$parts = explode (",", $t);
|
||||
|
||||
foreach ($parts as $off=>$part) {
|
||||
$parts[$off] = trim ($part, " \n\r\t\v\0.");
|
||||
}
|
||||
|
||||
$citation = $parts[0] .', ' .$parts[1] .'.';
|
||||
}
|
||||
|
||||
// check if we have author from the citation
|
||||
public static function isAuthor($citation) {
|
||||
global $PDO;
|
||||
|
||||
author::_cleanCitation($citation);
|
||||
|
||||
try {
|
||||
$stmt = $PDO->prepare("SELECT id FROM l_person where citation=:citation");
|
||||
$stmt->execute(array($citation));
|
||||
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
if ($r = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||
return $r[0];
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static function findOrAdd ($name1="", $name2="", $surname1="", $surname2="", $citation="") {
|
||||
|
||||
$id = author::isAuthorByName($name1, $name2, $surname1, $surname2, $citation);
|
||||
|
||||
if ($id == false) {
|
||||
$id = author::insertAuthorDetailed ($name1, $name2, $surname1, $surname2, $citation);
|
||||
}
|
||||
|
||||
return $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* check if we have an author by this name, surname, name2, surname2, citation
|
||||
*
|
||||
* @param type $name1
|
||||
* @param type $name2
|
||||
* @param type $surname1
|
||||
* @param type $surname2
|
||||
* @param type $citation
|
||||
* @return boolean
|
||||
*/
|
||||
public static function isAuthorByName($name1="", $name2="", $surname1="", $surname2="", $citation="") {
|
||||
|
||||
global $PDO;
|
||||
|
||||
$citation = trim ($citation);
|
||||
|
||||
try {
|
||||
$stmt = $PDO->prepare("SELECT id FROM l_person where first_name=:name1 AND middle_name=:name2 AND last_name=:surname1 AND last_name_2=:surname2 AND citation=:citation");
|
||||
$stmt->execute(array('name1' => $name1, 'name2' => $name2, 'surname1' => $surname1, 'surname2' => $surname2, 'citation' => $citation));
|
||||
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
if ($r = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||
return $r[0];
|
||||
}
|
||||
else {
|
||||
unset ($stmt);
|
||||
// maybe citation is off?
|
||||
$stmt = $PDO->prepare("SELECT id FROM l_person where first_name=:name1 AND middle_name=:name2 AND last_name=:surname1 AND last_name_2=:surname2");
|
||||
$stmt->execute(array('name1' => $name1, 'name2' => $name2, 'surname1' => $surname1, 'surname2' => $surname2));
|
||||
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
if ($r = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||
return $r[0];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert author by name, surname, name2, surname2, citation (email later :))
|
||||
*
|
||||
* @param type $name1 first name
|
||||
* @param type $name2 middle name
|
||||
* @param type $surname1 last name
|
||||
* @param type $surname2 last name 2
|
||||
* @param type $citation citation
|
||||
* @return boolean
|
||||
*/
|
||||
public static function insertAuthorDetailed ($name1, $name2, $surname1, $surname2, $citation) {
|
||||
global $PDO;
|
||||
|
||||
$citation = trim ($citation);
|
||||
|
||||
try {
|
||||
$stmt = $PDO->prepare("INSERT INTO l_person (first_name, middle_name, last_name, last_name_2, citation) VALUES (:first_name, :middle_name, :last_name, :last_name_2, :citation)");
|
||||
$stmt->execute(array(
|
||||
'first_name' => $name1,
|
||||
'middle_name' => $name2,
|
||||
'last_name' => $surname1,
|
||||
'last_name_2' => $surname2,
|
||||
'citation' => $citation
|
||||
));
|
||||
|
||||
return $PDO->lastInsertId();
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// $author is short version from citation
|
||||
public static function insertAuthor ($citation) {
|
||||
global $PDO;
|
||||
|
||||
author::_cleanCitation($citation);
|
||||
$nameSurname = explode (",", $citation);
|
||||
|
||||
try {
|
||||
$stmt = $PDO->prepare("INSERT INTO l_person (citation, last_name, first_name, editMe) VALUES (:citation, :last_name, :first_name, 'Y')");
|
||||
$stmt->execute(array(
|
||||
'citation' => $citation,
|
||||
'last_name' => trim($nameSurname[0]),
|
||||
'first_name' => trim($nameSurname[1])
|
||||
));
|
||||
|
||||
return $PDO->lastInsertId();
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
389
classes/browse.php
Normal file
389
classes/browse.php
Normal file
@ -0,0 +1,389 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of browse
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
class browse {
|
||||
private $PDO;
|
||||
|
||||
private $conditions = array (
|
||||
'pubType' => 0,
|
||||
'affiliation1' => 0,
|
||||
'affiliation2' => 0,
|
||||
'affil1auth1' => 0,
|
||||
'affil2auth2' => 0,
|
||||
'topic' => array(),
|
||||
'topic_logic' => 0,
|
||||
'item' => array(),
|
||||
'item_logic' => 0,
|
||||
'module' => array(),
|
||||
'module_logic' => 0,
|
||||
'author' => '',
|
||||
'title_words' => '',
|
||||
'journal' => '',
|
||||
'round' => 0,
|
||||
'jField' => 0);
|
||||
|
||||
private $sql_cond = "";
|
||||
private $query_result;
|
||||
|
||||
public function __construct() {
|
||||
global $PDO;
|
||||
|
||||
$this->PDO = $PDO;
|
||||
$this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
}
|
||||
|
||||
public function getRecords() {
|
||||
// first, create condition base on posted data
|
||||
$this->_post2arr();
|
||||
$this->_sql_cond();
|
||||
return $this->_sql_query();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns number of all (online) records in the database
|
||||
*
|
||||
* @return type integer
|
||||
*/
|
||||
public function numRecords() {
|
||||
// first, create condition base on posted data
|
||||
$this->_post2arr();
|
||||
$this->_sql_cond();
|
||||
return count($this->_sql_query());
|
||||
|
||||
}
|
||||
|
||||
public function item_citations() {
|
||||
if (intval($_POST['d'])>0) {
|
||||
$this->sql_cond = ' AND publication.id IN (SELECT id_publication FROM dict_pub_item WHERE id_item = ' .intval($_POST['d']) .') ';
|
||||
return $this->_sql_query();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function spreadsheet_export() {
|
||||
// first, create condition base on posted data
|
||||
$this->_post2arr();
|
||||
$this->_sql_cond();
|
||||
return $this->_spreadsheet_query();
|
||||
}
|
||||
|
||||
public function spreadsheet_item() {
|
||||
// first, create condition base on posted data
|
||||
if (intval($_POST['id'])>0) {
|
||||
$this->sql_cond = ' AND publication.id IN (SELECT id_publication FROM dict_pub_item WHERE id_item = ' .intval($_POST['id']) .')';
|
||||
return $this->_spreadsheet_query();
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
// checks what came through the POST and sets the query conditions
|
||||
private function _post2arr() {
|
||||
// this is after passing the thing around PHP (it gets escaped so it's not an array any more)
|
||||
if ($_POST['spr'] == 1) {
|
||||
$_POST['d'] = json_decode ($_POST['d'], true);
|
||||
}
|
||||
|
||||
foreach ($_POST['d'] as $field) {
|
||||
|
||||
if (is_array ($this->conditions[$field['name']])) {
|
||||
$this->conditions[$field['name']][] = intval($field['value']);
|
||||
}
|
||||
else {
|
||||
$this->conditions[$field['name']] = $field['value'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function _spreadsheet_query () {
|
||||
|
||||
$output = '"ONLINE ID",'
|
||||
. '"SCHOLAR SPSS ID",'
|
||||
. '"YEAR",'
|
||||
. '"AUTHORS' ."\n" .'(all)",'
|
||||
. '"AUTHOR 1",'
|
||||
. '"A1 AFFILIATION",'
|
||||
. '"AUTHOR 2",'
|
||||
. '"A2 AFFILIATION",'
|
||||
. '"AUTHOR 3",'
|
||||
. '"A3 AFFILIATION",'
|
||||
. '"AUTHOR 4",'
|
||||
. '"A4 AFFILIATION",'
|
||||
. '"AUTHOR 5",'
|
||||
. '"A5 AFFILIATION",'
|
||||
. '"TITLE (english)",'
|
||||
. '"TITLE (original)",'
|
||||
. '"PUBLICATION AFFILIATION",'
|
||||
. '"ENGLISH ABSTRACT",'
|
||||
. '"ORIGINAL ABSTRACT",'
|
||||
. '"BIBLIOGRAPHIC TYPE",'
|
||||
. '"JOURNAL, NEWSPAPER, MAGAZINE, BOOK CONFERENCE TITLE/NAME' ."\n" .'(only selected pub types)",'
|
||||
. '"VOLUME' ."\n" .'(journal article only)",'
|
||||
. '"ISSUE' ."\n" .'(journal article only)",'
|
||||
. '"FROM PAGE",'
|
||||
. '"TO PAGE",'
|
||||
. '"NUM PAGES",'
|
||||
. '"MAIN TOPIC",'
|
||||
. '"SECOND TOPIC",'
|
||||
. '"ALL TOPICS' ."\n" .'(incl. T1 and T2)",'
|
||||
. '"ITEMS USED",'
|
||||
. '"MODULES USED",'
|
||||
. '"ESS ROUNDS USED",'
|
||||
. '"CITATION' ."\n" .'(where provided)",'
|
||||
. '"DOI' ."\n" .'(where provided)",'
|
||||
. "\n";
|
||||
|
||||
|
||||
$query = "SELECT "
|
||||
. "publication.id as id,"
|
||||
. "publication.id_manual as id_manual,"
|
||||
. "publication.year as year,"
|
||||
. "GROUP_CONCAT(DISTINCT l_person.citation ORDER BY dict_pub_author.ord) as authors,"
|
||||
. "A1.author as author1, "
|
||||
. "A1.affiliation as affil_auth1,"
|
||||
. "A2.author as author2, "
|
||||
. "A2.affiliation as affil_auth2,"
|
||||
. "A3.author as author3, "
|
||||
. "A3.affiliation as affil_auth3,"
|
||||
. "A4.author as author4, "
|
||||
. "A4.affiliation as affil_auth4,"
|
||||
. "A5.author as author5, "
|
||||
. "A5.affiliation as affil_auth5,"
|
||||
. "topic1.topic as topic1, "
|
||||
. "topic2.topic as topic2, "
|
||||
. "GROUP_CONCAT(DISTINCT topics.topic) as topics, "
|
||||
. "GROUP_CONCAT(DISTINCT items.item) as items, "
|
||||
. "GROUP_CONCAT(DISTINCT modules.module) as modules, "
|
||||
. "GROUP_CONCAT(DISTINCT rounds.round) as rounds, "
|
||||
. "publication.title_eng as title_eng, "
|
||||
. "publication.title_orig as title_orig, "
|
||||
. "pub_country.country as pub_country, "
|
||||
. "publication.abstract_eng as abstract_eng, "
|
||||
. "publication.abstract_orig as abstract_orig, "
|
||||
. "l_pubType.name as bibtype, "
|
||||
. "IF (publication.type=1,l_journal.name,"
|
||||
. " IF(publication.type=4,l_conference.name, "
|
||||
. " IF(publication.type=8,bookpart.title, "
|
||||
. " IF(publication.type=10,l_newspaper.name,'')))) as masterName, "
|
||||
. "IF (publication.type=1,p_journalArticle.fromPage,IF (publication.type=8,p_bookChapter.fromPage,IF(publication.type=10,p_newspaperArticle.fromPage,''))) as fromPage,"
|
||||
. "IF (publication.type=1,p_journalArticle.toPage,IF (publication.type=8,p_bookChapter.toPage,IF(publication.type=10,p_newspaperArticle.toPage,''))) as toPage,"
|
||||
. "IF (publication.type=1 AND p_journalArticle.toPage>p_journalArticle.fromPage,(p_journalArticle.toPage-p_journalArticle.fromPage),"
|
||||
." IF (publication.type=2,p_book.numPages,"
|
||||
." IF (publication.type=3,p_workPaper.numPages,"
|
||||
." IF (publication.type=5,p_report.numPages,"
|
||||
." IF (publication.type=6,p_thesis.numPages,"
|
||||
." IF (publication.type=11,p_manuscript.numPages,"
|
||||
." IF (publication.type=8 AND p_journalArticle.toPage>p_journalArticle.fromPage,(p_bookChapter.toPage-p_bookChapter.fromPage),"
|
||||
. " IF(publication.type=10 AND p_journalArticle.toPage>p_journalArticle.fromPage,(p_newspaperArticle.toPage-p_newspaperArticle.fromPage),'')))))))) as numPages,"
|
||||
. "p_journalArticle.volume as volume, "
|
||||
. "p_journalArticle.issue as issue, "
|
||||
. "publication.citation as citation, "
|
||||
. "publication.doi as doi "
|
||||
. "FROM publication "
|
||||
. "LEFT JOIN dict_pub_author ON dict_pub_author.id_publication=publication.id "
|
||||
. "LEFT JOIN l_person ON l_person.id=dict_pub_author.id_person "
|
||||
. "LEFT JOIN p_journalArticle ON (publication.type=1 AND p_journalArticle.id=publication.id_parent ) "
|
||||
. "LEFT JOIN l_journal ON l_journal.id=p_journalArticle.id_journal "
|
||||
. "LEFT JOIN l_pubType ON l_pubType.id=publication.type "
|
||||
. "LEFT JOIN p_bookChapter ON (publication.type=8 AND p_bookChapter.id=publication.id_parent) "
|
||||
. "LEFT JOIN p_book bookpart ON (p_bookChapter.id_book=bookpart.id) "
|
||||
. "LEFT JOIN p_newspaperArticle ON (publication.type=10 AND p_newspaperArticle.id=publication.id_parent) "
|
||||
. "LEFT JOIN l_newspaper ON (p_newspaperArticle.id_newspaper=l_newspaper.id) "
|
||||
. "LEFT JOIN p_book ON (publication.type=2 AND p_book.id=publication.id_parent) "
|
||||
. "LEFT JOIN p_workPaper ON (publication.type=3 AND p_workPaper.id=publication.id_parent) "
|
||||
. "LEFT JOIN p_report ON (publication.type=5 AND p_report.id=publication.id_parent) "
|
||||
. "LEFT JOIN p_thesis ON (publication.type=6 AND p_thesis.id=publication.id_parent) "
|
||||
. "LEFT JOIN p_manuscript ON (publication.type=11 AND p_manuscript.id=publication.id_parent) "
|
||||
. "LEFT JOIN (SELECT l_person.citation as author, l_country.name as affiliation, dict_pub_author.id_publication as id_publication FROM dict_pub_author LEFT JOIN l_person ON l_person.id=dict_pub_author.id_person LEFT JOIN l_country ON l_country.id=dict_pub_author.id_country WHERE dict_pub_author.ord=1) A1 ON A1.id_publication=publication.id "
|
||||
. "LEFT JOIN (SELECT l_person.citation as author, l_country.name as affiliation, dict_pub_author.id_publication as id_publication FROM dict_pub_author LEFT JOIN l_person ON l_person.id=dict_pub_author.id_person LEFT JOIN l_country ON l_country.id=dict_pub_author.id_country WHERE dict_pub_author.ord=2) A2 ON A2.id_publication=publication.id "
|
||||
. "LEFT JOIN (SELECT l_person.citation as author, l_country.name as affiliation, dict_pub_author.id_publication as id_publication FROM dict_pub_author LEFT JOIN l_person ON l_person.id=dict_pub_author.id_person LEFT JOIN l_country ON l_country.id=dict_pub_author.id_country WHERE dict_pub_author.ord=3) A3 ON A3.id_publication=publication.id "
|
||||
. "LEFT JOIN (SELECT l_person.citation as author, l_country.name as affiliation, dict_pub_author.id_publication as id_publication FROM dict_pub_author LEFT JOIN l_person ON l_person.id=dict_pub_author.id_person LEFT JOIN l_country ON l_country.id=dict_pub_author.id_country WHERE dict_pub_author.ord=4) A4 ON A4.id_publication=publication.id "
|
||||
. "LEFT JOIN (SELECT l_person.citation as author, l_country.name as affiliation, dict_pub_author.id_publication as id_publication FROM dict_pub_author LEFT JOIN l_person ON l_person.id=dict_pub_author.id_person LEFT JOIN l_country ON l_country.id=dict_pub_author.id_country WHERE dict_pub_author.ord=5) A5 ON A5.id_publication=publication.id "
|
||||
. "LEFT JOIN (SELECT l_topic.name as topic, dict_pub_topic.id_publication FROM dict_pub_topic, l_topic WHERE dict_pub_topic.weight=1 AND l_topic.id=dict_pub_topic.id_topic) topic1 ON (topic1.id_publication=publication.id ) "
|
||||
. "LEFT JOIN (SELECT l_topic.name as topic, dict_pub_topic.id_publication FROM dict_pub_topic, l_topic WHERE dict_pub_topic.weight=2 AND l_topic.id=dict_pub_topic.id_topic) topic2 ON (topic2.id_publication=publication.id ) "
|
||||
. "LEFT JOIN (SELECT l_topic.name as topic, dict_pub_topic.id_publication FROM dict_pub_topic, l_topic WHERE l_topic.id=dict_pub_topic.id_topic) topics ON (topics.id_publication=publication.id ) "
|
||||
. "LEFT JOIN (SELECT l_ess_item.name as item, dict_pub_item.id_publication FROM dict_pub_item, l_ess_item WHERE l_ess_item.id=dict_pub_item.id_item) items ON (items.id_publication=publication.id ) "
|
||||
. "LEFT JOIN (SELECT l_module.name as module, dict_pub_module.id_publication FROM dict_pub_module, l_module WHERE l_module.id=dict_pub_module.id_module) modules ON (modules.id_publication=publication.id ) "
|
||||
. "LEFT JOIN (SELECT CONCAT (l_ess_round.name, ' (', l_ess_round.year, ')') as round, dict_pub_round.id_publication FROM dict_pub_round, l_ess_round WHERE l_ess_round.id=dict_pub_round.id_round) rounds ON (rounds.id_publication=publication.id ) "
|
||||
. "LEFT JOIN (SELECT l_country.name as country, dict_pub_country.id_publication FROM dict_pub_country, l_country WHERE dict_pub_country.id_country=l_country.id) pub_country ON (pub_country.id_publication=publication.id) "
|
||||
. "LEFT JOIN p_conferencePP ON (publication.type=4 AND publication.id_parent=p_conferencePP.id) "
|
||||
. "LEFT JOIN l_conference ON (l_conference.id = p_conferencePP.id_conference) "
|
||||
. " WHERE 1=1 AND publication.status='Online' " .$this->sql_cond
|
||||
. " GROUP BY publication.id ";
|
||||
|
||||
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare($query);
|
||||
|
||||
//common::except ($query);
|
||||
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
$this->query_result = $stmt;
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
while ($r = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$output .= '"' .$r['id'] .'",'
|
||||
.'"' .common::field2csv($r['id_manual']) .'",'
|
||||
.'"' .common::field2csv($r['year']) .'",'
|
||||
.'"' .common::field2csv($r['authors']) .'",'
|
||||
.'"' .common::field2csv($r['author1']) .'",'
|
||||
.'"' .common::field2csv($r['affil_auth1']) .'",'
|
||||
.'"' .common::field2csv($r['author2']) .'",'
|
||||
.'"' .common::field2csv($r['affil_auth2']) .'",'
|
||||
.'"' .common::field2csv($r['author3']) .'",'
|
||||
.'"' .common::field2csv($r['affil_auth3']) .'",'
|
||||
.'"' .common::field2csv($r['author4']) .'",'
|
||||
.'"' .common::field2csv($r['affil_auth4']) .'",'
|
||||
.'"' .common::field2csv($r['author5']) .'",'
|
||||
.'"' .common::field2csv($r['affil_auth5']) .'",'
|
||||
.'"' .common::field2csv($r['title_eng']) .'",'
|
||||
.'"' .common::field2csv($r['title_orig']) .'",'
|
||||
.'"' .common::field2csv($r['pub_country']) .'",'
|
||||
.'"' .common::field2csv($r['abstract_eng']) .'",'
|
||||
.'"' .common::field2csv($r['abstract_orig']) .'",'
|
||||
.'"' .common::field2csv($r['bibtype']) .'",'
|
||||
.'"' .common::field2csv($r['masterName']) .'",'
|
||||
.'"' .common::field2csv($r['volume']) .'",'
|
||||
.'"' .common::field2csv($r['issue']) .'",'
|
||||
.'"' .common::field2csv($r['fromPage']) .'",'
|
||||
.'"' .common::field2csv($r['toPage']) .'",'
|
||||
.'"' .common::field2csv($r['numPages']) .'",'
|
||||
.'"' .common::field2csv($r['topic1']) .'",'
|
||||
.'"' .common::field2csv($r['topic2']) .'",'
|
||||
.'"' .common::field2csv($r['topics']) .'",'
|
||||
.'"' .common::field2csv($r['items']) .'",'
|
||||
.'"' .common::field2csv($r['modules']) .'",'
|
||||
.'"' .common::field2csv($r['rounds']) .'",'
|
||||
.'"' .common::field2csv($r['citation']) .'",'
|
||||
.'"' .common::field2csv($r['doi']) .'"' ."\n";
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function _sql_query () {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("SELECT IF(ISNULL(publication.citation),"
|
||||
. "CONCAT ("
|
||||
. "GROUP_CONCAT(l_person.citation ORDER BY dict_pub_author.ord),"
|
||||
. "' (', publication.year, '). ', "
|
||||
. "publication.title_eng, '. ',"
|
||||
// now fields for article
|
||||
." IF (publication.type=1,CONCAT("
|
||||
. " l_journal.name, '. ', p_journalArticle.volume, '(', p_journalArticle.issue, '), ', p_journalArticle.fromPage, '-', p_journalArticle.toPage, '.')"
|
||||
. ",'') )"
|
||||
. " ,"
|
||||
. "publication.citation) as citation FROM publication "
|
||||
. "LEFT JOIN dict_pub_author ON dict_pub_author.id_publication=publication.id "
|
||||
. "LEFT JOIN l_person ON l_person.id=dict_pub_author.id_person "
|
||||
. "LEFT JOIN p_journalArticle ON p_journalArticle.id=publication.id_parent "
|
||||
. "LEFT JOIN l_journal ON l_journal.id=p_journalArticle.id_journal "
|
||||
. " WHERE 1=1 AND publication.status='Online' " .$this->sql_cond
|
||||
. " GROUP BY publication.id ORDER BY publication.id DESC");
|
||||
$stmt->execute();
|
||||
|
||||
$this->query_result = $stmt;
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
if ($r = $stmt->fetchAll(PDO::FETCH_ASSOC)) {
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function _sql_cond() {
|
||||
|
||||
// publication type
|
||||
if (intval($this->conditions['pubType']) > 0) {
|
||||
$this->sql_cond .= ' AND publication.type=' .intval($this->conditions['pubType']) .' ';
|
||||
}
|
||||
|
||||
|
||||
// affiliation 1
|
||||
if (intval($this->conditions['affiliation1']) > 0) {
|
||||
$this->sql_cond .= ' AND publication.id IN (SELECT id_publication FROM dict_pub_author WHERE id_country=' .intval($this->conditions['affiliation1']) .(intval($this->conditions['affil1auth1'])==1?' AND ord=1':'') .') ';
|
||||
}
|
||||
|
||||
// affiliation 2
|
||||
if (intval($this->conditions['affiliation2']) > 0) {
|
||||
$this->sql_cond .= ' AND publication.id IN (SELECT id_publication FROM dict_pub_author WHERE id_country=' .intval($this->conditions['affiliation2']) .(intval($this->conditions['affil2auth2'])==1?' AND ord=2':'') .') ';
|
||||
}
|
||||
|
||||
if (count($this->conditions['topic'])>0) {
|
||||
// ANY of the selected
|
||||
if (intval($this->conditions['topic_logic']) == 0) {
|
||||
$this->sql_cond .= ' AND publication.id IN (SELECT id_publication FROM dict_pub_topic WHERE id_topic IN (' .implode (',', $this->conditions['topic']) .')) ';
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
if (count($this->conditions['item'])>0) {
|
||||
// ANY of the selected
|
||||
if (intval($this->conditions['item_logic']) == 0) {
|
||||
$this->sql_cond .= ' AND publication.id IN (SELECT id_publication FROM dict_pub_item WHERE id_item IN (' .implode (',', $this->conditions['item']) .')) ';
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
if (count($this->conditions['module'])>0) {
|
||||
// ANY of the selected
|
||||
|
||||
if (intval($this->conditions['module_logic']) == 0) {
|
||||
$this->sql_cond .= ' AND publication.id IN (SELECT id_publication FROM dict_pub_module WHERE id_module IN (' .implode (',', $this->conditions['module']) .')) ';
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
|
||||
if (intval($this->conditions['round']) > 0) {
|
||||
$this->sql_cond .= ' AND publication.id IN (SELECT id_publication FROM dict_pub_round WHERE id_round=' .intval($this->conditions['round']).') ';
|
||||
}
|
||||
if (intval($this->conditions['jField']) > 0) {
|
||||
$this->sql_cond .= ' AND publication.id IN (select publication.id FROM publication, p_journalArticle, dict_journal_field WHERE publication.type=1 AND dict_journal_field.id_field=' .intval($this->conditions['jField']) .' AND dict_journal_field.id_journal=p_journalArticle.id_journal AND publication.id_parent=p_journalArticle.id) ';
|
||||
}
|
||||
|
||||
if ($this->conditions['author']!='') {
|
||||
$author = preg_replace ('/^[A-Z0-9,. ]/i', '', $this->conditions['author']);
|
||||
$this->sql_cond .= ' AND publication.id IN (select dict_pub_author.id_publication FROM dict_pub_author, l_person WHERE dict_pub_author.id_person=l_person.id AND (l_person.citation LIKE (\'%' . $this->conditions['author'] .'%\') OR l_person.last_name LIKE (\'%' . $this->conditions['author'] .'%\'))) ';
|
||||
}
|
||||
|
||||
if ($this->conditions['title_words']!='') {
|
||||
$this->sql_cond .= ' AND (publication.title_eng LIKE (\'%' .preg_replace ('/^[A-Z0-9,. ]/i', '', $this->conditions['title_words']) .'%\') OR publication.title_orig LIKE (\'%' .preg_replace ('/^[A-Z0-9,. ]/i', '', $this->conditions['title_words']) .'%\' )) ';
|
||||
}
|
||||
|
||||
|
||||
if ($this->conditions['journal']!='') {
|
||||
$author = preg_replace ('/^[A-Z0-9,. ]/i', '', $this->conditions['journal']);
|
||||
$this->sql_cond .= ' AND publication.id IN (SELECT publication.id FROM publication, p_journalArticle, l_journal WHERE publication.type=1 AND publication.id_parent=p_journalArticle.id AND p_journalArticle.id_journal=l_journal.id AND l_journal.name LIKE (\'' . $this->conditions['journal']. '\')) ';
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
433
classes/citation.php
Normal file
433
classes/citation.php
Normal file
@ -0,0 +1,433 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of citation
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
class citation {
|
||||
// entry point to parse citations. Type is needed.
|
||||
|
||||
public static function parse ($citation, $type) {
|
||||
$record = -1;
|
||||
|
||||
// check for DOI first
|
||||
// skip for speed
|
||||
$record = citation::_checkDOI($citation);
|
||||
|
||||
// we don't have DOI
|
||||
if ($record == -1) {
|
||||
|
||||
// while type is hardcoded here due to obvious reasons,
|
||||
// friendly names can indeed be changed in the DB
|
||||
switch ($type) {
|
||||
|
||||
case 1:
|
||||
// Journal article
|
||||
$record = citation::_journal2arr($citation);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
// Book
|
||||
$record = citation::_book2arr($citation);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
// Work paper
|
||||
$record = citation::_workpaper2arr($citation);
|
||||
break;
|
||||
|
||||
case 4:
|
||||
// Conference paper
|
||||
$record = citation::_conference2arr($citation);
|
||||
break;
|
||||
|
||||
case 5:
|
||||
// Report
|
||||
$record = citation::_report2arr($citation);
|
||||
break;
|
||||
|
||||
case 6:
|
||||
// Thesis
|
||||
$record = citation::_thesis2arr($citation);
|
||||
break;
|
||||
|
||||
case 8:
|
||||
// chapter
|
||||
$record = citation::_chapter2arr($citation);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
case 7: // project
|
||||
case 9: // ESRA paper
|
||||
case 10: // newspaper, magazine articles
|
||||
case 11: // manuscripts
|
||||
return -2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $record;
|
||||
}
|
||||
|
||||
private static function _checkDOI ($citation) {
|
||||
$_d = -1;
|
||||
$doi = -1;
|
||||
// check for DOI (must be at the end of citation!)
|
||||
preg_match ('/(.*)doi:(.*)/i', $citation, $hits);
|
||||
|
||||
if (count($hits) == 3) {
|
||||
$doi = trim($hits[2], " \n\r\t\v\0.");
|
||||
}
|
||||
preg_match ('/(.*)doi.org\/(.*)/', $citation, $hits);
|
||||
if (count($hits) == 3) {
|
||||
$doi = trim($hits[2], " \n\r\t\v\0.");
|
||||
}
|
||||
|
||||
if ($doi != -1) {
|
||||
$_d = doi::fetchData($doi);
|
||||
}
|
||||
|
||||
|
||||
return $_d;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static function _book2arr ($citation) {
|
||||
$back = -1;
|
||||
/*
|
||||
* Authors (YEAR). TITLE. City: Publisher.
|
||||
*/
|
||||
preg_match ('/(.*?[^(]+)' // authors - before (
|
||||
. '\(' // (
|
||||
.'([0-9]?[^)]+)' // year - digits before )
|
||||
. '\)\.' // ).
|
||||
.'(.*[^.]+|.*[^?]+)' // title in form 'title.' or 'title?' OR 'title (series)'. Two dots are a problem, sugest changing it to : .
|
||||
.'[\.?]' //
|
||||
.'(.*?[^\:]+)' // City
|
||||
.'[\:]' // series OR dot.
|
||||
.'(.*?[^\.]+)' // publisher
|
||||
.'.*' // junk
|
||||
.'/', $citation, $hits);
|
||||
|
||||
// If everything's OK, we get size of 6
|
||||
if (count($hits)==6) {
|
||||
$hits = citation::_trim ($hits);
|
||||
|
||||
$back = array (
|
||||
'author' => $hits[1],
|
||||
'year' => $hits[2],
|
||||
'title' => $hits[3],
|
||||
'city' => $hits[4],
|
||||
'publisher' => $hits[5]);
|
||||
|
||||
if (strpos ($hits[3], '(')!==false) {
|
||||
|
||||
$tmp = explode ('(', $hits[3]);
|
||||
|
||||
$back['title'] = trim($tmp[0]);
|
||||
$back['series'] = trim($tmp[1], " \(\)\n\r\t\{\}\,\.");
|
||||
}
|
||||
}
|
||||
|
||||
return $back;
|
||||
}
|
||||
|
||||
private static function _trim ($arr) {
|
||||
$back = array();
|
||||
|
||||
foreach ($arr as $offset=>$line) {
|
||||
$line = trim($line, " \n\r\t\{\}\,\.");
|
||||
$line = rtrim($line, "(");
|
||||
$line = rtrim($line, " ");
|
||||
$line = rtrim($line, ",");
|
||||
$line = ltrim($line, ")");
|
||||
$line = ltrim($line, " ");
|
||||
$back[$offset] = ltrim($line, ",");
|
||||
}
|
||||
return $back;
|
||||
}
|
||||
|
||||
private static function _journal2arr ($citation) {
|
||||
|
||||
/*
|
||||
// Authors (year). title. journal, i(v), pages.
|
||||
*
|
||||
*/
|
||||
if (substr ($citation, -1)!='.') {
|
||||
$citation .= '.';
|
||||
}
|
||||
|
||||
preg_match ('/(.*?[^(]+)' // authors - before (
|
||||
. '\(' // (
|
||||
.'([0-9]?[^)]+)' // year - digits before )
|
||||
. '\)\.' // ).
|
||||
.'(.*[^.]+|.*[^?]+)' // title in form 'title.' or 'title?'
|
||||
.'[\.?]'
|
||||
.'(.*?[^0-9]+)' // journal (some have commas, so until ( or digit (pages, volume,...)
|
||||
.'(.*?[^,]+)' // vol/issue (match until comma)
|
||||
.'\,'
|
||||
.'(.*?[^\.\,]+)' // pages (match against , or .)
|
||||
.'(\.|,)' // check for size
|
||||
.'(.*)' // check for size
|
||||
.'/', $citation, $hits);
|
||||
|
||||
if (count($hits) == 9) {
|
||||
|
||||
$hits = citation::_trim($hits);
|
||||
|
||||
return array (
|
||||
'author' => $hits[1],
|
||||
'year' => $hits[2],
|
||||
'title' => $hits[3],
|
||||
'journal' => $hits[4],
|
||||
'issue' => $hits[5],
|
||||
'pages' => $hits[6]
|
||||
);
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
// plan B:
|
||||
// retrieve authors, year, title, journal and leave the rest.
|
||||
preg_match ('/(.*?[^(]+)' // authors - before (
|
||||
. '\(' // (
|
||||
.'([0-9]?[^)]+)' // year - digits before )
|
||||
. '\)\.' // ).
|
||||
.'(.*?[^.]+|.*?[^?]+)' // title in form 'title.' or 'title?'
|
||||
.'[\.?]'
|
||||
.'(.*?[^.]+|.*?[^,]+)' // journal in form 'title.' or 'title?'
|
||||
.'[\.,]'
|
||||
.'(.*)' // check for size
|
||||
.'/', $citation, $hits);
|
||||
|
||||
if (count($hits) == 6 && trim($hits[4]!="")) {
|
||||
|
||||
$hits = citation::_trim($hits);
|
||||
|
||||
return array (
|
||||
'author' => $hits[1],
|
||||
'year' => $hits[2],
|
||||
'title' => $hits[3],
|
||||
'journal' => $hits[4]
|
||||
);
|
||||
}
|
||||
else {
|
||||
echo "\n***Journal article not recognised***\n";
|
||||
print_r ($hits);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static function _workpaper2arr ($citation) {
|
||||
|
||||
/*
|
||||
* This is problematic, as there are many different forms (citation styles).
|
||||
* We're taking Authors (Year). Title. Series. publisher
|
||||
*/
|
||||
|
||||
|
||||
// let's just take out fields 1-3 (authors, year, title (whatever it is)
|
||||
preg_match ('/(.*?[^(]+)' // authors - before (
|
||||
. '\(' // (
|
||||
.'([0-9]?[^)]+)' // year - digits before )
|
||||
. '\)\.' // ).
|
||||
.'(.*[^.]+|.*[^?]+)' // title in form 'title.' or 'title?'
|
||||
.'[\.?]'
|
||||
.'(.*?[^\.]+)' // series
|
||||
.'\.'
|
||||
/* .'(.*?[^\.]+)' // publisher
|
||||
.'[\.]' // check for size */
|
||||
.'(.*)' // check for size
|
||||
.'/', $citation, $hits);
|
||||
|
||||
$hits = citation::_trim($hits);
|
||||
|
||||
// field 3 can be broken. Manual fix needed.
|
||||
return array (
|
||||
'author' => $hits[1],
|
||||
'year' => $hits[2],
|
||||
'title' => $hits[3]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static function _conference2arr ($citation) {
|
||||
|
||||
/*
|
||||
* This is problematic, as there are many different forms (citation styles).
|
||||
* We're taking Authors (Year). Title. - same as working paper
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// let's just take out fields 1-3 (authors, year, title (whatever it is)
|
||||
preg_match ('/(.*?[^(]+)' // authors - before (
|
||||
. '\(' // (
|
||||
.'([0-9]?[^)]+)' // year - digits before )
|
||||
. '\)\.' // ).
|
||||
.'(.*[^.]+|.*[^?]+)' // title in form 'title.' or 'title?'
|
||||
.'[\.?]'
|
||||
.'(.*) for the' //
|
||||
.'(.*?[^,]+)'
|
||||
.','
|
||||
.'(.*)' // check for size
|
||||
.'/', $citation, $hits);
|
||||
|
||||
$hits = citation::_trim($hits);
|
||||
|
||||
// field 3 can be broken. Manual fix needed.
|
||||
return array (
|
||||
'author' => $hits[1],
|
||||
'year' => $hits[2],
|
||||
'title' => $hits[3],
|
||||
'conference' => $hits[5],
|
||||
'city' => $hits[6]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static function _report2arr ($citation) {
|
||||
// this is a mess.
|
||||
// it is most often AUTHORS (YEAR).
|
||||
// but what's next is... random.
|
||||
// title. title. publisher.
|
||||
// or
|
||||
// title. series. publisher.
|
||||
// or
|
||||
// title. title. series. publisher.
|
||||
// or title in series ....
|
||||
// let's just take authors, year, [*], publisher
|
||||
|
||||
$back = -1;
|
||||
/*
|
||||
* Authors (YEAR). TITLE. REPORT_TYPE. Publisher.
|
||||
*/
|
||||
preg_match ('/(.*?[^(]+)' // authors - before (
|
||||
. '\(' // (
|
||||
.'([0-9]?[^)]+)' // year - digits before )
|
||||
. '\)\.' // ).
|
||||
.'(.*[^.])' // title in form 'title.' or 'title?'
|
||||
.'\.'
|
||||
.'(?:(.*?[^\.]+)\.(.*?[^\.]+))|(.*?[^\.]+)' // title in form 'title.' or 'title?' OR 'title (series)'. Two dots are a problem, sugest changing it to : .
|
||||
.'\.'
|
||||
.'(.*)' // rest
|
||||
.'/', $citation, $hits);
|
||||
|
||||
|
||||
// If everything's OK, we get size of 6
|
||||
if (count($hits)==6) {
|
||||
$hits = citation::_trim ($hits);
|
||||
|
||||
$back = array (
|
||||
'author' => $hits[1],
|
||||
'year' => $hits[2],
|
||||
'title' => $hits[3],
|
||||
'publisher' => $hits[4]);
|
||||
|
||||
}
|
||||
|
||||
return $back;
|
||||
}
|
||||
|
||||
private static function _thesis2arr ($citation) {
|
||||
|
||||
|
||||
$back = -1;
|
||||
/*
|
||||
*
|
||||
* Authors (YEAR). TITLE. TYPE. PUBLISHER.
|
||||
*/
|
||||
preg_match ('/(.*?[^(]+)' // authors - before (
|
||||
. '\(' // (
|
||||
.'([0-9]?[^)]+)' // year - digits before )
|
||||
. '\)\.' // ).
|
||||
.'(.*[^.]+|.*[^?]+)' // title in form 'title.' or 'title?'
|
||||
.'[\.?]'
|
||||
.'(.*[^.]+|.*[^,]+)' // type
|
||||
.'[\.\,]'
|
||||
.'(.*[^.]+)' // location
|
||||
.'\.'
|
||||
.'(.*)' // rest
|
||||
.'/', $citation, $hits);
|
||||
|
||||
// If everything's OK, we get size of 6
|
||||
if (count($hits)==7) {
|
||||
$hits = citation::_trim ($hits);
|
||||
|
||||
$back = array (
|
||||
'author' => $hits[1],
|
||||
'year' => $hits[2],
|
||||
'title' => $hits[3],
|
||||
'thesis_type' => $hits[4],
|
||||
'publisher' => $hits[5]);
|
||||
|
||||
}
|
||||
|
||||
return $back;
|
||||
}
|
||||
|
||||
|
||||
private static function _chapter2arr ($citation) {
|
||||
|
||||
|
||||
$back = -1;
|
||||
/*
|
||||
|
||||
|
||||
* Authors (YEAR). TITLE. WHERE (pp) publisher)
|
||||
*/
|
||||
preg_match ('/(.*?[^(]+)' // authors - before (
|
||||
. '\(' // (
|
||||
.'([0-9]?[^)]+)' // year - digits before )
|
||||
. '\)\.' // ).
|
||||
.'(.*[^.]+|.*[^?]+) in ' // title in form 'title. IN' or 'title? IN'
|
||||
// .'([\.?] in )'
|
||||
.'(.*?[^)]+)' // book author before )
|
||||
. '\)' // ).
|
||||
// .'(.*)\(pp' // book
|
||||
.'(.*)\bpp' // book
|
||||
.'(.*?[^)]+)' // pps
|
||||
. '\)[\.\,]' // ).
|
||||
.'(.*[^\:]+)' // location
|
||||
.'\:'
|
||||
.'(.*)' // publisher
|
||||
.'/i', $citation, $hits);
|
||||
|
||||
// If everything's OK, we get size of 6
|
||||
if (count($hits)==9) {
|
||||
$hits = citation::_trim ($hits);
|
||||
|
||||
$back = array (
|
||||
'author' => $hits[1],
|
||||
'year' => $hits[2],
|
||||
'title' => $hits[3],
|
||||
'book_author' => trim(preg_replace ('/(.*?[^(]+)(.*)/', '$1',$hits[4])),
|
||||
'booktitle' => trim ($hits[5], " \n\r\t\v\0("),
|
||||
'pages' => $hits[6],
|
||||
'location' => $hits[7],
|
||||
'publisher' => $hits[8]);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
print_r ($hits);
|
||||
}
|
||||
|
||||
return $back;
|
||||
}
|
||||
}
|
||||
|
26
classes/common.php
Normal file
26
classes/common.php
Normal file
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
class common {
|
||||
|
||||
public static function except ($txt) {
|
||||
|
||||
// in any case, we log it!
|
||||
$fp = fopen(ERROR_LOG, 'a'); //opens file in append mode
|
||||
fwrite($fp, $txt ."\n");
|
||||
fclose($fp);
|
||||
|
||||
if (DEBUG == 1) {
|
||||
echo ($txt);
|
||||
}
|
||||
else {
|
||||
echo ('There has been an error. Please try again later or contact ' .CONTACT);
|
||||
}
|
||||
}
|
||||
|
||||
public static function field2csv($txt) {
|
||||
return str_replace (array ('"', "\n"), array ('', ''), $txt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
128
classes/doi.php
Normal file
128
classes/doi.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Description of doi
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
class doi {
|
||||
//put your code here
|
||||
public static $requests = 0;
|
||||
|
||||
private $doi="x";
|
||||
|
||||
public function __construct() {
|
||||
|
||||
}
|
||||
|
||||
// retrieves DOI data from thw doi server
|
||||
public static function fetchData($doi) {
|
||||
$data = -1;
|
||||
|
||||
if (strlen ($doi) < 1) {
|
||||
return $data;
|
||||
}
|
||||
|
||||
// check if it's already in the DB!
|
||||
if ($db_id = doi::isPublication($doi)) {
|
||||
return $db_id;
|
||||
}
|
||||
|
||||
// limit number of requests (testing, importing huge databases, etc.
|
||||
else if (doi::$requests < DOI_REQ_LIMIT) {
|
||||
$ch = curl_init();
|
||||
|
||||
$headers = array('Accept: application/x-bibtex');
|
||||
|
||||
curl_setopt($ch, CURLOPT_URL, 'http://dx.doi.org/' .$doi);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
|
||||
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
|
||||
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
|
||||
|
||||
if ($res = curl_exec($ch)) {
|
||||
if(!curl_error($ch)) {
|
||||
$data = doi::_bibtex2arr($res);
|
||||
}
|
||||
}
|
||||
|
||||
doi::$requests++;
|
||||
|
||||
curl_close($ch);
|
||||
return $data;
|
||||
}
|
||||
else {
|
||||
return $data ." (OVER DOI_REQ_LIMIT!!!)";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// check if we already have this DOI
|
||||
public static function isPublication($doi) {
|
||||
global $PDO;
|
||||
|
||||
$d_arr = explode ("doi.org/", $doi);
|
||||
if (count ($d_arr)> 1) {
|
||||
$doi = $d_arr[1];
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $PDO->prepare("SELECT id FROM publication where doi=:doi");
|
||||
$stmt->execute(array($doi));
|
||||
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
if ($r = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||
return $r[0];
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// converts from DOI to array (that canbe inserted into the DB)
|
||||
private static function _bibtex2arr($data) {
|
||||
|
||||
$record = array();
|
||||
|
||||
/*
|
||||
@article{R_der_2015,
|
||||
doi = {10.1111/imre.12113},
|
||||
url = {https://doi.org/10.1111%2Fimre.12113},
|
||||
year = 2015,
|
||||
month = {dec},
|
||||
publisher = {{SAGE} Publications},
|
||||
volume = {49},
|
||||
number = {4},
|
||||
pages = {1042--1070},
|
||||
author = {Antje Röder},
|
||||
title = {Immigrants' Attitudes toward Homosexuality: Socialization) Religion, and Acculturation in European Host Societies},
|
||||
journal = {International Migration Review}
|
||||
*
|
||||
* let's make it universal for all kinds of sources:
|
||||
- 1 data field (incl. name) per line (explode \n; trim \r; )
|
||||
- ' = ' is separator; explode, again and name and value. Make sure only to explode ONE TIME
|
||||
*/
|
||||
|
||||
$line_arr = explode ("\n", $data);
|
||||
|
||||
foreach ($line_arr as $line) {
|
||||
$fields = explode ("=", trim($line), 2);
|
||||
|
||||
if (count ($fields) == 2) {
|
||||
$record[trim($fields[0])] = trim($fields[1], " \n\r\t\{\}\,");
|
||||
}
|
||||
}
|
||||
return $record;
|
||||
}
|
||||
}
|
35
classes/lists/_list.php
Normal file
35
classes/lists/_list.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
class _list {
|
||||
|
||||
protected $entity = "";
|
||||
protected $PDO;
|
||||
|
||||
|
||||
public function __construct() {
|
||||
global $PDO;
|
||||
|
||||
$this->PDO = $PDO;
|
||||
$this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
}
|
||||
|
||||
|
||||
public function listAll() {
|
||||
|
||||
// returns an array of all
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("SELECT id, name FROM l_" .$this->entity ." ORDER BY name ASC");
|
||||
$stmt->execute();
|
||||
|
||||
if ($r = $stmt->fetchAll(PDO::FETCH_ASSOC)) {
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
17
classes/lists/country.php
Normal file
17
classes/lists/country.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of country
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
|
||||
class country extends _list {
|
||||
protected $entity = 'country';
|
||||
}
|
52
classes/lists/item.php
Normal file
52
classes/lists/item.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
class item extends _list {
|
||||
protected $entity = "ess_item";
|
||||
|
||||
|
||||
public function getData () {
|
||||
$id = intval($_POST['id']??'');
|
||||
$data = array();
|
||||
|
||||
if (strlen ($id) > 0) {
|
||||
|
||||
// Block, label, text, name
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("SELECT name, label, txt, block FROM l_ess_item WHERE id=:id");
|
||||
$stmt->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$stmt->execute();
|
||||
|
||||
if ($r = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
$data = $r;
|
||||
}
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function listAll() {
|
||||
|
||||
// returns an array of all
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("SELECT id, CONCAT(name, ' (', substring(label, 1, 80), IF(LENGTH(label)>80,'...',''), ')') as name FROM l_" .$this->entity ." ORDER BY id ASC");
|
||||
$stmt->execute();
|
||||
|
||||
if ($r = $stmt->fetchAll(PDO::FETCH_ASSOC)) {
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
19
classes/lists/journalField.php
Normal file
19
classes/lists/journalField.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of country
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
|
||||
class journalField extends _list {
|
||||
protected $entity = 'journalField';
|
||||
}
|
||||
|
||||
|
17
classes/lists/language.php
Normal file
17
classes/lists/language.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of country
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
|
||||
class language extends _list {
|
||||
protected $entity = 'language';
|
||||
}
|
17
classes/lists/module.php
Normal file
17
classes/lists/module.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of country
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
|
||||
class module extends _list {
|
||||
protected $entity = 'module';
|
||||
}
|
17
classes/lists/pubType.php
Normal file
17
classes/lists/pubType.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of country
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
|
||||
class pubType extends _list {
|
||||
protected $entity = 'pubType';
|
||||
}
|
37
classes/lists/round.php
Normal file
37
classes/lists/round.php
Normal file
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of country
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
|
||||
class round extends _list {
|
||||
protected $entity = 'ess_round';
|
||||
|
||||
|
||||
public function listAll() {
|
||||
|
||||
// returns an array of all
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("SELECT id, CONCAT(name, ' (', year, ')') as name FROM l_" .$this->entity ." ORDER BY year ASC");
|
||||
$stmt->execute();
|
||||
|
||||
if ($r = $stmt->fetchAll(PDO::FETCH_ASSOC)) {
|
||||
return $r;
|
||||
}
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
17
classes/lists/topic.php
Normal file
17
classes/lists/topic.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of country
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
|
||||
class topic extends _list {
|
||||
protected $entity = 'topic';
|
||||
}
|
319
classes/publications/_publication.php
Normal file
319
classes/publications/_publication.php
Normal file
@ -0,0 +1,319 @@
|
||||
<?php
|
||||
|
||||
class _publication {
|
||||
|
||||
protected $PDO;
|
||||
protected $pub_name; // name of publication
|
||||
protected $pub_year = 0; // year of publication
|
||||
protected $authors, // array of author IDs
|
||||
$authorsCountries,
|
||||
$abstract_orig,
|
||||
$abstract_eng,
|
||||
$id,
|
||||
$id_manual,
|
||||
$citation,
|
||||
$language=2,
|
||||
$type = -1; // this needs to be set in derived class!
|
||||
protected $city;
|
||||
protected $publisher;
|
||||
protected $publisher_id = -1;
|
||||
protected $fromPage = 0;
|
||||
protected $toPage = 0;
|
||||
protected $DOI = "";
|
||||
|
||||
|
||||
public function __construct($name="") {
|
||||
global $PDO;
|
||||
|
||||
$this->PDO = $PDO;
|
||||
$this->pub_name = $name;
|
||||
if ($this->pub_name != "") {
|
||||
$this->_cleanName();
|
||||
}
|
||||
}
|
||||
|
||||
public function setDOI ($doi) {
|
||||
$this->DOI = $doi;
|
||||
return;
|
||||
}
|
||||
|
||||
public function setName ($name) {
|
||||
$this->pub_name = $this->_cleanField($name);
|
||||
}
|
||||
|
||||
public function setLanguage ($language) {
|
||||
$this->language = $this->_cleanField($language);
|
||||
}
|
||||
|
||||
|
||||
public function setAbstractOrig ($abstract) {
|
||||
$this->abstract_orig= $this->_cleanField($abstract);
|
||||
}
|
||||
|
||||
public function setAbstractEng ($abstract) {
|
||||
$this->abstract_eng= $this->_cleanField($abstract);
|
||||
}
|
||||
|
||||
public function setAuthors ($authors) {
|
||||
$this->authors = $authors;
|
||||
}
|
||||
public function setAuthorsCountries ($authorsCountries) {
|
||||
$this->authorsCountries = $authorsCountries;
|
||||
}
|
||||
|
||||
public function setYear ($year) {
|
||||
if ($year < 10000) {
|
||||
$this->pub_year = $year;
|
||||
}
|
||||
}
|
||||
|
||||
public function setCity ($city) {
|
||||
$this->city = $this->_cleanField($city);
|
||||
}
|
||||
|
||||
public function setPublisher($publisher) {
|
||||
$this->publisher = $this->_cleanField($publisher);
|
||||
}
|
||||
|
||||
public function setCitation ($citation) {
|
||||
if (strlen($citation)>3) $this->citation = $citation;
|
||||
else $this->citation = NULL;
|
||||
|
||||
}
|
||||
|
||||
public function setId_manual ($id_manual) {
|
||||
$this->id_manual = $id_manual;
|
||||
}
|
||||
|
||||
|
||||
protected function _cleanField($in) {
|
||||
// make sure it is in form Surname, N. no leading/trailing whitespaces, no double whitespaces,...)
|
||||
// also remove dot (and add it again, later)
|
||||
return trim ($in, " \n\r\t\v\0.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Add record (after fields are set)
|
||||
*
|
||||
* @param type $authors_processed set to true if you have array of author ids
|
||||
* @return boolean
|
||||
*/
|
||||
public function add($authors_processed=true, &$already_in=false) {
|
||||
|
||||
// first make sure that publication is in. This also sets publication id ($this->id)
|
||||
if (!$this->_isPublication()) {
|
||||
if (!$this->_addPublication()) {
|
||||
common::except ('Err cannot add publication, terminating (in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__ .')');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// set id manual if needed
|
||||
$this->_is_ID_manual();
|
||||
$alredy_in = true;
|
||||
}
|
||||
|
||||
$this->_linkAuthors($authors_processed);
|
||||
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
protected function _isPublisher() {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("SELECT id FROM l_publisher where name=:name");
|
||||
$stmt->execute(array($this->publisher));
|
||||
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
if ($r = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||
$this->publisher_id = $r[0];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _addPublisher() {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("INSERT INTO l_publisher (name) VALUES (:name)");
|
||||
$stmt->execute(array($this->publisher));
|
||||
|
||||
$this->publisher_id = $this->PDO->lastInsertId();
|
||||
return true;
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function _is_ID_manual() {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("SELECT IF(ISNULL(id_manual),0,id_manual) as idm FROM publication where id=:id");
|
||||
$stmt->execute(array($this->id));
|
||||
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
if ($r = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||
|
||||
if ($r[0] == 0) {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("UPDATE publication SET id_manual=:id_manual where id=:id");
|
||||
$stmt->execute(array('id_manual'=>$this->id_manual, 'id'=>$this->id));
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// links authors to publications
|
||||
protected function _linkAuthors($authors_processed = false) {
|
||||
|
||||
// link authors from array in $this->authors
|
||||
foreach ($this->authors as $offset=>$author) {
|
||||
|
||||
// in case of import from citation (no author IDS)
|
||||
if (!$authors_processed) {
|
||||
$author = author::isAuthor($author);
|
||||
}
|
||||
|
||||
$country = $this->authorsCountries[$offset]??NULL;
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("REPLACE INTO dict_pub_author (id_person, id_publication, ord, id_country) VALUES (:author, :pub, :ord, :country)");
|
||||
$stmt->execute(array(
|
||||
'author' => $author,
|
||||
'pub' => $this->id,
|
||||
'ord' => ($offset+1),
|
||||
'country' => $country));
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
// this is only a placeholder and *MUST GET IMPLEMENTED FOR DERIVED CLASSES*
|
||||
/*
|
||||
protected function _addMaster() {
|
||||
common::except ('PLEASE CREATE DERIVED _addMaster for this type of literature! (in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__ .')');
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
protected function _addPublication() {
|
||||
|
||||
if (!$master_id = $this->_addMaster()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->type == -1) {
|
||||
common::except ('PLEASE set pub type in derived class!!! (in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__ .')');
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("INSERT INTO publication (citation, title_eng, year, type, id_manual, id_parent, doi, abstract_orig, abstract_eng, id_language) VALUES (:citation, :title, :year, :type, :id_manual, :id_master, :doi, :abstract_orig, :abstract_eng, :id_language)");
|
||||
$stmt->execute(array(
|
||||
'citation' => $this->citation,
|
||||
'title' => $this->pub_name,
|
||||
'year' => $this->pub_year,
|
||||
'type' => $this->type,
|
||||
'id_manual' => $this->id_manual,
|
||||
'id_master' => $master_id,
|
||||
'doi' => $this->DOI,
|
||||
'abstract_orig' => $this->abstract_orig,
|
||||
'abstract_eng' => $this->abstract_eng,
|
||||
'id_language' => $this->language));
|
||||
|
||||
$this->id = $this->PDO->lastInsertId();
|
||||
return true;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected function _isPublication () {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("SELECT id, doi FROM publication where title_eng = :title_eng AND year=:year AND type=:type");
|
||||
$stmt->execute(array('title_eng' => $this->pub_name, 'year' => $this->pub_year, 'type' => $this->type));
|
||||
|
||||
if ($r = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||
$this->id = $r[0];
|
||||
|
||||
// UPDATE DOI
|
||||
if ($this->DOI != "" && $r[1] == "") {
|
||||
$this->_updateDOI();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function _updateDOI() {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("UPDATE publication SET doi=:doi WHERE id=:id");
|
||||
$stmt->execute(array(
|
||||
'id' => $this->id,
|
||||
'doi' => $this->DOI));
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function setPages ($pages) {
|
||||
// doi returns as a--b
|
||||
$pages = str_replace ("--", "-", $pages);
|
||||
|
||||
$pps = explode ("-", preg_replace('/[^\d-]/', '', $pages));
|
||||
$this->fromPage = preg_replace ('/\D/', '', $pps[0]);
|
||||
if ($this->fromPage > 32000) {
|
||||
$this->fromPage = 0;
|
||||
}
|
||||
|
||||
if (count ($pps) > 1) {
|
||||
$this->toPage = preg_replace ('/\D/', '', $pps[1]);
|
||||
if ($this->toPage > 32000) {
|
||||
$this->toPage = 0;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
43
classes/publications/book.php
Normal file
43
classes/publications/book.php
Normal file
@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
class book extends _publication {
|
||||
|
||||
protected $type = 2;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// each type has its own master record
|
||||
// THIS ONLY ADDS article (master of publication)
|
||||
protected function _addMaster() {
|
||||
|
||||
if (!$this->_isPublisher()) {
|
||||
$this->_addPublisher();
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("INSERT INTO p_book (title, id_publisher, city) VALUES (:title, :id_publisher, :city)");
|
||||
|
||||
$stmt->execute(array(
|
||||
'title' => $this->pub_name,
|
||||
'id_publisher' => $this->publisher_id,
|
||||
'city' => $this->city));
|
||||
|
||||
$master_id = $this->PDO->lastInsertId();
|
||||
|
||||
return $master_id;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
128
classes/publications/chapter.php
Normal file
128
classes/publications/chapter.php
Normal file
@ -0,0 +1,128 @@
|
||||
<?php
|
||||
|
||||
class chapter extends _publication {
|
||||
|
||||
protected $type = 8;
|
||||
private $book_title = "";
|
||||
private $id_book = 0;
|
||||
private $book_authors = "";
|
||||
|
||||
|
||||
public function setBookTitle($title) {
|
||||
$this->book_title = $title;
|
||||
}
|
||||
|
||||
public function setBookAuthors($authors) {
|
||||
$this->book_authors = $authors;
|
||||
}
|
||||
// each type has its own master record
|
||||
// THIS ONLY ADDS article (master of publication)
|
||||
protected function _addMaster() {
|
||||
|
||||
|
||||
|
||||
// first process book p_Book: book_title, book_authors, publisher, city
|
||||
// then book authors dict_book_author: id_book,. id_author, order [those are here]
|
||||
// then chapter p_bookchapter: ID_BOOK, FROM_PAGE, TO_PAGE
|
||||
|
||||
|
||||
if (!$this->_isPublisher()) {
|
||||
$this->_addPublisher();
|
||||
}
|
||||
|
||||
if (!$this->_isMasterBook()) {
|
||||
$this->_addMasterBook();
|
||||
}
|
||||
|
||||
if ($this->id_book > 0) {
|
||||
$this->_linkBookAuthors();
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("REPLACE INTO p_bookChapter (id_book, fromPage, toPage) VALUES (:id_book, :fromPage, :toPage)");
|
||||
$stmt->execute(array(
|
||||
'id_book' => $this->id_book,
|
||||
'fromPage' => $this->fromPage,
|
||||
'toPage' => $this->toPage));
|
||||
|
||||
return $this->PDO->lastInsertId();
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
echo "FromPage: " .$this->fromPage .", topage: " .$this->toPage ."\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
else {
|
||||
common::except ('Couldnt get book id (for chapter)- in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
// links authors to publications
|
||||
protected function _linkBookAuthors() {
|
||||
// link authors from array in $this->authors
|
||||
foreach ($this->book_authors as $offset=>$author) {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("REPLACE INTO dict_book_author (id_author, id_book, `order`) VALUES (:author, :pub, :ord)");
|
||||
$stmt->execute(array(
|
||||
'author' => author::isAuthor($author), // convert citation into ID!
|
||||
'pub' => $this->id,
|
||||
'ord' => ($offset+1)));
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private function _isMasterBook () {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("SELECT id FROM p_book where title = :book_title AND chapter=1 AND city=:city AND id_publisher=:id_publisher");
|
||||
$stmt->execute(array('book_title' => $this->book_title, 'city' => $this->city, 'id_publisher' => $this->publisher_id));
|
||||
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
if ($r = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||
$this->id_book = $r[0];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function _addMasterBook() {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("INSERT INTO p_book (title, id_publisher, city, chapter) VALUES (:title, :id_publisher, :city, 1)");
|
||||
|
||||
$stmt->execute(array(
|
||||
'title' => $this->book_title,
|
||||
'id_publisher' => $this->publisher_id,
|
||||
'city' => $this->city));
|
||||
|
||||
$this->id_book = $this->PDO->lastInsertId();
|
||||
return true;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
113
classes/publications/conferencePP.php
Normal file
113
classes/publications/conferencePP.php
Normal file
@ -0,0 +1,113 @@
|
||||
<?php
|
||||
|
||||
class conferencePP extends _publication {
|
||||
|
||||
protected $type = 4;
|
||||
private $conference_name = "";
|
||||
private $conference_city = "";
|
||||
private $conference_start = NULL;
|
||||
private $conference_end = NULL;
|
||||
private $id_conference = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
public function setConferenceName ($name) {
|
||||
$this->conference_name = $this->_cleanField($name);
|
||||
}
|
||||
|
||||
public function setConferenceCity ($city) {
|
||||
$this->conference_city = $this->_cleanField($city);
|
||||
}
|
||||
|
||||
// it should be double-master (publication->p_conferencePP->conference
|
||||
// but we only get that data from DOI as we don't have standard form
|
||||
protected function _addMaster() {
|
||||
|
||||
if (!$this->_isConference()) {
|
||||
$this->_addConference();
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
// citation is not standardized, so we cannot get details.
|
||||
// just insert it to get ID
|
||||
$stmt = $this->PDO->prepare("INSERT INTO p_conferencePP (type, id_conference) VALUES ('paper', :id_conference)");
|
||||
|
||||
$stmt->execute(array('id_conference'=>$this->id_conference));
|
||||
|
||||
$master_id = $this->PDO->lastInsertId();
|
||||
|
||||
return $master_id;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private function _isConference() {
|
||||
try {
|
||||
|
||||
$check_array = array ('conference_name' => $this->conference_name,
|
||||
'location'=> $this->conference_city);
|
||||
|
||||
$check_start = "startDate IS NULL";
|
||||
if ($this->conference_start != '') {
|
||||
$check_start = "startDate=:startDate";
|
||||
$check_array['startDate'] = $this->conference_start;
|
||||
}
|
||||
|
||||
$check_end = "endDate IS NULL";
|
||||
if ($this->conference_end != '') {
|
||||
$check_end = "endDate=:endDate";
|
||||
$check_array['endDate'] = $this->conference_end;
|
||||
}
|
||||
|
||||
$stmt = $this->PDO->prepare("SELECT id FROM l_conference where name = :conference_name AND location=:location and " .$check_start ." AND " .$check_end);
|
||||
$stmt->execute($check_array);
|
||||
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
if ($r = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||
$this->id_conference = $r[0];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private function _addConference() {
|
||||
try {
|
||||
|
||||
|
||||
$stmt = $this->PDO->prepare("INSERT INTO l_conference (name, location, startDate, endDate) VALUES (:name, :location, :startDate, :endDate)");
|
||||
|
||||
$stmt->execute(array(
|
||||
'name' => $this->conference_name,
|
||||
'location' => $this->conference_city,
|
||||
'startDate' => $this->conference_start,
|
||||
'endDate' => $this->conference_end,
|
||||
));
|
||||
|
||||
$this->id_conference = $this->PDO->lastInsertId();
|
||||
return true;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
147
classes/publications/journalArticle.php
Normal file
147
classes/publications/journalArticle.php
Normal file
@ -0,0 +1,147 @@
|
||||
<?php
|
||||
|
||||
class journalArticle extends _publication {
|
||||
|
||||
private $journal_name = "";
|
||||
private $journal_id = "";
|
||||
private $article_id = "";
|
||||
private $volume = 0;
|
||||
private $issue = 0;
|
||||
protected $type = 1;
|
||||
|
||||
public function setJournal($name) {
|
||||
$this->journal_name = $name;
|
||||
return;
|
||||
}
|
||||
|
||||
public function setVolumeIssue($volumeIssue) {
|
||||
/* volume (issue) */
|
||||
$vi = explode ("(", preg_replace('/[^\d(]/', '', $volumeIssue));
|
||||
$this->volume = preg_replace ('/\D/', '', $vi[0]);
|
||||
|
||||
if (count ($vi)>1) {
|
||||
$this->issue = preg_replace ('/\D/', '', $vi[1]);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
public function setVolume($volume) {
|
||||
/* volume (issue) */
|
||||
$this->volume = preg_replace ('/\D/', '', $volume);
|
||||
return;
|
||||
}
|
||||
public function setIssue($issue) {
|
||||
|
||||
$this->issue = preg_replace ('/\D/', '', $issue);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// each type has its own master record
|
||||
// THIS ONLY ADDS article (master of publication)
|
||||
protected function _addMaster() {
|
||||
|
||||
$this->type = 1;
|
||||
|
||||
if (!$this->_isJournal()) {
|
||||
if (!$this->_addJournal()) {
|
||||
common::except ('Err cannot add journal, terminating (in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__ .')');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->_isArticle()) {
|
||||
if (!$this->_addArticle()) {
|
||||
common::except ('Err cannot add journal article, terminating (in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__ .')');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->article_id;
|
||||
|
||||
}
|
||||
|
||||
private function _isArticle() {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("SELECT id FROM p_journalArticle WHERE id_journal=:id_journal AND volume=:volume AND issue=:issue AND fromPage=:fromPage AND toPage=:toPage");
|
||||
$stmt->execute(array(
|
||||
'id_journal' => $this->journal_id,
|
||||
'volume' => $this->volume,
|
||||
'issue' => $this->issue,
|
||||
'fromPage' => $this->fromPage,
|
||||
'toPage' => $this->toPage));
|
||||
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
if ($r = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||
$this->article_id = $r[0];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
private function _addArticle() {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("INSERT INTO p_journalArticle (id_journal, volume, issue, fromPage, toPage) VALUES (:id_journal, :volume, :issue, :fromPage, :toPage)");
|
||||
$stmt->execute(array(
|
||||
'id_journal' => $this->journal_id,
|
||||
'volume' => intval($this->volume),
|
||||
'issue' => intval($this->issue),
|
||||
'fromPage' => intval($this->fromPage),
|
||||
'toPage' => intval($this->toPage)));
|
||||
|
||||
$this->article_id = $this->PDO->lastInsertId();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function _addJournal() {
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("INSERT INTO l_journal (name) VALUES (:name)");
|
||||
$stmt->execute(array($this->journal_name));
|
||||
|
||||
$this->journal_id = $this->PDO->lastInsertId();
|
||||
return true;
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private function _isJournal() {
|
||||
try {
|
||||
for ($x=1; $x<=2; $x++) {
|
||||
$stmt = $this->PDO->prepare("SELECT id FROM l_journal where name=:name " .($x==1?'AND id_issn!="" ':'') ." order by id asc");
|
||||
$stmt->execute(array($this->journal_name));
|
||||
|
||||
// this instead of rowCount to make in compatible with non-mysql DB
|
||||
if ($r = $stmt->fetch(PDO::FETCH_NUM)) {
|
||||
$this->journal_id = $r[0];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
40
classes/publications/report.php
Normal file
40
classes/publications/report.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
class report extends _publication {
|
||||
|
||||
protected $type = 5;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// each type has its own master record
|
||||
// THIS ONLY ADDS article (master of publication)
|
||||
protected function _addMaster() {
|
||||
|
||||
if (!$this->_isPublisher()) {
|
||||
$this->_addPublisher();
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("INSERT INTO p_report (id_inst) VALUES (:id_publisher)");
|
||||
|
||||
$stmt->execute(array('id_publisher' => $this->publisher_id));
|
||||
|
||||
$master_id = $this->PDO->lastInsertId();
|
||||
|
||||
return $master_id;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
52
classes/publications/thesis.php
Normal file
52
classes/publications/thesis.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
class thesis extends _publication {
|
||||
|
||||
protected $type = 6;
|
||||
private $thesis_type = "N/A";
|
||||
|
||||
public function setThesisType($txt) {
|
||||
|
||||
if (strpos ($txt, 'bachelor')!==false) {
|
||||
$this->thesis_type = 'bachelor';
|
||||
}
|
||||
else if (strpos ($txt, 'doctor')!==false) {
|
||||
$this->thesis_type = 'dissertation';
|
||||
}
|
||||
else if (strpos ($txt, 'master')!==false) {
|
||||
$this->thesis_type = 'thesis';
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// each type has its own master record
|
||||
// THIS ONLY ADDS article (master of publication)
|
||||
protected function _addMaster() {
|
||||
|
||||
if (!$this->_isPublisher()) {
|
||||
$this->_addPublisher();
|
||||
}
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare("INSERT INTO p_thesis (id_inst, type) VALUES (:id_publisher, :type)");
|
||||
|
||||
$stmt->execute(array('id_publisher' => $this->publisher_id,
|
||||
'type'=>$this->thesis_type));
|
||||
|
||||
$master_id = $this->PDO->lastInsertId();
|
||||
|
||||
return $master_id;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
42
classes/publications/workpaper.php
Normal file
42
classes/publications/workpaper.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
class workpaper extends _publication {
|
||||
|
||||
protected $type = 3;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// each type has its own master record
|
||||
// THIS ONLY ADDS article (master of publication)
|
||||
protected function _addMaster() {
|
||||
|
||||
if (!$this->_isPublisher()) {
|
||||
$this->_addPublisher();
|
||||
}
|
||||
|
||||
try {
|
||||
// citation is not standardized, so we cannot get details.
|
||||
// just insert it to get ID
|
||||
$stmt = $this->PDO->prepare("INSERT INTO p_workPaper (id_inst) VALUES (:publisher)");
|
||||
|
||||
$stmt->execute(array('publisher'=>$this->publisher_id));
|
||||
|
||||
$master_id = $this->PDO->lastInsertId();
|
||||
|
||||
return $master_id;
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
124
classes/publish.php
Normal file
124
classes/publish.php
Normal file
@ -0,0 +1,124 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class for publishing, updating, deleting, approving entries
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
class publish extends _import {
|
||||
|
||||
private $authors = [],
|
||||
$authors_countries = []; // same order as above, country ids for dict_pub_author.id_country
|
||||
|
||||
protected $publication_id = 0;
|
||||
|
||||
/**
|
||||
* Add entry for the consideration (review)
|
||||
*
|
||||
* @param type $json_data Json data from the form
|
||||
*/
|
||||
public function consider($json_data) {
|
||||
|
||||
$data = json_decode(htmlspecialchars_decode($json_data));
|
||||
|
||||
$this->current_recors['topic'] = [];
|
||||
$this->current_recors['module'] = [];
|
||||
$this->current_recors['round'] = [];
|
||||
$this->current_recors['item'] = [];
|
||||
|
||||
foreach ($data as $element) {
|
||||
switch ($element->name) {
|
||||
|
||||
case 'topic':
|
||||
case 'item':
|
||||
case 'module':
|
||||
case 'round':
|
||||
$this->current_record[$element->name][] = $element->value;
|
||||
break;
|
||||
|
||||
default:
|
||||
$this->current_record[$element->name] = $element->value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$this->compose_authors()) {
|
||||
return "ERROR";
|
||||
}
|
||||
|
||||
// Prepare array for _import::add_publication
|
||||
$this->prep_array();
|
||||
|
||||
if (!$this->publication_id = $this->add_publication(true)) {
|
||||
return ('Record already exists in the database.');
|
||||
}
|
||||
|
||||
$this->linkItems();
|
||||
$this->linkModules();
|
||||
$this->linkTopics();
|
||||
$this->linkrounds();
|
||||
|
||||
return ("OK");
|
||||
}
|
||||
|
||||
private function prep_array() {
|
||||
// currently for journal article only
|
||||
$this->current_record['citation_data'] = array();
|
||||
$this->current_record['citation_data']['journal'] = $this->current_record['journalName']??'';
|
||||
$this->current_record['citation_data']['title'] = $this->current_record['title']??'';
|
||||
$this->current_record['citation_data']['doi'] = $this->current_record['doi']??'';
|
||||
$this->current_record['citation_data']['volume'] = $this->current_record['volume']??'';
|
||||
$this->current_record['citation_data']['issue'] = $this->current_record['issue']??'';
|
||||
$this->current_record['citation_data']['number'] = $this->current_record['issue']??'';
|
||||
$this->current_record['citation_data']['abstract_eng'] = $this->current_record['abstract_eng']??'';
|
||||
$this->current_record['citation_data']['abstract_orig'] = $this->current_record['abstract_orig']??'';
|
||||
$this->current_record['citation_data']['number'] = $this->current_record['issue']??'';
|
||||
$this->current_record['citation_data']['pages'] = $this->current_record['fromPage'] . '--' .$this->current_record['toPage'];
|
||||
$this->current_record['citation'] = $this->current_record['citation']??NULL;
|
||||
|
||||
$this->current_record['year_pub'] = $this->current_record['year']??'';
|
||||
$this->current_record['type'] = $this->current_record['pubType']??'';
|
||||
|
||||
if ($this->current_record['language'] == -1) {
|
||||
$this->current_record['language'] = $this->newLanguage($this->current_record['newLang']);
|
||||
}
|
||||
else {
|
||||
$this->current_record['language'] = $this->current_record['language']??'';
|
||||
}
|
||||
$this->current_record['author_data'] = $this->authors;
|
||||
$this->current_record['author_countries'] = $this->authors_countries;
|
||||
}
|
||||
|
||||
|
||||
// make sure you insert them
|
||||
private function compose_authors () {
|
||||
// up to 99 authors
|
||||
for ($num=1; $num<100; $num++) {
|
||||
|
||||
// if author n=x exists
|
||||
if (isset ($this->current_record['auth' .$num .'name1'])) {
|
||||
|
||||
// get the ID
|
||||
$auth_id = author::findOrAdd(
|
||||
$this->current_record['auth' .$num .'name1'],
|
||||
$this->current_record['auth' .$num .'name2'],
|
||||
$this->current_record['auth' .$num .'lastname'],
|
||||
$this->current_record['auth' .$num .'lastname2'],
|
||||
$this->current_record['auth' .$num .'citation']);
|
||||
|
||||
if ($auth_id!=false) {
|
||||
$this->authors[] = $auth_id;
|
||||
$this->authors_countries[] = $this->current_record['auth' .$num .'affil'];
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
25
classes/record.php
Normal file
25
classes/record.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Description of record
|
||||
*
|
||||
* @author may
|
||||
*/
|
||||
class record {
|
||||
//put your code here
|
||||
protected $PDO;
|
||||
|
||||
public function __construct() {
|
||||
global $PDO;
|
||||
|
||||
$this->PDO = $PDO;
|
||||
|
||||
}
|
||||
|
||||
}
|
91
classes/search.php
Normal file
91
classes/search.php
Normal file
@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
class search {
|
||||
|
||||
private $PDO;
|
||||
|
||||
public function __construct() {
|
||||
global $PDO;
|
||||
|
||||
$this->PDO = $PDO;
|
||||
$this->PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
}
|
||||
|
||||
public function query () {
|
||||
$txt = $_POST['txt']??'';
|
||||
|
||||
// search by NAME, LABEL, TXT
|
||||
$query = 'SELECT id, block, name, label FROM l_ess_item WHERE id=:id ';
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare($query);
|
||||
$stmt->execute(array($id));
|
||||
|
||||
// let's make it easier to format by doing it here instead of in SQL
|
||||
if ($r = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
// return json array so the client forms it
|
||||
|
||||
return array (
|
||||
'id' => $r['id'],
|
||||
'name' => $r['name'],
|
||||
'label' => $r['label'],
|
||||
'block' => $r['block']);
|
||||
|
||||
}
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
}
|
||||
|
||||
public function txtSearch($suggestions=false) {
|
||||
$back = array(); // this we return
|
||||
$txt = $_POST['txt']??'';
|
||||
|
||||
if (strlen ($txt) > 0) {
|
||||
// search by NAME, LABEL, TXT
|
||||
$query = 'SELECT DISTINCT '
|
||||
."id, block, name, label, txt, 100 as factor FROM l_ess_item WHERE name LIKE (?) UNION SELECT "
|
||||
."id, block, name, label, txt, 80 as factor FROM l_ess_item where label LIKE (?) UNION SELECT "
|
||||
."id, block, name, label, txt, 60 as factor FROM l_ess_item where txt LIKE (?) UNION SELECT "
|
||||
."id, block, name, label, txt, 40 as factor FROM l_ess_item where name LIKE (?) UNION SELECT "
|
||||
."id, block, name, label, txt, 20 as factor FROM l_ess_item where label LIKE (?) UNION SELECT "
|
||||
."id, block, name, label, txt, 10 as factor FROM l_ess_item where txt LIKE (?) "
|
||||
."ORDER BY factor desc " .($suggestions == true?' limit 10':'');
|
||||
|
||||
try {
|
||||
$stmt = $this->PDO->prepare($query);
|
||||
$txta= $txt .'%';
|
||||
$txtb= '%' .$txt .'%';
|
||||
|
||||
$stmt->execute(array($txta, $txta, $txta, $txtb, $txtb, $txtb));
|
||||
|
||||
while ($r = $stmt->fetch(PDO::FETCH_ASSOC)) {
|
||||
|
||||
// return json array so the client forms it as they wish
|
||||
$back[] = array (
|
||||
'id' => $r['id'],
|
||||
'name' => $r['name'],
|
||||
'label' => $r['label'],
|
||||
'block' => $r['block'],
|
||||
'txt' => $r['txt']);
|
||||
|
||||
}
|
||||
return $back;
|
||||
|
||||
}
|
||||
catch (exception $ex) {
|
||||
common::except ('Err: ' .$ex .' in ' .__DIR__ .'/' .__FILE__ .':' .__LINE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function basicSearch() {
|
||||
|
||||
return '<div><a onclick="#">Prvi predlog</a></div>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
5
import.bash
Executable file
5
import.bash
Executable file
@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
mysqldump -u root ess_biblio > backups/ess_biblio_$(date +%s).sql
|
||||
# mysql -u root ess_biblio < ess2new.sql
|
||||
|
23
import_scholar.php
Normal file
23
import_scholar.php
Normal file
@ -0,0 +1,23 @@
|
||||
MAKE pre-flight check!
|
||||
<br><br>
|
||||
DID YOU READ PRE-FLIGHT CHECK?
|
||||
<?php
|
||||
|
||||
include_once('settings.php');
|
||||
|
||||
|
||||
$import = new _import();
|
||||
// reads parses the citation and adds biblio
|
||||
|
||||
//$import->readTXT($site_path .'imports/2022/0-2021-A-rev1.txt', "A");
|
||||
|
||||
// linkTXT only links items, topics, etc. to existing db.
|
||||
// it's working on id_manual
|
||||
|
||||
//$import->linkTXT($site_path .'FULLB.txt', "B");
|
||||
//$import->linkTXT($site_path .'FULLC.txt', "C");
|
||||
|
||||
// BrinaMeta
|
||||
$import->linkScholar($site_path .'imports/2022/0-2021-scholar_updates.txt');
|
||||
|
||||
?>
|
BIN
imports/2021/1_ESS 2003-2019 Publications with A-Core.ods
Normal file
BIN
imports/2021/1_ESS 2003-2019 Publications with A-Core.ods
Normal file
Binary file not shown.
BIN
imports/2021/1_ESS 2003-2019 Publications with A-Core.xlsx
Normal file
BIN
imports/2021/1_ESS 2003-2019 Publications with A-Core.xlsx
Normal file
Binary file not shown.
1048611
imports/2021/3_ESS 2003-2019 Publications with C-Core.csv
Normal file
1048611
imports/2021/3_ESS 2003-2019 Publications with C-Core.csv
Normal file
File diff suppressed because it is too large
Load Diff
4914
imports/2021/FULLA.txt
Normal file
4914
imports/2021/FULLA.txt
Normal file
File diff suppressed because it is too large
Load Diff
4914
imports/2021/FULLB.txt
Normal file
4914
imports/2021/FULLB.txt
Normal file
File diff suppressed because it is too large
Load Diff
4914
imports/2021/FULLC.txt
Normal file
4914
imports/2021/FULLC.txt
Normal file
File diff suppressed because it is too large
Load Diff
BIN
imports/2021/Google_Scholar_3_2003-2019Final.sav
Normal file
BIN
imports/2021/Google_Scholar_3_2003-2019Final.sav
Normal file
Binary file not shown.
4914
imports/2021/brinaScholar_ti_import.csv
Normal file
4914
imports/2021/brinaScholar_ti_import.csv
Normal file
File diff suppressed because it is too large
Load Diff
5973
imports/2022/0-2021-A-rev1.txt
Normal file
5973
imports/2022/0-2021-A-rev1.txt
Normal file
File diff suppressed because it is too large
Load Diff
5973
imports/2022/0-2021-covid.txt
Normal file
5973
imports/2022/0-2021-covid.txt
Normal file
File diff suppressed because it is too large
Load Diff
5973
imports/2022/0-2021-scholar_updates.txt
Normal file
5973
imports/2022/0-2021-scholar_updates.txt
Normal file
File diff suppressed because it is too large
Load Diff
6
nbproject/private/private.properties
Normal file
6
nbproject/private/private.properties
Normal file
@ -0,0 +1,6 @@
|
||||
copy.src.files=false
|
||||
copy.src.on.open=false
|
||||
copy.src.target=/var/www/biblio_backend
|
||||
index.file=
|
||||
run.as=LOCAL
|
||||
url=http://localhost/backend/
|
7
nbproject/project.properties
Normal file
7
nbproject/project.properties
Normal file
@ -0,0 +1,7 @@
|
||||
include.path=${php.global.include.path}
|
||||
php.version=PHP_80
|
||||
source.encoding=UTF-8
|
||||
src.dir=.
|
||||
tags.asp=false
|
||||
tags.short=false
|
||||
web.root=.
|
9
nbproject/project.xml
Normal file
9
nbproject/project.xml
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||
<type>org.netbeans.modules.php.project</type>
|
||||
<configuration>
|
||||
<data xmlns="http://www.netbeans.org/ns/php-project/1">
|
||||
<name>biblio_backend</name>
|
||||
</data>
|
||||
</configuration>
|
||||
</project>
|
63
settings.php
Normal file
63
settings.php
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
define ('SITE_PATH', '/var/www/biblio_back/');
|
||||
define ("DEBUG", 1);
|
||||
define ("CONTACT", 'May at may.dousak @ fdv.uni-lj.si');
|
||||
define ("ERROR_LOG", SITE_PATH .'logs/err.log');
|
||||
define ('FILE_LINES_LIMIT', 10000);
|
||||
define ('FILE_LINES_SKIP', 0);
|
||||
define ('DOI_REQ_LIMIT', 0);
|
||||
|
||||
|
||||
ini_set ('display_errors', DEBUG);
|
||||
ini_set ('error_reporting', DEBUG);
|
||||
|
||||
|
||||
$sql_host = 'r3';
|
||||
$sql_user = "biblio";
|
||||
$sql_pass = "biblio";
|
||||
$sql_db = "ess_biblio";
|
||||
|
||||
/*
|
||||
$sql_host = 'localhost';
|
||||
$sql_user = "biblio";
|
||||
$sql_pass = "biblio";
|
||||
$sql_db = "ess_2022";
|
||||
*/
|
||||
|
||||
// DATABASE STUFF
|
||||
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
try {
|
||||
$PDO = new PDO("mysql:host=" .$sql_host .";dbname=" .$sql_db .";charset=utf8", $sql_user, $sql_pass);
|
||||
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$PDO->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
die ('Cannot connect to the database! Error: ' .$ex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// autoload stuff (backend only)
|
||||
|
||||
function loadClass($class) {
|
||||
|
||||
if (is_file (SITE_PATH .'classes/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/' . $class .'.php';
|
||||
}
|
||||
else if (is_file (SITE_PATH .'classes/publications/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/publications/' . $class .'.php';
|
||||
}
|
||||
else if (is_file (SITE_PATH .'classes/lists/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/lists/' . $class .'.php';
|
||||
}
|
||||
}
|
||||
|
||||
spl_autoload_register('loadClass');
|
||||
|
||||
?>
|
63
settings.php.example
Normal file
63
settings.php.example
Normal file
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
define ('SITE_PATH', '/var/www/biblio_back/');
|
||||
define ("DEBUG", 1);
|
||||
define ("CONTACT", 'May at may.dousak @ fdv.uni-lj.si');
|
||||
define ("ERROR_LOG", SITE_PATH .'logs/err.log');
|
||||
define ('FILE_LINES_LIMIT', 10000);
|
||||
define ('FILE_LINES_SKIP', 0);
|
||||
define ('DOI_REQ_LIMIT', 0);
|
||||
|
||||
|
||||
ini_set ('display_errors', DEBUG);
|
||||
ini_set ('error_reporting', DEBUG);
|
||||
|
||||
/*
|
||||
$sql_host = 'r3';
|
||||
$sql_user = "biblio";
|
||||
$sql_pass = "biblio";
|
||||
$sql_db = "ess_biblio";
|
||||
*/
|
||||
|
||||
$sql_host = 'localhost';
|
||||
$sql_user = "biblio";
|
||||
$sql_pass = "biblio";
|
||||
$sql_db = "ess_2022";
|
||||
|
||||
|
||||
// DATABASE STUFF
|
||||
|
||||
date_default_timezone_set("Europe/London");
|
||||
|
||||
try {
|
||||
$PDO = new PDO("mysql:host=" .$sql_host .";dbname=" .$sql_db .";charset=utf8", $sql_user, $sql_pass);
|
||||
$PDO->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$PDO->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
|
||||
|
||||
}
|
||||
catch (PDOException $ex) {
|
||||
die ('Cannot connect to the database! Error: ' .$ex);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// autoload stuff (backend only)
|
||||
|
||||
function loadClass($class) {
|
||||
|
||||
if (is_file (SITE_PATH .'classes/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/' . $class .'.php';
|
||||
}
|
||||
else if (is_file (SITE_PATH .'classes/publications/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/publications/' . $class .'.php';
|
||||
}
|
||||
else if (is_file (SITE_PATH .'classes/lists/' . $class .'.php')) {
|
||||
require_once SITE_PATH .'classes/lists/' . $class .'.php';
|
||||
}
|
||||
}
|
||||
|
||||
spl_autoload_register('loadClass');
|
||||
|
||||
?>
|
37
update.sql
Normal file
37
update.sql
Normal file
@ -0,0 +1,37 @@
|
||||
## V 0.223
|
||||
|
||||
INSERT INTO language (id, name, name_eng) VALUES (1, 'English', 'English');
|
||||
INSERT INTO language (id, name, name_eng) VALUES (2, 'German', 'German');
|
||||
INSERT INTO language (id, name, name_eng) VALUES (3, 'Italian', 'Italian');
|
||||
INSERT INTO language (id, name, name_eng) VALUES (4, 'Spanish', 'Spanish');
|
||||
INSERT INTO language (id, name, name_eng) VALUES (5, 'Portugese', 'Portugese');
|
||||
INSERT INTO language (id, name, name_eng) VALUES (6, 'Dutch', 'Dutch');
|
||||
|
||||
|
||||
|
||||
## V 0.223_2
|
||||
UPDATE l_topic set name='Politics, democratic system, political participation, political parties, populism, LR placement' where id=1;
|
||||
UPDATE l_topic set name='Citizenship, volunteering' where id=2;
|
||||
UPDATE l_topic set name='Welfare stare, welfare attitudes, welfare chauvinism' where id=3;
|
||||
UPDATE l_topic set name='Post-socialism, transition' where id=4;
|
||||
UPDATE l_topic set name='Social inequalities, social class, social mobility' where id=5;
|
||||
UPDATE l_topic set name='Immigration issues, ethnic diversity, ethnic discrimination' where id=6;
|
||||
UPDATE l_topic set name='Nation, national identity' where id=7;
|
||||
UPDATE l_topic set name='Crime, criminal justice, corruption' where id=8;
|
||||
UPDATE l_topic set name='Economy, financial crisis, economic values, consumerism' where id=9;
|
||||
UPDATE l_topic set name='Subjective well-being, happiness, life satisfaction, quality of life' where id=10;
|
||||
UPDATE l_topic set name='Health, subjective health, health system ' where id=11;
|
||||
UPDATE l_topic set name='Culture, values' where id=12;
|
||||
UPDATE l_topic set name='Social capital, trust, social networks' where id=13;
|
||||
UPDATE l_topic set name='Family, family roles, norms, work-life balance, family planning' where id=14;
|
||||
UPDATE l_topic set name='Paid work, labour market, industrial relations, trade unions' where id=15;
|
||||
UPDATE l_topic set name='Media, internet, ICT' where id=16;
|
||||
UPDATE l_topic set name='Religion, religiosity, religious change' where id=17;
|
||||
UPDATE l_topic set name='Education, skills, educational inequalities' where id=18;
|
||||
UPDATE l_topic set name='Age groups, ageism, the elderly, the young' where id=19;
|
||||
UPDATE l_topic set name='Gender issues, gender roles' where id=20;
|
||||
UPDATE l_topic set name='Environment, climate change' where id=21;
|
||||
UPDATE l_topic set name='Europe, European Union, euroscepticism' where id=22;
|
||||
UPDATE l_topic set name='Survey methods' where id=99;
|
||||
INSERT INTO l_topic VALUES (49, 'Covid-19 pandemic');
|
||||
|
Loading…
x
Reference in New Issue
Block a user