114 lines
3.5 KiB
PHP
114 lines
3.5 KiB
PHP
![]() |
<?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__);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
}
|