-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to assign URIs to Publishers. (#77)
- Loading branch information
1 parent
4e2e5c2
commit 1440a65
Showing
9 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
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,9 @@ | ||
CREATE TABLE `Publishers_URIs` ( | ||
`Sequence_ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT, | ||
`Publisher_ID` int(11) NOT NULL, | ||
`Predicate_ID` int(11) NOT NULL, | ||
`URI` varchar(2048) NOT NULL, | ||
PRIMARY KEY (`Sequence_ID`), | ||
FOREIGN KEY (`Publisher_ID`) REFERENCES `Publishers` (`Publisher_ID`), | ||
FOREIGN KEY (`Predicate_ID`) REFERENCES `Predicates` (`Predicate_ID`) | ||
) ENGINE=INNODB DEFAULT CHARSET=utf8; |
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
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
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
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
99 changes: 99 additions & 0 deletions
99
module/GeebyDeeby/src/GeebyDeeby/Db/Table/PublishersURIs.php
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,99 @@ | ||
<?php | ||
/** | ||
* Table Definition for Publishers_URIs | ||
* | ||
* PHP version 5 | ||
* | ||
* Copyright (C) Demian Katz 2020. | ||
* | ||
* This program is free software; you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License version 2, | ||
* as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
* | ||
* @category GeebyDeeby | ||
* @package Db_Table | ||
* @author Demian Katz <demian.katz@villanova.edu> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://github.com/demiankatz/Geeby-Deeby Main Site | ||
*/ | ||
namespace GeebyDeeby\Db\Table; | ||
|
||
use Zend\Db\Adapter\Adapter; | ||
use Zend\Db\RowGateway\RowGateway; | ||
|
||
/** | ||
* Table Definition for Publishers_URIs | ||
* | ||
* @category GeebyDeeby | ||
* @package Db_Table | ||
* @author Demian Katz <demian.katz@villanova.edu> | ||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License | ||
* @link https://github.com/demiankatz/Geeby-Deeby Main Site | ||
*/ | ||
class PublishersURIs extends Gateway | ||
{ | ||
/** | ||
* Constructor | ||
* | ||
* @param Adapter $adapter Database adapter | ||
* @param PluginManager $tm Table manager | ||
* @param RowGateway $rowObj Row prototype object (null for default) | ||
*/ | ||
public function __construct(Adapter $adapter, PluginManager $tm, | ||
RowGateway $rowObj = null | ||
) { | ||
parent::__construct($adapter, $tm, $rowObj, 'Publishers_URIs'); | ||
} | ||
|
||
/** | ||
* Get a list of URIs for the specified publisher. | ||
* | ||
* @param int $publisherID Publisher ID | ||
* | ||
* @return mixed | ||
*/ | ||
public function getURIsForPublisher($publisherID) | ||
{ | ||
$callback = function ($select) use ($publisherID) { | ||
$select->join( | ||
['pr' => 'Predicates'], | ||
'Publishers_URIs.Predicate_ID = pr.Predicate_ID' | ||
); | ||
$select->where->equalTo('Publisher_ID', $publisherID); | ||
}; | ||
return $this->select($callback); | ||
} | ||
|
||
/** | ||
* Get a list of publishers for the specified URI. | ||
* | ||
* @param string $uri URI | ||
* | ||
* @return mixed | ||
*/ | ||
public function getPublishersForURI($uri) | ||
{ | ||
$callback = function ($select) use ($uri) { | ||
$select->join( | ||
['p' => 'Publishers'], | ||
'Publishers_URIs.Publisher_ID = p.Publisher_ID' | ||
); | ||
$select->join( | ||
['pr' => 'Predicates'], | ||
'Publishers_URIs.Predicate_ID = pr.Predicate_ID' | ||
); | ||
$select->order(['Publisher_Name']); | ||
$select->where->equalTo('URI', $uri); | ||
}; | ||
return $this->select($callback); | ||
} | ||
} |
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
18 changes: 18 additions & 0 deletions
18
module/GeebyDeeby/view/geeby-deeby/edit-publisher/uri-list.phtml
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,18 @@ | ||
<?php if (isset($uris) && count($uris) > 0): ?> | ||
<?php foreach ($uris as $current): ?> | ||
<table class="list_item"> | ||
<tr> | ||
<td><a href="<?=$this->escapeHtmlAttr($current['URI'])?>"><?=$this->escapeHtml($current['URI'])?></a> (<?=$this->escapeHtml($current['Predicate_Abbrev'])?>)</td> | ||
<td> | ||
<?=$this->iconButton( | ||
'trash', | ||
"Publisher.unlink('URI', '" . addslashes($current['URI']) . "')", | ||
'Unlink ' . $current['URI'] | ||
)?> | ||
</td> | ||
</tr> | ||
</table> | ||
<?php endforeach; ?> | ||
<?php else: ?> | ||
No URIs defined. | ||
<?php endif; ?> |
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