forked from aces/Loris
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[document_repository] Data framework (aces#8906)
Fixes aces#8894
- Loading branch information
1 parent
43108f9
commit b08cb72
Showing
3 changed files
with
200 additions
and
44 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
modules/document_repository/php/docrepoprovisioner.class.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* This file implements a data provisioner to get all modules | ||
* for the Module Manager menu page. | ||
* | ||
* PHP Version 7 | ||
* | ||
* @category Core | ||
* @package Main | ||
* @subpackage Core | ||
* @author Shen Wang <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
|
||
namespace LORIS\document_repository; | ||
|
||
/** | ||
* This class implements a data provisioner to get all modules | ||
* for the module manager menu page. | ||
* | ||
* PHP Version 7 | ||
* | ||
* @category Core | ||
* @package Main | ||
* @subpackage Core | ||
* @author Shen Wang <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
class DocRepoProvisioner extends \LORIS\Data\Provisioners\DBRowProvisioner | ||
{ | ||
/** | ||
* Create a ModuleManagerProvisioner, which gets modules for the | ||
* module manager menu table. | ||
*/ | ||
function __construct() | ||
{ | ||
parent::__construct( | ||
" | ||
SELECT | ||
v.File_name, | ||
v.version, | ||
v.File_type, | ||
v.Instrument, | ||
v.uploaded_by, | ||
(SELECT name FROM psc WHERE CenterID = v.For_site) as site, | ||
v.comments, | ||
v.Date_uploaded, | ||
v.record_id as Edit, | ||
v.record_id as Delete_File, | ||
v.File_category as category, | ||
v.Data_dir, | ||
v.For_site | ||
FROM | ||
document_repository v | ||
WHERE | ||
COALESCE(v.hide_video, false) = false | ||
ORDER BY | ||
v.File_name; | ||
", | ||
[], | ||
); | ||
} | ||
|
||
/** | ||
* Returns an instance of a HelpRow object for a given | ||
* table row. | ||
* | ||
* @param array $row The database row from the LORIS Database class. | ||
* | ||
* @return \LORIS\Data\DataInstance An instance representing this row. | ||
*/ | ||
public function getInstance($row) : \LORIS\Data\DataInstance | ||
{ | ||
$cid = \CenterID::singleton(intval($row['For_site'])); | ||
return new DocRepoRow($row, $cid); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* This class implements a data Instance which represents a single | ||
* module in the acknowledgements menu table. | ||
* | ||
* PHP Version 7 | ||
* | ||
* @category Core | ||
* @package Main | ||
* @subpackage Core | ||
* @author Dave MacFarlane <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
|
||
namespace LORIS\document_repository; | ||
|
||
/** | ||
* A ModuleRow represents a row in the acknowledgements menu table. | ||
* | ||
* The acknowledgements requires a specific "row" concept because | ||
* the \Module class does not have any concept of the Active flag | ||
* for the module in order to serialize it as JSON for the data | ||
* table. | ||
* | ||
* @category Core | ||
* @package Main | ||
* @subpackage Core | ||
* @author Dave MacFarlane <[email protected]> | ||
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3 | ||
* @link https://www.github.com/aces/Loris/ | ||
*/ | ||
class DocRepoRow implements | ||
\LORIS\Data\DataInstance, | ||
\LORIS\StudyEntities\SiteHaver | ||
{ | ||
protected $DBRow; | ||
|
||
private \CenterID $CenterID; | ||
/** | ||
* Create a new HelpRow | ||
* | ||
* @param array $row The row | ||
* @param \CenterID $cid The CenterID | ||
*/ | ||
public function __construct(array $row, \CenterID $cid) | ||
{ | ||
$this->DBRow = $row; | ||
$this->CenterID = $cid; | ||
} | ||
/** | ||
* Returns the CenterID for this row | ||
* | ||
* @return \CenterID | ||
*/ | ||
public function getCenterID(): \CenterID | ||
{ | ||
return $this->CenterID; | ||
} | ||
/** | ||
* Implements \LORIS\Data\DataInstance interface for this row. | ||
* | ||
* @return array which can be serialized by json_encode() | ||
*/ | ||
public function jsonSerialize() : array | ||
{ | ||
return $this->DBRow; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters