Feed - fix some whacky "text mode" rendering code
Summary: ...add a "renderingTarget" to FeedStory and use it as appropos. Overall, not a ton of changes was necessary to make this work. I think this could be made to be even cleaner by going through each and every feed story and re-implementing as necessary with the full toolset available. But this is good enough for now I think, and just something to keep cleaning up when we're in here. Fixes T4630. Test Plan: made a task. gave it a token. viewed my feed - saw stories. used conduit.feed.query with mode == 'text' and got good readable results. Reviewers: epriestley Reviewed By: epriestley Subscribers: spicyj, epriestley, Korvin Maniphest Tasks: T4630 Differential Revision: https://secure.phabricator.com/D8750
This commit is contained in:
@@ -28,27 +28,29 @@ final class PhabricatorTokenGivenFeedStory
|
||||
$href = $this->getHandle($this->getPrimaryObjectPHID())->getURI();
|
||||
$view->setHref($href);
|
||||
|
||||
$token = $this->getObject($this->getValue('tokenPHID'));
|
||||
$view->setTitle($this->renderTitle());
|
||||
$view->setImage($this->getHandle($author_phid)->getImageURI());
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
private function renderTitle() {
|
||||
$token = $this->getObject($this->getValue('tokenPHID'));
|
||||
$title = pht(
|
||||
'%s awarded %s a %s token.',
|
||||
$this->linkTo($this->getValue('authorPHID')),
|
||||
$this->linkTo($this->getValue('objectPHID')),
|
||||
$token->getName());
|
||||
|
||||
$view->setTitle($title);
|
||||
$view->setImage($this->getHandle($author_phid)->getImageURI());
|
||||
|
||||
return $view;
|
||||
return $title;
|
||||
}
|
||||
|
||||
public function renderText() {
|
||||
// TODO: This is grotesque; the feed notification handler relies on it.
|
||||
return htmlspecialchars_decode(
|
||||
strip_tags(
|
||||
hsprintf(
|
||||
'%s',
|
||||
$this->renderView()->getTitle())));
|
||||
$old_target = $this->getRenderingTarget();
|
||||
$this->setRenderingTarget(PhabricatorApplicationTransaction::TARGET_TEXT);
|
||||
$title = $this->renderTitle();
|
||||
$this->setRenderingTarget($old_target);
|
||||
return $title;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user