- composer updates
- syntax improvements PSR2 - delete Book.php and BorrowController.php - correct GeoLocation() method in Dataset.php - use namesspace of Breadcrumbs class in breadcrumbs.php - npm updates
This commit is contained in:
parent
27464d08f7
commit
6a8b27efa6
14 changed files with 216 additions and 328 deletions
50
app/Book.php
50
app/Book.php
|
@ -1,50 +0,0 @@
|
|||
<?php
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Book extends Model
|
||||
{
|
||||
protected $table = 'books';
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'author',
|
||||
'year',
|
||||
'stock',
|
||||
'project_id'
|
||||
];
|
||||
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo('App\Models\Project', 'project_id', 'id');
|
||||
}
|
||||
|
||||
// public function shelf()
|
||||
// {
|
||||
// return $this->belongsTo('App\Shelf');
|
||||
// }
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
//model, foreign key on the Transaction model is book_id, local id
|
||||
return $this->hasMany('App\Transaction', 'book_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function scopeAvailable($query)
|
||||
{
|
||||
return $query->where('stock', '>', 0);
|
||||
}
|
||||
|
||||
public function scopeOrderByTitle($query)
|
||||
{
|
||||
return $query->orderBy('title');
|
||||
}
|
||||
|
||||
public function hasProject()
|
||||
{
|
||||
return $this->project()->exists();
|
||||
}
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Book;
|
||||
use App\Person;
|
||||
use App\Transaction;
|
||||
use App\Models\Project;
|
||||
use App\Http\Requests\PeminjamanRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BorrowController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
//$books = Book::available()->orderByTitle()->lists('title', 'id');
|
||||
$persons = Person::active()->orderByName()->pluck('last_name', 'id');
|
||||
//$categories = Category::lists('category', 'id');
|
||||
$categories = Project::get();
|
||||
|
||||
return view('rdr.borrow.borrow', compact('persons', 'categories'));
|
||||
}
|
||||
|
||||
public function store(PeminjamanRequest $request)
|
||||
{
|
||||
$input = $request->all();
|
||||
$book_id = $input['book_id'];
|
||||
$person_id = $input['person_id'];
|
||||
$input['borrowed_at'] = time();
|
||||
$transaction = Transaction::create($input);
|
||||
$book = Book::findOrFail($book_id);
|
||||
$stock = $book['stock'] - 1;
|
||||
$book->update(['stock' => $stock]);
|
||||
$person = Person::findOrFail($person_id);
|
||||
$borrow = $person['borrow'] + 1;
|
||||
$person->update(['borrow' => $borrow]);
|
||||
session()->flash('flash_message', 'You have added 1 transaction!');
|
||||
|
||||
return redirect()->route('borrow.report');
|
||||
}
|
||||
|
||||
public function report()
|
||||
{
|
||||
$dateNow = time();
|
||||
$transactions = Transaction::with('student', 'book')->notReturnedYet()->get();
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
$dateDiff = $dateNow - $transaction['borrowed_at'];
|
||||
$durasi = floor($dateDiff/(60 * 60 * 24));
|
||||
// $fines = Fine::first();
|
||||
// if($durasi > $fines['days'])
|
||||
// {
|
||||
// $hariDenda = $durasi - $fines['days'];
|
||||
// $denda = $hariDenda * $fines['fines'];
|
||||
// $transaction->update(['fines' => $denda]);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// $denda = 0;
|
||||
// $transaction->update(['fines' => $denda]);
|
||||
// }
|
||||
}
|
||||
//ambil tanggal
|
||||
//$date2 = mktime(0,0,0,05,31,2015);
|
||||
//return $date2;
|
||||
return view('rdr.borrow.report', compact('transactions', 'durasi'));
|
||||
}
|
||||
|
||||
public function pengembalian($id)
|
||||
{
|
||||
$returnedAt = time();
|
||||
$transaction = Transaction::findOrFail($id);
|
||||
$transaction->update(['status' => 1, 'returned_at' => $returnedAt]);
|
||||
|
||||
$book = Book::findOrFail($transaction['book_id']);
|
||||
$stock = $book['stock'] + 1;
|
||||
$book->update(['stock' => $stock]);
|
||||
$student = Student::findOrFail($transaction['student_id']);
|
||||
$borrow = $student['borrow'] - 1;
|
||||
$student->update(['borrow' => $borrow]);
|
||||
|
||||
session()->flash('flash_message', 'You have returned 1 book!');
|
||||
return redirect()->route('borrow.histori');
|
||||
}
|
||||
|
||||
public function perpanjang($id)
|
||||
{
|
||||
$transaction = Transaction::findOrFail($id);
|
||||
$dateNow = time();
|
||||
$transaction->update(['borrowed_at' => $dateNow, 'fines' => 0]);
|
||||
session()->flash('flash_message', 'You have added 1 perpanjang!');
|
||||
return redirect()->route('borrow.report');
|
||||
}
|
||||
|
||||
public function histori()
|
||||
{
|
||||
$transactions = Transaction::returned()->get();
|
||||
return view('rdr.borrow.histori', compact('transactions'));
|
||||
}
|
||||
}
|
|
@ -1,16 +1,16 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Oai;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Exceptions\OaiModelException;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Dataset;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Exceptions\OaiModelException;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use App\Models\Oai\OaiModelError;
|
||||
use App\Models\Oai\ResumptionToken;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use \Exception;
|
||||
|
||||
|
||||
class RequestController extends Controller
|
||||
{
|
||||
/**
|
||||
|
@ -19,17 +19,16 @@ class RequestController extends Controller
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
private $deliveringDocumentStates = array('published', 'deleted'); // maybe deleted documents too
|
||||
private $deliveringDocumentStates = array('published', 'deleted'); // maybe deleted documents too
|
||||
private $xMetaDissRestriction = array('doctoralthesis', 'habilitation');
|
||||
const SET_SPEC_PATTERN = '[A-Za-z0-9\-_\.!~\*\'\(\)]+';
|
||||
|
||||
|
||||
/**
|
||||
* Holds xml representation of document information to be processed.
|
||||
*
|
||||
* @var \DomDocument Defaults to null.
|
||||
*/
|
||||
protected $_xml = null;
|
||||
protected $xml = null;
|
||||
|
||||
/**
|
||||
* Holds the stylesheet for the transformation.
|
||||
|
@ -43,7 +42,7 @@ class RequestController extends Controller
|
|||
*
|
||||
* @var \XSLTProcessor Defaults to null.
|
||||
*/
|
||||
protected $_proc = null;
|
||||
protected $proc = null;
|
||||
|
||||
/**
|
||||
* Load an xslt stylesheet.
|
||||
|
@ -54,19 +53,19 @@ class RequestController extends Controller
|
|||
{
|
||||
$this->xslt = new \DomDocument;
|
||||
$this->xslt->load($stylesheet);
|
||||
$this->_proc->importStyleSheet($this->xslt);
|
||||
$this->proc->importStyleSheet($this->xslt);
|
||||
if (isset($_SERVER['HTTP_HOST'])) {
|
||||
$this->_proc->setParameter('', 'host', $_SERVER['HTTP_HOST']);
|
||||
$this->proc->setParameter('', 'host', $_SERVER['HTTP_HOST']);
|
||||
}
|
||||
//$this->_proc->setParameter('', 'server', $this->getRequest()->getBaseUrl());
|
||||
//$this->proc->setParameter('', 'server', $this->getRequest()->getBaseUrl());
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//$this->middleware('auth');
|
||||
// Initialize member variables.
|
||||
$this->_xml = new \DomDocument;
|
||||
$this->_proc = new \XSLTProcessor;
|
||||
$this->xml = new \DomDocument;
|
||||
$this->proc = new \XSLTProcessor;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
|
@ -82,40 +81,38 @@ class RequestController extends Controller
|
|||
} catch (OaiModelException $e) {
|
||||
$errorCode = OaiModelError::mapCode($e->getCode());
|
||||
//$this->getLogger()->err($errorCode);
|
||||
$this->_proc->setParameter('', 'oai_error_code', $errorCode);
|
||||
$this->proc->setParameter('', 'oai_error_code', $errorCode);
|
||||
//$this->getLogger()->err($e->getMessage());
|
||||
$this->_proc->setParameter('', 'oai_error_message', htmlentities($e->getMessage()));
|
||||
$this->proc->setParameter('', 'oai_error_message', htmlentities($e->getMessage()));
|
||||
} catch (Exception $e) {
|
||||
//$this->getLogger()->err($e);
|
||||
$this->_proc->setParameter('', 'oai_error_code', 'unknown');
|
||||
$this->_proc->setParameter('', 'oai_error_message', 'An internal error occured.');
|
||||
$this->proc->setParameter('', 'oai_error_code', 'unknown');
|
||||
$this->proc->setParameter('', 'oai_error_message', 'An internal error occured.');
|
||||
//$this->getResponse()->setHttpResponseCode(500);
|
||||
}
|
||||
// $xml = $this->_xml->saveXML();
|
||||
$xml = $this->_proc->transformToXML($this->_xml);
|
||||
// $xml = $this->xml->saveXML();
|
||||
$xml = $this->proc->transformToXML($this->xml);
|
||||
|
||||
//$xml = $this->doc->asXML();
|
||||
return response($xml)//->view('rss', array('rss'=>$this->rss))
|
||||
->header('Content-Type', 'application/xml')
|
||||
->header('charset', 'utf-8');
|
||||
//$xml = $this->doc->asXML();
|
||||
return response($xml) //->view('rss', array('rss'=>$this->rss))
|
||||
->header('Content-Type', 'application/xml')
|
||||
->header('charset', 'utf-8');
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function __handleRequest(array $oaiRequest)
|
||||
{
|
||||
// Setup stylesheet
|
||||
// Setup stylesheet
|
||||
$this->loadStyleSheet('datasetxml2oai-pmh.xslt');
|
||||
|
||||
// Set response time
|
||||
$this->_proc->setParameter('', 'responseDate', date("Y-m-d\TH:i:s\Z"));
|
||||
$this->proc->setParameter('', 'responseDate', date("Y-m-d\TH:i:s\Z"));
|
||||
|
||||
// set OAI base url
|
||||
$uri = explode('?', $_SERVER['REQUEST_URI'], 2);
|
||||
$this->_proc->setParameter('', 'baseURL', url('/') . $uri[0]);
|
||||
$this->proc->setParameter('', 'baseURL', url('/') . $uri[0]);
|
||||
|
||||
if (isset($oaiRequest['verb'])) {
|
||||
$this->_proc->setParameter('', 'oai_verb', $oaiRequest['verb']);
|
||||
$this->proc->setParameter('', 'oai_verb', $oaiRequest['verb']);
|
||||
if ($oaiRequest['verb'] == 'Identify') {
|
||||
$this->handleIdentify();
|
||||
} elseif ($oaiRequest['verb'] == 'ListMetadataFormats') {
|
||||
|
@ -133,7 +130,7 @@ class RequestController extends Controller
|
|||
}
|
||||
} else {
|
||||
$oaiRequest['verb'] = 'Identify';
|
||||
$this->_proc->setParameter('', 'oai_verb', $oaiRequest['verb']);
|
||||
$this->proc->setParameter('', 'oai_verb', $oaiRequest['verb']);
|
||||
$this->doc = $this->handleIdentify();
|
||||
}
|
||||
}
|
||||
|
@ -148,16 +145,17 @@ class RequestController extends Controller
|
|||
$email = "repository@geologie.ac.at";
|
||||
$repositoryName = "Tethys RDR";
|
||||
$repIdentifier = "tethys.geologie.ac.at";
|
||||
$sampleIdentifier = "oai:" . $repIdentifier . ":27";//$this->_configuration->getSampleIdentifier();
|
||||
$earliestDateFromDb = Dataset::earliestPublicationDate() != null ? Dataset::earliestPublicationDate()->server_date_published: null;
|
||||
$sampleIdentifier = "oai:" . $repIdentifier . ":27"; //$this->_configuration->getSampleIdentifier();
|
||||
$earliestDateFromDb = Dataset::earliestPublicationDate() != null ?
|
||||
Dataset::earliestPublicationDate()->server_date_published : null;
|
||||
|
||||
// set parameters for oai-pmh.xslt
|
||||
$this->_proc->setParameter('', 'email', $email);
|
||||
$this->_proc->setParameter('', 'repositoryName', $repositoryName);
|
||||
$this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||
$this->_proc->setParameter('', 'sampleIdentifier', $sampleIdentifier);
|
||||
$this->_proc->setParameter('', 'earliestDatestamp', $earliestDateFromDb);
|
||||
$this->_xml->appendChild($this->_xml->createElement('Datasets'));
|
||||
$this->proc->setParameter('', 'email', $email);
|
||||
$this->proc->setParameter('', 'repositoryName', $repositoryName);
|
||||
$this->proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||
$this->proc->setParameter('', 'sampleIdentifier', $sampleIdentifier);
|
||||
$this->proc->setParameter('', 'earliestDatestamp', $earliestDateFromDb);
|
||||
$this->xml->appendChild($this->xml->createElement('Datasets'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -176,7 +174,7 @@ class RequestController extends Controller
|
|||
try {
|
||||
//$dataset = new Opus_Document($docId);
|
||||
$dataset = Dataset::findOrFail($dataId);
|
||||
} catch (ModelNotFoundException $ex) {
|
||||
} catch (ModelNotFoundException $ex) {
|
||||
throw new OaiModelException(
|
||||
'The value of the identifier argument is unknown or illegal in this repository.',
|
||||
OaiModelError::IDDOESNOTEXIST
|
||||
|
@ -187,17 +185,17 @@ class RequestController extends Controller
|
|||
if (true === array_key_exists('metadataPrefix', $oaiRequest)) {
|
||||
$metadataPrefix = $oaiRequest['metadataPrefix'];
|
||||
}
|
||||
$this->_proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix);
|
||||
$this->proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix);
|
||||
|
||||
// do not deliver datasets which are restricted by document state
|
||||
if (is_null($dataset)
|
||||
//or (false === in_array($dataset->getServerState(), $this->_deliveringDocumentStates))
|
||||
or (false === $dataset->whereIn('server_state', $this->deliveringDocumentStates))
|
||||
or (false === $dataset->whereIn('server_state', $this->deliveringDocumentStates))
|
||||
or (false === $dataset->hasEmbargoPassed())) {
|
||||
throw new OaiModelException('Document is not available for OAI export!', OaiModelError::NORECORDSMATCH);
|
||||
}
|
||||
|
||||
$this->_xml->appendChild($this->_xml->createElement('Datasets'));
|
||||
$this->xml->appendChild($this->xml->createElement('Datasets'));
|
||||
$this->createXmlRecord($dataset);
|
||||
}
|
||||
|
||||
|
@ -236,9 +234,6 @@ class RequestController extends Controller
|
|||
return $dataId;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Implements response for OAI-PMH verb 'ListMetadataFormats'.
|
||||
*
|
||||
|
@ -247,7 +242,7 @@ class RequestController extends Controller
|
|||
*/
|
||||
private function handleListMetadataFormats()
|
||||
{
|
||||
$this->_xml->appendChild($this->_xml->createElement('Datasets'));
|
||||
$this->xml->appendChild($this->xml->createElement('Datasets'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -258,7 +253,7 @@ class RequestController extends Controller
|
|||
*/
|
||||
private function handleListRecords($oaiRequest)
|
||||
{
|
||||
$maxRecords = 30;//$this->_configuration->getMaxListRecords();
|
||||
$maxRecords = 30; //$this->_configuration->getMaxListRecords();
|
||||
$this->handlingOfLists($oaiRequest, $maxRecords);
|
||||
}
|
||||
|
||||
|
@ -270,7 +265,7 @@ class RequestController extends Controller
|
|||
*/
|
||||
private function handleListIdentifiers(array &$oaiRequest)
|
||||
{
|
||||
$maxIdentifier = 5;//$this->_configuration->getMaxListIdentifiers();
|
||||
$maxIdentifier = 5; //$this->_configuration->getMaxListIdentifiers();
|
||||
$this->handlingOfLists($oaiRequest, $maxIdentifier);
|
||||
}
|
||||
|
||||
|
@ -283,8 +278,8 @@ class RequestController extends Controller
|
|||
private function handleListSets()
|
||||
{
|
||||
$repIdentifier = "tethys.geologie.ac.at";
|
||||
$this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||
$this->_xml->appendChild($this->_xml->createElement('Datasets'));
|
||||
$this->proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||
$this->xml->appendChild($this->xml->createElement('Datasets'));
|
||||
|
||||
//$oaiSets = new Oai_Model_Sets();
|
||||
$sets = array(
|
||||
|
@ -298,27 +293,25 @@ class RequestController extends Controller
|
|||
//$sets = $this->getSetsForDocumentTypes();
|
||||
|
||||
foreach ($sets as $type => $name) {
|
||||
$opusDoc = $this->_xml->createElement('Rdr_Sets');
|
||||
$typeAttr = $this->_xml->createAttribute('Type');
|
||||
$typeValue = $this->_xml->createTextNode($type);
|
||||
$opusDoc = $this->xml->createElement('Rdr_Sets');
|
||||
$typeAttr = $this->xml->createAttribute('Type');
|
||||
$typeValue = $this->xml->createTextNode($type);
|
||||
$typeAttr->appendChild($typeValue);
|
||||
$opusDoc->appendChild($typeAttr);
|
||||
$nameAttr = $this->_xml->createAttribute('TypeName');
|
||||
$nameValue = $this->_xml->createTextNode($name);
|
||||
$nameAttr = $this->xml->createAttribute('TypeName');
|
||||
$nameValue = $this->xml->createTextNode($name);
|
||||
$nameAttr->appendChild($nameValue);
|
||||
$opusDoc->appendChild($nameAttr);
|
||||
$this->_xml->documentElement->appendChild($opusDoc);
|
||||
$this->xml->documentElement->appendChild($opusDoc);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function handleIllegalVerb()
|
||||
{
|
||||
$this->_proc->setParameter('', 'oai_error_code', 'badVerb');
|
||||
$this->_proc->setParameter('', 'oai_error_message', 'The verb provided in the request is illegal.');
|
||||
$this->proc->setParameter('', 'oai_error_code', 'badVerb');
|
||||
$this->proc->setParameter('', 'oai_error_message', 'The verb provided in the request is illegal.');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method for handling lists.
|
||||
*
|
||||
|
@ -336,9 +329,9 @@ class RequestController extends Controller
|
|||
$repIdentifier = "tethys.geologie.ac.at";
|
||||
$tokenTempPath = storage_path('app/resumption'); //$this->_configuration->getResumptionTokenPath();
|
||||
|
||||
$this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||
$this->_xml->appendChild($this->_xml->createElement('Datasets'));
|
||||
|
||||
$this->proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||
$this->xml->appendChild($this->xml->createElement('Datasets'));
|
||||
|
||||
// do some initialisation
|
||||
$cursor = 0;
|
||||
//$totalIds = 0;
|
||||
|
@ -349,7 +342,7 @@ class RequestController extends Controller
|
|||
if (true === array_key_exists('metadataPrefix', $oaiRequest)) {
|
||||
$metadataPrefix = $oaiRequest['metadataPrefix'];
|
||||
}
|
||||
$this->_proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix);
|
||||
$this->proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix);
|
||||
|
||||
// parameter resumptionToken is given
|
||||
if (false === empty($oaiRequest['resumptionToken'])) {
|
||||
|
@ -372,8 +365,7 @@ class RequestController extends Controller
|
|||
$reldocIds = $finder->pluck('id')->toArray();
|
||||
}
|
||||
|
||||
|
||||
// handling of document ids
|
||||
// handling of document ids
|
||||
$restIds = $reldocIds;
|
||||
$workIds = array_splice($restIds, 0, $maxRecords);
|
||||
//foreach ($datasets as $dataset)
|
||||
|
@ -385,21 +377,21 @@ class RequestController extends Controller
|
|||
|
||||
private function createXmlRecord(Dataset $dataset)
|
||||
{
|
||||
//$node = $this->_xml->createElement('Rdr_Dataset');
|
||||
//$node = $this->xml->createElement('Rdr_Dataset');
|
||||
$domNode = $this->getDatasetXmlDomNode($dataset);
|
||||
// add frontdoor url
|
||||
// add frontdoor url
|
||||
$this->addLandingPageAttribute($domNode, $dataset->id);
|
||||
|
||||
// add access rights to element
|
||||
//$this->_addAccessRights($domNode, $dataset);
|
||||
|
||||
$node = $this->_xml->importNode($domNode, true);
|
||||
$node = $this->xml->importNode($domNode, true);
|
||||
|
||||
//$node->setAttribute("Id", $dataset->id);
|
||||
//$node->setAttribute("ServerState", $dataset->server_state);
|
||||
|
||||
////$child = new \DOMElement("ServerDateModified");
|
||||
//$child = $this->_xml->createElement('ServerDateModified');
|
||||
//$child = $this->xml->createElement('ServerDateModified');
|
||||
//$child->setAttribute("Year", $dataset->server_date_modified->format('Y'));
|
||||
//$child->setAttribute("Month", $dataset->server_date_modified->month);
|
||||
//$child->setAttribute("Day", $dataset->server_date_modified->day);
|
||||
|
@ -409,7 +401,7 @@ class RequestController extends Controller
|
|||
$this->addSpecInformation($node, 'data-type:' . $dataset->type);
|
||||
//$this->addSpecInformation($node, 'bibliography:' . 'false');
|
||||
|
||||
$this->_xml->documentElement->appendChild($node);
|
||||
$this->xml->documentElement->appendChild($node);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -431,12 +423,12 @@ class RequestController extends Controller
|
|||
|
||||
private function addSpecInformation(\DOMNode $document, $information)
|
||||
{
|
||||
$setSpecAttribute = $this->_xml->createAttribute('Value');
|
||||
$setSpecAttributeValue = $this->_xml->createTextNode($information);
|
||||
$setSpecAttribute = $this->xml->createAttribute('Value');
|
||||
$setSpecAttributeValue = $this->xml->createTextNode($information);
|
||||
$setSpecAttribute->appendChild($setSpecAttributeValue);
|
||||
|
||||
$setSpecElement = $this->_xml->createElement('SetSpec');
|
||||
//$setSpecElement =new \DOMElement("SetSpec");
|
||||
$setSpecElement = $this->xml->createElement('SetSpec');
|
||||
//$setSpecElement =new \DOMElement("SetSpec");
|
||||
$setSpecElement->appendChild($setSpecAttribute);
|
||||
$document->appendChild($setSpecElement);
|
||||
}
|
||||
|
@ -454,7 +446,7 @@ class RequestController extends Controller
|
|||
$xmlModel = new \App\Library\Xml\XmlModel();
|
||||
$xmlModel->setModel($dataset);
|
||||
$xmlModel->excludeEmptyFields();
|
||||
$cache = ($dataset->xmlCache) ? $dataset->xmlCache : new \App\Models\XmlCache();
|
||||
$cache = ($dataset->xmlCache) ? $dataset->xmlCache : new \App\Models\XmlCache();
|
||||
$xmlModel->setXmlCache($cache);
|
||||
return $xmlModel->getDomDocument()->getElementsByTagName('Rdr_Dataset')->item(0);
|
||||
}
|
||||
|
|
|
@ -8,15 +8,15 @@ class Kernel extends HttpKernel
|
|||
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
* @var array
|
||||
*/
|
||||
*
|
||||
* These middleware are run during every request to your application.
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
\Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
|
||||
\App\Http\Middleware\TrimStrings::class,
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class
|
||||
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -65,6 +65,6 @@ class Kernel extends HttpKernel
|
|||
'ability' => \Zizaco\Entrust\Middleware\EntrustAbility::class,
|
||||
'isUserDatasetAdmin' => \App\Http\Middleware\WebAuthorizeDataset::class,
|
||||
'isUserFileOwner' => \App\Http\Middleware\WebAuthorizeFile::class,
|
||||
|
||||
|
||||
];
|
||||
}
|
||||
|
|
|
@ -4,18 +4,18 @@ namespace App\Models;
|
|||
|
||||
use App\Library\Xml\DatasetExtension;
|
||||
use App\Models\Collection;
|
||||
use App\Models\License;
|
||||
use App\Models\User;
|
||||
use App\Models\Project;
|
||||
use App\Models\Coverage;
|
||||
use App\Models\Description;
|
||||
use App\Models\Title;
|
||||
use App\Models\Person;
|
||||
use App\Models\XmlCache;
|
||||
use App\Models\File;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Models\License;
|
||||
use App\Models\Person;
|
||||
use App\Models\Project;
|
||||
use App\Models\Title;
|
||||
use App\Models\User;
|
||||
use App\Models\XmlCache;
|
||||
use Carbon\Carbon;
|
||||
// use App\Models\GeolocationBox;
|
||||
use App\Models\Coverage;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Dataset extends Model
|
||||
{
|
||||
|
@ -45,10 +45,10 @@ class Dataset extends Model
|
|||
'reviewer_id',
|
||||
'reject_reviewer_note',
|
||||
'reject_editor_note',
|
||||
'reviewer_note_visible'
|
||||
'reviewer_note_visible',
|
||||
];
|
||||
//protected $guarded = [];
|
||||
/**
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
|
@ -96,7 +96,7 @@ class Dataset extends Model
|
|||
return $this->belongsTo(Project::class, 'project_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* Get the account that the dataset belongs to
|
||||
*/
|
||||
public function user()
|
||||
|
@ -175,7 +175,7 @@ class Dataset extends Model
|
|||
public function contributors()
|
||||
{
|
||||
return $this
|
||||
->persons()
|
||||
->persons()
|
||||
// ->belongsToMany(Person::class, 'link_documents_persons', 'document_id', 'person_id')
|
||||
->wherePivot('role', 'contributor');
|
||||
}
|
||||
|
@ -196,7 +196,7 @@ class Dataset extends Model
|
|||
{
|
||||
return $this->hasMany(Title::class, 'document_id', 'id')->where('type', 'Main')->first();
|
||||
}
|
||||
|
||||
|
||||
public function addMainTitle(Title $title)
|
||||
{
|
||||
$title->type = 'main';
|
||||
|
@ -251,7 +251,6 @@ class Dataset extends Model
|
|||
return $this->hasMany(\App\Models\Subject::class, 'document_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the xml-cache record associated with the dataset.
|
||||
*
|
||||
|
@ -285,7 +284,7 @@ class Dataset extends Model
|
|||
->where('server_state', 'published')
|
||||
->orderBy('server_date_published', 'asc')
|
||||
->first();
|
||||
//->server_date_published;
|
||||
//->server_date_published;
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
@ -300,7 +299,6 @@ class Dataset extends Model
|
|||
return $this->project()->exists();
|
||||
}
|
||||
|
||||
|
||||
public function hasEmbargoPassed($now = null)
|
||||
{
|
||||
$embargoDate = $this->embargo_date;
|
||||
|
@ -320,7 +318,7 @@ class Dataset extends Model
|
|||
// $dt->year = 2015;
|
||||
// $dt->month = 04;
|
||||
// $dt->day = 21;
|
||||
$embargoDate->hour = 23;
|
||||
$embargoDate->hour = 23;
|
||||
$embargoDate->minute = 59;
|
||||
$embargoDate->second = 59;
|
||||
|
||||
|
@ -330,7 +328,7 @@ class Dataset extends Model
|
|||
|
||||
public function getRemainingTimeAttribute()
|
||||
{
|
||||
$dateDiff =$this->server_date_modified->addDays(14);
|
||||
$dateDiff = $this->server_date_modified->addDays(14);
|
||||
if ($this->server_state == "approved") {
|
||||
return Carbon::now()->diffInDays($dateDiff, false);
|
||||
} else {
|
||||
|
@ -346,6 +344,34 @@ class Dataset extends Model
|
|||
. ' * WEST-BOUND LONGITUDE: ' . $this->coverage->y_min . ","
|
||||
. ' * NORTH-BOUND LATITUDE: ' . $this->coverage->x_max . ","
|
||||
. ' * EAST-BOUND LONGITUDE: ' . $this->coverage->y_max;
|
||||
|
||||
$elevation = '';
|
||||
if ($this->coverage->elevation_min != null && $this->coverage->elevation_max != null) {
|
||||
$elevation = $elevation . '* ELEVATION MIN: ' . $this->coverage->elevation_min
|
||||
. ', * ELEVATION MAX: ' . $this->coverage->elevation_max;
|
||||
} elseif ($this->coverage->elevation_absolut != null) {
|
||||
$elevation = $elevation . '* ELEVATION ABSOLUT: ' . $this->coverage->elevation_absolut;
|
||||
}
|
||||
$geolocation = $elevation == '' ? $geolocation : $geolocation . ", " . $elevation;
|
||||
|
||||
$depth = '';
|
||||
if ($this->coverage->depth_min != null && $this->coverage->depth_max != null) {
|
||||
$depth = $depth . '* DEPTH MIN: ' . $this->coverage->depth_min
|
||||
. ', * DEPTH MAX: ' . $this->coverage->depth_max;
|
||||
} elseif ($this->coverage->depth_absolut != null) {
|
||||
$depth = $depth . '* DEPTH ABSOLUT: ' . $this->coverage->depth_absolut;
|
||||
}
|
||||
$geolocation = $depth == '' ? $geolocation : $geolocation . ", " . $depth;
|
||||
|
||||
$time = '';
|
||||
if ($this->coverage->time_min != null && $this->coverage->time_max != null) {
|
||||
$time = $time . '* TIME MIN: ' . $this->coverage->time_min
|
||||
. ', * TIME MAX: ' . $this->coverage->time_max;
|
||||
} elseif ($this->coverage->time_absolut != null) {
|
||||
$time = $time . '* TIME ABSOLUT: ' . $this->coverage->time_absolut;
|
||||
}
|
||||
$geolocation = $time == '' ? $geolocation : $geolocation . ", " . $time;
|
||||
|
||||
return $geolocation;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
editor.link_modal.header
Reference in a new issue