Changeset View
Changeset View
Standalone View
Standalone View
src/applications/phriction/editor/PhrictionTransactionEditor.php
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | ||||
return $xaction->getNewValue(); | return $xaction->getNewValue(); | ||||
case PhrictionTransaction::TYPE_MOVE_TO: | case PhrictionTransaction::TYPE_MOVE_TO: | ||||
$document = $xaction->getNewValue(); | $document = $xaction->getNewValue(); | ||||
// grab the real object now for the sub-editor to come | // grab the real object now for the sub-editor to come | ||||
$this->moveAwayDocument = $document; | $this->moveAwayDocument = $document; | ||||
$dict = array( | $dict = array( | ||||
'id' => $document->getID(), | 'id' => $document->getID(), | ||||
'phid' => $document->getPHID(), | 'phid' => $document->getPHID(), | ||||
'content' => $document->getContent()->getContent(),); | 'content' => $document->getContent()->getContent(), | ||||
'title' => $document->getContent()->getTitle(),); | |||||
return $dict; | return $dict; | ||||
case PhrictionTransaction::TYPE_MOVE_AWAY: | case PhrictionTransaction::TYPE_MOVE_AWAY: | ||||
$document = $xaction->getNewValue(); | $document = $xaction->getNewValue(); | ||||
$dict = array( | $dict = array( | ||||
'id' => $document->getID(), | 'id' => $document->getID(), | ||||
'phid' => $document->getPHID(), | 'phid' => $document->getPHID(), | ||||
'content' => $document->getContent()->getContent(),); | 'content' => $document->getContent()->getContent(), | ||||
'title' => $document->getContent()->getTitle(),); | |||||
return $dict; | return $dict; | ||||
} | } | ||||
} | } | ||||
protected function shouldApplyInitialEffects( | protected function shouldApplyInitialEffects( | ||||
PhabricatorLiskDAO $object, | PhabricatorLiskDAO $object, | ||||
array $xactions) { | array $xactions) { | ||||
▲ Show 20 Lines • Show All 46 Lines • ▼ Show 20 Lines | switch ($xaction->getTransactionType()) { | ||||
case PhrictionTransaction::TYPE_CONTENT: | case PhrictionTransaction::TYPE_CONTENT: | ||||
if ($this->getIsNewObject()) { | if ($this->getIsNewObject()) { | ||||
break; | break; | ||||
} | } | ||||
$content = $xaction->getNewValue(); | $content = $xaction->getNewValue(); | ||||
if ($content === '') { | if ($content === '') { | ||||
$xactions[] = id(new PhrictionTransaction()) | $xactions[] = id(new PhrictionTransaction()) | ||||
->setTransactionType(PhrictionTransaction::TYPE_DELETE) | ->setTransactionType(PhrictionTransaction::TYPE_DELETE) | ||||
->setNewValue(true); | ->setNewValue(true) | ||||
->setMetadataValue('contentDelete', true); | |||||
} | } | ||||
break; | break; | ||||
case PhrictionTransaction::TYPE_MOVE_TO: | case PhrictionTransaction::TYPE_MOVE_TO: | ||||
$document = $xaction->getNewValue(); | $document = $xaction->getNewValue(); | ||||
$xactions[] = id(new PhrictionTransaction()) | $xactions[] = id(new PhrictionTransaction()) | ||||
->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) | ->setTransactionType(PhabricatorTransactions::TYPE_VIEW_POLICY) | ||||
->setNewValue($document->getViewPolicy()); | ->setNewValue($document->getViewPolicy()); | ||||
$xactions[] = id(new PhrictionTransaction()) | $xactions[] = id(new PhrictionTransaction()) | ||||
Show All 22 Lines | switch ($xaction->getTransactionType()) { | ||||
case PhrictionTransaction::TYPE_DELETE: | case PhrictionTransaction::TYPE_DELETE: | ||||
$this->getNewContent()->setContent(''); | $this->getNewContent()->setContent(''); | ||||
$this->getNewContent()->setChangeType( | $this->getNewContent()->setChangeType( | ||||
PhrictionChangeType::CHANGE_DELETE); | PhrictionChangeType::CHANGE_DELETE); | ||||
break; | break; | ||||
case PhrictionTransaction::TYPE_MOVE_TO: | case PhrictionTransaction::TYPE_MOVE_TO: | ||||
$dict = $xaction->getNewValue(); | $dict = $xaction->getNewValue(); | ||||
$this->getNewContent()->setContent($dict['content']); | $this->getNewContent()->setContent($dict['content']); | ||||
$this->getNewContent()->setTitle($dict['title']); | |||||
$this->getNewContent()->setChangeType( | $this->getNewContent()->setChangeType( | ||||
PhrictionChangeType::CHANGE_MOVE_HERE); | PhrictionChangeType::CHANGE_MOVE_HERE); | ||||
$this->getNewContent()->setChangeRef($dict['id']); | $this->getNewContent()->setChangeRef($dict['id']); | ||||
break; | break; | ||||
case PhrictionTransaction::TYPE_MOVE_AWAY: | case PhrictionTransaction::TYPE_MOVE_AWAY: | ||||
$dict = $xaction->getNewValue(); | $dict = $xaction->getNewValue(); | ||||
$this->getNewContent()->setContent(''); | $this->getNewContent()->setContent(''); | ||||
$this->getNewContent()->setChangeType( | $this->getNewContent()->setChangeType( | ||||
▲ Show 20 Lines • Show All 347 Lines • ▼ Show 20 Lines | foreach ($xactions as $xaction) { | ||||
$xaction); | $xaction); | ||||
$errors[] = $error; | $errors[] = $error; | ||||
} | } | ||||
break; | break; | ||||
case PhrictionTransaction::TYPE_DELETE: | case PhrictionTransaction::TYPE_DELETE: | ||||
switch ($object->getStatus()) { | switch ($object->getStatus()) { | ||||
case PhrictionDocumentStatus::STATUS_DELETED: | case PhrictionDocumentStatus::STATUS_DELETED: | ||||
$e_text = pht('An already deleted document can not be deleted.'); | if ($xaction->getMetadataValue('contentDelete')) { | ||||
$e_text = pht( | |||||
'This document is already deleted. You must specify '. | |||||
'content to re-create the document and make further edits.'); | |||||
} else { | |||||
$e_text = pht( | |||||
'An already deleted document can not be deleted.'); | |||||
} | |||||
break; | break; | ||||
case PhrictionDocumentStatus::STATUS_MOVED: | case PhrictionDocumentStatus::STATUS_MOVED: | ||||
$e_text = pht('A moved document can not be deleted.'); | $e_text = pht('A moved document can not be deleted.'); | ||||
break; | break; | ||||
case PhrictionDocumentStatus::STATUS_STUB: | case PhrictionDocumentStatus::STATUS_STUB: | ||||
$e_text = pht('A stub document can not be deleted.'); | $e_text = pht('A stub document can not be deleted.'); | ||||
break; | break; | ||||
default: | default: | ||||
▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines |