Skip to content

Commit ede04bd

Browse files
authored
Add web-based "convert to issue" functionality to dimenovels.org. (#121)
1 parent f2d21f1 commit ede04bd

File tree

8 files changed

+176
-6
lines changed

8 files changed

+176
-6
lines changed

module/GeebyDeeby/view/geeby-deeby/edit-edition/edit-full.phtml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
?>
66
<div class="edit_container" style="width: 800px;">
77
<?=$this->render('geeby-deeby/edit-edition/index.phtml')?>
8+
<?php if ($item['Material_Type_ID'] === 1 /* Work */): ?>
9+
<a href="<?=$this->url('edit/edition', ['id' => $edition['Edition_ID'], 'action' => 'converttoissue'])?>">Convert to Issue</a>
10+
<?php endif; ?>
811
</div>
912
<hr />
1013
<ul class="nav nav-tabs">

module/GeebyDeebyLocal/config/module.config.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
'controllers' => [
4545
'aliases' => [
4646
'GeebyDeeby\Controller\About' => 'GeebyDeebyLocal\Controller\AboutController',
47+
'GeebyDeeby\Controller\EditEdition' => 'GeebyDeebyLocal\Controller\EditEditionController',
4748
'GeebyDeeby\Controller\Edition' => 'GeebyDeebyLocal\Controller\EditionController',
4849
'GeebyDeeby\Controller\Ingest' => 'GeebyDeebyLocal\Controller\IngestController',
4950
'GeebyDeeby\Controller\Item' => 'GeebyDeebyLocal\Controller\ItemController',
@@ -185,6 +186,7 @@
185186
],
186187
'service_manager' => [
187188
'factories' => [
189+
'GeebyDeebyLocal\Ingest\ConsoleIssueMaker' => 'GeebyDeebyLocal\Ingest\IssueMakerFactory',
188190
'GeebyDeebyLocal\Ingest\DatabaseIngester' => 'GeebyDeebyLocal\Ingest\DatabaseIngesterFactory',
189191
'GeebyDeebyLocal\Ingest\FedoraHarvester' => 'GeebyDeebyLocal\Ingest\FedoraHarvesterFactory',
190192
'GeebyDeebyLocal\Ingest\IssueMaker' => 'GeebyDeebyLocal\Ingest\IssueMakerFactory',

module/GeebyDeebyLocal/src/GeebyDeebyLocal/Command/Make/IssueCommandFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
namespace GeebyDeebyLocal\Command\Make;
3131

32-
use GeebyDeebyLocal\Ingest\IssueMaker;
32+
use GeebyDeebyLocal\Ingest\ConsoleIssueMaker;
3333
use Interop\Container\ContainerInterface;
3434
use Laminas\ServiceManager\Factory\FactoryInterface;
3535

@@ -68,7 +68,7 @@ public function __invoke(
6868
}
6969
$dbManager = $container->get(\GeebyDeeby\Db\Table\PluginManager::class);
7070
return new $requestedName(
71-
$container->get(IssueMaker::class),
71+
$container->get(ConsoleIssueMaker::class),
7272
$dbManager->get('edition'),
7373
$dbManager->get('series')
7474
);

module/GeebyDeebyLocal/src/GeebyDeebyLocal/Command/Make/IssuesCommandFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
namespace GeebyDeebyLocal\Command\Make;
3131

32-
use GeebyDeebyLocal\Ingest\IssueMaker;
32+
use GeebyDeebyLocal\Ingest\ConsoleIssueMaker;
3333
use Interop\Container\ContainerInterface;
3434
use Laminas\ServiceManager\Factory\FactoryInterface;
3535

@@ -68,7 +68,7 @@ public function __invoke(
6868
}
6969
$dbManager = $container->get(\GeebyDeeby\Db\Table\PluginManager::class);
7070
return new $requestedName(
71-
$container->get(IssueMaker::class),
71+
$container->get(ConsoleIssueMaker::class),
7272
$dbManager->get('series')
7373
);
7474
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
<?php
2+
3+
/**
4+
* Edit Edition controller
5+
*
6+
* PHP version 5
7+
*
8+
* Copyright (C) Demian Katz 2025.
9+
*
10+
* This program is free software; you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License version 2,
12+
* as published by the Free Software Foundation.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22+
*
23+
* @category GeebyDeeby
24+
* @package Controller
25+
* @author Demian Katz <demian.katz@villanova.edu>
26+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
27+
* @link https://github.com/demiankatz/Geeby-Deeby Main Site
28+
*/
29+
30+
namespace GeebyDeebyLocal\Controller;
31+
32+
/**
33+
* Edit Edition controller
34+
*
35+
* @category GeebyDeeby
36+
* @package Controller
37+
* @author Demian Katz <demian.katz@villanova.edu>
38+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
39+
* @link https://github.com/demiankatz/Geeby-Deeby Main Site
40+
*/
41+
class EditEditionController extends \GeebyDeeby\Controller\EditEditionController
42+
{
43+
/**
44+
* Convert to an issue
45+
*
46+
* @return mixed
47+
*/
48+
public function convertToIssueAction()
49+
{
50+
$ok = $this->checkPermission('Data_Manager');
51+
if ($ok !== true) {
52+
return $ok;
53+
}
54+
$view = $this->createViewModel();
55+
$editionId = $this->params()->fromRoute('id');
56+
$edition = $this->getDbTable('edition')->getByPrimaryKey($editionId);
57+
58+
if ($this->params()->fromPost('convert')) {
59+
$prefix = $this->params()->fromPost('prefix');
60+
if (empty($prefix)) {
61+
$view->result = 'Prefix cannot be blank!';
62+
return $view;
63+
}
64+
$issueMaker = $this->serviceLocator->get(\GeebyDeebyLocal\Ingest\IssueMaker::class);
65+
if ($issueMaker->createIssueForWork($edition, $prefix)) {
66+
$view->result = 'Conversion successful';
67+
} else {
68+
$view->result = 'Conversion unsuccessful: ' . $issueMaker->getLastMessage();
69+
}
70+
} else {
71+
$series = $this->getDbTable('series')->getByPrimaryKey($edition->Series_ID);
72+
$view->prefix = $series->Series_Name . ', no. ';
73+
}
74+
75+
$view->parent = $edition->Parent_Edition_ID;
76+
return $view;
77+
}
78+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/**
4+
* Class to move Works into Issues within a Series (console version).
5+
*
6+
* PHP version 5
7+
*
8+
* Copyright (C) Demian Katz 2025.
9+
*
10+
* This program is free software; you can redistribute it and/or modify
11+
* it under the terms of the GNU General Public License version 2,
12+
* as published by the Free Software Foundation.
13+
*
14+
* This program is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+
* GNU General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU General Public License
20+
* along with this program; if not, write to the Free Software
21+
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22+
*
23+
* @category GeebyDeeby
24+
* @package Ingest
25+
* @author Demian Katz <demian.katz@villanova.edu>
26+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
27+
* @link https://github.com/demiankatz/Geeby-Deeby Main Site
28+
*/
29+
30+
namespace GeebyDeebyLocal\Ingest;
31+
32+
/**
33+
* Class to move Works into Issues within a Series (console version).
34+
*
35+
* @category GeebyDeeby
36+
* @package Ingest
37+
* @author Demian Katz <demian.katz@villanova.edu>
38+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License
39+
* @link https://github.com/demiankatz/Geeby-Deeby Main Site
40+
*/
41+
class ConsoleIssueMaker extends IssueMaker
42+
{
43+
use \GeebyDeebyConsole\ConsoleOutputTrait;
44+
}

module/GeebyDeebyLocal/src/GeebyDeebyLocal/Ingest/IssueMaker.php

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545
*/
4646
class IssueMaker
4747
{
48-
use \GeebyDeebyConsole\ConsoleOutputTrait;
49-
5048
// constant values drawn from dimenovels.org database:
5149
public const MATERIALTYPE_WORK = 1;
5250
public const MATERIALTYPE_ISSUE = 2;
@@ -65,6 +63,35 @@ class IssueMaker
6563
*/
6664
protected $articles;
6765

66+
/**
67+
* Last message sent to writeln()
68+
*
69+
* @var string
70+
*/
71+
protected $lastMessage = '';
72+
73+
/**
74+
* Process a status message
75+
*
76+
* @param string $msg Message
77+
*
78+
* @return void
79+
*/
80+
protected function writeln(string $msg)
81+
{
82+
$this->lastMessage = $msg;
83+
}
84+
85+
/**
86+
* Get the last message
87+
*
88+
* @return string
89+
*/
90+
public function getLastMessage()
91+
{
92+
return $this->lastMessage;
93+
}
94+
6895
/**
6996
* Constructor
7097
*
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php $this->layout()->title = 'Convert to Issue' ?>
2+
3+
<?php if ($result): ?>
4+
<?=$this->escapeHtml($result)?>
5+
<?php endif; ?>
6+
7+
<?php if ($parent): ?>
8+
<p>
9+
<a href="<?=$this->url('edit/edition', ['id' => $parent])?>">Issue Edition</a>
10+
</p>
11+
<?php else: ?>
12+
<form target="" method="post">
13+
<label>Issue Title Prefix (number will be automatically added): <input style="width: 100%;" type="text" name="prefix" value="<?=$this->escapeHtmlAttr($prefix)?>"></label><br>
14+
<input type="submit" name="convert" value="Convert">
15+
</form>
16+
<?php endif; ?>

0 commit comments

Comments
 (0)