my changes
This commit is contained in:
parent
28301e4312
commit
8dc1f1b048
31
.env
31
.env
|
@ -1,15 +1,16 @@
|
|||
APP_ENV=local
|
||||
APP_ENV=debug
|
||||
APP_DEBUG=true
|
||||
APP_KEY=OKMcQgJBQ0qfAfBP8AqR6acRwMUt67xj
|
||||
APP_KEY=base64:mbyRHBYCM6Uh6ZRiTWvsd7jf2QK8jpmVCJwZuSA9KgA=
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=localhost
|
||||
DB_DATABASE=library
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
DB_CONNECTION=sqlsrv
|
||||
DB_HOST=zontik\test
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=opusdb
|
||||
DB_USERNAME=opus4admin
|
||||
DB_PASSWORD=opus4admin007
|
||||
|
||||
CACHE_DRIVER=file
|
||||
SESSION_DRIVER=file
|
||||
SESSION_DRIVER=cookie
|
||||
QUEUE_DRIVER=sync
|
||||
|
||||
MAIL_DRIVER=smtp
|
||||
|
@ -18,16 +19,4 @@ MAIL_PORT=587
|
|||
MAIL_FROM=test.laravel123@gmail.com
|
||||
MAIL_USERNAME=test.laravel123@gmail.com
|
||||
MAIL_PASSWORD=testinglaravel
|
||||
MAIL_ENCRYPTION=tls
|
||||
|
||||
GITHUB_CLIENT_ID=c9ec9dcffeea678b2bca
|
||||
GITHUB_CLIENT_SECRET=dcb3e7d2ce96a746467be42d8afc4d9e68f034cf
|
||||
|
||||
GOOGLE_CLIENT_ID=
|
||||
GOOGLE_CLIENT_SECRET=
|
||||
|
||||
FACEBOOK_CLIENT_ID=
|
||||
FACEBOOK_CLIENT_SECRET=
|
||||
|
||||
TWITTER_CLIENT_ID=
|
||||
TWITTER_CLIENT_SECRET=
|
||||
MAIL_ENCRYPTION=tls
|
21
.gitignore
vendored
21
.gitignore
vendored
|
@ -1,2 +1,21 @@
|
|||
/node_modules
|
||||
/Properties
|
||||
|
||||
/.vs/lms/v15
|
||||
/lms.user
|
||||
/lms.sln
|
||||
/lms.phpproj.user
|
||||
/lms.phpproj
|
||||
|
||||
# Composer
|
||||
/composer.lock
|
||||
/composer.phar
|
||||
/vendor
|
||||
/node_modules
|
||||
|
||||
# Linux
|
||||
*~
|
||||
*.swp
|
||||
|
||||
# Windows
|
||||
Thumbs.db
|
||||
desktop.ini
|
2
.vscode/.gitignore
vendored
Normal file
2
.vscode/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
75
app/Book.php
75
app/Book.php
|
@ -1,51 +1,50 @@
|
|||
<?php namespace App;
|
||||
<?php
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Book extends Model {
|
||||
class Book extends Model
|
||||
{
|
||||
protected $table = 'books';
|
||||
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'author',
|
||||
'year',
|
||||
'stock',
|
||||
'category_id',
|
||||
'shelf_id'
|
||||
];
|
||||
protected $fillable = [
|
||||
'title',
|
||||
'author',
|
||||
'year',
|
||||
'stock',
|
||||
'project_id'
|
||||
];
|
||||
|
||||
public function category()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Category');
|
||||
|
||||
}
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo('App\Project', 'project_id', 'id');
|
||||
}
|
||||
|
||||
public function shelf()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Shelf');
|
||||
|
||||
}
|
||||
// public function shelf()
|
||||
// {
|
||||
// return $this->belongsTo('App\Shelf');
|
||||
// }
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
public function transactions()
|
||||
{
|
||||
//model, foreign key on the Transaction model is book_id, local id
|
||||
return $this->hasMany('App\Transaction', 'book_id', 'id');
|
||||
}
|
||||
|
||||
return $this->hasMany('App\Transaction');
|
||||
|
||||
}
|
||||
|
||||
public function scopeAvailable($query)
|
||||
{
|
||||
|
||||
return $query->where('stock', '>', 0);
|
||||
public function scopeAvailable($query)
|
||||
{
|
||||
return $query->where('stock', '>', 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function scopeOrderByTitle($query)
|
||||
{
|
||||
|
||||
return $query->orderBy('title');
|
||||
|
||||
}
|
||||
public function scopeOrderByTitle($query)
|
||||
{
|
||||
return $query->orderBy('title');
|
||||
}
|
||||
|
||||
public function hasProject()
|
||||
{
|
||||
return $this->project()->exists();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Category extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'category'
|
||||
];
|
||||
|
||||
|
||||
public function books()
|
||||
{
|
||||
return $this->hasMany('App\Book');
|
||||
}
|
||||
|
||||
}
|
14
app/Collection.php
Normal file
14
app/Collection.php
Normal file
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Collection extends Model
|
||||
{
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->belongsToMany(\App\Dataset::class, 'link_documents_collections', 'collection_id', 'document_id');
|
||||
}
|
||||
}
|
184
app/Dataset.php
Normal file
184
app/Dataset.php
Normal file
|
@ -0,0 +1,184 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use App\Library\Xml\DatasetExtension;
|
||||
use phpDocumentor\Reflection\Types\Null_;
|
||||
|
||||
class Dataset extends Model
|
||||
{
|
||||
use DatasetExtension;
|
||||
protected $table = 'documents';
|
||||
|
||||
//public $timestamps = false; //default true
|
||||
// customize the names of the columns used to store the timestamps:
|
||||
const CREATED_AT = 'server_date_created';
|
||||
const UPDATED_AT = 'server_date_modified';
|
||||
const PUBLISHED_AT = 'server_date_published';
|
||||
|
||||
protected $fillable = [
|
||||
'type',
|
||||
'publication_state',
|
||||
'thesis_year_accepted',
|
||||
'project_id',
|
||||
'embargo_date'
|
||||
];
|
||||
/**
|
||||
* The attributes that should be mutated to dates.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $dates = [
|
||||
'server_date_created',
|
||||
'server_date_modified',
|
||||
'server_date_published'
|
||||
];
|
||||
//protected $dateFormat = 'Y-m-d';
|
||||
|
||||
|
||||
public function __construct(array $attributes = array())
|
||||
{
|
||||
parent::__construct($attributes);
|
||||
// $this->_init();
|
||||
}
|
||||
|
||||
public function project()
|
||||
{
|
||||
return $this->belongsTo(\App\Project::class, 'project_id', 'id');
|
||||
}
|
||||
|
||||
public function collections()
|
||||
{
|
||||
return $this
|
||||
->belongsToMany(\App\Collection::class, 'link_documents_collections', 'document_id', 'collection_id');
|
||||
}
|
||||
|
||||
#region [person table]
|
||||
|
||||
//return all persons attached to this film
|
||||
public function persons()
|
||||
{
|
||||
return $this->belongsToMany(\App\Person::class, 'link_documents_persons', 'document_id', 'person_id')
|
||||
->withPivot('role');
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all authors for this dataset
|
||||
*
|
||||
* @return \App\Person
|
||||
*/
|
||||
public function authors()
|
||||
{
|
||||
return $this
|
||||
->belongsToMany(\App\Person::class, 'link_documents_persons', 'document_id', 'person_id')
|
||||
->wherePivot('role', 'author');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add author to dataset
|
||||
*
|
||||
* @param \App\User $user user to add
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function addAuthor(\App\User $user) : void
|
||||
{
|
||||
$this->persons()->save($user, ['role' => 'author']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return all contributors for this dataset
|
||||
*
|
||||
* @return \App\Person
|
||||
*/
|
||||
public function contributors()
|
||||
{
|
||||
return $this
|
||||
->belongsToMany(\App\Person::class, 'link_documents_persons', 'document_id', 'person_id')
|
||||
->wherePivot('role', 'contributor');
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region title table:
|
||||
|
||||
public function titles()
|
||||
{
|
||||
return $this->hasMany(\App\Title::class, 'document_id', 'id')
|
||||
->where('type', 'main');
|
||||
}
|
||||
// public function addTitle(\App\Title $title)
|
||||
// {
|
||||
// $this->persons()->save($title, ['type' => 'main']);
|
||||
// }
|
||||
|
||||
/**
|
||||
* Relation abstracts
|
||||
*
|
||||
* @return \App\Title
|
||||
*/
|
||||
public function abstracts()
|
||||
{
|
||||
return $this->hasMany(\App\Title::class, 'document_id', 'id')
|
||||
->where('type', 'abstract');
|
||||
}
|
||||
// public function addAbstract (\App\Title $title)
|
||||
// {
|
||||
// $this->persons()->save($title, ['type' => 'abstract']);
|
||||
// }
|
||||
|
||||
#endregion
|
||||
|
||||
public function licenses()
|
||||
{
|
||||
return $this->belongsToMany(\App\License::class, 'link_documents_licences', 'document_id', 'licence_id');
|
||||
}
|
||||
|
||||
public function files()
|
||||
{
|
||||
return $this->hasMany(\App\File::class, 'document_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the xml-cache record associated with the dataset.
|
||||
*
|
||||
* @return \App\XmlCache
|
||||
*/
|
||||
public function xmlCache()
|
||||
{
|
||||
return $this->hasOne(\App\XmlCache::class, 'document_id', 'id');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function scopeOrderByType($query)
|
||||
{
|
||||
return $query->orderBy('type');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get earliest publication date.
|
||||
*
|
||||
* @param \Illuminate\Database\Eloquent\Builder $query sql-query
|
||||
* @param string $column column
|
||||
*
|
||||
* @return \Carbon\Carbon\Date
|
||||
*/
|
||||
public function scopeEarliestPublicationDate($query, string $column = null)
|
||||
{
|
||||
if (!$column) {
|
||||
$column = self::PUBLISHED_AT;
|
||||
}
|
||||
return $query->whereNotNull('server_date_published')
|
||||
->where('server_state', 'published')
|
||||
->orderBy('server_date_published', 'asc')
|
||||
->first()
|
||||
->server_date_published;
|
||||
}
|
||||
|
||||
public function hasProject()
|
||||
{
|
||||
return $this->project()->exists();
|
||||
}
|
||||
}
|
112
app/DatasetFinder.php
Normal file
112
app/DatasetFinder.php
Normal file
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
namespace App;
|
||||
|
||||
use App\Dataset;
|
||||
|
||||
/**
|
||||
* DocumentFinder short summary.
|
||||
*
|
||||
* DocumentFinder description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author kaiarn
|
||||
*/
|
||||
class DatasetFinder
|
||||
{
|
||||
/**
|
||||
* @var \Illuminate\Database\Eloquent\Builder
|
||||
*/
|
||||
private $_select = null;
|
||||
/**
|
||||
* Create new instance of Opus_DocumentList class. The created object
|
||||
* allows to get custom subsets (or lists) of all existing Opus_Documents.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// $table = Opus_Db_TableGateway::getInstance(self::$_tableGatewayClass);
|
||||
|
||||
// $this->_db = $table->getAdapter();
|
||||
// $this->_select = $this->_db->select()->from(array('d' => 'documents'));
|
||||
|
||||
$this->_select = Dataset::query(); //>select('name', 'email as user_email')
|
||||
}
|
||||
|
||||
/**
|
||||
* Add constraints to be applied on the result set.
|
||||
*
|
||||
* @param string $serverStateArray
|
||||
* @return DatasetFinder Fluent interface.
|
||||
*/
|
||||
public function setServerStateInList($serverStateArray)
|
||||
{
|
||||
$this->_select->whereIn('server_state', $serverStateArray);
|
||||
//$this->_select->where('server_state IN (?)', $serverStateArray);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add constraints to be applied on the result set.
|
||||
*
|
||||
* @param string $type
|
||||
* @return DatasetFinder Fluent interface.
|
||||
*/
|
||||
public function setType($type)
|
||||
{
|
||||
$this->_select->where('type', $type);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add constraints to be applied on the result set.
|
||||
*
|
||||
* @param string $type
|
||||
* @return DatasetFinder Fluent interface.
|
||||
*/
|
||||
public function setServerState($serverState)
|
||||
{
|
||||
//$this->_select->where('server_state', '=', $serverState);
|
||||
$this->_select->where('server_state', 'LIKE', "%".$serverState."%");
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of distinct document types for the given constraint set.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function groupedTypesPlusCount()
|
||||
{
|
||||
//$this->_select->reset('columns');
|
||||
$test = $this->_select
|
||||
//->select("type") // "count(DISTINCT id)");
|
||||
->selectRaw('type, count(DISTINCT id) as count')
|
||||
->groupBy('type')
|
||||
->pluck('count', 'type')
|
||||
->toArray();
|
||||
return $test;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of (distinct) documents for the given constraint set.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count()
|
||||
{
|
||||
$this->_select->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of (distinct) document ids for the given constraint set.
|
||||
*
|
||||
* NOTE: It was not possible to make sure only DISTINCT identifiers are returned. Therefore array_unique is used.
|
||||
* See OPUSVIER-3644 for more information.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function ids()
|
||||
{
|
||||
//return array_unique($this->_db->fetchCol($this->getSelectIds()));
|
||||
return $this->_select->pluck('id')->toArray();
|
||||
}
|
||||
}
|
19
app/File.php
Normal file
19
app/File.php
Normal file
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class File extends Model
|
||||
{
|
||||
protected $table = 'document_files';
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
protected $fillable = [];
|
||||
|
||||
public function dataset()
|
||||
{
|
||||
return $this->belongsTo(\App\Dataset::class, 'document_id', 'id');
|
||||
}
|
||||
}
|
12
app/Fine.php
12
app/Fine.php
|
@ -1,12 +0,0 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fine extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'days',
|
||||
'fines'
|
||||
];
|
||||
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
<?php namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\Registrar;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesAndRegistersUsers;
|
||||
|
||||
class AuthController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Registration & Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users, as well as the
|
||||
| authentication of existing users. By default, this controller uses
|
||||
| a simple trait to add these behaviors. Why don't you explore it?
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesAndRegistersUsers;
|
||||
|
||||
//kalo sudah login redirect kemana
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new authentication controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\Registrar $registrar
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, Registrar $registrar)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->registrar = $registrar;
|
||||
|
||||
$this->middleware('guest', ['except' => 'getLogout']);
|
||||
}
|
||||
|
||||
}
|
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
32
app/Http/Controllers/Auth/ForgotPasswordController.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
|
||||
|
||||
class ForgotPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset emails and
|
||||
| includes a trait which assists in sending these notifications from
|
||||
| your application to your users. Feel free to explore this trait.
|
||||
|
|
||||
*/
|
||||
|
||||
use SendsPasswordResetEmails;
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
51
app/Http/Controllers/Auth/LoginController.php
Normal file
51
app/Http/Controllers/Auth/LoginController.php
Normal file
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\AuthenticatesUsers;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class LoginController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Login Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles authenticating users for the application and
|
||||
| redirecting them to your home screen. The controller uses a trait
|
||||
| to conveniently provide its functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
use AuthenticatesUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after login.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest', ['except' => 'logout']);
|
||||
}
|
||||
|
||||
public function logout(Request $request)
|
||||
{
|
||||
$this->guard()->logout();
|
||||
|
||||
$request->session()->flush();
|
||||
|
||||
$request->session()->regenerate();
|
||||
|
||||
return redirect('/');
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
<?php namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Contracts\Auth\PasswordBroker;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class PasswordController extends Controller {
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Create a new password controller instance.
|
||||
*
|
||||
* @param \Illuminate\Contracts\Auth\Guard $auth
|
||||
* @param \Illuminate\Contracts\Auth\PasswordBroker $passwords
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth, PasswordBroker $passwords)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->passwords = $passwords;
|
||||
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
}
|
71
app/Http/Controllers/Auth/RegisterController.php
Normal file
71
app/Http/Controllers/Auth/RegisterController.php
Normal file
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\User;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Foundation\Auth\RegistersUsers;
|
||||
|
||||
class RegisterController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller handles the registration of new users as well as their
|
||||
| validation and creation. By default this controller uses a trait to
|
||||
| provide this functionality without requiring any additional code.
|
||||
|
|
||||
*/
|
||||
|
||||
use RegistersUsers;
|
||||
|
||||
/**
|
||||
* Where to redirect users after registration.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|min:6|confirmed',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return User
|
||||
*/
|
||||
protected function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
39
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
39
app/Http/Controllers/Auth/ResetPasswordController.php
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Auth;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Foundation\Auth\ResetsPasswords;
|
||||
|
||||
class ResetPasswordController extends Controller
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Password Reset Controller
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This controller is responsible for handling password reset requests
|
||||
| and uses a simple trait to include this behavior. You're free to
|
||||
| explore this trait and override any methods you wish to tweak.
|
||||
|
|
||||
*/
|
||||
|
||||
use ResetsPasswords;
|
||||
|
||||
/**
|
||||
* Where to redirect users after resetting their password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $redirectTo = '/';
|
||||
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('guest');
|
||||
}
|
||||
}
|
|
@ -1,96 +1,82 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Book;
|
||||
use App\Category;
|
||||
use App\Project;
|
||||
use App\Shelf;
|
||||
use App\Http\Requests\BookRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class BookController extends Controller {
|
||||
class BookController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
public function index() : View
|
||||
{
|
||||
//$books = Book::with('category', 'shelf')->get();
|
||||
$books = Book::with('project')->get();
|
||||
return view('rdr.settings.book.book', compact('books'));
|
||||
}
|
||||
|
||||
$this->middleware('auth');
|
||||
public function add()
|
||||
{
|
||||
$categories = Project::pluck('name', 'id');
|
||||
$shelves = Shelf::pluck('shelf', 'id');
|
||||
|
||||
$datum = date('Y-m-d');
|
||||
$nowYear = substr($datum, 0, 4);
|
||||
$years = array();
|
||||
for ($jahr = 1990; $jahr <= $nowYear; $jahr++) {
|
||||
$years[$jahr] = $jahr;
|
||||
}
|
||||
|
||||
return view('rdr.settings.book.add', compact('categories', 'shelves', 'years'));
|
||||
}
|
||||
|
||||
}
|
||||
public function store(BookRequest $request)
|
||||
{
|
||||
$input = $request->all();
|
||||
$book = Book::create($input);
|
||||
session()->flash('flash_message', 'You have been addded 1 book!');
|
||||
return redirect()->route('settings.book');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$books = Book::with('category', 'shelf')->get();
|
||||
public function edit($id)
|
||||
{
|
||||
$book = Book::findOrFail($id);
|
||||
$categories = Project::pluck('name', 'id');
|
||||
// $shelves = Shelf::pluck('shelf', 'id');
|
||||
|
||||
$datum = date('Y-m-d');
|
||||
$nowYear = substr($datum, 0, 4);
|
||||
$years = array();
|
||||
for ($jahr = 1990; $jahr <= $nowYear; $jahr++) {
|
||||
$years[$jahr] = $jahr;
|
||||
}
|
||||
return view('rdr.settings.book.edit', compact('book', 'categories', 'years'));
|
||||
//return view('rdr.settings.book.edit', compact('book', 'categories', 'shelves', 'years'));
|
||||
}
|
||||
|
||||
return view('lms.settings.book.book', compact('books'));
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
$categories = Category::lists('category', 'id');
|
||||
$shelves = Shelf::lists('shelf', 'id');
|
||||
|
||||
$tanggal = date('Y-m-d');
|
||||
$ambilTahun = substr($tanggal, 0, 4);
|
||||
for($tahun = 1990; $tahun <= $ambilTahun; $tahun++){
|
||||
$years[] = $tahun;
|
||||
}
|
||||
|
||||
return view('lms.settings.book.add', compact('categories', 'shelves', 'years'));
|
||||
}
|
||||
|
||||
public function store(BookRequest $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$book = Book::create($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been addded 1 book!');
|
||||
|
||||
return redirect()->route('settings.book');
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$book = Book::findOrFail($id);
|
||||
$categories = Category::lists('category', 'id');
|
||||
$shelves = Shelf::lists('shelf', 'id');
|
||||
|
||||
return view('lms.settings.book.edit', compact('book', 'categories', 'shelves'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function update($id, BookRequest $request)
|
||||
{
|
||||
|
||||
$book = Book::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$book->update($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been updated 1 book!');
|
||||
|
||||
return redirect()->route('settings.book');
|
||||
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
|
||||
$book = Book::findOrFail($id);
|
||||
|
||||
$book->delete();
|
||||
|
||||
session()->flash('flash_message', 'You have been deleted 1 book!');
|
||||
|
||||
return redirect()->route('settings.book');
|
||||
|
||||
}
|
||||
public function update($id, BookRequest $request)
|
||||
{
|
||||
$book = Book::findOrFail($id);
|
||||
$input = $request->all();
|
||||
$book->update($input);
|
||||
session()->flash('flash_message', 'You have updated 1 book!');
|
||||
return redirect()->route('settings.book');
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
$book = Book::findOrFail($id);
|
||||
$book->delete();
|
||||
session()->flash('flash_message', 'You have deleted 1 book!');
|
||||
return redirect()->route('settings.book');
|
||||
}
|
||||
}
|
||||
|
|
107
app/Http/Controllers/BorrowController.php
Normal file
107
app/Http/Controllers/BorrowController.php
Normal file
|
@ -0,0 +1,107 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Book;
|
||||
use App\Person;
|
||||
use App\Transaction;
|
||||
use App\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,85 +0,0 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Category;
|
||||
use App\Http\Requests\CategoryRequest;
|
||||
|
||||
class CategoryController extends Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$categories = Category::get();
|
||||
|
||||
return view('lms.settings.category.category', compact('categories'));
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
return view('lms.settings.category.add');
|
||||
|
||||
}
|
||||
|
||||
public function store(CategoryRequest $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$category = Category::create($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been addded 1 category!');
|
||||
|
||||
return redirect()->route('settings.category');
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$category = Category::findOrFail($id);
|
||||
|
||||
return view('lms.settings.category.edit', compact('category'));
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function update($id, CategoryRequest $request)
|
||||
{
|
||||
|
||||
$category = Category::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
session()->flash('flash_message', 'You have been updated 1 category!');
|
||||
|
||||
$category->update($input);
|
||||
|
||||
return redirect()->route('settings.category');
|
||||
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
|
||||
$category = Category::findOrFail($id);
|
||||
|
||||
$category->delete();
|
||||
|
||||
session()->flash('flash_message', 'You have been deleted 1 category!');
|
||||
|
||||
return redirect()->route('settings.category');
|
||||
|
||||
}
|
||||
|
||||
}
|
96
app/Http/Controllers/CollectionController.php
Normal file
96
app/Http/Controllers/CollectionController.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Collection;
|
||||
|
||||
class CollectionController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//$collections = Collection::take(10)->get();
|
||||
//$collections = Collection::get();
|
||||
$collections = Collection::with('documents')
|
||||
->paginate(8); //get();
|
||||
return view('rdr.settings.collection.collection', compact('collections'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
|
@ -1,11 +1,13 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Foundation\Bus\DispatchesCommands;
|
||||
//use Illuminate\Foundation\Bus\DispatchesCommands;
|
||||
use Illuminate\Foundation\Bus\DispatchesJobs;
|
||||
use Illuminate\Routing\Controller as BaseController;
|
||||
use Illuminate\Foundation\Validation\ValidatesRequests;
|
||||
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
|
||||
|
||||
abstract class Controller extends BaseController {
|
||||
|
||||
use DispatchesCommands, ValidatesRequests;
|
||||
|
||||
abstract class Controller extends BaseController
|
||||
{
|
||||
use AuthorizesRequests, DispatchesJobs, ValidatesRequests;
|
||||
}
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Fine;
|
||||
use App\Http\Requests\FinesRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class FinesController extends Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$fines = Fine::get();
|
||||
|
||||
return view('lms.settings.fine.fine', compact('fines'));
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$fine = Fine::findOrFail($id);
|
||||
|
||||
return view('lms.settings.fine.edit', compact('fine'));
|
||||
|
||||
}
|
||||
|
||||
public function update($id, FinesRequest $request)
|
||||
{
|
||||
$fines = Fine::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$fines->update($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been updated fines!');
|
||||
|
||||
return redirect()->route('settings.fines');
|
||||
|
||||
}
|
||||
|
||||
}
|
85
app/Http/Controllers/HomeController.php
Normal file
85
app/Http/Controllers/HomeController.php
Normal file
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class HomeController extends Controller
|
||||
{
|
||||
/**
|
||||
* Create a new controller instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
//$this->middleware('auth');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
// $tglSekarang = time();
|
||||
|
||||
// $students = Student::get();
|
||||
|
||||
// foreach ($students as $student) {
|
||||
|
||||
// $dateDiff = $tglSekarang - $student['registered_at'];
|
||||
// $durasi = floor($dateDiff/(60 * 60 * 24));
|
||||
// $periode = Periode::first();
|
||||
// if($durasi > $periode['days']){
|
||||
// $student->update(['status' => 0]);
|
||||
// }
|
||||
// else{
|
||||
// $student->update(['status' => 1]);
|
||||
// }
|
||||
|
||||
// }
|
||||
return view('rdr.home.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function contact(): View
|
||||
{
|
||||
return view('rdr.home.contact');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function imprint(): View
|
||||
{
|
||||
return view('rdr.home.imprint');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function about(): View
|
||||
{
|
||||
return view('rdr.home.about');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the application dashboard.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function news(): View
|
||||
{
|
||||
return view('rdr.home.news');
|
||||
}
|
||||
}
|
417
app/Http/Controllers/Oai/RequestController.php
Normal file
417
app/Http/Controllers/Oai/RequestController.php
Normal file
|
@ -0,0 +1,417 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Oai;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Dataset;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use App\Book;
|
||||
|
||||
class RequestController extends Controller
|
||||
{
|
||||
/**
|
||||
* Holds information about which dataset state aka server_state
|
||||
* are delivered out
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
private $_deliveringDocumentStates = array('published', 'deleted'); // maybe deleted documents too
|
||||
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;
|
||||
|
||||
/**
|
||||
* Holds the stylesheet for the transformation.
|
||||
*
|
||||
* @var \DomDocument Defaults to null.
|
||||
*/
|
||||
protected $_xslt = null;
|
||||
|
||||
/**
|
||||
* Holds the xslt processor.
|
||||
*
|
||||
* @var \XSLTProcessor Defaults to null.
|
||||
*/
|
||||
protected $_proc = null;
|
||||
|
||||
/**
|
||||
* Load an xslt stylesheet.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function loadStyleSheet($stylesheet)
|
||||
{
|
||||
$this->_xslt = new \DomDocument;
|
||||
$this->_xslt->load($stylesheet);
|
||||
$this->_proc->importStyleSheet($this->_xslt);
|
||||
if (isset($_SERVER['HTTP_HOST'])) {
|
||||
$this->_proc->setParameter('', 'host', $_SERVER['HTTP_HOST']);
|
||||
}
|
||||
//$this->_proc->setParameter('', 'server', $this->getRequest()->getBaseUrl());
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//$this->middleware('auth');
|
||||
// Initialize member variables.
|
||||
$this->_xml = new \DomDocument;
|
||||
$this->_proc = new \XSLTProcessor;
|
||||
}
|
||||
|
||||
public function index(Request $request)
|
||||
{
|
||||
$oaiRequest = $request->all();
|
||||
$safeRemoveParameters = array('module', 'controller', 'action', 'role');
|
||||
foreach ($safeRemoveParameters as $parameter) {
|
||||
unset($oaiRequest[$parameter]);
|
||||
}
|
||||
return $this->__handleRequest($oaiRequest);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function __handleRequest(array $oaiRequest)
|
||||
{
|
||||
// Setup stylesheet
|
||||
$this->loadStyleSheet('oai-pmh.xslt');
|
||||
|
||||
// Set response time
|
||||
$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]);
|
||||
|
||||
if (isset($oaiRequest['verb'])) {
|
||||
$this->_proc->setParameter('', 'oai_verb', $oaiRequest['verb']);
|
||||
if ($oaiRequest['verb'] == 'Identify') {
|
||||
$this->_handleIdentify();
|
||||
} elseif ($oaiRequest['verb'] == 'ListMetadataFormats') {
|
||||
$this->_handleListMetadataFormats();
|
||||
} elseif ($oaiRequest['verb'] == 'ListRecords') {
|
||||
$this->_handleListRecords($oaiRequest);
|
||||
} elseif ($oaiRequest['verb'] == 'ListIdentifiers') {
|
||||
$this->_handleListIdentifiers($oaiRequest);
|
||||
} elseif ($oaiRequest['verb'] == 'ListSets') {
|
||||
$this->_handleListSets($oaiRequest);
|
||||
} else {
|
||||
$this->_handleIllegalVerb();
|
||||
}
|
||||
} else {
|
||||
$oaiRequest['verb'] = 'Identify';
|
||||
$this->_proc->setParameter('', 'oai_verb', $oaiRequest['verb']);
|
||||
$this->doc = $this->_handleIdentify();
|
||||
}
|
||||
|
||||
//$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');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements response for OAI-PMH verb 'Identify'.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _handleIdentify()
|
||||
{
|
||||
$email = "repository@geologie.ac.at";
|
||||
$repositoryName = "Data Research Repository";
|
||||
$repIdentifier = "rdr.gba.ac.at";
|
||||
//$sampleIdentifier = $this->_configuration->getSampleIdentifier();
|
||||
$earliestDateFromDb = Dataset::earliestPublicationDate();
|
||||
|
||||
// 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('Documents'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Implements response for OAI-PMH verb 'ListMetadataFormats'.
|
||||
*
|
||||
* @param array &$oaiRequest Contains full request information
|
||||
* @return void
|
||||
*/
|
||||
private function _handleListMetadataFormats()
|
||||
{
|
||||
$this->_xml->appendChild($this->_xml->createElement('Documents'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements response for OAI-PMH verb 'ListRecords'.
|
||||
*
|
||||
* @param array &$oaiRequest Contains full request information
|
||||
* @return void
|
||||
*/
|
||||
private function _handleListRecords($oaiRequest)
|
||||
{
|
||||
$maxRecords = 20;//$this->_configuration->getMaxListRecords();
|
||||
$this->_handlingOfLists($oaiRequest, $maxRecords);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements response for OAI-PMH verb 'ListIdentifiers'.
|
||||
*
|
||||
* @param array &$oaiRequest Contains full request information
|
||||
* @return void
|
||||
*/
|
||||
private function _handleListIdentifiers(array &$oaiRequest)
|
||||
{
|
||||
$maxIdentifier = 20;//$this->_configuration->getMaxListIdentifiers();
|
||||
$this->_handlingOfLists($oaiRequest, $maxIdentifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements response for OAI-PMH verb 'ListSets'.
|
||||
*
|
||||
* @param array &$oaiRequest Contains full request information
|
||||
* @return void
|
||||
*/
|
||||
private function _handleListSets()
|
||||
{
|
||||
$repIdentifier = "rdr.gba.ac.at";
|
||||
$this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||
$this->_xml->appendChild($this->_xml->createElement('Documents'));
|
||||
|
||||
//$oaiSets = new Oai_Model_Sets();
|
||||
$sets = array(
|
||||
'bibliography:true' => 'Set for bibliographic entries',
|
||||
'bibliography:false' => 'Set for non-bibliographic entries',
|
||||
);
|
||||
$sets = array_merge(
|
||||
$sets,
|
||||
$this->getSetsForDocumentTypes()
|
||||
);
|
||||
//$sets = $this->getSetsForDocumentTypes();
|
||||
|
||||
foreach ($sets as $type => $name) {
|
||||
$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->appendChild($nameValue);
|
||||
$opusDoc->appendChild($nameAttr);
|
||||
$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.');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method for handling lists.
|
||||
*
|
||||
* @param array $oaiRequest query parameter
|
||||
* @param mixed $maxRecords max count of records
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function _handlingOfLists(array &$oaiRequest, $maxRecords)
|
||||
{
|
||||
if (true === empty($maxRecords)) {
|
||||
$maxRecords = 100;
|
||||
}
|
||||
$repIdentifier = "rdr.gba.ac.at";
|
||||
$this->_proc->setParameter('', 'repIdentifier', $repIdentifier);
|
||||
$this->_xml->appendChild($this->_xml->createElement('Documents'));
|
||||
|
||||
// do some initialisation
|
||||
$cursor = 0;
|
||||
//$totalIds = 0;
|
||||
$start = $maxRecords + 1;
|
||||
$reldocIds = array();
|
||||
|
||||
$metadataPrefix = null;
|
||||
if (true === array_key_exists('metadataPrefix', $oaiRequest)) {
|
||||
$metadataPrefix = $oaiRequest['metadataPrefix'];
|
||||
}
|
||||
$this->_proc->setParameter('', 'oai_metadataPrefix', $metadataPrefix);
|
||||
|
||||
// no resumptionToken is given
|
||||
$finder = Dataset::query();
|
||||
// add server state restrictions
|
||||
$finder->whereIn('server_state', $this->_deliveringDocumentStates);
|
||||
if (array_key_exists('set', $oaiRequest)) {
|
||||
$setarray = explode(':', $oaiRequest['set']);
|
||||
if ($setarray[0] == 'doc-type') {
|
||||
if (count($setarray) === 2 and !empty($setarray[1])) {
|
||||
$finder->where('type', $setarray[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$totalIds = $finder->count();
|
||||
$reldocIds = $finder->pluck('id')->toArray();
|
||||
|
||||
// handling of document ids
|
||||
$restIds = $reldocIds;
|
||||
$workIds = array_splice($restIds, 0, $maxRecords);
|
||||
//foreach ($datasets as $dataset)
|
||||
foreach ($workIds as $dataId) {
|
||||
$dataset = Dataset::findOrFail($dataId);
|
||||
$this->createXmlRecord($dataset);
|
||||
}
|
||||
}
|
||||
|
||||
private function createXmlRecord(Dataset $dataset)
|
||||
{
|
||||
//$node = $this->_xml->createElement('Rdr_Dataset');
|
||||
$domNode = $this->getDatasetXmlDomNode($dataset);
|
||||
// add frontdoor url
|
||||
$this->_addLandingPageAttribute($domNode, $dataset->id);
|
||||
|
||||
// add access rights to element
|
||||
//$this->_addAccessRights($domNode, $dataset);
|
||||
|
||||
$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->setAttribute("Year", $dataset->server_date_modified->format('Y'));
|
||||
//$child->setAttribute("Month", $dataset->server_date_modified->month);
|
||||
//$child->setAttribute("Day", $dataset->server_date_modified->day);
|
||||
//$node->appendChild($child);
|
||||
|
||||
//$type = $dataset->type;
|
||||
$this->_addSpecInformation($node, 'doc-type:' . $dataset->type);
|
||||
//$this->_addSpecInformation($node, 'bibliography:' . 'false');
|
||||
|
||||
$this->_xml->documentElement->appendChild($node);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the landingpage attribute to Rdr_Dataset XML output.
|
||||
*
|
||||
* @param \DOMNode $document Rdr_Dataset XML serialisation
|
||||
* @param string $docid Id of the dataset
|
||||
* @return void
|
||||
*/
|
||||
private function _addLandingPageAttribute(\DOMNode $document, $dataid)
|
||||
{
|
||||
$url = route('document.show', $dataid);
|
||||
|
||||
$owner = $document->ownerDocument;
|
||||
$attr = $owner->createAttribute('landingpage');
|
||||
$attr->appendChild($owner->createTextNode($url));
|
||||
$document->appendChild($attr);
|
||||
}
|
||||
|
||||
private function _addSpecInformation(\DOMNode $document, $information)
|
||||
{
|
||||
$setSpecAttribute = $this->_xml->createAttribute('Value');
|
||||
$setSpecAttributeValue = $this->_xml->createTextNode($information);
|
||||
$setSpecAttribute->appendChild($setSpecAttributeValue);
|
||||
|
||||
$setSpecElement = $this->_xml->createElement('SetSpec');
|
||||
//$setSpecElement =new \DOMElement("SetSpec");
|
||||
$setSpecElement->appendChild($setSpecAttribute);
|
||||
$document->appendChild($setSpecElement);
|
||||
}
|
||||
|
||||
private function getDatasetXmlDomNode($dataset)
|
||||
{
|
||||
if (!in_array($dataset->server_state, $this->_deliveringDocumentStates)) {
|
||||
$message = 'Trying to get a document in server state "' . $dataset->server_state . '"';
|
||||
//Zend_Registry::get('Zend_Log')->err($message);
|
||||
Log::error("server state: $message");
|
||||
throw new \Exception($message);
|
||||
}
|
||||
|
||||
$dataset->fetchValues();
|
||||
$xmlModel = new \App\Library\Xml\XmlModel();
|
||||
$xmlModel->setModel($dataset);
|
||||
$xmlModel->excludeEmptyFields();
|
||||
$xmlModel->setXmlCache(new \App\XmlCache());
|
||||
return $xmlModel->getDomDocument()->getElementsByTagName('Rdr_Dataset')->item(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns oai sets for document types.
|
||||
* @return array
|
||||
*/
|
||||
private function getSetsForDocumentTypes()
|
||||
{
|
||||
$setSpecPattern = self::SET_SPEC_PATTERN;
|
||||
$sets = array();
|
||||
|
||||
$finder = new \App\DatasetFinder();
|
||||
$finder->setServerState('published');
|
||||
foreach ($finder->groupedTypesPlusCount() as $doctype => $row) {
|
||||
if (0 == preg_match("/^$setSpecPattern$/", $doctype)) {
|
||||
$msg = "Invalid SetSpec (doctype='" . $doctype . "')."
|
||||
. " Allowed characters are [$setSpecPattern].";
|
||||
Log::error("OAI-PMH: $msg");
|
||||
continue;
|
||||
}
|
||||
|
||||
$setSpec = 'doc-type:' . $doctype;
|
||||
// $count = $row['count'];
|
||||
$sets[$setSpec] = "Set for document type '$doctype'";
|
||||
}
|
||||
|
||||
return $sets;
|
||||
}
|
||||
|
||||
private function handleIdentifyOld()
|
||||
{
|
||||
//$earliestDateFromDb = Opus_Document::getEarliestPublicationDate();
|
||||
//$earliestDateFromDb = Dataset::select('server_date_created')->orderBy('server_date_created', 'desc')->first()->toDateTimeString();
|
||||
$earliestDateFromDb = Dataset::earliestPublicationDate();
|
||||
|
||||
$sxe = new \SimpleXMLElement('<?xml version="1.0"?><?xml-stylesheet type="text/xsl" href="xsl/oai2.xslt"?><OAI-PMH/>');
|
||||
$sxe->addAttribute('xmlns', 'http://www.openarchives.org/OAI/2.0/');
|
||||
$sxe->addAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
||||
$sxe->addAttribute('xmlns:mml', 'http://www.w3.org/1998/Math/MathML');
|
||||
$sxe->addAttribute('xsi:schemaLocation', 'http://www.openarchives.org/OAI/2.0/ http://www.openarchives.org/OAI/2.0/OAI-PMH.xsd');
|
||||
$sxe->addChild('responseDate', date("Y-m-d\TH:i:s\Z"));
|
||||
|
||||
$uri = explode('?', $_SERVER['REQUEST_URI'], 2);
|
||||
$requestChild = $sxe->addChild('request', url('/') . $uri[0]);
|
||||
$requestChild->addAttribute('verb', 'Identify');
|
||||
|
||||
$identify = $sxe->addChild('Identify');
|
||||
$identify->addChild('repositoryName', "Data Research Repository");
|
||||
$identify->addChild('baseURL', "http://rdr.gba.geolba.ac.at/");
|
||||
$identify->addChild('protocolVersion', '2.0');
|
||||
$identify->addChild('adminEmail', 'repository@geologie.ac.at');
|
||||
//$identify->addChild('earliestDatestamp', '2017-04-07');
|
||||
$identify->addChild('earliestDatestamp', $earliestDateFromDb);
|
||||
$identify->addChild('deletedRecord', 'persistent');
|
||||
|
||||
//$description = $identify->addChild('description');
|
||||
//$oaiIdentifier = $description->addChild('oai-identifier');
|
||||
//$oaiIdentifier->addAttribute('xmlns', 'http://www.openarchives.org/OAI/2.0/oai-identifier');
|
||||
//$oaiIdentifier->addAttribute('xsi:schemaLocation', 'http://www.openarchives.org/OAI/2.0/oai-identifier');
|
||||
//$oaiIdentifier->addChild('scheme', 'oai');
|
||||
|
||||
return $sxe;
|
||||
}
|
||||
}
|
|
@ -1,57 +1,42 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Dataset;
|
||||
use App\Book;
|
||||
use App\Category;
|
||||
use App\Shelf;
|
||||
use App\Periode;
|
||||
use App\Student;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class PagesController extends Controller {
|
||||
class PagesController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// $this->middleware('auth');
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$tglSekarang = time();
|
||||
|
||||
$students = Student::get();
|
||||
|
||||
foreach ($students as $student) {
|
||||
|
||||
$dateDiff = $tglSekarang - $student['registered_at'];
|
||||
$durasi = floor($dateDiff/(60 * 60 * 24));
|
||||
$periode = Periode::first();
|
||||
if($durasi > $periode['days']){
|
||||
$student->update(['status' => 0]);
|
||||
}
|
||||
else{
|
||||
$student->update(['status' => 1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return view('lms.index');
|
||||
|
||||
}
|
||||
|
||||
public function books()
|
||||
{
|
||||
|
||||
$books = Book::with('category', 'shelf')->orderByTitle()->get();
|
||||
|
||||
return view('lms.books', compact('books'));
|
||||
|
||||
}
|
||||
public function documents() : View
|
||||
{
|
||||
// $books = Book::with('category', 'shelf')->orderByTitle()->get();
|
||||
$documents = Dataset::orderByType()->get();
|
||||
return view('rdr.document.documents', compact('documents'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id): View
|
||||
{
|
||||
$document = Dataset::findOrFail($id);
|
||||
$document->load('titles');
|
||||
$document->load('abstracts');
|
||||
return view('rdr.document.show', compact('document'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,148 +0,0 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Book;
|
||||
use App\Student;
|
||||
use App\Transaction;
|
||||
use App\Fine;
|
||||
use App\Category;
|
||||
use App\Http\Requests\PeminjamanRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PeminjamanController extends Controller {
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
//$books = Book::available()->orderByTitle()->lists('title', 'id');
|
||||
$students = Student::notLimit()->active()->orderByName()->lists('name', 'id');
|
||||
//$categories = Category::lists('category', 'id');
|
||||
$categories = Category::get();
|
||||
|
||||
|
||||
return view('lms.peminjaman.peminjaman', compact('students', 'categories'));
|
||||
|
||||
}
|
||||
|
||||
public function store(PeminjamanRequest $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$book_id = $input['book_id'];
|
||||
|
||||
$student_id = $input['student_id'];
|
||||
|
||||
$input['borrowed_at'] = time();
|
||||
|
||||
$transaction = Transaction::create($input);
|
||||
|
||||
$book = Book::findOrFail($book_id);
|
||||
|
||||
$stock = $book['stock'] - 1;
|
||||
|
||||
$book->update(['stock' => $stock]);
|
||||
|
||||
$student = Student::findOrFail($student_id);
|
||||
|
||||
$borrow = $student['borrow'] + 1;
|
||||
|
||||
$student->update(['borrow' => $borrow]);
|
||||
|
||||
session()->flash('flash_message', 'You have been added 1 transaction!');
|
||||
|
||||
return redirect()->route('peminjaman.laporan');
|
||||
|
||||
}
|
||||
|
||||
public function laporan()
|
||||
{
|
||||
$tglSekarang = time();
|
||||
|
||||
$transactions = Transaction::with('student', 'book')->notReturnedYet()->get();
|
||||
|
||||
foreach ($transactions as $transaction) {
|
||||
|
||||
$dateDiff = $tglSekarang - $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('lms.peminjaman.laporan', compact('transactions', 'durasi'));
|
||||
}
|
||||
|
||||
public function pengembalian($id)
|
||||
{
|
||||
$returnedAt = time();
|
||||
|
||||
$transaction = Transaction::findOrFail($id);
|
||||
|
||||
$transaction->update(['status' => 1, 'returned_at' => $returnedAt]);
|
||||
|
||||
//ini bisa langsung, cuman kan harus ambil data stock nya dulu mzzz
|
||||
//$transaction->book()->update(['stock' => 7]);
|
||||
|
||||
$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 been doing 1 returned transaction!');
|
||||
|
||||
return redirect()->route('peminjaman.histori');
|
||||
|
||||
}
|
||||
|
||||
public function perpanjang($id)
|
||||
{
|
||||
|
||||
$transaction = Transaction::findOrFail($id);
|
||||
|
||||
$dateNow = time();
|
||||
|
||||
$transaction->update(['borrowed_at' => $dateNow, 'fines' => 0]);
|
||||
|
||||
session()->flash('flash_message', 'You have been added 1 perpanjang!');
|
||||
|
||||
return redirect()->route('peminjaman.laporan');
|
||||
|
||||
}
|
||||
|
||||
public function histori()
|
||||
{
|
||||
$transactions = Transaction::returned()->get();
|
||||
|
||||
return view('lms.peminjaman.histori', compact('transactions'));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
@ -7,65 +8,51 @@ use App\Student;
|
|||
use App\Http\Requests\PeriodeRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class PeriodeController extends Controller {
|
||||
class PeriodeController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
}
|
||||
public function index()
|
||||
{
|
||||
$periodes = Periode::get();
|
||||
return view('lms.settings.periode.periode', compact('periodes'));
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$periodes = Periode::get();
|
||||
public function edit($id)
|
||||
{
|
||||
$periode = Periode::findOrFail($id);
|
||||
return view('lms.settings.periode.edit', compact('periode'));
|
||||
}
|
||||
|
||||
return view('lms.settings.periode.periode', compact('periodes'));
|
||||
public function update($id, PeriodeRequest $request)
|
||||
{
|
||||
$periode = Periode::findOrFail($id);
|
||||
|
||||
}
|
||||
$input = $request->all();
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$periode = Periode::findOrFail($id);
|
||||
$periode->update($input);
|
||||
|
||||
return view('lms.settings.periode.edit', compact('periode'));
|
||||
//process
|
||||
$tglSekarang = time();
|
||||
|
||||
}
|
||||
|
||||
public function update($id, PeriodeRequest $request)
|
||||
{
|
||||
$periode = Periode::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$periode->update($input);
|
||||
|
||||
//process
|
||||
$tglSekarang = time();
|
||||
|
||||
$students = Student::get();
|
||||
|
||||
foreach ($students as $student) {
|
||||
|
||||
$dateDiff = $tglSekarang - $student['registered_at'];
|
||||
$durasi = floor($dateDiff/(60 * 60 * 24));
|
||||
$periodes = Periode::first();
|
||||
if($durasi > $periodes['days']){
|
||||
$student->update(['status' => 0]);
|
||||
}
|
||||
else{
|
||||
$student->update(['status' => 1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
session()->flash('flash_message', 'You have been updated periode!');
|
||||
|
||||
return redirect()->route('settings.periode');
|
||||
|
||||
}
|
||||
$students = Student::get();
|
||||
|
||||
foreach ($students as $student) {
|
||||
$dateDiff = $tglSekarang - $student['registered_at'];
|
||||
$durasi = floor($dateDiff/(60 * 60 * 24));
|
||||
$periodes = Periode::first();
|
||||
if ($durasi > $periodes['days']) {
|
||||
$student->update(['status' => 0]);
|
||||
} else {
|
||||
$student->update(['status' => 1]);
|
||||
}
|
||||
}
|
||||
|
||||
session()->flash('flash_message', 'You have been updated periode!');
|
||||
return redirect()->route('settings.periode');
|
||||
}
|
||||
}
|
||||
|
|
219
app/Http/Controllers/Publish/IndexController.php
Normal file
219
app/Http/Controllers/Publish/IndexController.php
Normal file
|
@ -0,0 +1,219 @@
|
|||
<?php
|
||||
//https://www.5balloons.info/multi-page-step-form-in-laravel-with-validation/
|
||||
namespace App\Http\Controllers\Publish;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Dataset;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class IndexController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function createStep1(Request $request)
|
||||
{
|
||||
$dataset = $request->session()->get('dataset');
|
||||
return view('publish.create-step1', compact('dataset', $dataset));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function storeStep1(Request $request)
|
||||
{
|
||||
$validatedData = $this->validate($request, [
|
||||
'Type' => 'required|min:4',
|
||||
'rights' => 'required|boolean|in:1'
|
||||
]);
|
||||
// $validatedData = $request->validate([
|
||||
// 'name' => 'required|unique:products',
|
||||
// 'amount' => 'required|numeric',
|
||||
// 'company' => 'required',
|
||||
// 'available' => 'required',
|
||||
// 'description' => 'required',
|
||||
// ]);
|
||||
if (empty($request->session()->get('dataset'))) {
|
||||
// $dataset = new Dataset();
|
||||
//$dataset->fill($validatedData);
|
||||
// $dataset->type = $request->input('type');
|
||||
$dataset = $request->except('rights', '_token');
|
||||
$request->session()->put('dataset', $dataset);
|
||||
} else {
|
||||
$dataset = $request->session()->get('dataset');
|
||||
//$dataset->fill($validatedData);
|
||||
$dataset['Type'] = $request->input('Type');
|
||||
$request->session()->put('dataset', $dataset);
|
||||
}
|
||||
return redirect()->route('dataset.create2');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the step 2 Form for creating a new dataset.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function createStep2(Request $request)
|
||||
{
|
||||
//if no dataset is'nt in session variable return to step1
|
||||
if (empty($request->session()->get('dataset'))) {
|
||||
return redirect()->route('dataset.create1');
|
||||
}
|
||||
|
||||
$dataset = $request->session()->get('dataset');
|
||||
|
||||
//fill select variable
|
||||
$languages = DB::table('languages')
|
||||
->where('active', true)
|
||||
->pluck('part2_t', 'part2_t');
|
||||
|
||||
return view('publish.create-step2', compact('dataset', 'languages'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function storeStep2(Request $request)
|
||||
{
|
||||
$validatedData = $this->validate($request, [
|
||||
'Type' => 'required|min:4',
|
||||
'BelongsToBibliography' => 'required|boolean',
|
||||
"TitleMain.Value" => 'required|min:5|max:255',
|
||||
"TitleMain.Language" => 'required|min:3',
|
||||
"TitleAbstract.Value" => 'required|min:5|max:255',
|
||||
"TitleAbstract.Language" => 'required|min:3'
|
||||
]);
|
||||
$optionalData = $request->all();
|
||||
|
||||
// $dataset = $request->except('rights', '_token', 'input_img');
|
||||
|
||||
$dataset = $request->session()->get('dataset');
|
||||
|
||||
//update dataset with validated data
|
||||
$dataset['Type'] = $validatedData['Type'];
|
||||
$dataset['BelongsToBibliography'] = $validatedData['BelongsToBibliography'];
|
||||
$dataset['TitleMain']['Value'] = $validatedData['TitleMain']['Value'];
|
||||
$dataset['TitleMain']['Language'] = $validatedData['TitleMain']['Language'];
|
||||
$dataset['TitleAbstract']['Value'] = $validatedData['TitleAbstract']['Value'];
|
||||
$dataset['TitleAbstract']['Language'] = $validatedData['TitleAbstract']['Language'];
|
||||
if (isset($optionalData['CreatingCorporation'])) {
|
||||
$dataset['CreatingCorporation'] = $optionalData['CreatingCorporation'];
|
||||
}
|
||||
if (isset($optionalData['EmbargoDate'])) {
|
||||
$dataset['EmbargoDate'] = $optionalData['EmbargoDate'];
|
||||
}
|
||||
|
||||
if (!isset($dataset['DatasetFile'])) {
|
||||
$this->validate($request, [
|
||||
'dataset_file' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048'
|
||||
]);
|
||||
|
||||
//update session variable
|
||||
// $dataset = $request->session()->get('dataset');
|
||||
$image = $request->file('dataset_file');
|
||||
$fileName = "productImage-" . time() . '.' . $image->getClientOriginalExtension();
|
||||
$path = $image->storeAs(
|
||||
'files',
|
||||
$fileName
|
||||
);
|
||||
// $path = Storage::putFile('files', $image, $fileName);
|
||||
|
||||
//$dataset = $request->session()->get('dataset');
|
||||
$dataset['DatasetFile'] = $fileName;
|
||||
}
|
||||
$request->session()->put('dataset', $dataset);
|
||||
return redirect()->route('dataset.create3');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the Product Review page
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function createStep3(Request $request)
|
||||
{
|
||||
//if no dataset is'nt in session variable return to step1
|
||||
if (empty($request->session()->get('dataset'))) {
|
||||
return redirect()->route('dataset.create1');
|
||||
}
|
||||
$dataset = $request->session()->get('dataset');
|
||||
return view('publish.create-step3', compact('dataset'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
$dataset = $request->session()->get('dataset');
|
||||
// $product->save();
|
||||
// return redirect('/dataset');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
162
app/Http/Controllers/SearchController.php
Normal file
162
app/Http/Controllers/SearchController.php
Normal file
|
@ -0,0 +1,162 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Book;
|
||||
use App\Dataset;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use App\Library\Search\Navigation;
|
||||
use App\Library\Util\SolrSearchSearcher;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SearchController extends Controller
|
||||
{
|
||||
private $_query;
|
||||
private $_numOfHits;
|
||||
private $_searchtype;
|
||||
private $_resultList;
|
||||
private $_facetMenu;
|
||||
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* Initialize controller.
|
||||
*/
|
||||
public function __construct(\Solarium\Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
// $config = config('solarium');
|
||||
// $config = array(
|
||||
// 'endpoint' => array(
|
||||
// 'localhost' => array(
|
||||
// 'host' => '127.0.0.1',
|
||||
// 'port' => '8983',
|
||||
// 'path' => '/solr/#',
|
||||
// 'core' => 'opus4'
|
||||
// )
|
||||
// )
|
||||
// );
|
||||
// $this->client = new \Solarium\Client($config);
|
||||
}
|
||||
|
||||
public function ping()
|
||||
{
|
||||
// create a ping query
|
||||
$ping = $this->client->createPing();
|
||||
|
||||
// execute the ping query
|
||||
try {
|
||||
$this->client->ping($ping);
|
||||
return response()->json('OK');
|
||||
} catch (\Solarium\Exception\HttpException $e) {
|
||||
return response()->json('ERROR', 500);
|
||||
}
|
||||
}
|
||||
|
||||
public function search1(Request $request) : View
|
||||
{
|
||||
$this->_request = $request;
|
||||
$data=$request->all();
|
||||
//$this->_searchtype = $request->input('searchtype');
|
||||
$this->_searchtype = $request->input('searchtype');
|
||||
return view('rdr.solrsearch.index');
|
||||
}
|
||||
|
||||
public function search(Request $request) : View
|
||||
{
|
||||
Log::info('Received new search request. Redirecting to search action of IndexController.');
|
||||
$this->_request = $request;
|
||||
|
||||
//$filter =$request->input('query');
|
||||
// $query = $this->client->createSelect();
|
||||
// $query->setQuery('%P1%', array($filter));
|
||||
// // $query->setQuery('*:*');
|
||||
|
||||
// $results = $this->client->select($query);
|
||||
// // // display the total number of documents found by solr
|
||||
// echo 'NumFound: ' .$results->getNumFound();
|
||||
|
||||
//$this->_query = Navigation::getQueryUrl($request);
|
||||
$query = $this->buildQuery();
|
||||
if (!is_null($query)) {
|
||||
$this->_query = $query;
|
||||
$this->performSearch();
|
||||
|
||||
// set start and rows param (comparable to SQL limit) using fluent interface
|
||||
//$query->setStart(2)->setRows(20);
|
||||
// set fields to fetch (this overrides the default setting 'all fields')
|
||||
//$query->setFields(array('id','year'));
|
||||
|
||||
|
||||
$results = $this->_resultList->getResults();
|
||||
$numOfHits = $this->_numOfHits;
|
||||
|
||||
|
||||
return view('rdr.solrsearch.index', compact('results', 'numOfHits'));
|
||||
}
|
||||
return view('rdr.solrsearch.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays simple search form.
|
||||
*/
|
||||
public function index() : View
|
||||
{
|
||||
$totalNumOfDocs = Dataset::count();
|
||||
return view('rdr.solrsearch.index', compact('totalNumOfDocs'));
|
||||
}
|
||||
|
||||
|
||||
public function searchDb(Request $request) : View
|
||||
{
|
||||
$searchType = "simple";
|
||||
$params = $request->all();
|
||||
//build query
|
||||
$this->_searchtype = $request->input('searchtype');
|
||||
|
||||
|
||||
// Gets the query string from our form submission
|
||||
//$query = Request::input('search');
|
||||
$filter = $request->input('search');
|
||||
|
||||
//$query = Input::get('search', '');
|
||||
// Returns an array of articles that have the query string located somewhere within
|
||||
// our articles titles. Paginates them so we can break up lots of search results.
|
||||
$books = Book::where('title', 'LIKE', '%' . $filter . '%')
|
||||
->get();//paginate(10);
|
||||
|
||||
// returns a view and passes the view the list of articles and the original query.
|
||||
return view('rdr.solrsearch.index', compact('books'));
|
||||
}
|
||||
|
||||
|
||||
#region private helper
|
||||
|
||||
private function buildQuery()
|
||||
{
|
||||
$request = $this->_request;
|
||||
$this->_searchtype = $request->input('searchtype');
|
||||
return Navigation::getQueryUrl($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO this should happen in model class so it can be tested directly
|
||||
*/
|
||||
private function performSearch()
|
||||
{
|
||||
//$this->getLogger()->debug('performing search');
|
||||
try {
|
||||
$searcher = new SolrSearchSearcher();
|
||||
// $openFacets = $this->_facetMenu->buildFacetArray( $this->getRequest()->getParams() );
|
||||
// $searcher->setFacetArray($openFacets);
|
||||
$this->_resultList = $searcher->search($this->_query);
|
||||
// $this->view->openFacets = $openFacets;
|
||||
} catch (Exception $e) {
|
||||
// $this->getLogger()->err(__METHOD__ . ' : ' . $e);
|
||||
//throw new Application_SearchException($e);
|
||||
echo 'Exception abgefangen: ', $e->getMessage(), "\n";
|
||||
}
|
||||
$this->_numOfHits = $this->_resultList->getNumberOfHits();
|
||||
}
|
||||
#endregion private helper
|
||||
}
|
96
app/Http/Controllers/Settings/CategoryController.php
Normal file
96
app/Http/Controllers/Settings/CategoryController.php
Normal file
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Project;
|
||||
use App\Http\Requests\ProjectRequest;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class CategoryController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function index() : View
|
||||
{
|
||||
$projects = Project::get();
|
||||
return view('settings.project.category', compact('projects'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function add() : View
|
||||
{
|
||||
return view('settings.project.add');
|
||||
}
|
||||
|
||||
public function store(ProjectRequest $request) : RedirectResponse
|
||||
{
|
||||
$input = $request->all();
|
||||
Project::create($input);
|
||||
session()->flash('flash_message', 'You have added 1 project!');
|
||||
return redirect()->route('settings.project');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id) : View
|
||||
{
|
||||
$project = Project::findOrFail($id);
|
||||
return view('settings.project.edit', compact('project'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update($id, ProjectRequest $request) : RedirectResponse
|
||||
{
|
||||
$project = Project::findOrFail($id);
|
||||
$input = $request->all();
|
||||
$project->update($input);
|
||||
session()->flash('flash_message', 'You have updated 1 project!');
|
||||
return redirect()->route('settings.project');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function delete($id) : RedirectResponse
|
||||
{
|
||||
$project = Project::with('documents')->findOrFail($id);
|
||||
if ($project->documents->count() > 0) {
|
||||
session()->flash(
|
||||
'flash_message',
|
||||
'You cannot delete this project!'
|
||||
. ' There are '
|
||||
. $project->documents->count()
|
||||
. ' documents in this project!'
|
||||
);
|
||||
return redirect()->route('settings.project');
|
||||
} else {
|
||||
$project->delete();
|
||||
session()->flash('flash_message', 'You have deleted 1 project!');
|
||||
return redirect()->route('settings.project');
|
||||
}
|
||||
}
|
||||
}
|
200
app/Http/Controllers/Settings/DatasetController.php
Normal file
200
app/Http/Controllers/Settings/DatasetController.php
Normal file
|
@ -0,0 +1,200 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Dataset;
|
||||
use App\Project;
|
||||
use App\License;
|
||||
use App\Title;
|
||||
use App\Http\Requests\DocumentRequest;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DatasetController extends Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function index(Request $request) : View
|
||||
{
|
||||
|
||||
$searchType = $request->input('searchtype');
|
||||
$builder = Dataset::query();
|
||||
//$registers = array();
|
||||
|
||||
$filter = $request->input('search');
|
||||
$state = (strlen($request->input('state')) > 0) ? $request->input('state') : "published";
|
||||
|
||||
$data = $request->all();
|
||||
|
||||
if ($searchType == "simple") {
|
||||
if (strlen($filter) > 0) {
|
||||
//$builder->where('field1', '=', $criteria1);
|
||||
$builder->whereHas('titles', function ($query) use ($filter) {
|
||||
$query->where('value', 'LIKE', '%' . $filter . '%');
|
||||
});
|
||||
// ::with(['titles' => function ($query) use($filter) {
|
||||
// $query->where('value', 'LIKE', '%' . $filter . '%');
|
||||
// }])
|
||||
}
|
||||
}
|
||||
$builder->where('server_state', $state);
|
||||
|
||||
|
||||
//$perPage = $request->get('perPage', 20);
|
||||
$documents = $builder
|
||||
->paginate(8);
|
||||
return view('settings.document.document', compact('documents'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id): View
|
||||
{
|
||||
$document = Dataset::findOrFail($id);
|
||||
$document->load('titles');
|
||||
$document->load('abstracts');
|
||||
return view('settings.document.show', compact('document'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
// $categories = Category::lists('category', 'id');
|
||||
// $shelves = Shelf::lists('shelf', 'id');
|
||||
// $tanggal = date('Y-m-d');
|
||||
// $ambilTahun = substr($tanggal, 0, 4);
|
||||
// for($tahun = 1990; $tahun <= $ambilTahun; $tahun++){
|
||||
// $years[] = $tahun;
|
||||
// }
|
||||
// return view('lms.settings.book.add', compact('categories', 'shelves', 'years'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(DocumentRequest $request)
|
||||
{
|
||||
// $input = $request->all();
|
||||
// $book = Book::create($input);
|
||||
// session()->flash('flash_message', 'You have been addded 1 dataset!');
|
||||
// return redirect()->route('settings.book');
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id) : View
|
||||
{
|
||||
$document = Dataset::findOrFail($id);
|
||||
$document->load('licenses', 'titles', 'abstracts');
|
||||
|
||||
$projects = Project::pluck('label', 'id');
|
||||
|
||||
$datum = date('Y-m-d');
|
||||
$nowYear = substr($datum, 0, 4);
|
||||
$years = array();
|
||||
for ($jahr = 1990; $jahr <= $nowYear; $jahr++) {
|
||||
$years[$jahr] = $jahr;
|
||||
}
|
||||
|
||||
$languages = DB::table('languages')
|
||||
->where('active', true)
|
||||
->pluck('part2_t', 'part2_t');
|
||||
|
||||
//$options = License::all();
|
||||
$options = License::all('id', 'name_long');
|
||||
$checkeds = $document->licenses->pluck('id')->toArray();
|
||||
|
||||
//$shelves = Shelf::pluck('shelf', 'id');
|
||||
// $datum = date('Y-m-d');
|
||||
// $nowYear = substr($datum, 0, 4);
|
||||
// $years = array();
|
||||
// for($jahr = 1990; $jahr <= $nowYear; $jahr++){
|
||||
// $years[$jahr] = $jahr;
|
||||
// }
|
||||
return view('settings.document.edit', compact('document', 'projects', 'options', 'checkeds', 'years', 'languages'));
|
||||
}
|
||||
|
||||
//https://stackoverflow.com/questions/17480200/using-laravel-how-do-i-create-a-view-that-will-update-a-one-to-many-relationshi?rq=1
|
||||
// https://laravel.io/forum/06-11-2014-how-to-save-eloquent-model-with-relations-in-one-go
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(DocumentRequest $request, $id) : RedirectResponse
|
||||
{
|
||||
$document = Dataset::findOrFail($id);
|
||||
//$input = $request->all();
|
||||
$input = $request->except('licenses', 'titles');
|
||||
$document->update($input);
|
||||
// $document->type = $input['type'];
|
||||
// $document->thesis_year_accepted = $input['thesis_year_accepted'];
|
||||
// $document->project_id = $input['project_id'];
|
||||
// $document->save();
|
||||
|
||||
$licenses = $request->input('licenses');
|
||||
//$licenses = $input['licenses'];
|
||||
$document->licenses()->sync($licenses);
|
||||
|
||||
//save the titles:
|
||||
$titles = $request->input('titles');
|
||||
if (is_array($titles) && count($titles) > 0) {
|
||||
foreach ($titles as $key => $formTitle) {
|
||||
$title = Title::findOrFail($key);
|
||||
$title->value = $formTitle['value'];
|
||||
$title->language = $formTitle['language'];
|
||||
$title->save();
|
||||
}
|
||||
}
|
||||
|
||||
//save the abstracts:
|
||||
$abstracts = $request->input('abstracts');
|
||||
if (is_array($abstracts) && count($abstracts) > 0) {
|
||||
foreach ($abstracts as $key => $formAbstract) {
|
||||
$abstract = Title::findOrFail($key);
|
||||
$abstract->value = $formAbstract['value'];
|
||||
$abstract->language = $formAbstract['language'];
|
||||
$abstract->save();
|
||||
}
|
||||
}
|
||||
|
||||
session()->flash('flash_message', 'You have updated 1 dataset!');
|
||||
return redirect()->route('settings.document');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id) : RedirectResponse
|
||||
{
|
||||
// $document = Document::findOrFail($id);
|
||||
// $document->delete();
|
||||
// session()->flash('flash_message', 'You have been deleted 1 dataset!');
|
||||
return redirect()->route('settings.document');
|
||||
}
|
||||
}
|
47
app/Http/Controllers/Settings/LicenseController.php
Normal file
47
app/Http/Controllers/Settings/LicenseController.php
Normal file
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\License;
|
||||
use App\Language;
|
||||
use App\Http\Requests\LicenseRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LicenseController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
$test = "test";
|
||||
}
|
||||
|
||||
public function index() : View
|
||||
{
|
||||
$licenses = License::get();
|
||||
return view('settings.license.license', compact('licenses'));
|
||||
}
|
||||
|
||||
public function edit($id): View
|
||||
{
|
||||
$license = License::findOrFail($id);
|
||||
//$languages = Language::where('active', true)->pluck('part2_t');
|
||||
$languages = DB::table('languages')
|
||||
->where('active', true)
|
||||
->pluck('part2_t', 'part2_t');
|
||||
|
||||
return view('settings.license.edit', compact('license', 'languages'));
|
||||
}
|
||||
|
||||
public function update($id, LicenseRequest $request): RedirectResponse
|
||||
{
|
||||
$license = License::findOrFail($id);
|
||||
$input = $request->all();
|
||||
$license->update($input);
|
||||
session()->flash('flash_message', 'You have updated the license!');
|
||||
return redirect()->route('settings.license');
|
||||
}
|
||||
}
|
133
app/Http/Controllers/Settings/PersonController.php
Normal file
133
app/Http/Controllers/Settings/PersonController.php
Normal file
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Person;
|
||||
use App\Http\Requests\PersonRequest;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\View\View;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
|
||||
class PersonController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
//$this->middleware('role:reviewer');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(): View
|
||||
{
|
||||
//$persons = Person::get();
|
||||
$persons = Person::with('documents')->get();
|
||||
return view('settings.person.person', compact('persons'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function add(): View
|
||||
{
|
||||
return view('settings.person.add');
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(PersonRequest $request)
|
||||
{
|
||||
$input = $request->all();
|
||||
$input['registered_at'] = time();
|
||||
Person::create($input);
|
||||
session()->flash('flash_message', 'You have added 1 person!');
|
||||
return redirect()->route('settings.person');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$person = Person::with('documents')->findOrFail($id);
|
||||
return view('settings.person.edit', compact('person'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update($id, PersonRequest $request)
|
||||
{
|
||||
$person = Person::findOrFail($id);
|
||||
$input = $request->all();
|
||||
$person->update($input);
|
||||
session()->flash('flash_message', 'You have updated 1 person!');
|
||||
return redirect()->route('settings.person');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
$person = Person::with('documents')->findOrFail($id);
|
||||
if ($person->documents->count() > 0) {
|
||||
// $person->documents()->detach();
|
||||
// $person->delete();
|
||||
session()->flash('flash_message', 'You cannot delete this person!');
|
||||
} else {
|
||||
$person->delete();
|
||||
session()->flash('flash_message', 'You have deleted 1 person!');
|
||||
}
|
||||
return redirect()->route('settings.person');
|
||||
}
|
||||
|
||||
/**
|
||||
* deactivate author, submitter etc....
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function down($id): RedirectResponse
|
||||
{
|
||||
$person = Person::findOrFail($id);
|
||||
$person->update(['status' => 0, 'registered_at' => 00000000]);
|
||||
session()->flash('flash_message', 'person has been deactivated!');
|
||||
return redirect()->route('settings.person');
|
||||
}
|
||||
|
||||
/**
|
||||
* activatew author, submitter etc....
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function up($id): RedirectResponse
|
||||
{
|
||||
$dateNow = time();
|
||||
$person = Person::findOrFail($id);
|
||||
$person->update(['status' => 1, 'registered_at' => $dateNow]);
|
||||
session()->flash('flash_message', 'person has been activated!');
|
||||
return redirect()->route('settings.person');
|
||||
}
|
||||
}
|
108
app/Http/Controllers/Settings/RoleController.php
Normal file
108
app/Http/Controllers/Settings/RoleController.php
Normal file
|
@ -0,0 +1,108 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use App\Role;
|
||||
use App\Permission;
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
||||
class RoleController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$roles = Role::all();
|
||||
return view('settings.role.role', compact('roles'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
$permissions = Permission::all('id', 'name');
|
||||
return view('settings.role.create', compact('permissions'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Store a newly created resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function store(Request $request)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param \App\Role $role
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show(Role $role)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param \App\Role $role
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$role = Role::find($id);
|
||||
$permissions = Permission::all('id', 'name');
|
||||
|
||||
//$userRoles = $user->roles->pluck('name','name')->all();
|
||||
$checkeds = $role->permissions->pluck('id')->toArray();
|
||||
return view('settings.role.edit', compact('role', 'permissions', 'checkeds'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \App\Role $role
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$this->validate(request(), [
|
||||
'name' => 'required'
|
||||
]);
|
||||
$role = Role::findOrFail($id);
|
||||
$role->update($request->except('permissions'));
|
||||
|
||||
$permissions = $request->input('permissions') ? $request->input('permissions') : [];
|
||||
//$role->syncPermissions($permissions);
|
||||
if (isset($permissions)) {
|
||||
$role->permissions()->sync($permissions);//If one or more role is selected associate user to roles
|
||||
} else {
|
||||
$role->permissions()->detach(); //If no role is selected remove exisiting role associated to a user
|
||||
}
|
||||
|
||||
return redirect()->route('role.index')
|
||||
->with('flash_message', 'Role successfully edited.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param \App\Role $role
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy(Role $role)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
169
app/Http/Controllers/Settings/UserController.php
Normal file
169
app/Http/Controllers/Settings/UserController.php
Normal file
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers\Settings;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\User;
|
||||
//use Spatie\Permission\Models\Role;
|
||||
use App\Role;
|
||||
use Illuminate\Support\Facades\Gate;
|
||||
|
||||
class UserController extends Controller
|
||||
{
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function index(Request $request)
|
||||
{
|
||||
//if (! Gate::allows('settings'))
|
||||
//{
|
||||
// return abort(401, 'Unauthorized action.');
|
||||
//}
|
||||
|
||||
$users = User::orderBy('id', 'DESC')->paginate(5);
|
||||
return view('settings.user.user', compact('users'))
|
||||
->with('i', ($request->input('page', 1) - 1) * 5);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for creating a new resource.
|
||||
*
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
//$roles = Role::pluck('name','name')->all();
|
||||
$roles = Role::all('id', 'name');
|
||||
return view('settings.user.create', compact('roles'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* Store a newly created resource in storage.
|
||||
|
||||
*
|
||||
|
||||
* @param \Illuminate\Http\Request $request
|
||||
|
||||
* @return \Illuminate\Http\Response
|
||||
|
||||
*/
|
||||
|
||||
public function store(Request $request)
|
||||
{
|
||||
$this->validate($request, [
|
||||
'login' => 'required',
|
||||
'email' => 'required|email|unique:accounts',
|
||||
'password' => 'required|min:6|confirmed'
|
||||
//'roles' => 'required'
|
||||
]);
|
||||
|
||||
//$input = $request->all();
|
||||
$input = $request->only(['login', 'email', 'password']); //Retreive the name, email and password fields
|
||||
$input['password'] = bcrypt($input['password']);
|
||||
$user = User::create($input);
|
||||
|
||||
|
||||
$roles = $request['roles']; //Retrieving the roles field
|
||||
//Checking if a role was selected
|
||||
if (isset($roles)) {
|
||||
foreach ($roles as $role) {
|
||||
$role_r = Role::where('id', '=', $role)->firstOrFail();
|
||||
$user->assignRole($role_r); //Assigning role to user
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('user.index')
|
||||
->with('success', 'User has been created successfully');
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function show($id)
|
||||
{
|
||||
$user = User::find($id);
|
||||
return view('settings.user.show', compact('user'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the form for editing the specified resource.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$user = User::find($id);
|
||||
$roles = Role::all('id', 'name');
|
||||
|
||||
//$userRoles = $user->roles->pluck('name','name')->all();
|
||||
$checkeds = $user->roles->pluck('id')->toArray();
|
||||
|
||||
return view('settings.user.edit', compact('user', 'roles', 'checkeds'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the specified resource in storage.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
|
||||
$this->validate(request(), [
|
||||
'login' => 'required',
|
||||
'email' => 'required|email|unique:accounts,email,' . $id,
|
||||
'password' => 'required|min:6|confirmed'
|
||||
]);
|
||||
|
||||
$user = User::findOrFail($id);
|
||||
// $input = $request->except('roles');
|
||||
// $user->fill($input)->save();
|
||||
|
||||
$input = $request->only(['login', 'email', 'password']); //Retreive the name, email and password fields
|
||||
//$input = $request->all();
|
||||
$user->login = $input['login'];
|
||||
$user->email = $input['email'];
|
||||
$user->password = bcrypt($input['password']);
|
||||
$user->save();
|
||||
|
||||
$roles = $request['roles']; //Retreive all roles
|
||||
|
||||
if (isset($roles)) {
|
||||
$user->roles()->sync($roles);//If one or more role is selected associate user to roles
|
||||
} else {
|
||||
$user->roles()->detach(); //If no role is selected remove exisiting role associated to a user
|
||||
}
|
||||
|
||||
//return back()->with('flash_message', 'user successfully updated.');
|
||||
return redirect()
|
||||
->route('user.index')
|
||||
->with('flash_message', 'User successfully edited.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\Response
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//Find a user with a given id and delete
|
||||
$user = User::findOrFail($id);
|
||||
$user->delete();
|
||||
|
||||
return redirect()
|
||||
->route('user.index')
|
||||
->with('flash_message', 'User successfully deleted.');
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
|
@ -6,78 +7,64 @@ use App\Shelf;
|
|||
use App\Http\Requests\ShelfRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class ShelfController extends Controller {
|
||||
class ShelfController extends Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
$this->middleware('auth');
|
||||
public function index()
|
||||
{
|
||||
$shelves = Shelf::get();
|
||||
return view('lms.settings.shelf.shelf', compact('shelves'));
|
||||
}
|
||||
|
||||
}
|
||||
public function add()
|
||||
{
|
||||
return view('lms.settings.shelf.add');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$shelves = Shelf::get();
|
||||
public function store(ShelfRequest $request)
|
||||
{
|
||||
$input = $request->all();
|
||||
|
||||
return view('lms.settings.shelf.shelf', compact('shelves'));
|
||||
}
|
||||
$shelf = Shelf::create($input);
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
return view('lms.settings.shelf.add');
|
||||
//flash messaging
|
||||
session()->flash('flash_message', 'You have been added 1 shelf!');
|
||||
|
||||
}
|
||||
return redirect()->route('settings.shelf');
|
||||
}
|
||||
|
||||
public function store(ShelfRequest $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
public function edit($id)
|
||||
{
|
||||
$shelf = Shelf::findOrFail($id);
|
||||
return view('lms.settings.shelf.edit', compact('shelf'));
|
||||
}
|
||||
|
||||
$shelf = Shelf::create($input);
|
||||
public function update($id, ShelfRequest $request)
|
||||
{
|
||||
$shelf = Shelf::findOrFail($id);
|
||||
|
||||
//flash messaging
|
||||
session()->flash('flash_message', 'You have been added 1 shelf!');
|
||||
$input = $request->all();
|
||||
|
||||
return redirect()->route('settings.shelf');
|
||||
$shelf->update($input);
|
||||
|
||||
}
|
||||
session()->flash('flash_message', 'You have been updated 1 shelf!');
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$shelf = Shelf::findOrFail($id);
|
||||
return redirect()->route('settings.shelf');
|
||||
}
|
||||
|
||||
return view('lms.settings.shelf.edit', compact('shelf'));
|
||||
public function delete($id)
|
||||
{
|
||||
$shelf = Shelf::findOrFail($id);
|
||||
|
||||
}
|
||||
$shelf->delete();
|
||||
|
||||
public function update($id, ShelfRequest $request)
|
||||
{
|
||||
|
||||
$shelf = Shelf::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$shelf->update($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been updated 1 shelf!');
|
||||
|
||||
return redirect()->route('settings.shelf');
|
||||
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
|
||||
$shelf = Shelf::findOrFail($id);
|
||||
|
||||
$shelf->delete();
|
||||
|
||||
session()->flash('flash_message', 'You have been deleted 1 shelf!');
|
||||
|
||||
return redirect()->route('settings.shelf');
|
||||
|
||||
}
|
||||
session()->flash('flash_message', 'You have been deleted 1 shelf!');
|
||||
|
||||
return redirect()->route('settings.shelf');
|
||||
}
|
||||
}
|
||||
|
|
61
app/Http/Controllers/SitelinkController.php
Normal file
61
app/Http/Controllers/SitelinkController.php
Normal file
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Dataset;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SitelinkController extends Controller
|
||||
{
|
||||
|
||||
public function index()
|
||||
{
|
||||
//get server state published
|
||||
$serverState = 'published';
|
||||
$select = DB::table('documents')
|
||||
->where('server_state', 'LIKE', "%".$serverState."%");
|
||||
|
||||
$select
|
||||
->select(DB::raw('YEAR(published_date) as published_date'))
|
||||
->distinct(true);
|
||||
|
||||
$this->years = $select->pluck('published_date');
|
||||
$this->ids = array();
|
||||
return view('rdr.sitelink.index')->with(['years'=> $this->years,'documents'=> $this->ids]);
|
||||
}
|
||||
|
||||
public function list($year)
|
||||
{
|
||||
$this->index();
|
||||
if (preg_match('/^\d{4}$/', $year) > 0) {
|
||||
$serverState = 'published';
|
||||
//$select = DB::table('documents')
|
||||
//->where('server_state','LIKE', "%".$serverState."%");
|
||||
$select = Dataset::with('titles', 'authors')
|
||||
->where('server_state', 'LIKE', "%".$serverState."%");
|
||||
|
||||
$from = (int)$year;
|
||||
$until = $year + 1;
|
||||
$select
|
||||
->whereYear('server_date_published', '>=', $from)
|
||||
->whereYear('server_date_published', '<', $until);
|
||||
|
||||
|
||||
$documents = $select
|
||||
->get();
|
||||
|
||||
//$this->years = Dataset::select(DB::raw('YEAR(server_date_modified) as server_date_modified'))
|
||||
//->distinct(true)
|
||||
//->pluck('server_date_modified');
|
||||
//->filter(function ($item) use ($year){
|
||||
// return $item->year !== $year;
|
||||
//});
|
||||
|
||||
|
||||
//$select->select('id');
|
||||
//$this->ids = $select->pluck('id');
|
||||
//return view('rdr.sitelink.index')->with(['years'=> $this->years,'ids'=> $this->ids]);
|
||||
return view('rdr.sitelink.index')->with(['years'=> $this->years,'documents'=> $documents]);
|
||||
}
|
||||
}
|
||||
}
|
25
app/Http/Controllers/StaticPageController.php
Normal file
25
app/Http/Controllers/StaticPageController.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StaticPageController extends Controller
|
||||
{
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->middleware('auth');
|
||||
}
|
||||
|
||||
public function imprint()
|
||||
{
|
||||
////$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'));
|
||||
}
|
||||
}
|
|
@ -1,114 +0,0 @@
|
|||
<?php namespace App\Http\Controllers;
|
||||
|
||||
use App\Http\Requests;
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Student;
|
||||
use App\Http\Requests\StudentRequest;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StudentController extends Controller {
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
$this->middleware('auth');
|
||||
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
|
||||
$students = Student::get();
|
||||
|
||||
return view('lms.settings.student.student', compact('students'));
|
||||
|
||||
}
|
||||
|
||||
public function add()
|
||||
{
|
||||
|
||||
return view('lms.settings.student.add');
|
||||
|
||||
}
|
||||
|
||||
public function store(StudentRequest $request)
|
||||
{
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$input['registered_at'] = time();
|
||||
|
||||
$student = Student::create($input);
|
||||
|
||||
return redirect()->route('settings.student');
|
||||
|
||||
session()->flash('flash_message', 'You have been added 1 student!');
|
||||
|
||||
}
|
||||
|
||||
public function edit($id)
|
||||
{
|
||||
|
||||
$student = Student::findOrFail($id);
|
||||
|
||||
return view('lms.settings.student.edit', compact('student'));
|
||||
|
||||
}
|
||||
|
||||
public function update($id, StudentRequest $request)
|
||||
{
|
||||
|
||||
$student = Student::findOrFail($id);
|
||||
|
||||
$input = $request->all();
|
||||
|
||||
$student->update($input);
|
||||
|
||||
session()->flash('flash_message', 'You have been updated 1 student!');
|
||||
|
||||
return redirect()->route('settings.student');
|
||||
|
||||
}
|
||||
|
||||
public function delete($id)
|
||||
{
|
||||
|
||||
$student = Student::findOrFail($id);
|
||||
|
||||
$student->delete();
|
||||
|
||||
session()->flash('flash_message', 'You have been deleted 1 student!');
|
||||
|
||||
return redirect()->route('settings.student');
|
||||
|
||||
}
|
||||
|
||||
public function down($id)
|
||||
{
|
||||
|
||||
$student = Student::findOrFail($id);
|
||||
|
||||
$student->update(['status' => 0, 'registered_at' => 12960000]);
|
||||
|
||||
session()->flash('flash_message', 'Anda telah mematikan masa aktif 1 siswa!');
|
||||
|
||||
return redirect()->route('settings.student');
|
||||
|
||||
}
|
||||
|
||||
public function up($id)
|
||||
{
|
||||
$dateNow = time();
|
||||
|
||||
$student = Student::findOrFail($id);
|
||||
|
||||
$student->update(['status' => 1, 'registered_at' => $dateNow]);
|
||||
|
||||
session()->flash('flash_message', 'Anda telah melakukan perpanjangan masa aktif siswa!');
|
||||
|
||||
return redirect()->route('settings.student');
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,32 +1,63 @@
|
|||
<?php namespace App\Http;
|
||||
<?php
|
||||
namespace App\Http;
|
||||
|
||||
use Illuminate\Foundation\Http\Kernel as HttpKernel;
|
||||
|
||||
class Kernel extends HttpKernel {
|
||||
class Kernel extends HttpKernel
|
||||
{
|
||||
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middleware = [
|
||||
'Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode',
|
||||
'Illuminate\Cookie\Middleware\EncryptCookies',
|
||||
'Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse',
|
||||
'Illuminate\Session\Middleware\StartSession',
|
||||
'Illuminate\View\Middleware\ShareErrorsFromSession',
|
||||
'App\Http\Middleware\VerifyCsrfToken',
|
||||
];
|
||||
/**
|
||||
* The application's global HTTP middleware stack.
|
||||
*
|
||||
* 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
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
'auth' => 'App\Http\Middleware\Authenticate',
|
||||
'auth.basic' => 'Illuminate\Auth\Middleware\AuthenticateWithBasicAuth',
|
||||
'guest' => 'App\Http\Middleware\RedirectIfAuthenticated',
|
||||
];
|
||||
/**
|
||||
* The application's route middleware groups.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $middlewareGroups = [
|
||||
'web' => [
|
||||
\App\Http\Middleware\EncryptCookies::class,
|
||||
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
|
||||
// \Illuminate\Session\Middleware\AuthenticateSession::class,
|
||||
\Illuminate\Session\Middleware\StartSession::class,
|
||||
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
|
||||
\App\Http\Middleware\VerifyCsrfToken::class,
|
||||
\Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
//\Opus4\Http\Middleware\Locale::class,
|
||||
],
|
||||
|
||||
'api' => [
|
||||
'throttle:60,1',
|
||||
'bindings',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* The application's route middleware.
|
||||
*
|
||||
* These middleware may be assigned to groups or used individually.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $routeMiddleware = [
|
||||
//'auth' => 'App\Http\Middleware\Authenticate',
|
||||
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
|
||||
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
|
||||
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
|
||||
'can' => \Illuminate\Auth\Middleware\Authorize::class,
|
||||
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
|
||||
'role' => \Spatie\Permission\Middlewares\RoleMiddleware::class,
|
||||
'perm' => \App\Http\Middleware\PermissionMiddleware::class,
|
||||
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,50 +1,47 @@
|
|||
<?php namespace App\Http\Middleware;
|
||||
<?php
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
|
||||
class Authenticate {
|
||||
class Authenticate
|
||||
{
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest())
|
||||
{
|
||||
if ($request->ajax())
|
||||
{
|
||||
return response('Unauthorized.', 401);
|
||||
}
|
||||
else
|
||||
{
|
||||
return redirect()->guest('auth/login');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
return redirect()->guest('auth/login');
|
||||
}
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
16
app/Http/Middleware/EncryptCookies.php
Normal file
16
app/Http/Middleware/EncryptCookies.php
Normal file
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Cookie\Middleware\EncryptCookies as BaseEncrypter;
|
||||
|
||||
class EncryptCookies extends BaseEncrypter
|
||||
{
|
||||
/**
|
||||
* The names of the cookies that should not be encrypted.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
45
app/Http/Middleware/PermissionMiddleware.php
Normal file
45
app/Http/Middleware/PermissionMiddleware.php
Normal file
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Closure;
|
||||
|
||||
class PermissionMiddleware
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $permission)
|
||||
{
|
||||
if (Auth::guest()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
return redirect()->guest('/login');
|
||||
}
|
||||
}
|
||||
|
||||
//if (! $request->user()->hasRole($role))
|
||||
//{
|
||||
// abort(401);
|
||||
//}
|
||||
foreach ($request->user()->roles()->get() as $role) {
|
||||
if ($role->hasPermissionTo($permission)) {
|
||||
return $next($request);
|
||||
}
|
||||
//break(1);
|
||||
}
|
||||
|
||||
//if (! $request->user()->can($permission))
|
||||
//{
|
||||
// abort(401);
|
||||
//}
|
||||
return abort(401);
|
||||
//return $next($request);
|
||||
}
|
||||
}
|
|
@ -1,44 +1,25 @@
|
|||
<?php namespace App\Http\Middleware;
|
||||
<?php
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
class RedirectIfAuthenticated {
|
||||
|
||||
/**
|
||||
* The Guard implementation.
|
||||
*
|
||||
* @var Guard
|
||||
*/
|
||||
protected $auth;
|
||||
|
||||
/**
|
||||
* Create a new filter instance.
|
||||
*
|
||||
* @param Guard $auth
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Guard $auth)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->check())
|
||||
{
|
||||
return new RedirectResponse(url('/home'));
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
class RedirectIfAuthenticated
|
||||
{
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next, $guard = null)
|
||||
{
|
||||
if (Auth::guard($guard)->check()) {
|
||||
return redirect('/');
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
|
|
25
app/Http/Middleware/TrimStrings.php
Normal file
25
app/Http/Middleware/TrimStrings.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Illuminate\Foundation\Http\Middleware\TrimStrings as BaseTrimmer;
|
||||
|
||||
/**
|
||||
* TrimStrings short summary.
|
||||
*
|
||||
* TrimStrings description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author kaiarn
|
||||
*/
|
||||
class TrimStrings extends BaseTrimmer
|
||||
{
|
||||
/**
|
||||
* The names of the attributes that should not be trimmed.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
'password',
|
||||
'password_confirmation',
|
||||
];
|
||||
}
|
|
@ -1,20 +1,16 @@
|
|||
<?php namespace App\Http\Middleware;
|
||||
<?php
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as BaseVerifier;
|
||||
|
||||
class VerifyCsrfToken extends BaseVerifier {
|
||||
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
return parent::handle($request, $next);
|
||||
}
|
||||
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
|
||||
|
||||
class VerifyCsrfToken extends Middleware
|
||||
{
|
||||
/**
|
||||
* The URIs that should be excluded from CSRF verification.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
];
|
||||
}
|
||||
|
|
|
@ -1,32 +1,33 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
<?php
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class BookRequest extends Request {
|
||||
class BookRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'title' => 'required|min:5',
|
||||
'author' => 'required|min:4',
|
||||
'stock' => 'required|integer',
|
||||
'year' => 'required|integer|min:4'
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'title' => 'required|min:5',
|
||||
'author' => 'required|min:4',
|
||||
'stock' => 'required|integer',
|
||||
'year' => 'required|integer|min:4'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class CategoryRequest extends Request {
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
'category' => 'required|min:3'
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
}
|
33
app/Http/Requests/DocumentRequest.php
Normal file
33
app/Http/Requests/DocumentRequest.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class DocumentRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'type' => 'required|min:5',
|
||||
// 'author' => 'required|min:4',
|
||||
// 'stock' => 'required|integer',
|
||||
// 'year' => 'required|integer|min:4'
|
||||
];
|
||||
}
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class FinesRequest extends Request {
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'days' => 'required|integer',
|
||||
'fines' => 'required|integer'
|
||||
];
|
||||
}
|
||||
|
||||
}
|
38
app/Http/Requests/LicenseRequest.php
Normal file
38
app/Http/Requests/LicenseRequest.php
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class LicenseRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'desc_text' => 'max:4000',
|
||||
'language' => 'max:3',
|
||||
'link_licence' => 'required|url:max:255',
|
||||
'link_logo' => 'url|max:255',
|
||||
'mime_type' => 'max:30',
|
||||
'name_long' => 'required|min:5|max:255',
|
||||
'sort_order' => 'required|integer',
|
||||
'active' => 'required|boolean',
|
||||
'pod_allowed' => 'required|boolean'
|
||||
];
|
||||
}
|
||||
}
|
|
@ -1,29 +1,30 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
<?php
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class PeminjamanRequest extends Request {
|
||||
class PeminjamanRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
//
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
<?php
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class PeriodeRequest extends Request {
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'days' => 'required|integer'
|
||||
];
|
||||
}
|
||||
class PeriodeRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'days' => 'required|integer'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
34
app/Http/Requests/PersonRequest.php
Normal file
34
app/Http/Requests/PersonRequest.php
Normal file
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class PersonRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'academic_title' => 'nullable|min:2|max:255',
|
||||
'last_name' => 'required|min:3|max:255',
|
||||
'first_name' => 'nullable|min:3|max:255',
|
||||
'email' => 'nullable|email|max:100',
|
||||
'identifier_orcid' => 'nullable|min:19|max:50',
|
||||
'status' => 'required|boolean'
|
||||
];
|
||||
}
|
||||
}
|
32
app/Http/Requests/ProjectRequest.php
Normal file
32
app/Http/Requests/ProjectRequest.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class ProjectRequest extends Request
|
||||
{
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
'name' => 'required|min:3|max:255',
|
||||
'label' => 'required|min:3|max:10'
|
||||
|
||||
];
|
||||
}
|
||||
}
|
|
@ -1,9 +1,9 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
<?php
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use Illuminate\Foundation\Http\FormRequest;
|
||||
|
||||
abstract class Request extends FormRequest {
|
||||
|
||||
//
|
||||
|
||||
abstract class Request extends FormRequest
|
||||
{
|
||||
//
|
||||
}
|
||||
|
|
|
@ -1,29 +1,30 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
<?php
|
||||
namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class ShelfRequest extends Request {
|
||||
class ShelfRequest extends Request
|
||||
{
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'shelf' => 'required'
|
||||
];
|
||||
}
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
'shelf' => 'required'
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
<?php namespace App\Http\Requests;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
|
||||
class StudentRequest extends Request {
|
||||
|
||||
/**
|
||||
* Determine if the user is authorized to make this request.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function authorize()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the validation rules that apply to the request.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
|
||||
'name' => 'required|min:5'
|
||||
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
<?php
|
||||
use App\Book;
|
||||
use App\Dataset;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Routes
|
||||
|
@ -9,184 +11,15 @@ use App\Book;
|
|||
| It's a breeze. Simply tell Laravel the URIs it should respond to
|
||||
| and give it the controller to call when that URI is requested.
|
||||
|
|
||||
*/
|
||||
|
||||
//Route::get('/api/dropdown/peminjaman/{id}', [
|
||||
// 'as' => 'api.dropdown.peminjaman', 'uses' => 'PeminjamanController@dropdown'
|
||||
// ]);
|
||||
|
||||
Route::get('/api/dropdown/peminjaman/{id}', function($id){
|
||||
|
||||
if(Request::ajax()){
|
||||
|
||||
//$category_id = Input::get('category_id');
|
||||
|
||||
$books = Book::available()->orderByTitle()->where('category_id', '=', $id)->get();
|
||||
|
||||
return Response::json($books);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
*/
|
||||
// Route::get('/api/dropdown/peminjaman/{id}', [
|
||||
// 'as' => 'api.dropdown.peminjaman', 'uses' => 'PeminjamanController@dropdown'
|
||||
// ]);
|
||||
Route::get('/api/dropdown/borrow/{id}', function ($id) {
|
||||
if (Request::ajax()) {
|
||||
//$category_id = Input::get('category_id');
|
||||
// $books = Book::available()->orderByTitle()->where('category_id', '=', $id)->get();
|
||||
$books = Dataset::OrderByType()->where('project_id', '=', $id)->get();
|
||||
return Response::json($books);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Route::get('/', [
|
||||
'as' => 'index', 'uses' => 'PagesController@index'
|
||||
]);
|
||||
Route::get('books', [
|
||||
'as' => 'books', 'uses' => 'PagesController@books'
|
||||
]);
|
||||
|
||||
Route::get('peminjaman', [
|
||||
'as' => 'peminjaman.peminjaman', 'uses' => 'PeminjamanController@index'
|
||||
]);
|
||||
Route::post('peminjaman', [
|
||||
'as' => 'peminjaman.post', 'uses' => 'PeminjamanController@store'
|
||||
]);
|
||||
|
||||
Route::get('laporan', [
|
||||
'as' => 'peminjaman.laporan', 'uses' => 'PeminjamanController@laporan'
|
||||
]);
|
||||
Route::get('pengembalian/{id}', [
|
||||
'as' => 'peminjaman.pengembalian', 'uses' => 'PeminjamanController@pengembalian'
|
||||
]);
|
||||
Route::get('perpanjang/{id}', [
|
||||
'as' => 'peminjaman.perpanjang', 'uses' => 'PeminjamanController@perpanjang'
|
||||
]);
|
||||
|
||||
Route::get('histori', [
|
||||
'as' => 'peminjaman.histori', 'uses' => 'PeminjamanController@histori'
|
||||
]);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//setting
|
||||
|
||||
|
||||
//=================================================setting category====================================================
|
||||
Route::get('/settings/category', [
|
||||
'as' => 'settings.category', 'uses' => 'CategoryController@index'
|
||||
]);
|
||||
Route::get('/settings/category/add', [
|
||||
'as' => 'settings.category.add', 'uses' => 'CategoryController@add'
|
||||
]);
|
||||
Route::post('settings/category/add', [
|
||||
'as' => 'settings.category.post', 'uses' => 'CategoryController@store'
|
||||
]);
|
||||
Route::get('settings/category/edit/{id}', [
|
||||
'as' => 'settings.category.edit', 'uses' => 'CategoryController@edit'
|
||||
]);
|
||||
Route::patch('settings/category/edit/{id}', [
|
||||
'as' => 'settings.category.update', 'uses' => 'CategoryController@update'
|
||||
]);
|
||||
Route::get('settings/category/delete/{id}', [
|
||||
'as' => 'settings.category.delete', 'uses' => 'CategoryController@delete'
|
||||
]);
|
||||
//==========================================================================================================================
|
||||
|
||||
|
||||
//=================================================setting shelf==========================================================
|
||||
Route::get('/settings/shelf', [
|
||||
'as' => 'settings.shelf', 'uses' => 'ShelfController@index'
|
||||
]);
|
||||
Route::get('/settings/shelf/add', [
|
||||
'as' => 'settings.shelf.add', 'uses' => 'ShelfController@add'
|
||||
]);
|
||||
Route::post('settings/shelf/add', [
|
||||
'as' => 'settings.shelf.post', 'uses' => 'ShelfController@store'
|
||||
]);
|
||||
Route::get('settings/shelf/edit/{id}', [
|
||||
'as' => 'settings.shelf.edit', 'uses' => 'ShelfController@edit'
|
||||
]);
|
||||
Route::patch('settings/shelf/edit/{id}', [
|
||||
'as' => 'settings.shelf.update', 'uses' => 'ShelfController@update'
|
||||
]);
|
||||
Route::get('settings/category/delete/{id}', [
|
||||
'as' => 'settings.shelf.delete', 'uses' => 'ShelfController@delete'
|
||||
]);
|
||||
//==========================================================================================================================
|
||||
|
||||
|
||||
//=================================================setting fines==========================================================
|
||||
Route::get('/settings/fines', [
|
||||
'as' => 'settings.fines', 'uses' => 'FinesController@index'
|
||||
]);
|
||||
Route::get('settings/fines/edit/{id}', [
|
||||
'as' => 'settings.fines.edit', 'uses' => 'FinesController@edit'
|
||||
]);
|
||||
Route::patch('settings/fines/edit/{id}', [
|
||||
'as' => 'settings.fines.update', 'uses' => 'FinesController@update'
|
||||
]);
|
||||
//==========================================================================================================================
|
||||
|
||||
|
||||
//=================================================setting periode==========================================================
|
||||
Route::get('/settings/periode', [
|
||||
'as' => 'settings.periode', 'uses' => 'PeriodeController@index'
|
||||
]);
|
||||
Route::get('settings/periode/edit/{id}', [
|
||||
'as' => 'settings.periode.edit', 'uses' => 'PeriodeController@edit'
|
||||
]);
|
||||
Route::patch('settings/periode/edit/{id}', [
|
||||
'as' => 'settings.periode.update', 'uses' => 'PeriodeController@update'
|
||||
]);
|
||||
//==========================================================================================================================
|
||||
|
||||
//=================================================setting student==========================================================
|
||||
Route::get('/settings/student', [
|
||||
'as' => 'settings.student', 'uses' => 'StudentController@index'
|
||||
]);
|
||||
Route::get('/settings/student/add', [
|
||||
'as' => 'settings.student.add', 'uses' => 'StudentController@add'
|
||||
]);
|
||||
Route::post('settings/student/add', [
|
||||
'as' => 'settings.student.post', 'uses' => 'StudentController@store'
|
||||
]);
|
||||
Route::get('settings/student/edit/{id}', [
|
||||
'as' => 'settings.student.edit', 'uses' => 'StudentController@edit'
|
||||
]);
|
||||
Route::patch('settings/student/edit/{id}', [
|
||||
'as' => 'settings.student.update', 'uses' => 'StudentController@update'
|
||||
]);
|
||||
Route::get('settings/student/delete/{id}', [
|
||||
'as' => 'settings.student.delete', 'uses' => 'StudentController@delete'
|
||||
]);
|
||||
Route::get('settings/student/down/{id}', [
|
||||
'as' => 'settings.student.down', 'uses' => 'StudentController@down'
|
||||
]);
|
||||
Route::get('settings/student/up/{id}', [
|
||||
'as' => 'settings.student.up', 'uses' => 'StudentController@up'
|
||||
]);
|
||||
//==========================================================================================================================
|
||||
|
||||
//=================================================setting book=============================================================
|
||||
Route::get('/settings/book', [
|
||||
'as' => 'settings.book', 'uses' => 'BookController@index'
|
||||
]);
|
||||
Route::get('/settings/book/add', [
|
||||
'as' => 'settings.book.add', 'uses' => 'BookController@add'
|
||||
]);
|
||||
Route::post('settings/book/add', [
|
||||
'as' => 'settings.book.post', 'uses' => 'BookController@store'
|
||||
]);
|
||||
Route::get('settings/book/edit/{id}', [
|
||||
'as' => 'settings.book.edit', 'uses' => 'BookController@edit'
|
||||
]);
|
||||
Route::patch('settings/book/edit/{id}', [
|
||||
'as' => 'settings.book.update', 'uses' => 'BookController@update'
|
||||
]);
|
||||
Route::get('settings/book/delete/{id}', [
|
||||
'as' => 'settings.book.delete', 'uses' => 'BookController@delete'
|
||||
]);
|
||||
|
||||
//========================================================================================================================
|
||||
|
||||
|
||||
Route::controllers([
|
||||
'auth' => 'Auth\AuthController',
|
||||
'password' => 'Auth\PasswordController',
|
||||
]);
|
||||
|
|
13
app/Language.php
Normal file
13
app/Language.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Language extends Model
|
||||
{
|
||||
|
||||
//protected $table = 'languages';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [];
|
||||
}
|
68
app/Library/Search/Navigation.php
Normal file
68
app/Library/Search/Navigation.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
namespace App\Library\Search;
|
||||
|
||||
use App\Library\Util\QueryBuilder;
|
||||
use App\Library\Util\Searchtypes;
|
||||
use App\Library\Util\SolrSearchQuery;
|
||||
|
||||
/**
|
||||
* Class for navigation in search results.
|
||||
*/
|
||||
class Navigation
|
||||
{
|
||||
|
||||
/**
|
||||
* Builds query for Solr search.
|
||||
* @return SolrSearchQuery|void
|
||||
* @throws Application_Exception, Application_Util_BrowsingParamsException, Application_Util_QueryBuilderException
|
||||
*/
|
||||
public static function getQueryUrl(\Illuminate\Http\Request $request) : SolrSearchQuery
|
||||
{
|
||||
$queryBuilder = new QueryBuilder();
|
||||
$queryBuilderInput = $queryBuilder->createQueryBuilderInputFromRequest($request);
|
||||
|
||||
if (is_null($request->input('sortfield')) &&
|
||||
($request->input('browsing') === 'true' || $request->input('searchtype') === 'collection')) {
|
||||
$queryBuilderInput['sortField'] = 'server_date_published';
|
||||
}
|
||||
|
||||
if ($request->input('searchtype') === Searchtypes::LATEST_SEARCH) {
|
||||
return $queryBuilder->createSearchQuery(self::validateInput($queryBuilderInput, 10, 100));
|
||||
}
|
||||
|
||||
$solrSearchQuery = $queryBuilder->createSearchQuery(self::validateInput($queryBuilderInput, 1, 100));
|
||||
return $solrSearchQuery;
|
||||
//$queryBuilder->createSearchQuery(self::validateInput($queryBuilderInput,1, 100));
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjust the actual rows parameter value if it is not between $min
|
||||
* and $max (inclusive). In case the actual value is smaller (greater)
|
||||
* than $min ($max) it is adjusted to $min ($max).
|
||||
*
|
||||
* Sets the actual start parameter value to 0 if it is negative.
|
||||
*
|
||||
* @param array $data An array that contains the request parameters.
|
||||
* @param int $lowerBoundInclusive The lower bound.
|
||||
* @param int $upperBoundInclusive The upper bound.
|
||||
* @return int Returns the actual rows parameter value or an adjusted value if
|
||||
* it is not in the interval [$lowerBoundInclusive, $upperBoundInclusive].
|
||||
*
|
||||
*/
|
||||
private static function validateInput(array $input, $min = 1, $max = 100) : array
|
||||
{
|
||||
if ($input['rows'] > $max) {
|
||||
// $logger->warn("Values greater than $max are currently not allowed for the rows paramter.");
|
||||
$input['rows'] = $max;
|
||||
}
|
||||
if ($input['rows'] < $min) {
|
||||
// $logger->warn("rows parameter is smaller than $min: adjusting to $min.");
|
||||
$input['rows'] = $min;
|
||||
}
|
||||
if ($input['start'] < 0) {
|
||||
// $logger->warn("A negative start parameter is ignored.");
|
||||
$input['start'] = 0;
|
||||
}
|
||||
return $input;
|
||||
}
|
||||
}
|
313
app/Library/Search/SearchResult.php
Normal file
313
app/Library/Search/SearchResult.php
Normal file
|
@ -0,0 +1,313 @@
|
|||
<?php
|
||||
namespace App\Library\Search;
|
||||
|
||||
/**
|
||||
* Implements API for describing successful response to search query.
|
||||
*/
|
||||
|
||||
use App\Library\Util\SearchResultMatch;
|
||||
|
||||
class SearchResult
|
||||
{
|
||||
protected $data = array(
|
||||
'matches' => null,
|
||||
'count' => null,
|
||||
'querytime' => null,
|
||||
'facets' => null,
|
||||
);
|
||||
protected $validated = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return SearchResult
|
||||
*/
|
||||
public static function create()
|
||||
{
|
||||
return new static();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns matches returned in response to search query.
|
||||
*
|
||||
* @param mixed $documentId ID of document considered match of related search query
|
||||
* @return SearchResultMatch
|
||||
*/
|
||||
public function addMatch($documentId)
|
||||
{
|
||||
if (!is_array($this->data['matches'])) {
|
||||
$this->data['matches'] = array();
|
||||
}
|
||||
$match = SearchResultMatch::create($documentId);
|
||||
$this->data['matches'][] = $match;
|
||||
|
||||
return $match;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets number of all matching documents.
|
||||
*
|
||||
* @note This may include documents not listed as matches here due to using
|
||||
* paging parameters on query.
|
||||
*
|
||||
* @param int $allMatchesCount number of all matching documents
|
||||
* @return $this fluent interface
|
||||
*/
|
||||
public function setAllMatchesCount($allMatchesCount)
|
||||
{
|
||||
if (!is_null($this->data['count'])) {
|
||||
throw new RuntimeException('must not set count of all matches multiple times');
|
||||
}
|
||||
|
||||
if (!ctype_digit(trim($allMatchesCount))) {
|
||||
throw new InvalidArgumentException('invalid number of overall matches');
|
||||
}
|
||||
$this->data['count'] = intval($allMatchesCount);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets information on time taken for querying search engine.
|
||||
*
|
||||
* @param string $time
|
||||
* @return $this fluent interface
|
||||
*/
|
||||
public function setQueryTime($time)
|
||||
{
|
||||
if (!is_null($this->data['querytime'])) {
|
||||
throw new RuntimeException('must not set query time multiple times');
|
||||
}
|
||||
if (!is_null($time)) {
|
||||
$this->data['querytime'] = trim($time);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds another result of faceted search to current result set.
|
||||
*
|
||||
* @param string $facetField name of field result of faceted search is related to
|
||||
* @param string $text description on particular faceted result on field (e.g. single value in field)
|
||||
* @param int $count number of occurrences of facet on field in all matches
|
||||
* @return $this fluent interface
|
||||
*
|
||||
* TODO special year_inverted facet handling should be moved to separate class
|
||||
*/
|
||||
public function addFacet($facetField, $text, $count)
|
||||
{
|
||||
$facetField = strval($facetField);
|
||||
|
||||
// remove inverted sorting prefix from year values
|
||||
if ($facetField === 'year_inverted') {
|
||||
$text = explode(':', $text, 2)[1];
|
||||
|
||||
// treat 'year_inverted' as if it was 'year'
|
||||
$facetField = 'year';
|
||||
}
|
||||
|
||||
// treat 'year_inverted' as if it was 'year'
|
||||
if ($facetField === 'year_inverted') {
|
||||
$facetField = 'year';
|
||||
}
|
||||
|
||||
if (!is_array($this->data['facets'])) {
|
||||
$this->data['facets'] = array();
|
||||
}
|
||||
|
||||
if (!array_key_exists($facetField, $this->data['facets'])) {
|
||||
$this->data['facets'][$facetField] = array();
|
||||
}
|
||||
|
||||
$this->data['facets'][$facetField][] = new Opus_Search_Result_Facet($text, $count);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves results of faceted search.
|
||||
*
|
||||
* @return Opus_Search_Result_Facet[][] map of fields' names into sets of facet result per field
|
||||
*/
|
||||
public function getFacets()
|
||||
{
|
||||
return is_null($this->data['facets']) ? array() : $this->data['facets'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves set of facet results on single field selected by name.
|
||||
*
|
||||
* @param string $fieldName name of field returned facet result is related to
|
||||
* @return Opus_Search_Result_Facet[] set of facet results on selected field
|
||||
*/
|
||||
public function getFacet($fieldName)
|
||||
{
|
||||
if ($this->data['facets'] && array_key_exists($fieldName, $this->data['facets'])) {
|
||||
return $this->data['facets'][$fieldName];
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves set of matching and locally existing documents returned in
|
||||
* response to some search query.
|
||||
*
|
||||
* @return Opus_Search_Result_Match[]
|
||||
*/
|
||||
public function getReturnedMatches()
|
||||
{
|
||||
if (is_null($this->data['matches'])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
// map AND FILTER set of returned matches ensuring to list related
|
||||
// documents existing locally, only
|
||||
$matches = array();
|
||||
|
||||
foreach ($this->data['matches'] as $match) {
|
||||
try {
|
||||
/** @var SearchResultMatch $match */
|
||||
// $match->getDocument();
|
||||
$matches[] = $match;
|
||||
} catch (Opus_Document_Exception $e) {
|
||||
Opus_Log::get()->warn('skipping matching but locally missing document #' . $match->getId());
|
||||
}
|
||||
}
|
||||
return $matches;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves set of matching documents' IDs returned in response to some
|
||||
* search query.
|
||||
*
|
||||
* @note If query was requesting to retrieve non-qualified matches this set
|
||||
* might include IDs of documents that doesn't exist locally anymore.
|
||||
*
|
||||
* @return int[]
|
||||
*/
|
||||
public function getReturnedMatchingIds()
|
||||
{
|
||||
if (is_null($this->data['matches'])) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return array_map(function ($match) {
|
||||
/** @var SearchResultMatch $match */
|
||||
return $match->getId();
|
||||
}, $this->data['matches']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves set of matching documents.
|
||||
*
|
||||
* @note This is provided for downward compatibility, though it's signature
|
||||
* has changed in that it's returning set of Opus_Document instances
|
||||
* rather than set of Opus_SolrSearch_Result instances.
|
||||
*
|
||||
* @note The wording is less specific in that all information in response to
|
||||
* search query may considered results of search. Thus this new API
|
||||
* prefers "matches" over "results".
|
||||
*
|
||||
* @deprecated
|
||||
* @return Opus_Document[]
|
||||
*/
|
||||
public function getResults()
|
||||
{
|
||||
return $this->getReturnedMatches();
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all returned matches referring to Opus documents missing in local
|
||||
* database.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function dropLocallyMissingMatches()
|
||||
{
|
||||
if (!$this->validated) {
|
||||
$finder = new Opus_DocumentFinder();
|
||||
|
||||
$returnedIds = $this->getReturnedMatchingIds();
|
||||
$existingIds = $finder
|
||||
->setServerState('published')
|
||||
->setIdSubset($returnedIds)
|
||||
->ids();
|
||||
|
||||
if (count($returnedIds) !== count($existingIds)) {
|
||||
Opus_Log::get()->err(sprintf(
|
||||
"inconsistency between db and search index: index returns %d documents, but only %d found in db",
|
||||
count($returnedIds),
|
||||
count($existingIds)
|
||||
));
|
||||
|
||||
// update set of returned matches internally
|
||||
$this->data['matches'] = array();
|
||||
foreach ($existingIds as $id) {
|
||||
$this->addMatch($id);
|
||||
}
|
||||
// set mark to prevent validating matches again
|
||||
$this->validated = true;
|
||||
}
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves overall number of matches.
|
||||
*
|
||||
* @note This number includes matches not included in fetched subset of
|
||||
* matches.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getAllMatchesCount()
|
||||
{
|
||||
if (is_null($this->data['count'])) {
|
||||
throw new RuntimeException('count of matches have not been provided yet');
|
||||
}
|
||||
return $this->data['count'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves overall number of matches.
|
||||
*
|
||||
* @note This is provided for downward compatibility.
|
||||
*
|
||||
* @deprecated
|
||||
* @return int
|
||||
*/
|
||||
public function getNumberOfHits()
|
||||
{
|
||||
return $this->getAllMatchesCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves information on search query's processing time.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getQueryTime()
|
||||
{
|
||||
return $this->data['querytime'];
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
switch (strtolower(trim($name))) {
|
||||
case 'matches':
|
||||
return $this->getReturnedMatches();
|
||||
|
||||
case 'allmatchescount':
|
||||
return $this->getAllMatchesCount();
|
||||
|
||||
case 'querytime':
|
||||
return $this->getQueryTime();
|
||||
default:
|
||||
throw new RuntimeException('invalid request for property ' . $name);
|
||||
}
|
||||
}
|
||||
}
|
218
app/Library/Search/SolariumAdapter.php
Normal file
218
app/Library/Search/SolariumAdapter.php
Normal file
|
@ -0,0 +1,218 @@
|
|||
<?php
|
||||
|
||||
namespace App\Library\Search;
|
||||
|
||||
//use App\Library\Util\SolrSearchQuery;
|
||||
use App\Library\Util\SearchParameter;
|
||||
use App\Library\Search\SearchResult;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SolariumAdapter
|
||||
{
|
||||
protected $options;
|
||||
|
||||
/**
|
||||
* @var \Solarium\Core\Client\Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
public function __construct($serviceName, $options)
|
||||
{
|
||||
$this->options = $options;
|
||||
$this->client = new \Solarium\Client($options);
|
||||
|
||||
// ensure service is basically available
|
||||
$ping = $this->client->createPing();
|
||||
$this->execute($ping, 'failed pinging service ' . $serviceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Maps name of field returned by search engine into name of asset to use
|
||||
* on storing field's value in context of related match.
|
||||
*
|
||||
* This mapping relies on runtime configuration. Mapping is defined per
|
||||
* service in
|
||||
*
|
||||
* @param string $fieldName
|
||||
* @return string
|
||||
*/
|
||||
protected function mapResultFieldToAsset($fieldName)
|
||||
{
|
||||
//if ( $this->options->fieldToAsset instanceof Zend_Config )
|
||||
//{
|
||||
// return $this->options->fieldToAsset->get( $fieldName, $fieldName );
|
||||
//}
|
||||
return $fieldName;
|
||||
}
|
||||
|
||||
public function getDomain()
|
||||
{
|
||||
return 'solr';
|
||||
}
|
||||
|
||||
public function createQuery() : SearchParameter
|
||||
{
|
||||
return new SearchParameter();
|
||||
}
|
||||
|
||||
public function customSearch(SearchParameter $queryParameter)
|
||||
{
|
||||
$search = $this->client->createSelect();
|
||||
$solariumQuery = $this->applyParametersToSolariumQuery($search, $queryParameter, false);
|
||||
$searchResult = $this->processQuery($solariumQuery);
|
||||
return $searchResult;
|
||||
}
|
||||
|
||||
protected function applyParametersToSolariumQuery(\Solarium\QueryType\Select\Query\Query $query, SearchParameter $parameters = null, $preferOriginalQuery = false)
|
||||
{
|
||||
if ($parameters) {
|
||||
//$subfilters = $parameters->getSubFilters();
|
||||
//if ( $subfilters !== null ) {
|
||||
// foreach ( $subfilters as $name => $subfilter ) {
|
||||
// if ( $subfilter instanceof Opus_Search_Solr_Filter_Raw || $subfilter instanceof Opus_Search_Solr_Solarium_Filter_Complex ) {
|
||||
// $query->createFilterQuery( $name )
|
||||
// ->setQuery( $subfilter->compile( $query ) );
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
// $filter = $parameters->getFilter();//"aa"
|
||||
// if ( $filter instanceof Opus_Search_Solr_Filter_Raw || $filter instanceof Opus_Search_Solr_Solarium_Filter_Complex ) {
|
||||
// if ( !$query->getQuery() || !$preferOriginalQuery ) {
|
||||
// $compiled = $filter->compile( $query );
|
||||
// if ( $compiled !== null ) {
|
||||
// // compile() hasn't implicitly assigned query before
|
||||
// $query->setQuery( $compiled );
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
$filter = $parameters->getFilter();//"aa" all: '*:*'
|
||||
if ($filter !== null) {
|
||||
//$query->setStart( intval( $start ) );
|
||||
//$query->setQuery('%P1%', array($filter));
|
||||
$query->setQuery($filter);
|
||||
}
|
||||
|
||||
|
||||
$start = $parameters->getStart();
|
||||
if ($start !== null) {
|
||||
$query->setStart(intval($start));
|
||||
}
|
||||
|
||||
$rows = $parameters->getRows();
|
||||
if ($rows !== null) {
|
||||
$query->setRows(intval($rows));
|
||||
}
|
||||
|
||||
$union = $parameters->getUnion();
|
||||
if ($union !== null) {
|
||||
$query->setQueryDefaultOperator($union ? 'OR' : 'AND');
|
||||
}
|
||||
|
||||
$fields = $parameters->getFields();
|
||||
if ($fields !== null) {
|
||||
$query->setFields($fields);
|
||||
}
|
||||
|
||||
$sortings = $parameters->getSort();
|
||||
if ($sortings !== null) {
|
||||
$query->setSorts($sortings);
|
||||
}
|
||||
|
||||
$facet = $parameters->getFacet();
|
||||
if ($facet !== null) {
|
||||
$facetSet = $query->getFacetSet();
|
||||
foreach ($facet->getFields() as $field) {
|
||||
$facetSet->createFacetField($field->getName())
|
||||
->setField($field->getName())
|
||||
->setMinCount($field->getMinCount())
|
||||
->setLimit($field->getLimit())
|
||||
->setSort($field->getSort() ? 'index' : null);
|
||||
}
|
||||
if ($facet->isFacetOnly()) {
|
||||
$query->setFields(array());
|
||||
}
|
||||
}
|
||||
}
|
||||
return $query;
|
||||
}
|
||||
|
||||
protected function execute($query, $actionText)
|
||||
{
|
||||
$result = null;
|
||||
try {
|
||||
$result = $this->client->execute($query);
|
||||
} catch (\Solarium\Exception\HttpException $e) {
|
||||
sprintf('%s: %d %s', $actionText, $e->getCode(), $e->getStatusMessage());
|
||||
} finally {
|
||||
return $result;
|
||||
}
|
||||
|
||||
// if ( $result->getStatus() ) {
|
||||
// throw new Opus_Search_Exception( $actionText, $result->getStatus() );
|
||||
// }
|
||||
}
|
||||
|
||||
protected function processQuery(\Solarium\QueryType\Select\Query\Query $query) : SearchResult
|
||||
{
|
||||
// send search query to service
|
||||
$request = $this->execute($query, 'failed querying search engine');
|
||||
|
||||
//$count = $request->getDocuments();
|
||||
// create result descriptor
|
||||
$result = SearchResult::create()
|
||||
->setAllMatchesCount($request->getNumFound())
|
||||
->setQueryTime($request->getQueryTime());
|
||||
|
||||
// add description on every returned match
|
||||
$excluded = 0;
|
||||
foreach ($request->getDocuments() as $document) {
|
||||
/** @var \Solarium\QueryType\Select\Result\Document $document */
|
||||
$fields = $document->getFields();
|
||||
|
||||
if (array_key_exists('id', $fields)) {
|
||||
$match = $result->addMatch($fields['id']);
|
||||
|
||||
foreach ($fields as $fieldName => $fieldValue) {
|
||||
switch ($fieldName) {
|
||||
case 'id':
|
||||
break;
|
||||
|
||||
case 'score':
|
||||
$match->setScore($fieldValue);
|
||||
break;
|
||||
|
||||
case 'server_date_modified':
|
||||
$match->setServerDateModified($fieldValue);
|
||||
break;
|
||||
|
||||
case 'fulltext_id_success':
|
||||
$match->setFulltextIDsSuccess($fieldValue);
|
||||
break;
|
||||
|
||||
case 'fulltext_id_failure':
|
||||
$match->setFulltextIDsFailure($fieldValue);
|
||||
break;
|
||||
|
||||
default:
|
||||
$match->setAsset($fieldName, $fieldValue);
|
||||
//$match->setAsset( $this->mapResultFieldToAsset( $fieldName ), $fieldValue );
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$excluded++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($excluded > 0) {
|
||||
Log::warning(sprintf(
|
||||
'search yielded %d matches not available in result set for missing ID of related document',
|
||||
$excluded
|
||||
));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
257
app/Library/Util/QueryBuilder.php
Normal file
257
app/Library/Util/QueryBuilder.php
Normal file
|
@ -0,0 +1,257 @@
|
|||
<?php
|
||||
namespace App\Library\Util;
|
||||
|
||||
use App\Library\Util\Searchtypes;
|
||||
use App\Library\Util\SolrSearchQuery;
|
||||
|
||||
class QueryBuilder
|
||||
{
|
||||
private $_logger;
|
||||
private $_filterFields;
|
||||
private $_searchFields;
|
||||
private $_export = false;
|
||||
|
||||
const SEARCH_MODIFIER_CONTAINS_ALL = "contains_all";
|
||||
const SEARCH_MODIFIER_CONTAINS_ANY = "contains_any";
|
||||
const SEARCH_MODIFIER_CONTAINS_NONE = "contains_none";
|
||||
|
||||
const MAX_ROWS = 2147483647;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param boolean $export
|
||||
*/
|
||||
public function __construct($export = false)
|
||||
{
|
||||
$this->_filterFields = array();
|
||||
|
||||
// $filters = Opus_Search_Config::getFacetFields();
|
||||
// if ( !count( $filters ) ) {
|
||||
// $this->_logger->debug( 'key searchengine.solr.facets is not present in config. skipping filter queries' );
|
||||
// } else {
|
||||
// $this->_logger->debug( 'searchengine.solr.facets is set to ' . implode( ',', $filters ) );
|
||||
// }
|
||||
|
||||
// foreach ($filters as $filterfield) {
|
||||
// if ($filterfield == 'year_inverted') {
|
||||
// $filterfield = 'year';
|
||||
// }
|
||||
// array_push($this->_filterFields, trim($filterfield));
|
||||
// }
|
||||
|
||||
$this->_searchFields = array('author', 'title', 'persons', 'referee', 'abstract', 'fulltext', 'year');
|
||||
$this->_export = $export;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function createQueryBuilderInputFromRequest($request) : array
|
||||
{
|
||||
if (is_null($request->all())) {
|
||||
throw new Application_Util_QueryBuilderException('Unable to read request data.Search cannot be performed.');
|
||||
}
|
||||
|
||||
if (is_null($request->input('searchtype'))) {
|
||||
throw new Application_Util_QueryBuilderException('Unspecified search type: unable to create query.');
|
||||
}
|
||||
|
||||
if (!Searchtypes::isSupported($request->input('searchtype'))) {
|
||||
throw new Application_Util_QueryBuilderException(
|
||||
'Unsupported search type ' . $request->input('searchtype') . ' : unable to create query.'
|
||||
);
|
||||
}
|
||||
|
||||
$this->validateParamsType($request);
|
||||
|
||||
if ($request->input('sortfield')) {
|
||||
$sorting = array($request->input('sortfield'), 'asc');
|
||||
} else {
|
||||
//$sorting = Opus_Search_Query::getDefaultSorting();
|
||||
$sorting = array('score', 'desc' );
|
||||
}
|
||||
|
||||
$input = array(
|
||||
'searchtype' => $request->input('searchtype'),
|
||||
'start' => $request->input('start'),//, Opus_Search_Query::getDefaultStart()),
|
||||
'rows' => $request->input('rows'),// Opus_Search_Query::getDefaultRows()),
|
||||
'sortField' => $sorting[0],
|
||||
'sortOrder' => $request->input('sortorder', $sorting[1]),
|
||||
'docId' => $request->input('docId'),
|
||||
'query' => $request->input('query', '*:*')
|
||||
);
|
||||
|
||||
//if ($this->_export) {
|
||||
// $maxRows = self::MAX_ROWS;
|
||||
// // pagination within export was introduced in OPUS 4.2.2
|
||||
// $startParam = $request->input('start', 0);
|
||||
// $rowsParam = $request->input('rows', $maxRows);
|
||||
// $start = intval($startParam);
|
||||
// $rows = intval($rowsParam);
|
||||
// $input['start'] = $start > 0 ? $start : 0;
|
||||
// $input['rows'] = $rows > 0 || ($rows == 0 && $rowsParam == '0') ? $rows : $maxRows;
|
||||
// if ($input['start'] > $maxRows) {
|
||||
// $input['start'] = $maxRows;
|
||||
// }
|
||||
// if ($input['rows'] + $input['start'] > $maxRows) {
|
||||
// $input['rows'] = $maxRows - $start;
|
||||
// }
|
||||
//}
|
||||
|
||||
foreach ($this->_searchFields as $searchField) {
|
||||
$input[$searchField] = $request->input($searchField, '');
|
||||
$input[$searchField . 'modifier'] = $request->input(
|
||||
$searchField . 'modifier',
|
||||
self::SEARCH_MODIFIER_CONTAINS_ALL
|
||||
);
|
||||
}
|
||||
|
||||
// foreach ($this->_filterFields as $filterField) {
|
||||
// $param = $filterField . 'fq';
|
||||
// $input[$param] = $request->getParam($param, '');
|
||||
// }
|
||||
|
||||
|
||||
// if ($request->getParam('searchtype') === Searchtypes::COLLECTION_SEARCH
|
||||
// || $request->input('searchtype') === Searchtypes::SERIES_SEARCH)
|
||||
// {
|
||||
// $searchParams = new Application_Util_BrowsingParams($request, $this->_logger);
|
||||
// switch ($request->input('searchtype')) {
|
||||
// case Searchtypes::COLLECTION_SEARCH:
|
||||
// $input['collectionId'] = $searchParams->getCollectionId();
|
||||
// break;
|
||||
// case Searchtypes::SERIES_SEARCH:
|
||||
// $input['seriesId'] = $searchParams->getSeriesId();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
return $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if all given parameters are of type string. Otherwise, throws Application_Util_QueryBuilderException.
|
||||
*
|
||||
* @throws //Application_Util_QueryBuilderException
|
||||
*/
|
||||
private function validateParamsType($request)
|
||||
{
|
||||
$paramNames = array(
|
||||
'searchtype',
|
||||
'start',
|
||||
'rows',
|
||||
'sortField',
|
||||
'sortOrder',
|
||||
'search',
|
||||
'collectionId',
|
||||
'seriesId'
|
||||
);
|
||||
foreach ($this->_searchFields as $searchField) {
|
||||
array_push($paramNames, $searchField, $searchField . 'modifier');
|
||||
}
|
||||
foreach ($this->_filterFields as $filterField) {
|
||||
array_push($paramNames, $filterField . 'fq');
|
||||
}
|
||||
|
||||
foreach ($paramNames as $paramName) {
|
||||
$paramValue = $request->input($paramName, null);
|
||||
if (!is_null($paramValue) && !is_string($paramValue)) {
|
||||
throw new Application_Util_QueryBuilderException('Parameter ' . $paramName . ' is not of type string');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $input
|
||||
* @return SolrSearchQuery
|
||||
*/
|
||||
public function createSearchQuery($input) : SolrSearchQuery
|
||||
{
|
||||
if ($input['searchtype'] === Searchtypes::SIMPLE_SEARCH) {
|
||||
return $this->createSimpleSearchQuery($input);
|
||||
//return $this->createAllSearchQuery($input);
|
||||
}
|
||||
|
||||
if ($input['searchtype'] === Searchtypes::ALL_SEARCH) {
|
||||
return $this->createAllSearchQuery($input);
|
||||
}
|
||||
return $this->createSimpleSearchQuery($input);
|
||||
}
|
||||
|
||||
// private function createIdSearchQuery($input) {
|
||||
// $this->_logger->debug("Constructing query for id search.");
|
||||
|
||||
// if (is_null($input['docId'])) {
|
||||
// throw new Application_Exception("No id provided.", 404);
|
||||
// }
|
||||
|
||||
// $query = new Opus_SolrSearch_Query(Opus_SolrSearch_Query::DOC_ID);
|
||||
// $query->setField('id', $input['docId']);
|
||||
|
||||
// if ($this->_export) {
|
||||
// $query->setReturnIdsOnly(true);
|
||||
// }
|
||||
|
||||
// $this->_logger->debug("Query $query complete");
|
||||
// return $query;
|
||||
// }
|
||||
|
||||
private function createAllSearchQuery($input)
|
||||
{
|
||||
//$this->_logger->debug("Constructing query for all search.");
|
||||
|
||||
$query = new SolrSearchQuery(SolrSearchQuery::ALL_DOCS);
|
||||
$query->setStart("0");//$input['start']);
|
||||
//$query->setRows($input['rows']);
|
||||
$query->setRows("10");
|
||||
$query->setSortField($input['sortField']);
|
||||
$query->setSortOrder($input['sortOrder']);
|
||||
|
||||
//$this->addFiltersToQuery($query, $input);
|
||||
|
||||
//if ($this->_export) {
|
||||
// $query->setReturnIdsOnly(true);
|
||||
//}
|
||||
|
||||
//$this->_logger->debug("Query $query complete");
|
||||
return $query;
|
||||
}
|
||||
|
||||
private function createSimpleSearchQuery($input) : SolrSearchQuery
|
||||
{
|
||||
// $this->_logger->debug("Constructing query for simple search.");
|
||||
|
||||
$solrQuery = new SolrSearchQuery(SolrSearchQuery::SIMPLE);
|
||||
$solrQuery->setStart($input['start']);
|
||||
$solrQuery->setRows("10");//$input['rows']);
|
||||
$solrQuery->setSortField($input['sortField']);
|
||||
$solrQuery->setSortOrder($input['sortOrder']);
|
||||
|
||||
$solrQuery->setCatchAll($input['query']);
|
||||
//$this->addFiltersToQuery($solrQuery, $input);
|
||||
|
||||
// if ($this->_export) {
|
||||
// $solrQuery->setReturnIdsOnly(true);
|
||||
// }
|
||||
|
||||
// $this->_logger->debug("Query $solrQuery complete");
|
||||
return $solrQuery;
|
||||
}
|
||||
|
||||
private function addFiltersToQuery($query, $input)
|
||||
{
|
||||
foreach ($this->_filterFields as $filterField) {
|
||||
$facetKey = $filterField . 'fq';
|
||||
$facetValue = $input[$facetKey];
|
||||
if ($facetValue !== '') {
|
||||
$this->_logger->debug(
|
||||
"request has facet key: $facetKey - value is: $facetValue - corresponding facet is: $filterField"
|
||||
);
|
||||
$query->addFilterQuery($filterField, $facetValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
452
app/Library/Util/SearchParameter.php
Normal file
452
app/Library/Util/SearchParameter.php
Normal file
|
@ -0,0 +1,452 @@
|
|||
<?php
|
||||
namespace App\Library\Util;
|
||||
|
||||
/**
|
||||
* Implements API for describing search queries.
|
||||
*
|
||||
* @note This part of Opus search API differs from Solr in terminology in that
|
||||
* all requests for searching documents are considered "queries" with a
|
||||
* "filter" used to describe conditions matching documents has to met.
|
||||
* In opposition to Solr's "filter queries" this API supports "subfilters"
|
||||
* to reduce confusions on differences between filters, queries and
|
||||
* filter queries. Thus wording is mapped like this
|
||||
*
|
||||
* Solr --> Opus
|
||||
* "request" --> "query"
|
||||
* "query" --> "filter"
|
||||
* "filter query" --> "subfilter"
|
||||
*
|
||||
* @method int getStart( int $default = null )
|
||||
* @method int getRows( int $default = null )
|
||||
* @method string[] getFields( array $default = null )
|
||||
* @method array getSort( array $default = null )
|
||||
* @method bool getUnion( bool $default = null )
|
||||
* @method Opus_Search_Filter_Base getFilter( Opus_Search_Filter_Base $default = null )
|
||||
* @method Opus_Search_Facet_Set getFacet( Opus_Search_Facet_Set $default = null )
|
||||
* @method $this setStart( int $offset )
|
||||
* @method $this setRows( int $count )
|
||||
* @method $this setFields( $fields )
|
||||
* @method $this setSort( $sorting )
|
||||
* @method $this setUnion( bool $isUnion )
|
||||
* @method $this setFilter( Opus_Search_Filter_Base $filter ) assigns condition to be met by resulting documents
|
||||
* @method $this setFacet( Opus_Search_Facet_Set $facet )
|
||||
* @method $this addFields( string $fields )
|
||||
* @method $this addSort( $sorting )
|
||||
*/
|
||||
class SearchParameter
|
||||
{
|
||||
protected $_data;
|
||||
|
||||
public function reset()
|
||||
{
|
||||
$this->_data = array(
|
||||
'start' => null,
|
||||
'rows' => null,
|
||||
'fields' => null,
|
||||
'sort' => null,
|
||||
'union' => null,
|
||||
'filter' => null,
|
||||
'facet' => null,
|
||||
'subfilters' => null,
|
||||
);
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if provided name is actually name of known parameter normalizing it
|
||||
* on return.
|
||||
*
|
||||
* @throws InvalidArgumentException unless providing name of existing parameter
|
||||
* @param string $name name of parameter to access
|
||||
* @return string normalized name of existing parameter
|
||||
*/
|
||||
protected function isValidParameter($name)
|
||||
{
|
||||
if (!array_key_exists(strtolower(trim($name)), $this->_data)) {
|
||||
throw new InvalidArgumentException('invalid query parameter: ' . $name);
|
||||
}
|
||||
|
||||
return strtolower(trim($name));
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes one or more field names or set of comma-separated field names
|
||||
* into set of field names.
|
||||
*
|
||||
* @param string|string[] $input one or more field names or comma-separated lists of fields' names
|
||||
* @return string[] list of field names
|
||||
*/
|
||||
protected function normalizeFields($input)
|
||||
{
|
||||
if (!is_array($input)) {
|
||||
$input = array($input);
|
||||
}
|
||||
$output = array();
|
||||
|
||||
foreach ($input as $field) {
|
||||
if (!is_string($field)) {
|
||||
throw new InvalidArgumentException('invalid type of field selector');
|
||||
}
|
||||
|
||||
$fieldNames = preg_split('/[\s,]+/', $field, null, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($fieldNames as $name) {
|
||||
if (!preg_match('/^(?:\*|[a-z_][a-z0-9_]*)$/i', $name)) {
|
||||
throw new InvalidArgumentException('malformed field selector: ' . $name);
|
||||
}
|
||||
$output[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
if (!count($input)) {
|
||||
throw new InvalidArgumentException('missing field selector');
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses provided parameter for describing some sorting direction.
|
||||
*
|
||||
* @param string|bool $ascending one out of true, false, "asc" or "desc"
|
||||
* @return bool true if parameter is considered requesting to sort in ascending order
|
||||
*/
|
||||
protected function normalizeDirection($ascending)
|
||||
{
|
||||
if (!strcasecmp($ascending, 'asc')) {
|
||||
$ascending = true;
|
||||
} elseif (!strcasecmp($ascending, 'desc')) {
|
||||
$ascending = false;
|
||||
} elseif ($ascending !== false && $ascending !== true) {
|
||||
throw new InvalidArgumentException('invalid sorting direction selector');
|
||||
}
|
||||
return $ascending;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves value of selected query parameter.
|
||||
*
|
||||
* @param string $name name of parameter to read
|
||||
* @param mixed $defaultValue value to retrieve if parameter hasn't been set internally
|
||||
* @return mixed value of selected parameter, default if missing internally
|
||||
*/
|
||||
public function get($name, $defaultValue = null)
|
||||
{
|
||||
$name = $this->isValidParameter($name);
|
||||
|
||||
return is_null($this->_data[$name]) ? $defaultValue : $this->_data[$name];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets value of selected query parameter.
|
||||
*
|
||||
* @throws InvalidArgumentException in case of invalid arguments (e.g. on trying to add value to single-value param)
|
||||
* @param string $name name of query parameter to adjust
|
||||
* @param string[]|array|string|int $value value of query parameter to write
|
||||
* @param bool $adding true for adding given parameter to any existing one
|
||||
* @return $this
|
||||
*/
|
||||
public function set($name, $value, $adding = false) //filter, "aa", false
|
||||
{
|
||||
$name = $this->isValidParameter($name);
|
||||
|
||||
switch ($name) {
|
||||
case 'start':
|
||||
case 'rows':
|
||||
if ($adding) {
|
||||
throw new InvalidArgumentException('invalid parameter access on ' . $name);
|
||||
}
|
||||
|
||||
if (!is_scalar($value) || !ctype_digit(trim($value))) {
|
||||
throw new InvalidArgumentException('invalid parameter value on ' . $name);
|
||||
}
|
||||
|
||||
$this->_data[$name] = intval($value);
|
||||
break;
|
||||
|
||||
case 'fields':
|
||||
$fields = $this->normalizeFields($value);
|
||||
|
||||
if ($adding && is_null($this->_data['fields'])) {
|
||||
$adding = false;
|
||||
}
|
||||
|
||||
if ($adding) {
|
||||
$this->_data['fields'] = array_merge($this->_data['fields'], $fields);
|
||||
} else {
|
||||
if (!count($fields)) {
|
||||
throw new InvalidArgumentException('setting empty set of fields rejected');
|
||||
}
|
||||
$this->_data['fields'] = $fields;
|
||||
}
|
||||
|
||||
$this->_data['fields'] = array_unique($this->_data['fields']);
|
||||
break;
|
||||
|
||||
case 'sort':
|
||||
if (!is_array($value)) {
|
||||
$value = array($value, true);
|
||||
}
|
||||
|
||||
switch (count($value)) {
|
||||
case 2:
|
||||
$fields = array_shift($value);
|
||||
$ascending = array_shift($value);
|
||||
break;
|
||||
case 1:
|
||||
$fields = array_shift($value);
|
||||
$ascending = true;
|
||||
break;
|
||||
default:
|
||||
throw new InvalidArgumentException('invalid sorting selector');
|
||||
}
|
||||
|
||||
$this->addSorting($fields, $ascending, !$adding);
|
||||
break;
|
||||
|
||||
case 'union':
|
||||
if ($adding) {
|
||||
throw new InvalidArgumentException('invalid parameter access on ' . $name);
|
||||
}
|
||||
$this->_data[$name] = !!$value;
|
||||
break;
|
||||
|
||||
case 'filter':
|
||||
if ($adding) {
|
||||
throw new InvalidArgumentException('invalid parameter access on ' . $name);
|
||||
}
|
||||
|
||||
// if ( !( $value instanceof Opus_Search_Filter_Base ) ) {
|
||||
// throw new InvalidArgumentException( 'invalid filter' );
|
||||
// }
|
||||
|
||||
$this->_data[$name] = $value;
|
||||
break;
|
||||
|
||||
case 'facet':
|
||||
if ($adding) {
|
||||
throw new InvalidArgumentException('invalid parameter access on ' . $name);
|
||||
}
|
||||
|
||||
if (!($value instanceof Opus_Search_Facet_Set)) {
|
||||
throw new InvalidArgumentException('invalid facet options');
|
||||
}
|
||||
$this->_data[$name] = $value;
|
||||
break;
|
||||
|
||||
case 'subfilters':
|
||||
throw new RuntimeException('invalid access on sub filters');
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->get($name);
|
||||
}
|
||||
|
||||
public function __isset($name)
|
||||
{
|
||||
return !is_null($this->get($name));
|
||||
}
|
||||
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$this->set($name, $value, false);
|
||||
}
|
||||
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
if (preg_match('/^(get|set|add)([a-z]+)$/i', $method, $matches)) {
|
||||
$property = $this->isValidParameter($matches[2]);
|
||||
switch (strtolower($matches[1])) {
|
||||
case 'get':
|
||||
return $this->get($property, @$arguments[0]);
|
||||
|
||||
case 'set':
|
||||
$this->set($property, @$arguments[0], false);
|
||||
return $this;
|
||||
|
||||
case 'add':
|
||||
$this->set($property, @$arguments[0], true);
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
throw new RuntimeException('invalid method: ' . $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds request for sorting by some field in desired order.
|
||||
*
|
||||
* @param string|string[] $field one or more field names to add sorting (as array and/or comma-separated string)
|
||||
* @param bool $ascending true or "asc" for ascending by all given fields
|
||||
* @param bool $reset true for dropping previously declared sorting
|
||||
* @return $this fluent interface
|
||||
*/
|
||||
public function addSorting($field, $ascending = true, $reset = false)
|
||||
{
|
||||
$fields = $this->normalizeFields($field);
|
||||
$ascending = $this->normalizeDirection($ascending);
|
||||
|
||||
if (!count($fields)) {
|
||||
throw new InvalidArgumentException('missing field for sorting result');
|
||||
}
|
||||
|
||||
if ($reset || !is_array($this->_data['sort'])) {
|
||||
$this->_data['sort'] = array();
|
||||
}
|
||||
|
||||
foreach ($fields as $field) {
|
||||
if ($field === '*') {
|
||||
throw new InvalidArgumentException('invalid request for sorting by all fields (*)');
|
||||
}
|
||||
$this->_data['sort'][$field] = $ascending ? 'asc' : 'desc';
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares some subfilter.
|
||||
*
|
||||
* @note In Solr a search includes a "query" and optionally one or more
|
||||
* "filter query". This API intends different terminology for the
|
||||
* whole search request is considered a "query" with a "filter" used
|
||||
* to select actually desired documents by matching conditions. In
|
||||
* context with this terminology "subfilter" was used to describe what
|
||||
* is "filter query" in Solr world: some named query to be included on
|
||||
* selecting documents in database with some benefits regarding
|
||||
* performance, server-side result caching and non-affecting score.
|
||||
*
|
||||
* @see http://wiki.apache.org/solr/CommonQueryParameters#fq
|
||||
*
|
||||
* @param string $name name of query (used for server-side caching)
|
||||
* @param Opus_Search_Filter_Base $subFilter filter to be satisfied by all matching documents in addition
|
||||
* @return $this fluent interface
|
||||
*/
|
||||
public function setSubFilter($name, Opus_Search_Filter_Base $subFilter)
|
||||
{
|
||||
if (!is_string($name) || !$name) {
|
||||
throw new InvalidArgumentException('invalid sub filter name');
|
||||
}
|
||||
|
||||
if (!is_array($this->_data['subfilters'])) {
|
||||
$this->_data['subfilters'] = array($name => $subFilter);
|
||||
} else {
|
||||
$this->_data['subfilters'][$name] = $subFilter;
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes some previously defined subfilter from current query again.
|
||||
*
|
||||
* @note This isn't affecting server-side caching of selected filter but
|
||||
* reverting some parts of query compiled on client-side.
|
||||
*
|
||||
* @see Opus_Search_Query::setSubFilter()
|
||||
*
|
||||
* @param string $name name of filter to remove from query again
|
||||
* @return $this fluent interface
|
||||
*/
|
||||
public function removeSubFilter($name)
|
||||
{
|
||||
if (!is_string($name) || !$name) {
|
||||
throw new InvalidArgumentException('invalid sub filter name');
|
||||
}
|
||||
|
||||
if (is_array($this->_data['subfilters'])) {
|
||||
if (array_key_exists($name, $this->_data['subfilters'])) {
|
||||
unset($this->_data['subfilters'][$name]);
|
||||
}
|
||||
if (!count($this->_data['subfilters'])) {
|
||||
$this->_data['subfilters'] = null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves named map of subfilters to include on querying search engine.
|
||||
*
|
||||
* @return Opus_Search_Filter_Base[]
|
||||
*/
|
||||
public function getSubFilters()
|
||||
{
|
||||
return $this->_data['subfilters'];
|
||||
}
|
||||
|
||||
public static function getParameterDefault($name, $fallbackIfMissing, $oldName = null)
|
||||
{
|
||||
$config = Opus_Search_Config::getDomainConfiguration();
|
||||
$defaults = $config->parameterDefaults;
|
||||
|
||||
if ($defaults instanceof Zend_Config) {
|
||||
return $defaults->get($name, $fallbackIfMissing);
|
||||
}
|
||||
if ($oldName) {
|
||||
return $config->get($oldName, $fallbackIfMissing);
|
||||
}
|
||||
|
||||
return $fallbackIfMissing;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves configured default offset for paging results.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getDefaultStart()
|
||||
{
|
||||
return static::getParameterDefault('start', 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves configured default number of rows to show (per page).
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function getDefaultRows()
|
||||
{
|
||||
return static::getParameterDefault('rows', 10, 'numberOfDefaultSearchResults');
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves configured default sorting.
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public static function getDefaultSorting()
|
||||
{
|
||||
$sorting = static::getParameterDefault('sortField', 'score desc');
|
||||
|
||||
$parts = preg_split('/[\s,]+/', trim($sorting), null, PREG_SPLIT_NO_EMPTY);
|
||||
|
||||
$sorting = array(array_shift($parts));
|
||||
|
||||
if (!count($parts)) {
|
||||
$sorting[] = 'desc';
|
||||
} else {
|
||||
$dir = array_shift($parts);
|
||||
if (strcasecmp($dir, 'asc') || strcasecmp($dir, 'desc')) {
|
||||
$dir = 'desc';
|
||||
}
|
||||
$sorting[] = strtolower($dir);
|
||||
}
|
||||
return $sorting;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves configured name of field to use for sorting results by default.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function getDefaultSortingField()
|
||||
{
|
||||
$sorting = static::getDefaultSorting();
|
||||
return $sorting[0];
|
||||
}
|
||||
}
|
290
app/Library/Util/SearchResultMatch.php
Normal file
290
app/Library/Util/SearchResultMatch.php
Normal file
|
@ -0,0 +1,290 @@
|
|||
<?php
|
||||
namespace App\Library\Util;
|
||||
|
||||
use Carbon\Carbon;
|
||||
|
||||
/**
|
||||
* Describes local document as a match in context of a related search query.
|
||||
*/
|
||||
class SearchResultMatch
|
||||
{
|
||||
|
||||
/**
|
||||
* @var mixed
|
||||
*/
|
||||
protected $id = null;
|
||||
|
||||
/**
|
||||
* @var Opus_Document
|
||||
*/
|
||||
protected $doc = null;
|
||||
|
||||
/**
|
||||
* @var float
|
||||
*/
|
||||
protected $score = null;
|
||||
|
||||
/**
|
||||
* @var Opus_Date
|
||||
*/
|
||||
protected $serverDateModified = null;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $fulltextIdSuccess = null;
|
||||
|
||||
/**
|
||||
* @var
|
||||
*/
|
||||
protected $fulltextIdFailure = null;
|
||||
|
||||
/**
|
||||
* Caches current document's mapping of containing serieses into document's
|
||||
* number in either series.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $seriesNumbers = null;
|
||||
|
||||
/**
|
||||
* Collects all additional information related to current match.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $data = array();
|
||||
|
||||
public function __construct($matchId)
|
||||
{
|
||||
$this->id = $matchId;
|
||||
}
|
||||
|
||||
public static function create($matchId)
|
||||
{
|
||||
return new static($matchId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves ID of document matching related search query.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves instance of Opus_Document related to current match.
|
||||
*
|
||||
* @throws Opus_Model_NotFoundException
|
||||
* @return Opus_Document
|
||||
*/
|
||||
public function getDocument()
|
||||
{
|
||||
if (is_null($this->doc)) {
|
||||
$this->doc = new Opus_Document($this->id);
|
||||
}
|
||||
return $this->doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns score of match in context of related search.
|
||||
*
|
||||
* @param $score
|
||||
* @return $this
|
||||
*/
|
||||
public function setScore($score)
|
||||
{
|
||||
if (!is_null($this->score)) {
|
||||
throw new RuntimeException('score has been set before');
|
||||
}
|
||||
$this->score = floatval($score);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves score of match in context of related search.
|
||||
*
|
||||
* @return float|null null if score was not set
|
||||
*/
|
||||
public function getScore()
|
||||
{
|
||||
return $this->score;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves matching document's number in series selected by its ID.
|
||||
*
|
||||
* This method is provided for downward compatibility. You are advised to
|
||||
* inspect document's model for this locally available information rather
|
||||
* than relying on search engine returning it.
|
||||
*
|
||||
* @deprecated
|
||||
* @return string
|
||||
*/
|
||||
public function getSeriesNumber($seriesId)
|
||||
{
|
||||
if (!$seriesId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!is_array($this->seriesNumbers)) {
|
||||
$this->seriesNumbers = array();
|
||||
|
||||
foreach ($this->getDocument()->getSeries() as $linkedSeries) {
|
||||
$id = $linkedSeries->getModel()->getId();
|
||||
$number = $linkedSeries->getNumber();
|
||||
|
||||
$this->seriesNumbers[$id] = $number;
|
||||
}
|
||||
}
|
||||
|
||||
return array_key_exists($seriesId, $this->seriesNumbers) ? $this->seriesNumbers[$seriesId] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assigns timestamp of last modification to document as tracked in search
|
||||
* index.
|
||||
*
|
||||
* @note This information is temporarily overloading related timestamp in
|
||||
* local document.
|
||||
*
|
||||
* @param {int} $timestamp Unix timestamp of last modification tracked in search index
|
||||
* @return $this fluent interface
|
||||
*/
|
||||
public function setServerDateModified($timestamp)
|
||||
{
|
||||
if (!is_null($this->serverDateModified)) {
|
||||
throw new RuntimeException('timestamp of modification has been set before');
|
||||
}
|
||||
|
||||
//$this->serverDateModified = new Opus_Date();
|
||||
//$this->serverDateModified = Carbon::createFromTimestamp($timestamp);
|
||||
$this->serverDateModified = Carbon::createFromTimestamp($timestamp)->toDateTimeString();
|
||||
|
||||
// if ( ctype_digit( $timestamp = trim( $timestamp ) ) ) {
|
||||
// $this->serverDateModified->setUnixTimestamp( intval( $timestamp ) );
|
||||
// } else {
|
||||
// $this->serverDateModified->setFromString( $timestamp );
|
||||
// }
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides timestamp of last modification preferring value provided by
|
||||
* search engine over value stored locally in document.
|
||||
*
|
||||
* @note This method is used by Opus to detect outdated records in search
|
||||
* index.
|
||||
*
|
||||
* @return string //old Opusdate
|
||||
*/
|
||||
public function getServerDateModified()
|
||||
{
|
||||
if (!is_null($this->serverDateModified)) {
|
||||
return $this->serverDateModified;
|
||||
}
|
||||
|
||||
return $this->getDocument()->getServerDateModified();
|
||||
}
|
||||
|
||||
public function setFulltextIDsSuccess($value)
|
||||
{
|
||||
if (!is_null($this->fulltextIdSuccess)) {
|
||||
throw new RuntimeException('successful fulltext IDs have been set before');
|
||||
}
|
||||
$this->fulltextIdSuccess = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFulltextIDsSuccess()
|
||||
{
|
||||
if (!is_null($this->fulltextIdSuccess)) {
|
||||
return $this->fulltextIdSuccess;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function setFulltextIDsFailure($value)
|
||||
{
|
||||
if (!is_null($this->fulltextIdFailure)) {
|
||||
throw new RuntimeException('failed fulltext IDs have been set before');
|
||||
}
|
||||
$this->fulltextIdFailure = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getFulltextIDsFailure()
|
||||
{
|
||||
if (!is_null($this->fulltextIdFailure)) {
|
||||
return $this->fulltextIdFailure;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes all unknown method invocations to related instance of
|
||||
* Opus_Document.
|
||||
*
|
||||
* @param string $method name of locally missing/protected method
|
||||
* @param mixed[] $args arguments used on invoking that method
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
return call_user_func_array(array($this->getDocument(), $method), $args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes access on locally missing/protected property to related instance
|
||||
* of Opus_Document.
|
||||
*
|
||||
* @param string $name name of locally missing/protected property
|
||||
* @return mixed value of property
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
return $this->getDocument()->{$name};
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches named asset to current match.
|
||||
*
|
||||
* Assets are additional information on match provided by search engine.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
* @return $this fluent interface
|
||||
*/
|
||||
public function setAsset($name, $value)
|
||||
{
|
||||
$this->data[$name] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves selected asset attached to current match or null if asset was
|
||||
* not assigned to match.
|
||||
*
|
||||
* @param string $name
|
||||
* @return mixed|null
|
||||
*/
|
||||
public function getAsset($name)
|
||||
{
|
||||
return isset($this->data[$name]) ? $this->data[$name] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if selected asset has been attached to current match.
|
||||
*
|
||||
* @param string $name name of asset to test
|
||||
* @return bool true if asset was assigned to current match
|
||||
*/
|
||||
public function hasAsset($name) : bool
|
||||
{
|
||||
return array_key_exists($name, $this->data);
|
||||
}
|
||||
}
|
30
app/Library/Util/Searchtypes.php
Normal file
30
app/Library/Util/Searchtypes.php
Normal file
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
namespace App\Library\Util;
|
||||
|
||||
class Searchtypes
|
||||
{
|
||||
|
||||
const SIMPLE_SEARCH = 'simple';
|
||||
const ADVANCED_SEARCH = 'advanced';
|
||||
const AUTHOR_SEARCH = 'authorsearch';
|
||||
const COLLECTION_SEARCH = 'collection';
|
||||
const LATEST_SEARCH = 'latest';
|
||||
const ALL_SEARCH = 'all';
|
||||
const SERIES_SEARCH = 'series';
|
||||
const ID_SEARCH = 'id';
|
||||
|
||||
public static function isSupported($searchtype)
|
||||
{
|
||||
$supportedTypes = array (
|
||||
self::SIMPLE_SEARCH,
|
||||
self::ADVANCED_SEARCH,
|
||||
self::AUTHOR_SEARCH,
|
||||
self::COLLECTION_SEARCH,
|
||||
self::LATEST_SEARCH,
|
||||
self::ALL_SEARCH,
|
||||
self::SERIES_SEARCH,
|
||||
self::ID_SEARCH
|
||||
);
|
||||
return in_array($searchtype, $supportedTypes);
|
||||
}
|
||||
}
|
413
app/Library/Util/SolrSearchQuery.php
Normal file
413
app/Library/Util/SolrSearchQuery.php
Normal file
|
@ -0,0 +1,413 @@
|
|||
<?php
|
||||
namespace App\Library\Util;
|
||||
|
||||
/**
|
||||
* Encapsulates all parameter values needed to build the Solr query URL.
|
||||
*/
|
||||
class SolrSearchQuery
|
||||
{
|
||||
// currently available search types
|
||||
const SIMPLE = 'simple';
|
||||
const ADVANCED = 'advanced';
|
||||
const FACET_ONLY = 'facet_only';
|
||||
const LATEST_DOCS = 'latest';
|
||||
const ALL_DOCS = 'all_docs';
|
||||
const DOC_ID = 'doc_id';
|
||||
|
||||
const DEFAULT_START = 0;
|
||||
const DEFAULT_ROWS = 10;
|
||||
// java.lang.Integer.MAX_VALUE
|
||||
const MAX_ROWS = 2147483647;
|
||||
const DEFAULT_SORTFIELD = 'score';
|
||||
const DEFAULT_SORTORDER = 'desc';
|
||||
const SEARCH_MODIFIER_CONTAINS_ALL = "contains_all";
|
||||
const SEARCH_MODIFIER_CONTAINS_ANY = "contains_any";
|
||||
const SEARCH_MODIFIER_CONTAINS_NONE = "contains_none";
|
||||
|
||||
private $start = self::DEFAULT_START;
|
||||
private $rows = self::DEFAULT_ROWS;
|
||||
private $sortField = self::DEFAULT_SORTFIELD;
|
||||
private $sortOrder = self::DEFAULT_SORTORDER;
|
||||
private $filterQueries = array();
|
||||
private $catchAll;
|
||||
private $searchType;
|
||||
private $modifier;
|
||||
private $fieldValues = array();
|
||||
private $escapingEnabled = true;
|
||||
private $q;
|
||||
private $facetField;
|
||||
private $returnIdsOnly = false;
|
||||
private $seriesId = null;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $searchType
|
||||
*/
|
||||
public function __construct($searchType = self::SIMPLE)
|
||||
{
|
||||
//$this->invalidQCache();
|
||||
$this->q = null;
|
||||
|
||||
if ($searchType === self::SIMPLE || $searchType === self::ADVANCED || $searchType === self::ALL_DOCS) {
|
||||
$this->searchType = $searchType;
|
||||
return;
|
||||
}
|
||||
|
||||
if ($searchType === self::FACET_ONLY) {
|
||||
$this->searchType = self::FACET_ONLY;
|
||||
$this->setRows(0);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($searchType === self::LATEST_DOCS) {
|
||||
$this->searchType = self::LATEST_DOCS;
|
||||
$this->sortField = 'server_date_published';
|
||||
$this->sortOrder = 'desc';
|
||||
return;
|
||||
}
|
||||
|
||||
if ($searchType === self::DOC_ID) {
|
||||
$this->searchType = self::DOC_ID;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public function getSearchType()
|
||||
{
|
||||
return $this->searchType;
|
||||
}
|
||||
|
||||
public function getFacetField()
|
||||
{
|
||||
return $this->facetField;
|
||||
}
|
||||
|
||||
public function setFacetField($facetField)
|
||||
{
|
||||
$this->facetField = $facetField;
|
||||
}
|
||||
|
||||
public function getStart()
|
||||
{
|
||||
return $this->start;
|
||||
}
|
||||
|
||||
public function setStart($start)
|
||||
{
|
||||
$this->start = $start;
|
||||
}
|
||||
|
||||
public static function getDefaultRows()
|
||||
{
|
||||
return SolrSearchQuery::getDefaultRows();
|
||||
}
|
||||
|
||||
public function getRows()
|
||||
{
|
||||
return $this->rows;
|
||||
}
|
||||
|
||||
public function setRows($rows)
|
||||
{
|
||||
$this->rows = $rows;
|
||||
}
|
||||
|
||||
public function getSortField()
|
||||
{
|
||||
return $this->sortField;
|
||||
}
|
||||
|
||||
public function setSortField($sortField)
|
||||
{
|
||||
if ($sortField === self::DEFAULT_SORTFIELD) {
|
||||
if ($this->searchType === self::ALL_DOCS) {
|
||||
// change the default sortfield for searchtype all
|
||||
// since sorting by relevance does not make any sense here
|
||||
$this->sortField = 'server_date_published';
|
||||
} else {
|
||||
$this->sortField = self::DEFAULT_SORTFIELD;
|
||||
}
|
||||
return;
|
||||
}
|
||||
$this->sortField = $sortField;
|
||||
if (strpos($sortField, 'doc_sort_order_for_seriesid_') !== 0 && strpos($sortField, 'server_date_published') !== 0) {
|
||||
// add _sort to the end of $sortField if not already done
|
||||
$suffix = '_sort';
|
||||
if (substr($sortField, strlen($sortField) - strlen($suffix)) !== $suffix) {
|
||||
$this->sortField .= $suffix;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getSortOrder()
|
||||
{
|
||||
return $this->sortOrder;
|
||||
}
|
||||
|
||||
public function setSortOrder($sortOrder)
|
||||
{
|
||||
$this->sortOrder = $sortOrder;
|
||||
}
|
||||
|
||||
public function getSeriesId()
|
||||
{
|
||||
return $this->seriesId;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array An array that contains all specified filter queries.
|
||||
*/
|
||||
public function getFilterQueries()
|
||||
{
|
||||
return $this->filterQueries;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $filterField The field that should be used in a filter query.
|
||||
* @param string $filterValue The field value that should be used in a filter query.
|
||||
*/
|
||||
public function addFilterQuery($filterField, $filterValue)
|
||||
{
|
||||
if ($filterField == 'has_fulltext') {
|
||||
$filterQuery = $filterField . ':' . $filterValue;
|
||||
} else {
|
||||
$filterQuery = '{!raw f=' . $filterField . '}' . $filterValue;
|
||||
}
|
||||
array_push($this->filterQueries, $filterQuery);
|
||||
|
||||
// we need to store the ID of the requested series here,
|
||||
// since we need it later to build the index field name
|
||||
if ($filterField === 'series_ids') {
|
||||
$this->seriesId = $filterValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $filterQueries An array of queries that should be used as filter queries.
|
||||
*/
|
||||
public function setFilterQueries($filterQueries)
|
||||
{
|
||||
$this->filterQueries = $filterQueries;
|
||||
}
|
||||
|
||||
public function getCatchAll()
|
||||
{
|
||||
return $this->catchAll;
|
||||
}
|
||||
|
||||
public function setCatchAll($catchAll)
|
||||
{
|
||||
$this->catchAll = $catchAll;
|
||||
$this->invalidQCache();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $name
|
||||
* @param string $value
|
||||
* @param string $modifier
|
||||
*/
|
||||
public function setField($name, $value, $modifier = self::SEARCH_MODIFIER_CONTAINS_ALL)
|
||||
{
|
||||
if (!empty($value)) {
|
||||
$this->fieldValues[$name] = $value;
|
||||
$this->modifier[$name] = $modifier;
|
||||
$this->invalidQCache();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $name
|
||||
* @return Returns null if no values was specified for the given field name.
|
||||
*/
|
||||
public function getField($name)
|
||||
{
|
||||
if (array_key_exists($name, $this->fieldValues)) {
|
||||
return $this->fieldValues[$name];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $fieldname
|
||||
* @return returns null if no modifier was specified for the given field name.
|
||||
*/
|
||||
public function getModifier($fieldname)
|
||||
{
|
||||
if (array_key_exists($fieldname, $this->modifier)) {
|
||||
return $this->modifier[$fieldname];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getQ()
|
||||
{
|
||||
if (is_null($this->q)) {
|
||||
// earlier cached query was marked as invalid: perform new setup of query cache
|
||||
$this->q = $this->setupQCache();
|
||||
}
|
||||
|
||||
// return cached result (caching is done here since building q is an expensive operation)
|
||||
return $this->q;
|
||||
}
|
||||
|
||||
private function setupQCache()
|
||||
{
|
||||
if ($this->searchType === self::SIMPLE) {
|
||||
if ($this->getCatchAll() === '*:*') {
|
||||
return $this->catchAll;
|
||||
}
|
||||
return $this->escape($this->getCatchAll());
|
||||
}
|
||||
if ($this->searchType === self::FACET_ONLY || $this->searchType === self::LATEST_DOCS || $this->searchType === self::ALL_DOCS) {
|
||||
return '*:*';
|
||||
}
|
||||
if ($this->searchType === self::DOC_ID) {
|
||||
return 'id:' . $this->fieldValues['id'];
|
||||
}
|
||||
return $this->buildAdvancedQString();
|
||||
}
|
||||
|
||||
private function invalidQCache()
|
||||
{
|
||||
$this->q = null;
|
||||
}
|
||||
|
||||
private function buildAdvancedQString()
|
||||
{
|
||||
$q = "{!lucene q.op=AND}";
|
||||
$first = true;
|
||||
foreach ($this->fieldValues as $fieldname => $fieldvalue) {
|
||||
if ($first) {
|
||||
$first = false;
|
||||
} else {
|
||||
$q .= ' ';
|
||||
}
|
||||
|
||||
if ($this->modifier[$fieldname] === self::SEARCH_MODIFIER_CONTAINS_ANY) {
|
||||
$q .= $this->combineSearchTerms($fieldname, $fieldvalue, 'OR');
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($this->modifier[$fieldname] === self::SEARCH_MODIFIER_CONTAINS_NONE) {
|
||||
$q .= '-' . $this->combineSearchTerms($fieldname, $fieldvalue, 'OR');
|
||||
continue;
|
||||
}
|
||||
|
||||
// self::SEARCH_MODIFIER_CONTAINS_ALL
|
||||
$q .= $this->combineSearchTerms($fieldname, $fieldvalue);
|
||||
}
|
||||
return $q;
|
||||
}
|
||||
|
||||
private function combineSearchTerms($fieldname, $fieldvalue, $conjunction = null)
|
||||
{
|
||||
$result = $fieldname . ':(';
|
||||
$firstTerm = true;
|
||||
$queryTerms = preg_split("/[\s]+/", $this->escape($fieldvalue), null, PREG_SPLIT_NO_EMPTY);
|
||||
foreach ($queryTerms as $queryTerm) {
|
||||
if ($firstTerm) {
|
||||
$firstTerm = false;
|
||||
} else {
|
||||
$result .= is_null($conjunction) ? " " : " $conjunction ";
|
||||
}
|
||||
$result .= $queryTerm;
|
||||
}
|
||||
$result .= ')';
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function disableEscaping()
|
||||
{
|
||||
$this->invalidQCache();
|
||||
$this->escapingEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape Lucene's special query characters specified in
|
||||
* http://lucene.apache.org/java/3_0_2/queryparsersyntax.html#Escaping%20Special%20Characters
|
||||
* Escaping currently ignores * and ? which are used as wildcard operators.
|
||||
* Additionally, double-quotes are not escaped and a double-quote is added to
|
||||
* the end of $query in case it contains an odd number of double-quotes.
|
||||
* @param string $query The query which needs to be escaped.
|
||||
*/
|
||||
private function escape($query)
|
||||
{
|
||||
if (!$this->escapingEnabled) {
|
||||
return $query;
|
||||
}
|
||||
$query = trim($query);
|
||||
// add one " to the end of $query if it contains an odd number of "
|
||||
if (substr_count($query, '"') % 2 == 1) {
|
||||
$query .= '"';
|
||||
}
|
||||
// escape special characters (currently ignore " \* \?) outside of ""
|
||||
$insidePhrase = false;
|
||||
$result = '';
|
||||
foreach (explode('"', $query) as $phrase) {
|
||||
if ($insidePhrase) {
|
||||
$result .= '"' . $phrase . '"';
|
||||
} else {
|
||||
$result .= preg_replace(
|
||||
'/(\+|-|&&|\|\||!|\(|\)|\{|}|\[|]|\^|~|:|\\\)/',
|
||||
'\\\$1',
|
||||
$this->lowercaseWildcardQuery($phrase)
|
||||
);
|
||||
}
|
||||
$insidePhrase = !$insidePhrase;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
private function lowercaseWildcardQuery($query)
|
||||
{
|
||||
// check if $query is a wildcard query
|
||||
if (strpos($query, '*') === false && strpos($query, '?') === false) {
|
||||
return $query;
|
||||
}
|
||||
// lowercase query
|
||||
return strtolower($query);
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
if ($this->searchType === self::SIMPLE) {
|
||||
return 'simple search with query ' . $this->getQ();
|
||||
}
|
||||
if ($this->searchType === self::FACET_ONLY) {
|
||||
return 'facet only search with query *:*';
|
||||
}
|
||||
if ($this->searchType === self::LATEST_DOCS) {
|
||||
return 'search for latest documents with query *:*';
|
||||
}
|
||||
if ($this->searchType === self::ALL_DOCS) {
|
||||
return 'search for all documents';
|
||||
}
|
||||
if ($this->searchType === self::DOC_ID) {
|
||||
return 'search for document id ' . $this->getQ();
|
||||
}
|
||||
return 'advanced search with query ' . $this->getQ();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param boolean $returnIdsOnly
|
||||
*/
|
||||
public function setReturnIdsOnly($returnIdsOnly)
|
||||
{
|
||||
$this->returnIdsOnly = $returnIdsOnly;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isReturnIdsOnly()
|
||||
{
|
||||
return $this->returnIdsOnly;
|
||||
}
|
||||
}
|
94
app/Library/Util/SolrSearchSearcher.php
Normal file
94
app/Library/Util/SolrSearchSearcher.php
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?php
|
||||
namespace App\Library\Util;
|
||||
|
||||
use App\Library\Search\SolariumAdapter;
|
||||
use App\Library\Search\SearchResult;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class SolrSearchSearcher
|
||||
{
|
||||
/*
|
||||
* Holds numbers of facets
|
||||
*/
|
||||
private $facetArray;
|
||||
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param SolrSearchQuery $query
|
||||
* @param bool $validateDocIds check document IDs coming from Solr index against database
|
||||
* @return SearchResult
|
||||
* @throws //Opus_SolrSearch_Exception If Solr server responds with an error or the response is empty.
|
||||
*/
|
||||
public function search(SolrSearchQuery $query, bool $validateDocIds = true) : SearchResult
|
||||
{
|
||||
|
||||
try {
|
||||
//Opus_Log::get()->debug("query: " . $query->getQ());
|
||||
|
||||
// get service adapter for searching
|
||||
// $service = SearchService::selectSearchingService( null, 'solr' );
|
||||
$service = new SolariumAdapter("solr", config('solarium'));
|
||||
|
||||
$filterText = $query->getQ();//"*:*"
|
||||
// basically create query
|
||||
$requestParameter = $service->createQuery()
|
||||
->setFilter($filterText)
|
||||
->setStart($query->getStart())
|
||||
->setRows($query->getRows());
|
||||
//start:0
|
||||
// rows:1
|
||||
// fields:null
|
||||
// sort:null
|
||||
// union:null
|
||||
// filter:"aa"
|
||||
// facet:null
|
||||
// subfilters:null
|
||||
|
||||
$requestParameter->setFields(array('*', 'score'));
|
||||
|
||||
$searchResult = $service->customSearch($requestParameter);
|
||||
|
||||
//if ( $validateDocIds )
|
||||
//{
|
||||
// $searchResult->dropLocallyMissingMatches();
|
||||
//}
|
||||
|
||||
return $searchResult;
|
||||
} catch (Exception $e) {
|
||||
return $this->mapException(null, $e);
|
||||
}
|
||||
// catch ( Opus_Search_InvalidServiceException $e ) {
|
||||
// return $this->mapException( Opus_SolrSearch_Exception::SERVER_UNREACHABLE, $e );
|
||||
// }
|
||||
// catch( Opus_Search_InvalidQueryException $e ) {
|
||||
// return $this->mapException( Opus_SolrSearch_Exception::INVALID_QUERY, $e );
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $type
|
||||
* @param //Exception $previousException
|
||||
* @throws //Opus_SolrSearch_Exception
|
||||
* @return no-return
|
||||
*/
|
||||
private function mapException($type, Exception $previousException)
|
||||
{
|
||||
$msg = 'Solr server responds with an error ' . $previousException->getMessage();
|
||||
//Opus_Log::get()->err($msg);
|
||||
Log::error($msg);
|
||||
|
||||
//throw new Opus_SolrSearch_Exception($msg, $type, $previousException);
|
||||
}
|
||||
|
||||
public function setFacetArray($array)
|
||||
{
|
||||
$this->facetArray = $array;
|
||||
}
|
||||
}
|
58
app/Library/Xml/Conf.php
Normal file
58
app/Library/Xml/Conf.php
Normal file
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
namespace App\Library\Xml;
|
||||
|
||||
use App\Library\Util\Searchtypes;
|
||||
use App\Dataset;
|
||||
|
||||
/**
|
||||
* Conf short summary.
|
||||
*
|
||||
* Conf description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author kaiarn
|
||||
*/
|
||||
class Conf
|
||||
{
|
||||
/**
|
||||
* Holds the current model either directly set or deserialized from XML.
|
||||
*
|
||||
* @var Dataset
|
||||
*/
|
||||
public $model = null;
|
||||
|
||||
/**
|
||||
* Holds the current DOM representation.
|
||||
*
|
||||
* @var \DOMDocument
|
||||
*/
|
||||
public $dom = null;
|
||||
|
||||
/**
|
||||
* List of fields to skip on serialization.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $excludeFields = array();
|
||||
|
||||
/**
|
||||
* True, if empty fields get excluded from serialization.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $excludeEmpty = false;
|
||||
|
||||
/**
|
||||
* Base URI for xlink:ref elements
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $baseUri = '';
|
||||
|
||||
/**
|
||||
* Map of model class names to resource names for URI generation.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $resourceNameMap = array();
|
||||
}
|
284
app/Library/Xml/DatasetExtension.php
Normal file
284
app/Library/Xml/DatasetExtension.php
Normal file
|
@ -0,0 +1,284 @@
|
|||
<?php
|
||||
namespace App\Library\Xml;
|
||||
|
||||
/**
|
||||
* DatasetExtension short summary.
|
||||
*
|
||||
* DatasetExtension description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author kaiarn
|
||||
*/
|
||||
trait DatasetExtension
|
||||
{
|
||||
protected $_externalFields = array(
|
||||
'TitleMain' => array(
|
||||
'model' => 'App\Title',
|
||||
'options' => array('type' => 'main'),
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
'TitleAbstract' => array(
|
||||
'model' => 'App\Title',
|
||||
'options' => array('type' => 'abstract'),
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
'Licence' => array(
|
||||
'model' => 'App\License',
|
||||
'through' => 'link_documents_licences',
|
||||
'relation' => 'licenses',
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
'PersonAuthor' => array(
|
||||
'model' => 'App\Person',
|
||||
'through' => 'link_documents_persons',
|
||||
'pivot' => array('role' => 'author'),
|
||||
//'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
|
||||
//'sort_field' => 'SortOrder',
|
||||
'relation' => 'authors',
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
'PersonContributor' => array(
|
||||
'model' => 'App\Person',
|
||||
'through' => 'link_documents_persons',
|
||||
'pivot' => array('role' => 'contributor'),
|
||||
// 'sort_order' => array('sort_order' => 'ASC'), // <-- We need a sorted authors list.
|
||||
//'sort_field' => 'SortOrder',
|
||||
'relation' => 'contributors',
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
'File' => array(
|
||||
'model' => 'App\File',
|
||||
'relation' => 'files',
|
||||
'fetch' => 'eager'
|
||||
),
|
||||
);
|
||||
|
||||
|
||||
protected $_internalFields = array();
|
||||
|
||||
protected $_fields = array();
|
||||
|
||||
protected function _initFields()
|
||||
{
|
||||
$fields = array(
|
||||
"Id",
|
||||
"CompletedDate", "CompletedYear",
|
||||
"ContributingCorporation",
|
||||
"CreatingCorporation",
|
||||
"ThesisDateAccepted", "ThesisYearAccepted",
|
||||
"Edition",
|
||||
"Issue",
|
||||
"Language",
|
||||
"PageFirst", "PageLast", "PageNumber",
|
||||
"PublishedDate", "PublishedYear",
|
||||
"PublisherName", "PublisherPlace",
|
||||
"PublicationState",
|
||||
"ServerDateCreated",
|
||||
"ServerDateModified",
|
||||
"ServerDatePublished",
|
||||
"ServerDateDeleted",
|
||||
"ServerState",
|
||||
"Type",
|
||||
"Volume",
|
||||
"BelongsToBibliography",
|
||||
"EmbargoDate"
|
||||
);
|
||||
|
||||
foreach ($fields as $fieldname) {
|
||||
$field = new Field($fieldname);
|
||||
$this->addField($field);
|
||||
}
|
||||
|
||||
foreach (array_keys($this->_externalFields) as $fieldname) {
|
||||
$field = new Field($fieldname);
|
||||
$field->setMultiplicity('*');
|
||||
$this->addField($field);
|
||||
}
|
||||
|
||||
// Initialize available date fields and set up date validator
|
||||
// if the particular field is present
|
||||
$dateFields = array(
|
||||
'ServerDateCreated', 'CompletedDate', 'PublishedDate',
|
||||
'ServerDateModified', 'ServerDatePublished', 'ServerDateDeleted', 'EmbargoDate'
|
||||
);
|
||||
foreach ($dateFields as $fieldName) {
|
||||
$this->getField($fieldName)
|
||||
->setValueModelClass('Carbon');
|
||||
}
|
||||
|
||||
// $this->_fetchValues();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of all fields attached to the model. Filters all fieldnames
|
||||
* that are defined to be inetrnal in $_internalFields.
|
||||
*
|
||||
* @see Opus_Model_Abstract::_internalFields
|
||||
* @return array List of fields
|
||||
*/
|
||||
public function describe()
|
||||
{
|
||||
return array_diff(array_keys($this->_fields), $this->_internalFields);
|
||||
}
|
||||
|
||||
public function addField(Field $field)
|
||||
{
|
||||
$fieldname = $field->getName();
|
||||
if (isset($fieldname, $this->_externalFields[$fieldname])) {
|
||||
$options = $this->_externalFields[$fieldname];
|
||||
|
||||
// set ValueModelClass if a through option is given
|
||||
if (isset($options['model'])) {
|
||||
$field->setValueModelClass($options['model']);
|
||||
}
|
||||
// set LinkModelClass if a through option is given
|
||||
//if (isset($options['through']))
|
||||
//{
|
||||
// $field->setLinkModelClass($options['through']);
|
||||
//}
|
||||
}
|
||||
|
||||
$this->_fields[$field->getName()] = $field;
|
||||
$field->setOwningModelClass(get_class($this));
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getField($name)
|
||||
{
|
||||
return $this->_getField($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a reference to an actual field.
|
||||
*
|
||||
* @param string $name Name of the requested field.
|
||||
* @return Field The requested field instance. If no such instance can be found, null is returned.
|
||||
*/
|
||||
protected function _getField($name)
|
||||
{
|
||||
if (isset($this->_fields[$name])) {
|
||||
return $this->_fields[$name];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public function fetchValues()
|
||||
{
|
||||
$this->_initFields();
|
||||
foreach ($this->_fields as $fieldname => $field) {
|
||||
if (isset($this->_externalFields[$fieldname]) === true) {
|
||||
$fetchmode = 'lazy';
|
||||
if (isset($this->_externalFields[$fieldname]['fetch']) === true) {
|
||||
$fetchmode = $this->_externalFields[$fieldname]['fetch'];
|
||||
}
|
||||
|
||||
if ($fetchmode === 'lazy') {
|
||||
// Remember the field to be fetched later.
|
||||
$this->_pending[] = $fieldname;
|
||||
// Go to next field
|
||||
continue;
|
||||
} else {
|
||||
// Immediately load external field if fetching mode is set to 'eager'
|
||||
$this->_loadExternal($fieldname);
|
||||
}
|
||||
} else {
|
||||
// Field is not external an gets handled by simply reading
|
||||
$property_name = self::convertFieldnameToColumn($fieldname);
|
||||
//$test = $this->server_date_created;
|
||||
$fieldval = $this->{$property_name};
|
||||
|
||||
// explicitly set null if the field represents a model except for dates
|
||||
if (null !== $field->getValueModelClass()) {
|
||||
if (true === empty($fieldval)) {
|
||||
$fieldval = null;
|
||||
} else {
|
||||
$fieldval = new \Carbon\Carbon($fieldval);
|
||||
}
|
||||
}
|
||||
|
||||
$field->setValue($fieldval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function convertFieldnameToColumn($fieldname)
|
||||
{
|
||||
return strtolower(preg_replace('/(?!^)[[:upper:]]/', '_\0', $fieldname));
|
||||
}
|
||||
|
||||
protected function _loadExternal($fieldname)
|
||||
{
|
||||
$field = $this->_fields[$fieldname];
|
||||
|
||||
$modelclass = $field->getLinkModelClass();
|
||||
if (!isset($modelclass)) {
|
||||
// For handling a value model, see 'model' option.
|
||||
$modelclass = $field->getValueModelClass();
|
||||
}
|
||||
|
||||
$tableclass = new $modelclass();//::getTableGatewayClass();
|
||||
// $table = Opus_Db_TableGateway::getInstance($tableclass);
|
||||
$select = $tableclass->query();//->where("document_id", $this->id);;
|
||||
|
||||
// If any declared constraints, add them to query
|
||||
if (isset($this->_externalFields[$fieldname]['options'])) {
|
||||
$options = $this->_externalFields[$fieldname]['options'];
|
||||
foreach ($options as $column => $value) {
|
||||
$select = $select->where($column, $value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get dependent rows
|
||||
$result = array();
|
||||
$datasetId = $this->id;
|
||||
|
||||
$rows = array();
|
||||
if (isset($this->_externalFields[$fieldname]['through'])) {
|
||||
$relation = $this->_externalFields[$fieldname]['relation'];
|
||||
//$rows = $select->datasets
|
||||
////->orderBy('name')
|
||||
//->get();
|
||||
//$licenses = $select->with('datasets')->get();
|
||||
//$rows = $supplier->datasets;
|
||||
$rows = $this->{$relation};
|
||||
//if (isset($this->_externalFields[$fieldname]['pivot']))
|
||||
//{
|
||||
// $pivArray = $this->_externalFields[$fieldname]['pivot'];
|
||||
// $rows = $rows->wherePivot('role', $pivArray['role']);
|
||||
//}
|
||||
} else {
|
||||
$rows = $select->whereHas('dataset', function ($q) use ($datasetId) {
|
||||
$q->where('id', $datasetId);
|
||||
})->get();
|
||||
}
|
||||
|
||||
foreach ($rows as $row) {
|
||||
// //$newModel = new $modelclass($row);
|
||||
// $result[] = $row;//->value;
|
||||
|
||||
$attributes = array_keys($row->getAttributes());
|
||||
$objArray = [];
|
||||
foreach ($attributes as $property_name) {
|
||||
$fieldName = self::convertColumnToFieldname($property_name);
|
||||
// $field =new Field($fieldName);
|
||||
$fieldval = $row->{$property_name};
|
||||
// $field->setValue($fieldval);
|
||||
// $this->_mapField($field, $dom, $rootNode);
|
||||
$objArray[$fieldName] = $fieldval;
|
||||
}
|
||||
$result[] = $objArray;
|
||||
}
|
||||
|
||||
// Set the field value
|
||||
$field->setValue($result);
|
||||
}
|
||||
|
||||
//snakeToCamel
|
||||
public static function convertColumnToFieldname($columnname)
|
||||
{
|
||||
//return lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $columnname))));
|
||||
return str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $columnname)));
|
||||
}
|
||||
}
|
213
app/Library/Xml/Field.php
Normal file
213
app/Library/Xml/Field.php
Normal file
|
@ -0,0 +1,213 @@
|
|||
<?php
|
||||
namespace App\Library\Xml;
|
||||
|
||||
/**
|
||||
* Field short summary.
|
||||
*
|
||||
* Field description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author kaiarn
|
||||
*/
|
||||
class Field
|
||||
{
|
||||
/**
|
||||
* Hold multiplicity constraint.
|
||||
*
|
||||
* @var Integer|String
|
||||
*/
|
||||
protected $_multiplicity = 1;
|
||||
|
||||
/**
|
||||
* Simple check for multiple values.
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
private $_hasMultipleValues = false;
|
||||
|
||||
/**
|
||||
* Holds the classname for external fields.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_valueModelClass = null;
|
||||
|
||||
/**
|
||||
* Holds the classname for link fields.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_linkModelClass = null;
|
||||
|
||||
/**
|
||||
* Holds the classname of the model that the field belongs to.
|
||||
*/
|
||||
protected $_owningModelClass = null;
|
||||
|
||||
/**
|
||||
* Hold the fields value.
|
||||
*
|
||||
* @var mixed
|
||||
*/
|
||||
protected $_value = null;
|
||||
|
||||
/**
|
||||
* Create an new field instance and set the given name.
|
||||
*
|
||||
* @param string $name Internal name of the field.
|
||||
*/
|
||||
public function __construct($name)
|
||||
{
|
||||
$this->_name = $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of model class if the field holds model instances.
|
||||
*
|
||||
* @return string Class name or null if the value is not a model.
|
||||
*/
|
||||
public function getValueModelClass()
|
||||
{
|
||||
return $this->_valueModelClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of model class if the field holds model instances.
|
||||
*
|
||||
* @param string $classname The name of the class that is used as model for this field or null.
|
||||
* @return Field Fluent interface.
|
||||
*/
|
||||
public function setValueModelClass($classname)
|
||||
{
|
||||
$this->_valueModelClass = $classname;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the name of the model class that owns the field.
|
||||
* @param string $classname The name of the class that owns the field.
|
||||
* @return Field Fluent interface.
|
||||
*/
|
||||
public function setOwningModelClass($classname)
|
||||
{
|
||||
$this->_owningModelClass = $classname;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
// If the fields value is not going to change, leave.
|
||||
if (is_object($value) === true) {
|
||||
// weak comparison for objects
|
||||
// TODO: DateTimeZone == DateTimeZone always returns true in weak equal check! Why?
|
||||
if ($value == $this->_value) {
|
||||
return $this;
|
||||
}
|
||||
} else {
|
||||
// strong comparison for other values
|
||||
if ($value === $this->_value) {
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
// if (true === is_array($value) and 1 === count($value)) {
|
||||
// //$value = array_pop($value);
|
||||
// }
|
||||
if (true === is_array($value) and 0 === count($value)) {
|
||||
$value = null;
|
||||
} elseif (is_bool($value)) {
|
||||
// make sure 'false' is not converted to '' (empty string), but 0 for database
|
||||
$value = (int)$value;
|
||||
}
|
||||
|
||||
// if null is given, delete dependent objects
|
||||
if (null === $value) {
|
||||
//$this->_deleteDependentModels();
|
||||
} else {
|
||||
$multiValueCondition = $this->hasMultipleValues();
|
||||
$arrayCondition = is_array($value);
|
||||
|
||||
// arrayfy value
|
||||
$values = $value;
|
||||
if (false === $arrayCondition) {
|
||||
$values = array($value);
|
||||
}
|
||||
// remove wrapper array if multivalue condition is not given
|
||||
if (false === $multiValueCondition) {
|
||||
$value = $values[0];
|
||||
}
|
||||
|
||||
$this->_value = $value;
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
public function getValue($index = null)
|
||||
{
|
||||
|
||||
// wrap start value in array if multivalue option is set for this field
|
||||
$this->_value = $this->_wrapValueInArrayIfRequired($this->_value);
|
||||
|
||||
// Caller requested a specific array index
|
||||
//if (!is_null($index)) {
|
||||
// if (true === is_array($this->_value)) {
|
||||
// if (true === isset($this->_value[$index])) {
|
||||
// return $this->_value[$index];
|
||||
// }
|
||||
// else {
|
||||
// throw new \Exception('Unvalid index: ' . $index);
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// throw new \Exception('Invalid index (' . $index . '). Requested value is not an array.');
|
||||
// }
|
||||
//}
|
||||
|
||||
return $this->_value;
|
||||
}
|
||||
|
||||
private function _wrapValueInArrayIfRequired($value)
|
||||
{
|
||||
if (is_array($value) or !$this->hasMultipleValues()) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
if (is_null($value)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return array($value);
|
||||
}
|
||||
|
||||
public function hasMultipleValues()
|
||||
{
|
||||
return $this->_hasMultipleValues;
|
||||
}
|
||||
|
||||
public function setMultiplicity($max)
|
||||
{
|
||||
if ($max !== '*') {
|
||||
if ((is_int($max) === false) or ($max < 1)) {
|
||||
throw new \Exception('Only integer values > 1 or "*" allowed.');
|
||||
}
|
||||
}
|
||||
$this->_multiplicity = $max;
|
||||
$this->_hasMultipleValues = (($max > 1) or ($max === '*'));
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the name of model class if the field holds link model instances.
|
||||
*
|
||||
* @return string Class name or null if the value is not a model.
|
||||
*/
|
||||
public function getLinkModelClass()
|
||||
{
|
||||
return $this->_linkModelClass;
|
||||
}
|
||||
}
|
232
app/Library/Xml/Strategy.php
Normal file
232
app/Library/Xml/Strategy.php
Normal file
|
@ -0,0 +1,232 @@
|
|||
<?php
|
||||
namespace App\Library\Xml;
|
||||
|
||||
use App\Dataset;
|
||||
use DOMDocument;
|
||||
|
||||
/**
|
||||
* Strategy short summary.
|
||||
*
|
||||
* Strategy description.
|
||||
*
|
||||
* @version 1.0
|
||||
* @author kaiarn
|
||||
*/
|
||||
class Strategy
|
||||
{
|
||||
/**
|
||||
* Holds current configuration.
|
||||
*
|
||||
* @var Conf
|
||||
*/
|
||||
private $_config;
|
||||
|
||||
/**
|
||||
* Holds current representation version.
|
||||
*
|
||||
* @var double
|
||||
*/
|
||||
protected $_version = null;
|
||||
|
||||
|
||||
/**
|
||||
* Initiate class with a valid config object.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_version = 1.0;
|
||||
$this->_config = new Conf();
|
||||
}
|
||||
|
||||
/**
|
||||
* (non-PHPdoc)
|
||||
* see library/Opus/Model/Xml/Opus_Model_Xml_Strategy#setDomDocument()
|
||||
*/
|
||||
public function setup(Conf $conf)
|
||||
{
|
||||
$this->_config = $conf;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a model has been set this method generates and returnes
|
||||
* DOM representation of it.
|
||||
*
|
||||
* @throws \Exception Thrown if no Model is given.
|
||||
* @return \DOMDocument DOM representation of the current Model.
|
||||
*/
|
||||
public function getDomDocument()
|
||||
{
|
||||
if (null === $this->_config->model) {
|
||||
throw new \Exception('No Model given for serialization.');
|
||||
}
|
||||
$this->_config->dom = new DOMDocument('1.0', 'UTF-8');
|
||||
$root = $this->_config->dom->createElement('Opus');
|
||||
$root->setAttribute('version', $this->getVersion());
|
||||
$this->_config->dom->appendChild($root);
|
||||
$root->setAttribute('xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
|
||||
$this->_mapModel($this->_config->model, $this->_config->dom, $root);
|
||||
|
||||
return $this->_config->dom;
|
||||
}
|
||||
|
||||
protected function _mapModel(Dataset $model, \DOMDocument $dom, \DOMNode $rootNode)
|
||||
{
|
||||
$fields = $model->describe();
|
||||
$excludeFields = $this->getConfig()->excludeFields;
|
||||
if (count($excludeFields) > 0) {
|
||||
$fieldsDiff = array_diff($fields, $excludeFields);
|
||||
} else {
|
||||
$fieldsDiff = $fields;
|
||||
}
|
||||
|
||||
$childNode = $this->createModelNode($dom, $model);
|
||||
$rootNode->appendChild($childNode);
|
||||
|
||||
foreach ($fieldsDiff as $fieldname) {
|
||||
$field = $model->getField($fieldname);
|
||||
$this->_mapField($field, $dom, $childNode);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _mapField(Field $field, DOMDocument $dom, \DOMNode $rootNode)
|
||||
{
|
||||
$modelClass = $field->getValueModelClass();
|
||||
$fieldValues = $field->getValue();
|
||||
|
||||
if (true === $this->getConfig()->excludeEmpty) {
|
||||
if (true === is_null($fieldValues)
|
||||
or (is_string($fieldValues) && trim($fieldValues) == '')
|
||||
or (is_array($fieldValues) && empty($fieldValues))) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $modelClass) {
|
||||
$this->mapSimpleField($dom, $rootNode, $field);
|
||||
} else {
|
||||
$fieldName = $field->getName();
|
||||
|
||||
if (!is_array($fieldValues)) {
|
||||
$fieldValues = array($fieldValues);
|
||||
}
|
||||
|
||||
foreach ($fieldValues as $value) {
|
||||
$childNode = $this->createFieldElement($dom, $fieldName);
|
||||
//$childNode->setAttribute("Value", $value);
|
||||
$rootNode->appendChild($childNode);
|
||||
|
||||
|
||||
// if a field has no value then is nothing more to do
|
||||
// TODO maybe must be there an other solution
|
||||
// FIXME remove code duplication (duplicates Opus_Model_Xml_Version*)
|
||||
if (is_null($value)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($value instanceof \Illuminate\Database\Eloquent\Model) {
|
||||
$this->_mapModelAttributes($value, $dom, $childNode);
|
||||
} elseif ($value instanceof \Carbon\Carbon) {
|
||||
$this->_mapDateAttributes($value, $dom, $childNode);
|
||||
} elseif (is_array($value)) {
|
||||
$this->_mapArrayAttributes($value, $dom, $childNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function mapSimpleField(DOMDocument $dom, \DOMNode $rootNode, Field $field)
|
||||
{
|
||||
$fieldName = $field->getName();
|
||||
$fieldValues = $this->getFieldValues($field);
|
||||
|
||||
// Replace invalid XML-1.0-Characters by UTF-8 replacement character.
|
||||
$fieldValues = preg_replace('/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/', "\xEF\xBF\xBD ", $fieldValues);
|
||||
$rootNode->setAttribute($fieldName, $fieldValues);
|
||||
}
|
||||
|
||||
protected function createFieldElement(DOMDocument $dom, $fieldName)
|
||||
{
|
||||
return $dom->createElement($fieldName);
|
||||
}
|
||||
|
||||
protected function _mapDateAttributes(\Carbon\Carbon $model, DOMDocument $dom, \DOMNode $rootNode)
|
||||
{
|
||||
$rootNode->setAttribute("Year", $model->year);
|
||||
$rootNode->setAttribute("Month", $model->month);
|
||||
$rootNode->setAttribute("Day", $model->day);
|
||||
$rootNode->setAttribute("Hour", $model->hour);
|
||||
$rootNode->setAttribute("Minute", $model->minute);
|
||||
$rootNode->setAttribute("Second", $model->second);
|
||||
$rootNode->setAttribute("UnixTimestamp", $model->timestamp);
|
||||
$rootNode->setAttribute("Timezone", $model->tzName);
|
||||
}
|
||||
|
||||
protected function _mapArrayAttributes(array $attributes, DOMDocument $dom, \DOMNode $rootNode)
|
||||
{
|
||||
//$attributes = array_keys($model->getAttributes());
|
||||
foreach ($attributes as $property_name => $value) {
|
||||
$fieldName = $property_name;
|
||||
$field = new Field($fieldName);
|
||||
$fieldval = $value;
|
||||
$field->setValue($fieldval);
|
||||
$this->_mapField($field, $dom, $rootNode);
|
||||
}
|
||||
}
|
||||
|
||||
protected function _mapModelAttributes(\Illuminate\Database\Eloquent\Model $model, DOMDocument $dom, \DOMNode $rootNode)
|
||||
{
|
||||
$attributes = array_keys($model->getAttributes());
|
||||
foreach ($attributes as $property_name) {
|
||||
$fieldName = self::convertColumnToFieldname($property_name);
|
||||
$field = new Field($fieldName);
|
||||
$fieldval = $model->{$property_name};
|
||||
$field->setValue($fieldval);
|
||||
$this->_mapField($field, $dom, $rootNode);
|
||||
}
|
||||
}
|
||||
|
||||
//snakeToCamel
|
||||
public static function convertColumnToFieldname($columnname)
|
||||
{
|
||||
//return lcfirst(str_replace(' ', '', ucwords(str_replace('_', ' ', $columnname))));
|
||||
return str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $columnname)));
|
||||
}
|
||||
|
||||
public function getFieldValues($field)
|
||||
{
|
||||
$fieldValues = $field->getValue();
|
||||
|
||||
// workaround for simple fields with multiple values
|
||||
if (true === $field->hasMultipleValues()) {
|
||||
$fieldValues = implode(',', $fieldValues);
|
||||
}
|
||||
//if ($fieldValues instanceOf DateTimeZone) {
|
||||
// $fieldValues = $fieldValues->getName();
|
||||
//}
|
||||
|
||||
return trim($fieldValues);
|
||||
}
|
||||
|
||||
|
||||
protected function createModelNode(DOMDocument $dom, Dataset $model)
|
||||
{
|
||||
$classname = "Rdr_" . substr(strrchr(get_class($model), '\\'), 1);
|
||||
return $dom->createElement($classname);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return version value of current xml representation.
|
||||
*
|
||||
* @see library/Opus/Model/Xml/Opus_Model_Xml_Strategy#getVersion()
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
return floor($this->_version);
|
||||
}
|
||||
|
||||
public function getConfig()
|
||||
{
|
||||
return $this->_config;
|
||||
}
|
||||
}
|
180
app/Library/Xml/XmlModel.php
Normal file
180
app/Library/Xml/XmlModel.php
Normal file
|
@ -0,0 +1,180 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Footer
|
||||
*
|
||||
* Main footer file for the theme.
|
||||
*
|
||||
* @category Components
|
||||
* @package ResearchRepository
|
||||
* @subpackage Publish
|
||||
* @author Your Name <yourname@example.com>
|
||||
* @license https://www.gnu.org/licenses/gpl-3.0.txt GNU/GPLv3
|
||||
* @link https://gisgba.geologie.ac.at
|
||||
* @since 1.0.0
|
||||
*/
|
||||
namespace App\Library\Xml;
|
||||
|
||||
use App\XmlCache;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
class XmlModel
|
||||
{
|
||||
/**
|
||||
* Holds current configuration.
|
||||
* @var Conf
|
||||
*/
|
||||
private $_config = null;
|
||||
|
||||
/**
|
||||
* Holds current xml strategy object.
|
||||
* @var Strategy
|
||||
*/
|
||||
private $_strategy = null;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
* @var XmlCache
|
||||
*/
|
||||
private $_cache = null;
|
||||
|
||||
|
||||
/**
|
||||
* Do some initial stuff like setting of a XML version and an empty
|
||||
* configuration.
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->_strategy = new Strategy();// Opus_Model_Xml_Version1;
|
||||
$this->_config = new Conf();
|
||||
$this->_strategy->setup($this->_config);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new XML version with current configuration up.
|
||||
*
|
||||
* @param Strategy $strategy Version of Xml to process
|
||||
*
|
||||
* @return XmlModel fluent interface.
|
||||
*/
|
||||
public function setStrategy(Strategy $strategy)
|
||||
{
|
||||
$this->_strategy = $strategy;
|
||||
$this->_strategy->setup($this->_config);
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a new XML version with current configuration up.
|
||||
*
|
||||
* @param XmlCache $cache cach table
|
||||
*
|
||||
* @return XmlModel fluent interface.
|
||||
*/
|
||||
public function setXmlCache(XmlCache $cache)
|
||||
{
|
||||
$this->_cache = $cache;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return cache table.
|
||||
*
|
||||
* @return XmlCache
|
||||
*/
|
||||
public function getXmlCache()
|
||||
{
|
||||
return $this->_cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Model for XML generation.
|
||||
*
|
||||
* @param \App\Dataset $model Model to serialize.
|
||||
*
|
||||
* @return XmlModel Fluent interface.
|
||||
*/
|
||||
public function setModel($model)
|
||||
{
|
||||
$this->_config->model = $model;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define that empty fields (value===null) shall be excluded.
|
||||
*
|
||||
* @return XmlModel Fluent interface
|
||||
*/
|
||||
public function excludeEmptyFields()
|
||||
{
|
||||
$this->_config->excludeEmpty = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* If a model has been set this method generates and returnes
|
||||
* DOM representation of it.
|
||||
*
|
||||
* @return \DOMDocument DOM representation of the current Model.
|
||||
*/
|
||||
public function getDomDocument()
|
||||
{
|
||||
$dataset = $this->_config->model;
|
||||
|
||||
$domDocument = $this->getDomDocumentFromXmlCache();
|
||||
if (!is_null($domDocument)) {
|
||||
return $domDocument;
|
||||
}
|
||||
|
||||
//create xml:
|
||||
$domDocument = $this->_strategy->getDomDocument();
|
||||
//if caching is not desired, return domDocument
|
||||
if (is_null($this->_cache)) {
|
||||
return $domDocument;
|
||||
} else {
|
||||
//create cache relation
|
||||
$this->_cache->fill(array(
|
||||
'document_id' => $dataset->id,
|
||||
'xml_version' => (int)$this->_strategy->getVersion(),
|
||||
'server_date_modified' => $dataset->server_date_modified,
|
||||
'xml_data' => $domDocument->saveXML()
|
||||
));
|
||||
$this->_cache->save();
|
||||
|
||||
Log::debug(__METHOD__ . ' cache refreshed for ' . get_class($dataset) . '#' . $dataset->id);
|
||||
return $domDocument;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This method tries to load the current model from the xml cache. Returns
|
||||
* null in case of an error/cache miss/cache disabled. Returns DOMDocument
|
||||
* otherwise.
|
||||
*
|
||||
* @return \DOMDocument DOM representation of the current Model.
|
||||
*/
|
||||
private function getDomDocumentFromXmlCache()
|
||||
{
|
||||
$dataset = $this->_config->model;
|
||||
if (null === $this->_cache) {
|
||||
//$logger->debug(__METHOD__ . ' skipping cache for ' . get_class($model));
|
||||
Log::debug(__METHOD__ . ' skipping cache for ' . get_class($dataset));
|
||||
return null;
|
||||
}
|
||||
//$cached = $this->_cache->hasValidEntry(
|
||||
// $dataset->id,
|
||||
// (int) $this->_strategy->getVersion(),
|
||||
// $dataset->server_date_modified
|
||||
//);
|
||||
|
||||
//$cached = false;
|
||||
$cache = XmlCache::where('document_id', $dataset->id)
|
||||
->first();// model or null
|
||||
if (!$cache) {
|
||||
Log::debug(__METHOD__ . ' cache miss for ' . get_class($dataset) . '#' . $dataset->id);
|
||||
return null;
|
||||
} else {
|
||||
return $cache->getDomDocument();
|
||||
}
|
||||
}
|
||||
}
|
29
app/License.php
Normal file
29
app/License.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class License extends Model
|
||||
{
|
||||
protected $table = 'document_licences';
|
||||
public $timestamps = false;
|
||||
|
||||
protected $fillable = [
|
||||
'active',
|
||||
'desc_text',
|
||||
'desc_text',
|
||||
'desc_text',
|
||||
'language',
|
||||
'link_licence',
|
||||
'link_logo',
|
||||
'mime_type',
|
||||
'name_long',
|
||||
'pod_allowed',
|
||||
'sort_order'
|
||||
];
|
||||
|
||||
public function datasets()
|
||||
{
|
||||
return $this->belongsToMany(\App\Dataset::class, 'link_documents_licences', 'licence_id', 'document_id');
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Periode extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'days'
|
||||
];
|
||||
|
||||
}
|
112
app/Permission.php
Normal file
112
app/Permission.php
Normal file
|
@ -0,0 +1,112 @@
|
|||
<?php
|
||||
namespace App;
|
||||
|
||||
use Spatie\Permission\Guard;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Spatie\Permission\Traits\RefreshesPermissionCache;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Spatie\Permission\PermissionRegistrar;
|
||||
use Spatie\Permission\Exceptions\PermissionAlreadyExists;
|
||||
use Spatie\Permission\Exceptions\PermissionDoesNotExist;
|
||||
use Spatie\Permission\Contracts\Permission as PermissionContract;
|
||||
|
||||
class Permission extends Model implements PermissionContract
|
||||
{
|
||||
use HasRoles;
|
||||
use RefreshesPermissionCache;
|
||||
|
||||
public $guarded = ['id'];
|
||||
|
||||
public function __construct(array $attributes = [])
|
||||
{
|
||||
$attributes['guard_name'] = $attributes['guard_name'] ?? config('auth.defaults.guard');
|
||||
|
||||
parent::__construct($attributes);
|
||||
|
||||
$this->setTable(config('permission.table_names.permissions'));
|
||||
}
|
||||
|
||||
public static function create(array $attributes = [])
|
||||
{
|
||||
$attributes['guard_name'] = $attributes['guard_name'] ?? Guard::getDefaultName(static::class);
|
||||
$permission = static::getPermissions()->filter(function ($permission) use ($attributes) {
|
||||
return $permission->name === $attributes['name'] && $permission->guard_name === $attributes['guard_name'];
|
||||
})->first();
|
||||
|
||||
if ($permission) {
|
||||
throw PermissionAlreadyExists::create($attributes['name'], $attributes['guard_name']);
|
||||
}
|
||||
if (isNotLumen() && app()::VERSION < '5.4') {
|
||||
return parent::create($attributes);
|
||||
}
|
||||
return static::query()->create($attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* A permission can be applied to roles.
|
||||
*/
|
||||
public function roles() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
\App\Role::class,
|
||||
config('permission.table_names.role_has_permissions'),
|
||||
'permission_id',
|
||||
'role_id'
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static function findByName(string $name, $guardName = null): PermissionContract
|
||||
{
|
||||
$guardName = $guardName ?? Guard::getDefaultName(static::class);
|
||||
|
||||
$permission = static::getPermissions()
|
||||
->filter(function ($permission) use ($name, $guardName) {
|
||||
return $permission->name === $name && $permission->guard_name === $guardName;
|
||||
})
|
||||
->first();
|
||||
|
||||
if (! $permission) {
|
||||
throw PermissionDoesNotExist::create($name, $guardName);
|
||||
}
|
||||
|
||||
return $permission;
|
||||
}
|
||||
|
||||
public static function findById(int $id, $guardName = null): PermissionContract
|
||||
{
|
||||
$guardName = $guardName ?? Guard::getDefaultName(static::class);
|
||||
$permission = static::getPermissions()
|
||||
->filter(function ($permission) use ($id, $guardName) {
|
||||
return $permission->id === $id && $permission->guard_name === $guardName;
|
||||
})
|
||||
->first();
|
||||
|
||||
if (! $permission) {
|
||||
throw PermissionDoesNotExist::withId($id, $guardName);
|
||||
}
|
||||
return $permission;
|
||||
}
|
||||
|
||||
public static function findOrCreate(string $name, $guardName = null): PermissionContract
|
||||
{
|
||||
$guardName = $guardName ?? Guard::getDefaultName(static::class);
|
||||
$permission = static::getPermissions()
|
||||
->filter(function ($permission) use ($name, $guardName) {
|
||||
return $permission->name === $name && $permission->guard_name === $guardName;
|
||||
})
|
||||
->first();
|
||||
|
||||
if (! $permission) {
|
||||
return static::create(['name' => $name, 'guard_name' => $guardName]);
|
||||
}
|
||||
return $permission;
|
||||
}
|
||||
|
||||
protected static function getPermissions(): Collection
|
||||
{
|
||||
return app(PermissionRegistrar::class)->getPermissions();
|
||||
}
|
||||
}
|
49
app/Person.php
Normal file
49
app/Person.php
Normal file
|
@ -0,0 +1,49 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Person extends Model
|
||||
{
|
||||
|
||||
protected $fillable = [
|
||||
'academic_title',
|
||||
'last_name',
|
||||
'first_name',
|
||||
'email',
|
||||
'identifier_orcid',
|
||||
'status'
|
||||
];
|
||||
protected $table = 'persons';
|
||||
public $timestamps = false;
|
||||
|
||||
public function documents()
|
||||
{
|
||||
return $this->belongsToMany(\App\Dataset::class, 'link_documents_persons', 'person_id', 'document_id')
|
||||
->withPivot('role');
|
||||
}
|
||||
|
||||
|
||||
// public function scopeNotLimit($query)
|
||||
// {
|
||||
// return $query->where('borrow', '<', 3);
|
||||
// }
|
||||
/**
|
||||
* Get the user's full name.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getFullName()
|
||||
{
|
||||
return $this->first_name . " " . $this->last_name;
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
return $query->where('status', 1);
|
||||
}
|
||||
|
||||
public function scopeOrderByName($query)
|
||||
{
|
||||
return $query->orderBy('last_name');
|
||||
}
|
||||
}
|
29
app/Project.php
Normal file
29
app/Project.php
Normal file
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Project extends Model
|
||||
{
|
||||
|
||||
//protected $table = 'projects';
|
||||
|
||||
// for using $input = $request->all();
|
||||
//$project = Project::create($input);
|
||||
protected $fillable = [
|
||||
'name', 'label'
|
||||
];
|
||||
|
||||
|
||||
public function documents()
|
||||
{
|
||||
//model, foreign key on the Document model is project_id, local id of category
|
||||
return $this->hasMany(\App\Dataset::class, 'project_id', 'id');
|
||||
}
|
||||
|
||||
// public function books()
|
||||
// {
|
||||
// //model, foreign key on the Book model is project_id, local id of category
|
||||
// return $this->hasMany('App\Book', 'project_id', 'id');
|
||||
// }
|
||||
}
|
|
@ -26,8 +26,8 @@ class AppServiceProvider extends ServiceProvider {
|
|||
public function register()
|
||||
{
|
||||
$this->app->bind(
|
||||
'Illuminate\Contracts\Auth\Registrar',
|
||||
'App\Services\Registrar'
|
||||
'Illuminate\Contracts\Auth\Registrar'
|
||||
// 'App\Services\Registrar'
|
||||
);
|
||||
}
|
||||
|
||||
|
|
24
app/Providers/BroadcastServiceProvider.php
Normal file
24
app/Providers/BroadcastServiceProvider.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Support\Facades\Broadcast;
|
||||
|
||||
class BroadcastServiceProvider extends ServiceProvider
|
||||
{
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @param \Illuminate\Bus\Dispatcher $dispatcher
|
||||
* @return void
|
||||
*/
|
||||
public function boot()
|
||||
{
|
||||
Broadcast::routes();
|
||||
|
||||
require base_path('routes/channels.php');
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
<?php namespace App\Providers;
|
||||
|
||||
use Illuminate\Bus\Dispatcher;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
|
||||
class BusServiceProvider extends ServiceProvider {
|
||||
|
||||
/**
|
||||
* Bootstrap any application services.
|
||||
*
|
||||
* @param \Illuminate\Bus\Dispatcher $dispatcher
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Dispatcher $dispatcher)
|
||||
{
|
||||
$dispatcher->mapUsing(function($command)
|
||||
{
|
||||
return Dispatcher::simpleMapping(
|
||||
$command, 'App\Commands', 'App\Handlers\Commands'
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Register any application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
}
|
|
@ -11,10 +11,10 @@ class EventServiceProvider extends ServiceProvider {
|
|||
* @var array
|
||||
*/
|
||||
protected $listen = [
|
||||
'event.name' => [
|
||||
'EventListener',
|
||||
],
|
||||
];
|
||||
'App\Events\Event' => [
|
||||
'App\Listeners\EventListener',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Register any other events for your application.
|
||||
|
@ -22,9 +22,9 @@ class EventServiceProvider extends ServiceProvider {
|
|||
* @param \Illuminate\Contracts\Events\Dispatcher $events
|
||||
* @return void
|
||||
*/
|
||||
public function boot(DispatcherContract $events)
|
||||
public function boot()
|
||||
{
|
||||
parent::boot($events);
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
<?php namespace App\Providers;
|
||||
<?php
|
||||
|
||||
use Illuminate\Routing\Router;
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\Facades\Route;
|
||||
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
|
||||
|
||||
class RouteServiceProvider extends ServiceProvider {
|
||||
class RouteServiceProvider extends ServiceProvider
|
||||
{
|
||||
|
||||
/**
|
||||
* This namespace is applied to the controller routes in your routes file.
|
||||
|
@ -20,9 +23,9 @@ class RouteServiceProvider extends ServiceProvider {
|
|||
* @param \Illuminate\Routing\Router $router
|
||||
* @return void
|
||||
*/
|
||||
public function boot(Router $router)
|
||||
public function boot()
|
||||
{
|
||||
parent::boot($router);
|
||||
parent::boot();
|
||||
|
||||
//
|
||||
}
|
||||
|
@ -33,12 +36,42 @@ class RouteServiceProvider extends ServiceProvider {
|
|||
* @param \Illuminate\Routing\Router $router
|
||||
* @return void
|
||||
*/
|
||||
public function map(Router $router)
|
||||
public function map()
|
||||
{
|
||||
$router->group(['namespace' => $this->namespace], function($router)
|
||||
{
|
||||
require app_path('Http/routes.php');
|
||||
});
|
||||
//Route::group(['namespace' => $this->namespace], function()
|
||||
//{
|
||||
// require app_path('Http/routes.php');
|
||||
//});
|
||||
$this->mapApiRoutes();
|
||||
$this->mapWebRoutes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "web" routes for the application.
|
||||
*
|
||||
* These routes all receive session state, CSRF protection, etc.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapWebRoutes()
|
||||
{
|
||||
Route::middleware('web')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/web.php'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the "api" routes for the application.
|
||||
*
|
||||
* These routes are typically stateless.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function mapApiRoutes()
|
||||
{
|
||||
Route::middleware('api')
|
||||
->namespace($this->namespace)
|
||||
->group(base_path('routes/api.php'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
43
app/Providers/SolariumServiceProvider.php
Normal file
43
app/Providers/SolariumServiceProvider.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace App\Providers;
|
||||
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Solarium\Client;
|
||||
|
||||
class SolariumServiceProvider extends ServiceProvider
|
||||
{
|
||||
protected $defer = true;
|
||||
|
||||
|
||||
/**
|
||||
* Register the application services.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$this->app->bind(Client::class, function ($app) {
|
||||
// $config = config('solarium');
|
||||
$config = array(
|
||||
'endpoint' => array(
|
||||
'localhost' => array(
|
||||
'host' => '127.0.0.1',
|
||||
'port' => '8983',
|
||||
'path' => '/solr/',
|
||||
'core' => 'opus4'
|
||||
)
|
||||
)
|
||||
);
|
||||
//return new Client($config);
|
||||
return new Client($config);
|
||||
//return new Client($app['config']['solarium']);
|
||||
});
|
||||
}
|
||||
|
||||
public function provides()
|
||||
{
|
||||
return [Client::class];
|
||||
}
|
||||
|
||||
}
|
122
app/Role.php
122
app/Role.php
|
@ -1,14 +1,122 @@
|
|||
<?php namespace App;
|
||||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Spatie\Permission\Contracts\Role as RoleContract;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
|
||||
use Spatie\Permission\Exceptions\RoleDoesNotExist;
|
||||
use Spatie\Permission\Exceptions\GuardDoesNotMatch;
|
||||
use Spatie\Permission\Exceptions\RoleAlreadyExists;
|
||||
use Spatie\Permission\Guard;
|
||||
|
||||
class Role extends Model {
|
||||
use Spatie\Permission\Traits\HasPermissions;
|
||||
use Spatie\Permission\Traits\RefreshesPermissionCache;
|
||||
|
||||
public function users()
|
||||
{
|
||||
|
||||
return $this->belongsToMany('App\User');
|
||||
class Role extends Model implements RoleContract
|
||||
{
|
||||
use HasPermissions;
|
||||
use RefreshesPermissionCache;
|
||||
|
||||
}
|
||||
//protected $table = 'user_roles';
|
||||
public $timestamps = false;
|
||||
|
||||
public $guarded = ['id'];
|
||||
|
||||
public function __construct(array $attributes = [])
|
||||
{
|
||||
$attributes['guard_name'] = $attributes['guard_name'] ?? config('auth.defaults.guard');
|
||||
parent::__construct($attributes);
|
||||
$this->setTable(config('permission.table_names.roles'));
|
||||
}
|
||||
|
||||
public static function create(array $attributes = [])
|
||||
{
|
||||
$attributes['guard_name'] = $attributes['guard_name'] ?? Guard::getDefaultName(static::class);
|
||||
|
||||
if (static::where('name', $attributes['name'])
|
||||
->where('guard_name', $attributes['guard_name'])->first()) {
|
||||
throw RoleAlreadyExists::create($attributes['name'], $attributes['guard_name']);
|
||||
}
|
||||
|
||||
if (isNotLumen() && app()::VERSION < '5.4') {
|
||||
return parent::create($attributes);
|
||||
}
|
||||
|
||||
return static::query()->create($attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* A role may be given various permissions.
|
||||
*/
|
||||
public function permissions() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
\App\Permission::class,
|
||||
config('permission.table_names.role_has_permissions'),
|
||||
'role_id',
|
||||
'permission_id'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* A role belongs to some users of the model associated with its guard.
|
||||
*/
|
||||
public function users() : BelongsToMany
|
||||
{
|
||||
return $this->belongsToMany(
|
||||
\App\User::class,
|
||||
config('permission.table_names.model_has_roles'),
|
||||
'role_id',
|
||||
'account_id'
|
||||
);
|
||||
}
|
||||
|
||||
public static function findByName(string $name, $guardName = null): RoleContract
|
||||
{
|
||||
$guardName = $guardName ?? Guard::getDefaultName(static::class);
|
||||
|
||||
$role = static::where('name', $name)->where('guard_name', $guardName)->first();
|
||||
if (! $role) {
|
||||
throw RoleDoesNotExist::named($name);
|
||||
}
|
||||
return $role;
|
||||
}
|
||||
|
||||
public static function findById(int $id, $guardName = null): RoleContract
|
||||
{
|
||||
$guardName = $guardName ?? Guard::getDefaultName(static::class);
|
||||
$role = static::where('id', $id)->where('guard_name', $guardName)->first();
|
||||
if (! $role) {
|
||||
throw RoleDoesNotExist::withId($id);
|
||||
}
|
||||
return $role;
|
||||
}
|
||||
|
||||
public static function findOrCreate(string $name, $guardName = null): RoleContract
|
||||
{
|
||||
$guardName = $guardName ?? Guard::getDefaultName(static::class);
|
||||
$role = static::where('name', $name)->where('guard_name', $guardName)->first();
|
||||
if (! $role) {
|
||||
return static::create(['name' => $name, 'guard_name' => $guardName]);
|
||||
}
|
||||
return $role;
|
||||
}
|
||||
|
||||
public function hasPermissionTo($permission): bool
|
||||
{
|
||||
if (is_string($permission)) {
|
||||
$permission = app(Permission::class)->findByName($permission, $this->getDefaultGuardName());
|
||||
}
|
||||
|
||||
if (is_int($permission)) {
|
||||
$permission = app(Permission::class)->findById($permission, $this->getDefaultGuardName());
|
||||
}
|
||||
|
||||
if (! $this->getGuardNames()->contains($permission->guard_name)) {
|
||||
throw GuardDoesNotMatch::create($permission->guard_name, $this->getGuardNames());
|
||||
}
|
||||
|
||||
return $this->permissions->contains('id', $permission->id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +1,40 @@
|
|||
<?php namespace App\Services;
|
||||
<?php
|
||||
namespace App\Services;
|
||||
|
||||
use App\User;
|
||||
use Validator;
|
||||
use Illuminate\Contracts\Auth\Registrar as RegistrarContract;
|
||||
|
||||
class Registrar implements RegistrarContract {
|
||||
class Registrar implements RegistrarContract
|
||||
{
|
||||
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
public function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|confirmed|min:6',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return User
|
||||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
}
|
||||
/**
|
||||
* Get a validator for an incoming registration request.
|
||||
*
|
||||
* @param array $data
|
||||
* @return \Illuminate\Contracts\Validation\Validator
|
||||
*/
|
||||
public function validator(array $data)
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|confirmed|min:6',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new user instance after a valid registration.
|
||||
*
|
||||
* @param array $data
|
||||
* @return User
|
||||
*/
|
||||
public function create(array $data)
|
||||
{
|
||||
return User::create([
|
||||
'name' => $data['name'],
|
||||
'email' => $data['email'],
|
||||
'password' => bcrypt($data['password']),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,16 +1,17 @@
|
|||
<?php namespace App;
|
||||
<?php
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Shelf extends Model {
|
||||
class Shelf extends Model
|
||||
{
|
||||
|
||||
protected $fillable = [
|
||||
'shelf'
|
||||
];
|
||||
|
||||
public function books()
|
||||
{
|
||||
return $this->hasMany('App\Book');
|
||||
}
|
||||
protected $fillable = [
|
||||
'shelf'
|
||||
];
|
||||
|
||||
// public function books()
|
||||
// {
|
||||
// return $this->hasMany('App\Book');
|
||||
// }
|
||||
}
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
<?php namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Student extends Model {
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'registered_at',
|
||||
'borrow',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function transactions()
|
||||
{
|
||||
|
||||
return $this->hasMany('App\Transaction');
|
||||
|
||||
}
|
||||
|
||||
public function scopeNotLimit($query)
|
||||
{
|
||||
|
||||
return $query->where('borrow', '<', 3);
|
||||
|
||||
}
|
||||
|
||||
public function scopeActive($query)
|
||||
{
|
||||
|
||||
return $query->where('status', 1);
|
||||
|
||||
}
|
||||
|
||||
public function scopeOrderByName($query)
|
||||
{
|
||||
|
||||
return $query->orderBy('name');
|
||||
|
||||
}
|
||||
|
||||
}
|
21
app/Title.php
Normal file
21
app/Title.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
namespace App;
|
||||
|
||||
//use App\Library\Xml\DatasetExtension;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Title extends Model
|
||||
{
|
||||
protected $table = 'document_title_abstracts';
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
protected $fillable = [
|
||||
];
|
||||
|
||||
public function dataset()
|
||||
{
|
||||
return $this->belongsTo(\App\Dataset::class, 'document_id', 'id');
|
||||
}
|
||||
}
|
|
@ -1,44 +1,38 @@
|
|||
<?php namespace App;
|
||||
<?php
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Transaction extends Model {
|
||||
class Transaction extends Model
|
||||
{
|
||||
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'book_id',
|
||||
'borrowed_at',
|
||||
'returned_at',
|
||||
'fines',
|
||||
'status'
|
||||
];
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'book_id',
|
||||
'borrowed_at',
|
||||
'returned_at',
|
||||
'fines',
|
||||
'status'
|
||||
];
|
||||
|
||||
public function student()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Student');
|
||||
|
||||
}
|
||||
public function student()
|
||||
{
|
||||
return $this->belongsTo('App\Person', 'student_id');
|
||||
}
|
||||
|
||||
public function book()
|
||||
{
|
||||
|
||||
return $this->belongsTo('App\Book');
|
||||
|
||||
}
|
||||
public function book()
|
||||
{
|
||||
//model, foreign key in tsis model, primary key of relation
|
||||
return $this->belongsTo('App\Book', 'book_id', 'id');
|
||||
}
|
||||
|
||||
public function scopeNotReturnedYet($query)
|
||||
{
|
||||
|
||||
return $query->where('status', 0);
|
||||
|
||||
}
|
||||
|
||||
public function scopeReturned($query)
|
||||
{
|
||||
|
||||
return $query->where('status', 1);
|
||||
|
||||
}
|
||||
public function scopeNotReturnedYet($query)
|
||||
{
|
||||
return $query->where('status', 0);
|
||||
}
|
||||
|
||||
public function scopeReturned($query)
|
||||
{
|
||||
return $query->where('status', 1);
|
||||
}
|
||||
}
|
||||
|
|
114
app/User.php
114
app/User.php
|
@ -1,70 +1,88 @@
|
|||
<?php namespace App;
|
||||
<?php
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Auth\Authenticatable;
|
||||
use Illuminate\Auth\Passwords\CanResetPassword;
|
||||
use Illuminate\Foundation\Auth\Access\Authorizable;
|
||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticatableContract;
|
||||
use Illuminate\Contracts\Auth\CanResetPassword as CanResetPasswordContract;
|
||||
use Illuminate\Contracts\Auth\Access\Authorizable as AuthorizableContract;
|
||||
#use Illuminate\Foundation\Auth\User as Authenticatable;
|
||||
use Spatie\Permission\Traits\HasRoles;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
|
||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract {
|
||||
class User extends Model implements AuthenticatableContract, CanResetPasswordContract, AuthorizableContract
|
||||
{
|
||||
|
||||
use Authenticatable, CanResetPassword;
|
||||
use Authenticatable, CanResetPassword, Authorizable;
|
||||
use HasRoles;
|
||||
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'users';
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'accounts';
|
||||
public $timestamps = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['name', 'email', 'password'];
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['login', 'email', 'password'];
|
||||
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
/**
|
||||
* The attributes excluded from the model's JSON form.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $hidden = ['password', 'remember_token'];
|
||||
|
||||
public function roles()
|
||||
public function setPasswordAttribute($password)
|
||||
{
|
||||
|
||||
return $this->belongsToMany('App\Role');
|
||||
|
||||
if ($password) {
|
||||
$this->attributes['password'] = app('hash')->needsRehash($password) ? Hash::make($password) : $password;
|
||||
}
|
||||
}
|
||||
|
||||
public function assignRole($role)
|
||||
//public function roles()
|
||||
//{
|
||||
// return $this->belongsToMany(\App\Role::class, 'link_accounts_roles', 'account_id', 'role_id');
|
||||
//}
|
||||
|
||||
public function is($roleName)
|
||||
{
|
||||
|
||||
return $this->roles()->attach($role);
|
||||
|
||||
}
|
||||
|
||||
public function revokeRole($role)
|
||||
{
|
||||
|
||||
return $this->roles()->detach($role);
|
||||
|
||||
}
|
||||
|
||||
public function hasRole($name)
|
||||
{
|
||||
|
||||
foreach ($this->roles as $role) {
|
||||
|
||||
if ($role->name === $name) {
|
||||
foreach ($this->roles()->get() as $role) {
|
||||
if ($role->name == $roleName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// public function assignRole($role)
|
||||
// {
|
||||
// return $this->roles()->attach($role);
|
||||
// }
|
||||
|
||||
// public function revokeRole($role)
|
||||
// {
|
||||
// return $this->roles()->detach($role);
|
||||
// }
|
||||
|
||||
// public function hasRole($name)
|
||||
// {
|
||||
// foreach ($this->roles as $role)
|
||||
// {
|
||||
// if ($role->name === $name)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
}
|
||||
|
|
81
app/XmlCache.php
Normal file
81
app/XmlCache.php
Normal file
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
|
||||
namespace App;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class XmlCache extends Model
|
||||
{
|
||||
/**
|
||||
* The database table used by the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'document_xml_cache';
|
||||
public $timestamps = false;
|
||||
|
||||
|
||||
/**
|
||||
* primaryKey
|
||||
*
|
||||
* @var integer
|
||||
* @access protected
|
||||
*/
|
||||
protected $primaryKey = null;
|
||||
public $incrementing = false;
|
||||
|
||||
/**
|
||||
* The attributes that are mass assignable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $fillable = ['document_id', 'xml_version', 'server_date_modified', 'xml_data'];
|
||||
|
||||
/**
|
||||
* Get the dataset that owns the xml cache.
|
||||
*/
|
||||
public function dataset()
|
||||
{
|
||||
return $this->belongsTo(\App\Dataset::class, 'document_id', 'id');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dom document of 'xml_data' string
|
||||
*
|
||||
* @return \DOMDocument
|
||||
*/
|
||||
public function getDomDocument()
|
||||
{
|
||||
$dom = new \DOMDocument('1.0', 'utf-8');
|
||||
$xmlData = $this->xml_data;
|
||||
$dom->loadXML($xmlData);
|
||||
return $dom;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a document in a specific xml version is already cached or not.
|
||||
*
|
||||
* @param mixed $datasetId
|
||||
* @param mixed $xmlVersion
|
||||
* @param mixed $serverDateModified
|
||||
* @return bool Returns true on cached hit else false.
|
||||
*/
|
||||
//public function scopeHasValidEntry($query, $datasetId, $xmlVersion, $serverDateModified)
|
||||
//{
|
||||
// //$select = $this->_table->select()->from($this->_table);
|
||||
// $query->where('document_id = ?', $datasetId)
|
||||
// ->where('xml_version = ?', $xmlVersion)
|
||||
// ->where('server_date_modified = ?', $serverDateModified);
|
||||
|
||||
// $row = $query->get();
|
||||
|
||||
// if (null === $row)
|
||||
// {
|
||||
// return false;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
//}
|
||||
}
|
1
artisan
1
artisan
|
@ -1,6 +1,7 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
//define('LARAVEL_START', microtime(true));
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Register The Auto Loader
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
*/
|
||||
|
||||
$app = new Illuminate\Foundation\Application(
|
||||
realpath(__DIR__.'/../')
|
||||
realpath(__DIR__.'/../')
|
||||
);
|
||||
|
||||
/*
|
||||
|
@ -27,18 +27,18 @@ $app = new Illuminate\Foundation\Application(
|
|||
*/
|
||||
|
||||
$app->singleton(
|
||||
'Illuminate\Contracts\Http\Kernel',
|
||||
'App\Http\Kernel'
|
||||
'Illuminate\Contracts\Http\Kernel',
|
||||
'App\Http\Kernel'
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
'Illuminate\Contracts\Console\Kernel',
|
||||
'App\Console\Kernel'
|
||||
'Illuminate\Contracts\Console\Kernel',
|
||||
'App\Console\Kernel'
|
||||
);
|
||||
|
||||
$app->singleton(
|
||||
'Illuminate\Contracts\Debug\ExceptionHandler',
|
||||
'App\Exceptions\Handler'
|
||||
'Illuminate\Contracts\Debug\ExceptionHandler',
|
||||
'App\Exceptions\Handler'
|
||||
);
|
||||
|
||||
/*
|
||||
|
@ -51,5 +51,4 @@ $app->singleton(
|
|||
| from the actual running of the application and sending responses.
|
||||
|
|
||||
*/
|
||||
|
||||
return $app;
|
||||
|
|
|
@ -29,7 +29,6 @@ require __DIR__.'/../vendor/autoload.php';
|
|||
|
||||
$compiledPath = __DIR__.'/../vendor/compiled.php';
|
||||
|
||||
if (file_exists($compiledPath))
|
||||
{
|
||||
require $compiledPath;
|
||||
if (file_exists($compiledPath)) {
|
||||
require $compiledPath;
|
||||
}
|
||||
|
|
2
bootstrap/cache/.gitignore
vendored
Normal file
2
bootstrap/cache/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
*
|
||||
!.gitignore
|
|
@ -1,20 +1,29 @@
|
|||
{
|
||||
"name": "laravel/laravel",
|
||||
"description": "The Laravel Framework.",
|
||||
"keywords": ["framework", "laravel"],
|
||||
"keywords": [
|
||||
"framework",
|
||||
"laravel"
|
||||
],
|
||||
"license": "MIT",
|
||||
"type": "project",
|
||||
"require": {
|
||||
"laravel/framework": "5.0.*",
|
||||
"illuminate/html": "5.0.0"
|
||||
"php": ">=7.0.0",
|
||||
"fideloper/proxy": "~3.3",
|
||||
"laravel/framework": "5.5.*",
|
||||
"laravel/tinker": "~1.0",
|
||||
"laravelcollective/html": "^5.5.0",
|
||||
"solarium/solarium": "^3.8",
|
||||
"spatie/laravel-permission": "^2.12"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0",
|
||||
"phpspec/phpspec": "~2.1"
|
||||
"phpunit/phpunit": "~6.0",
|
||||
"squizlabs/php_codesniffer": "^3.3"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"database"
|
||||
"database/seeds",
|
||||
"database/factories"
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\": "app/"
|
||||
|
@ -40,6 +49,17 @@
|
|||
]
|
||||
},
|
||||
"config": {
|
||||
"preferred-install": "dist"
|
||||
}
|
||||
"preferred-install": "dist",
|
||||
"sort-packages": true,
|
||||
"optimize-autoloader": true
|
||||
},
|
||||
"authors": [
|
||||
{
|
||||
"name": "Arno Kaimbacher",
|
||||
"email": "arno.kaimbacher@geologie.ac.at",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"prefer-stable": true,
|
||||
"homepage": "https://www.geologie.ac.at/"
|
||||
}
|
||||
|
|
3496
composer.lock
generated
3496
composer.lock
generated
File diff suppressed because it is too large
Load Diff
379
config/app.php
379
config/app.php
|
@ -2,202 +2,237 @@
|
|||
|
||||
return [
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Name
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value is the name of your application. This value is used when the
|
||||
| framework needs to place the application's name in a notification or
|
||||
| any other location as required by the application or its packages.
|
||||
|
|
||||
*/
|
||||
|
||||
'debug' => env('APP_DEBUG'),
|
||||
'name' => env('APP_NAME', 'App'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Environment
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This value determines the "environment" your application is currently
|
||||
| running in. This may determine how you prefer to configure various
|
||||
| services your application utilizes. Set this in your ".env" file.
|
||||
|
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| your application so that it is used when running Artisan tasks.
|
||||
|
|
||||
*/
|
||||
'env' => env('APP_ENV', 'debug'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Debug Mode
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When your application is in debug mode, detailed error messages with
|
||||
| stack traces will be shown on every error that occurs within your
|
||||
| application. If disabled, a simple generic error page is shown.
|
||||
|
|
||||
*/
|
||||
|
||||
'url' => 'http://localhost',
|
||||
'debug' => env('APP_DEBUG', false),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. We have gone
|
||||
| ahead and set this to a sensible default for you out of the box.
|
||||
|
|
||||
*/
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application URL
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This URL is used by the console to properly generate URLs when using
|
||||
| the Artisan command line tool. You should set this to the root of
|
||||
| your application so that it is used when running Artisan tasks.
|
||||
|
|
||||
*/
|
||||
|
||||
'timezone' => 'UTC',
|
||||
'url' => env('APP_URL', 'http://localhost'),
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by the translation service provider. You are free to set this value
|
||||
| to any of the locales which will be supported by the application.
|
||||
|
|
||||
*/
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Timezone
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may specify the default timezone for your application, which
|
||||
| will be used by the PHP date and date-time functions. We have gone
|
||||
| ahead and set this to a sensible default for you out of the box.
|
||||
|
|
||||
*/
|
||||
|
||||
'locale' => 'en',
|
||||
'timezone' => 'UTC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Fallback Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The fallback locale determines the locale to use when the current one
|
||||
| is not available. You may change the value to correspond to any of
|
||||
| the language folders that are provided through your application.
|
||||
|
|
||||
*/
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Locale Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The application locale determines the default locale that will be used
|
||||
| by the translation service provider. You are free to set this value
|
||||
| to any of the locales which will be supported by the application.
|
||||
|
|
||||
*/
|
||||
|
||||
'fallback_locale' => 'en',
|
||||
'locale' => 'en',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is used by the Illuminate encrypter service and should be set
|
||||
| to a random, 32 character string, otherwise these encrypted strings
|
||||
| will not be safe. Please do this before deploying an application!
|
||||
|
|
||||
*/
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Application Fallback Locale
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The fallback locale determines the locale to use when the current one
|
||||
| is not available. You may change the value to correspond to any of
|
||||
| the language folders that are provided through your application.
|
||||
|
|
||||
*/
|
||||
|
||||
'key' => env('APP_KEY', 'SomeRandomString'),
|
||||
'fallback_locale' => 'en',
|
||||
|
||||
'cipher' => MCRYPT_RIJNDAEL_128,
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Encryption Key
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This key is used by the Illuminate encrypter service and should be set
|
||||
| to a random, 32 character string, otherwise these encrypted strings
|
||||
| will not be safe. Please do this before deploying an application!
|
||||
|
|
||||
*/
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Logging Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log settings for your application. Out of
|
||||
| the box, Laravel uses the Monolog PHP logging library. This gives
|
||||
| you a variety of powerful log handlers / formatters to utilize.
|
||||
|
|
||||
| Available Settings: "single", "daily", "syslog", "errorlog"
|
||||
|
|
||||
*/
|
||||
'key' => env('APP_KEY', 'SomeRandomString'),
|
||||
|
||||
'log' => 'daily',
|
||||
'cipher' => 'AES-256-CBC',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autoloaded Service Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The service providers listed here will be automatically loaded on the
|
||||
| request to your application. Feel free to add your own services to
|
||||
| this array to grant expanded functionality to your applications.
|
||||
|
|
||||
*/
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Logging Configuration
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Here you may configure the log settings for your application. Out of
|
||||
| the box, Laravel uses the Monolog PHP logging library. This gives
|
||||
| you a variety of powerful log handlers / formatters to utilize.
|
||||
|
|
||||
| Available Settings: "single", "daily", "syslog", "errorlog"
|
||||
|
|
||||
*/
|
||||
|
||||
'providers' => [
|
||||
'log' => 'single',
|
||||
'log_level' => env('APP_LOG_LEVEL', 'debug'),
|
||||
|
||||
/*
|
||||
* Laravel Framework Service Providers...
|
||||
*/
|
||||
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
|
||||
'Illuminate\Auth\AuthServiceProvider',
|
||||
'Illuminate\Bus\BusServiceProvider',
|
||||
'Illuminate\Cache\CacheServiceProvider',
|
||||
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
|
||||
'Illuminate\Routing\ControllerServiceProvider',
|
||||
'Illuminate\Cookie\CookieServiceProvider',
|
||||
'Illuminate\Database\DatabaseServiceProvider',
|
||||
'Illuminate\Encryption\EncryptionServiceProvider',
|
||||
'Illuminate\Filesystem\FilesystemServiceProvider',
|
||||
'Illuminate\Foundation\Providers\FoundationServiceProvider',
|
||||
'Illuminate\Hashing\HashServiceProvider',
|
||||
'Illuminate\Mail\MailServiceProvider',
|
||||
'Illuminate\Pagination\PaginationServiceProvider',
|
||||
'Illuminate\Pipeline\PipelineServiceProvider',
|
||||
'Illuminate\Queue\QueueServiceProvider',
|
||||
'Illuminate\Redis\RedisServiceProvider',
|
||||
'Illuminate\Auth\Passwords\PasswordResetServiceProvider',
|
||||
'Illuminate\Session\SessionServiceProvider',
|
||||
'Illuminate\Translation\TranslationServiceProvider',
|
||||
'Illuminate\Validation\ValidationServiceProvider',
|
||||
'Illuminate\View\ViewServiceProvider',
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Autoloaded Service Providers
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The service providers listed here will be automatically loaded on the
|
||||
| request to your application. Feel free to add your own services to
|
||||
| this array to grant expanded functionality to your applications.
|
||||
|
|
||||
*/
|
||||
|
||||
'Illuminate\Html\HtmlServiceProvider',
|
||||
'providers' => [
|
||||
|
||||
/*
|
||||
* Application Service Providers...
|
||||
*/
|
||||
'App\Providers\AppServiceProvider',
|
||||
'App\Providers\BusServiceProvider',
|
||||
'App\Providers\ConfigServiceProvider',
|
||||
'App\Providers\EventServiceProvider',
|
||||
'App\Providers\RouteServiceProvider',
|
||||
/*
|
||||
* Laravel Framework Service Providers...
|
||||
*/
|
||||
'Illuminate\Auth\AuthServiceProvider',
|
||||
Illuminate\Broadcasting\BroadcastServiceProvider::class,
|
||||
'Illuminate\Bus\BusServiceProvider',
|
||||
'Illuminate\Cache\CacheServiceProvider',
|
||||
'Illuminate\Foundation\Providers\ConsoleSupportServiceProvider',
|
||||
//'Illuminate\Routing\ControllerServiceProvider',
|
||||
'Illuminate\Cookie\CookieServiceProvider',
|
||||
'Illuminate\Database\DatabaseServiceProvider',
|
||||
'Illuminate\Encryption\EncryptionServiceProvider',
|
||||
'Illuminate\Filesystem\FilesystemServiceProvider',
|
||||
'Illuminate\Foundation\Providers\FoundationServiceProvider',
|
||||
'Illuminate\Hashing\HashServiceProvider',
|
||||
'Illuminate\Mail\MailServiceProvider',
|
||||
Illuminate\Notifications\NotificationServiceProvider::class,
|
||||
'Illuminate\Pagination\PaginationServiceProvider',
|
||||
'Illuminate\Pipeline\PipelineServiceProvider',
|
||||
'Illuminate\Queue\QueueServiceProvider',
|
||||
'Illuminate\Redis\RedisServiceProvider',
|
||||
'Illuminate\Auth\Passwords\PasswordResetServiceProvider',
|
||||
'Illuminate\Session\SessionServiceProvider',
|
||||
'Illuminate\Translation\TranslationServiceProvider',
|
||||
'Illuminate\Validation\ValidationServiceProvider',
|
||||
'Illuminate\View\ViewServiceProvider',
|
||||
|
||||
],
|
||||
// 'Illuminate\Html\HtmlServiceProvider',
|
||||
// 'Collective\Html\HtmlServiceProvider',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Class Aliases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array of class aliases will be registered when this application
|
||||
| is started. However, feel free to register as many as you wish as
|
||||
| the aliases are "lazy" loaded so they don't hinder performance.
|
||||
|
|
||||
*/
|
||||
/*
|
||||
* Application Service Providers...
|
||||
*/
|
||||
'App\Providers\AppServiceProvider',
|
||||
// App\Providers\BroadcastServiceProvider::class,
|
||||
'App\Providers\ConfigServiceProvider',
|
||||
'App\Providers\EventServiceProvider',
|
||||
'App\Providers\RouteServiceProvider',
|
||||
|
||||
'aliases' => [
|
||||
// List off others providers...
|
||||
App\Providers\SolariumServiceProvider::class,
|
||||
Spatie\Permission\PermissionServiceProvider::class,
|
||||
|
||||
'App' => 'Illuminate\Support\Facades\App',
|
||||
'Artisan' => 'Illuminate\Support\Facades\Artisan',
|
||||
'Auth' => 'Illuminate\Support\Facades\Auth',
|
||||
'Blade' => 'Illuminate\Support\Facades\Blade',
|
||||
'Bus' => 'Illuminate\Support\Facades\Bus',
|
||||
'Cache' => 'Illuminate\Support\Facades\Cache',
|
||||
'Config' => 'Illuminate\Support\Facades\Config',
|
||||
'Cookie' => 'Illuminate\Support\Facades\Cookie',
|
||||
'Crypt' => 'Illuminate\Support\Facades\Crypt',
|
||||
'DB' => 'Illuminate\Support\Facades\DB',
|
||||
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
|
||||
'Event' => 'Illuminate\Support\Facades\Event',
|
||||
'File' => 'Illuminate\Support\Facades\File',
|
||||
'Hash' => 'Illuminate\Support\Facades\Hash',
|
||||
'Input' => 'Illuminate\Support\Facades\Input',
|
||||
'Inspiring' => 'Illuminate\Foundation\Inspiring',
|
||||
'Lang' => 'Illuminate\Support\Facades\Lang',
|
||||
'Log' => 'Illuminate\Support\Facades\Log',
|
||||
'Mail' => 'Illuminate\Support\Facades\Mail',
|
||||
'Password' => 'Illuminate\Support\Facades\Password',
|
||||
'Queue' => 'Illuminate\Support\Facades\Queue',
|
||||
'Redirect' => 'Illuminate\Support\Facades\Redirect',
|
||||
'Redis' => 'Illuminate\Support\Facades\Redis',
|
||||
'Request' => 'Illuminate\Support\Facades\Request',
|
||||
'Response' => 'Illuminate\Support\Facades\Response',
|
||||
'Route' => 'Illuminate\Support\Facades\Route',
|
||||
'Schema' => 'Illuminate\Support\Facades\Schema',
|
||||
'Session' => 'Illuminate\Support\Facades\Session',
|
||||
'Storage' => 'Illuminate\Support\Facades\Storage',
|
||||
'URL' => 'Illuminate\Support\Facades\URL',
|
||||
'Validator' => 'Illuminate\Support\Facades\Validator',
|
||||
'View' => 'Illuminate\Support\Facades\View',
|
||||
],
|
||||
|
||||
'Form' => 'Illuminate\Html\FormFacade',
|
||||
'HTML' => 'Illuminate\Html\HtmlFacade',
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Class Aliases
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| This array of class aliases will be registered when this application
|
||||
| is started. However, feel free to register as many as you wish as
|
||||
| the aliases are "lazy" loaded so they don't hinder performance.
|
||||
|
|
||||
*/
|
||||
|
||||
],
|
||||
'aliases' => [
|
||||
|
||||
'App' => 'Illuminate\Support\Facades\App',
|
||||
'Artisan' => 'Illuminate\Support\Facades\Artisan',
|
||||
'Auth' => 'Illuminate\Support\Facades\Auth',
|
||||
'Blade' => 'Illuminate\Support\Facades\Blade',
|
||||
'Bus' => 'Illuminate\Support\Facades\Bus',
|
||||
'Cache' => 'Illuminate\Support\Facades\Cache',
|
||||
'Config' => 'Illuminate\Support\Facades\Config',
|
||||
'Cookie' => 'Illuminate\Support\Facades\Cookie',
|
||||
'Crypt' => 'Illuminate\Support\Facades\Crypt',
|
||||
'DB' => 'Illuminate\Support\Facades\DB',
|
||||
'Eloquent' => 'Illuminate\Database\Eloquent\Model',
|
||||
'Event' => 'Illuminate\Support\Facades\Event',
|
||||
'File' => 'Illuminate\Support\Facades\File',
|
||||
'Hash' => 'Illuminate\Support\Facades\Hash',
|
||||
'Input' => 'Illuminate\Support\Facades\Input',
|
||||
'Inspiring' => 'Illuminate\Foundation\Inspiring',
|
||||
'Lang' => 'Illuminate\Support\Facades\Lang',
|
||||
'Log' => 'Illuminate\Support\Facades\Log',
|
||||
'Mail' => 'Illuminate\Support\Facades\Mail',
|
||||
'Password' => 'Illuminate\Support\Facades\Password',
|
||||
'Queue' => 'Illuminate\Support\Facades\Queue',
|
||||
'Redirect' => 'Illuminate\Support\Facades\Redirect',
|
||||
'Redis' => 'Illuminate\Support\Facades\Redis',
|
||||
'Request' => 'Illuminate\Support\Facades\Request',
|
||||
'Response' => 'Illuminate\Support\Facades\Response',
|
||||
'Route' => 'Illuminate\Support\Facades\Route',
|
||||
'Schema' => 'Illuminate\Support\Facades\Schema',
|
||||
'Session' => 'Illuminate\Support\Facades\Session',
|
||||
'Storage' => 'Illuminate\Support\Facades\Storage',
|
||||
'URL' => 'Illuminate\Support\Facades\URL',
|
||||
'Validator' => 'Illuminate\Support\Facades\Validator',
|
||||
'View' => 'Illuminate\Support\Facades\View',
|
||||
|
||||
// 'Form' => 'Illuminate\Html\FormFacade',
|
||||
// 'HTML' => 'Illuminate\Html\HtmlFacade',
|
||||
// 'Form' => 'Collective\Html\FormFacade',
|
||||
// 'Html' => 'Collective\Html\HtmlFacade',
|
||||
|
||||
],
|
||||
|
||||
];
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user