Skip to content

Commit

Permalink
Major refactoring to clean up old definition vs entry vs revision con…
Browse files Browse the repository at this point in the history
…fusion
  • Loading branch information
rowanseymour committed Aug 28, 2011
1 parent a999ed2 commit 5004155
Show file tree
Hide file tree
Showing 44 changed files with 773 additions and 773 deletions.
22 changes: 11 additions & 11 deletions admin/change.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
$change = Dictionary::getChangeService()->getChange($changeId);
if ($change->getAction() == Action::DELETE) {
$entry = $change->getEntry();
$definition = Dictionary::getDefinitionService()->getEntryRevision($entry, Revision::LAST);
$revision = Dictionary::getEntryService()->getEntryRevision($entry, Revision::LAST);
}
else {
$definition = Dictionary::getChangeService()->getChangeDefinition($change);
$entry = $definition->getEntry();
$revision = Dictionary::getChangeService()->getChangeRevision($change);
$entry = $revision->getEntry();
}
$curUser = Session::getCurrent()->getUser();
$commentText = '';
Expand Down Expand Up @@ -154,7 +154,7 @@ function onActionSubmit() {
<table class="form">
<tr>
<th><?php Templates::icon('entry'); ?> <?php echo KU_STR_ENTRY; ?></th>
<td><?php Templates::definitionLink($definition, $canEditDef); ?></td>
<td><?php Templates::wordLink($revision, $canEditDef); ?></td>
</tr>
<tr>
<th><?php Templates::icon('user'); ?> <?php echo KU_STR_SUBMITTED; ?></th>
Expand Down Expand Up @@ -190,23 +190,23 @@ function onActionSubmit() {
<td colspan="2" style="padding: 0">
<div id="difftable">
<?php
$accepted = Dictionary::getDefinitionService()->getEntryRevision($entry, Revision::ACCEPTED);
$accepted = Dictionary::getEntryService()->getEntryRevision($entry, RevisionPreset::ACCEPTED);

if ($change->getStatus() == Status::PENDING) {
if ($change->getAction() == Action::CREATE)
Diff::definitions($definition, KU_STR_PROPOSED, NULL, NULL);
Diff::revisions($revision, KU_STR_PROPOSED, NULL, NULL);
elseif ($change->getAction() == Action::MODIFY)
Diff::definitions($accepted, KU_STR_CURRENT, $definition, KU_STR_PROPOSED);
Diff::revisions($accepted, KU_STR_CURRENT, $revision, KU_STR_PROPOSED);
elseif ($change->getAction() == Action::DELETE)
Diff::definitions($accepted, KU_STR_CURRENT, NULL, NULL);
Diff::revisions($accepted, KU_STR_CURRENT, NULL, NULL);
}
else {
if ($change->getAction() == Action::CREATE)
Diff::definitions($definition, KU_STR_PROPOSED, NULL, NULL);
Diff::revisions($revision, KU_STR_PROPOSED, NULL, NULL);
elseif ($change->getAction() == Action::MODIFY)
Diff::definitions($definition, KU_STR_PROPOSED, $accepted, KU_STR_CURRENT);
Diff::revisions($revision, KU_STR_PROPOSED, $accepted, KU_STR_CURRENT);
elseif ($change->getAction() == Action::DELETE)
Diff::definitions($definition, KU_STR_LAST, NULL, NULL);
Diff::revisions($revision, KU_STR_LAST, NULL, NULL);
}
?>
</div>
Expand Down
20 changes: 10 additions & 10 deletions admin/entries.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,30 +74,30 @@
<?php
if ($search->hasResults()) {
foreach($search->getResults() as $entry) {
$definition = $entry->getHead();
$revision = $entry->getHead();

$itemUrl = 'entry.php?id='.$entry->getId().'&amp;ref='.urlencode(KUMVA_URL_CURRENT);
$editUrl = 'entryedit.php?id='.$entry->getId().'&amp;ref='.urlencode(KUMVA_URL_CURRENT);
$meanings = BeanUtils::getPropertyOfAll($definition->getMeanings(), 'meaning');
$meanings = BeanUtils::getPropertyOfAll($revision->getMeanings(), 'meaning');
?>
<tr class="rowlink" onclick="aka_goto('<?php echo $itemUrl; ?>')">
<td>&nbsp;</td>
<td>
<?php
if ($definition->isProposedRevision())
if ($revision->isProposed())
Templates::icon('proposal', KU_STR_PROPOSAL);
else
Templates::icon('entry', KU_STR_ENTRY);
?>
</td>
<td class="prefix" style="padding-right: 0; text-align: right"><?php echo $definition->getPrefix(); ?></td>
<td class="lemma primarycol" style="padding-left: 0; text-align: left"><?php echo $definition->getLemma(); ?></td>
<td><?php echo $definition->getModifier(); ?></td>
<td style="text-align: center"><?php echo $definition->getPronunciation(); ?></td>
<td style="text-align: center"><?php echo $definition->getWordClass(); ?></td>
<td style="text-align: center"><?php echo aka_makecsv($definition->getNounClasses()); ?></td>
<td class="prefix" style="padding-right: 0; text-align: right"><?php echo $revision->getPrefix(); ?></td>
<td class="lemma primarycol" style="padding-left: 0; text-align: left"><?php echo $revision->getLemma(); ?></td>
<td><?php echo $revision->getModifier(); ?></td>
<td style="text-align: center"><?php echo $revision->getPronunciation(); ?></td>
<td style="text-align: center"><?php echo $revision->getWordClass(); ?></td>
<td style="text-align: center"><?php echo aka_makecsv($revision->getNounClasses()); ?></td>
<td><?php echo implode('<br/>', $meanings); ?></td>
<td style="text-align: center"><?php if (!$definition->isUnverified()) Templates::icon('tick'); ?></td>
<td style="text-align: center"><?php if (!$revision->isUnverified()) Templates::icon('tick'); ?></td>
<td>
<?php
if (Session::getCurrent()->hasRole(Role::CONTRIBUTOR))
Expand Down
44 changes: 22 additions & 22 deletions admin/entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*
* Copyright Rowan Seymour 2010
*
* Purpose: Definition edit page
* Purpose: Entry edit page
*/

include_once '../inc/kumva.php';
Expand All @@ -26,7 +26,7 @@

// Get entry
$entryId = (int)Request::getGetParam('id', 0);
$entry = ($entryId > 0) ? Dictionary::getDefinitionService()->getEntry($entryId) : new Entry();
$entry = ($entryId > 0) ? Dictionary::getEntryService()->getEntry($entryId) : new Entry();

// Get pending change if there is one
$pendingChanges = Dictionary::getChangeService()->getChangesByEntry($entry, Status::PENDING);
Expand All @@ -45,15 +45,15 @@
}

// Get revision to view
$viewRev = (int)Request::getGetParam('rev', Revision::HEAD);
$definition = Dictionary::getDefinitionService()->getEntryRevision($entry, $viewRev);
if (!$definition)
$definition = Dictionary::getDefinitionService()->getEntryRevision($entry, Revision::LAST);
$viewRev = (int)Request::getGetParam('rev', RevisionPreset::HEAD);
$revision = Dictionary::getEntryService()->getEntryRevision($entry, $viewRev);
if (!$revision)
$revision = Dictionary::getEntryService()->getEntryRevision($entry, RevisionPreset::LAST);

$canEdit = !$entry->isDeleted() && !$pendingChange && Session::getCurrent()->hasRole(Role::CONTRIBUTOR);
$canDelete = !$entry->isDeleted() && !$pendingChange && Session::getCurrent()->hasRole(Role::CONTRIBUTOR);

$definitions = Dictionary::getDefinitionService()->getEntryRevisions($entry);
$revisions = Dictionary::getEntryService()->getEntryRevisions($entry);

include_once 'tpl/header.php';

Expand All @@ -63,7 +63,7 @@
function deleteEntry(id) {
if (confirm('<?php echo KU_MSG_CONFIRMDELETEENTRY; ?>')) {
$('#action').val('delete');
$('#definitionForm').submit();
$('#revisionForm').submit();
}
}
/* ]]> */
Expand All @@ -75,7 +75,7 @@ function deleteEntry(id) {
<?php Templates::buttonLink('back', Request::getGetParam('ref', 'entries.php'), KU_STR_BACK); ?>
</div>
<div style="float: right">
<form id="definitionForm" method="post">
<form id="revisionForm" method="post">
<input type="hidden" id="action" name="action" />
<?php
if ($canEdit)
Expand All @@ -94,7 +94,7 @@ function deleteEntry(id) {
$message = sprintf(KU_MSG_ENTRYCHANGEPENDING, $pendingChangeUrl);
elseif ($entry->isDeleted())
$message = KU_MSG_ENTRYDELETED;
elseif ($definition->isUnverified())
elseif ($revision->isUnverified())
$message = KU_MSG_ENTRYNOTVERIFIED;

if (isset($message))
Expand All @@ -103,25 +103,25 @@ function deleteEntry(id) {
<table class="form">
<tr>
<th><?php echo KU_STR_WORDCLASS.'/'.KU_STR_NOUNCLASSES; ?></th>
<td><?php echo $definition->getWordClass(); ?> <?php echo aka_makecsv($definition->getNounClasses()); ?></td>
<td><?php echo $revision->getWordClass(); ?> <?php echo aka_makecsv($revision->getNounClasses()); ?></td>
</tr>
<tr>
<th><?php echo KU_STR_PREFIX.'/'.KU_STR_LEMMA; ?></th>
<td><?php Templates::definition($definition, FALSE); ?></td>
<td><?php Templates::word($revision, FALSE); ?></td>
</tr>
<tr>
<th><?php echo KU_STR_MODIFIER; ?></th>
<td><?php echo $definition->getModifier(); ?></td>
<td><?php echo $revision->getModifier(); ?></td>
</tr>
<tr>
<th><?php echo KU_STR_PRONUNCIATION; ?></th>
<td>/<?php echo $definition->getPronunciation(); ?>/</td>
<td>/<?php echo $revision->getPronunciation(); ?>/</td>
</tr>
<tr>
<th><?php echo KU_STR_MEANINGS; ?></th>
<td>
<?php
foreach ($definition->getMeanings() as $meaning) {
foreach ($revision->getMeanings() as $meaning) {
echo aka_prephtml($meaning->getMeaning());

if ($meaning->getFlags() > 0) {
Expand All @@ -140,13 +140,13 @@ function deleteEntry(id) {
</tr>
<tr>
<th><?php echo KU_STR_COMMENT; ?></th>
<td><?php echo $definition->getComment(); ?></td>
<td><?php echo $revision->getComment(); ?></td>
</tr>
<tr>
<td colspan="2" class="sectionheader"><?php echo KU_STR_TAGS; ?></td>
</tr>
<?php foreach (Dictionary::getTagService()->getRelationships() as $relationship) {
$tags = $definition->getTags($relationship->getId());
$tags = $revision->getTags($relationship->getId());
$tagStrings = $relationship->makeTagStrings($tags);
?>
<tr>
Expand All @@ -162,7 +162,7 @@ function deleteEntry(id) {
</tr>
<tr>
<td colspan="2">
<?php Templates::exampleList($definition->getExamples()); ?>
<?php Templates::exampleList($revision->getExamples()); ?>
</td>
</tr>
</table>
Expand All @@ -181,14 +181,14 @@ function deleteEntry(id) {
<th style="width: 30px">&nbsp;</th>
</tr>
<?php
foreach ($definitions as $def) {
$change = $def->getChange();
$itemUrl = 'entry.php?id='.$entry->getId().'&amp;rev='.$def->getRevision().'&amp;ref='.urlencode(Request::getGetParam('ref'));
foreach ($revisions as $rev) {
$change = $rev->getChange();
$itemUrl = 'entry.php?id='.$entry->getId().'&amp;rev='.$rev->getNumber().'&amp;ref='.urlencode(Request::getGetParam('ref'));
?>
<tr class="rowlink" onclick="aka_goto('<?php echo $itemUrl; ?>')">
<td>&nbsp;</td>
<td><?php Templates::icon('change'); ?></td>
<td class="primarycol" style="text-align:center"><?php echo $def->getRevision(); ?></td>
<td class="primarycol" style="text-align:center"><?php echo $rev->getNumber(); ?></td>
<?php if ($change) { ?>
<td style="text-align:center"><a href="change.php?id=<?php echo $change->getId(); ?>"><?php echo $change->getId(); ?></a></td>
<td style="text-align:center"><?php echo Templates::dateTime($change->getSubmitted()); ?></td>
Expand Down
16 changes: 8 additions & 8 deletions admin/entryedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
*/

include_once '../inc/kumva.php';
include_once 'form/DefinitionForm.php';
include_once 'validator/DefinitionValidator.php';
include_once 'form/RevisionForm.php';
include_once 'validator/RevisionValidator.php';

Session::requireRole(Role::CONTRIBUTOR);

$pronunChars = defined('KUMVA_PRONUNCIATION_CHARS') ? aka_strsplit(KUMVA_PRONUNCIATION_CHARS) : array();

$returnUrl = Request::getGetParam('ref', 'entries.php');
$form = new DefinitionForm($returnUrl, new DefinitionValidator(), new FormRenderer());
$definition = $form->getEntity();
$form = new RevisionForm($returnUrl, new RevisionValidator(), new FormRenderer());
$revision = $form->getEntity();

include_once 'tpl/header.php';

Expand All @@ -39,7 +39,7 @@
/* <![CDATA[ */
function autoTag(relationshipId) {
$('#autotag').val(relationshipId);
$('#definitionform').submit();
$('#revisionForm').submit();
}

function addNewMeaning() {
Expand Down Expand Up @@ -97,13 +97,13 @@ function deleteExample(index) {
<?php
if ($form->entry && $form->entry->isDeleted())
echo '<div class="info">'.KU_MSG_ENTRYDELETED.'</div>';
elseif ($definition->isProposedRevision())
printf('<div class="info">'.KU_MSG_DEFINITIONPROPOSAL.'</div>', 'change.php?id='.$form->change->getId().'&amp;ref='.urlencode(KUMVA_URL_CURRENT));
elseif ($revision->isProposed())
printf('<div class="info">'.KU_MSG_REVISIONPROPOSAL.'</div>', 'change.php?id='.$form->change->getId().'&amp;ref='.urlencode(KUMVA_URL_CURRENT));

if (count($form->getErrors()->get()) > 0)
echo '<div class="error">'.implode('<br />', $form->getErrors()->get()).'</div>';

$form->start('definitionform');
$form->start('revisionForm');
?>
<input type="hidden" id="autotag" name="autotag" value="" />
<input type="hidden" id="saveType" name="saveType" value="propose" />
Expand Down
2 changes: 1 addition & 1 deletion admin/export.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
include_once 'tpl/header.php';
?>
<h3><?php echo KU_STR_EXPORT ?></h3>
<div class="description">Entries and definitions can be downloaded as XML files.</div>
<div class="description">Dictionary entries can be downloaded as XML files.</div>
<ul>
<li><?php echo KU_STR_ACCEPTEDREVISIONS; ?>: <a href="../meta/export.xml.php">link</a></li>
<li><?php echo KU_STR_COMPLETEENTRIES; ?>: <a href="../meta/export.xml.php?changes=1">link</a></li>
Expand Down
Loading

0 comments on commit 5004155

Please sign in to comment.