id = idx($data, 'id');
$this->page = idx($data, 'page');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$uri = $request->getRequestURI();
$project = id(new PhabricatorProject())->load($this->id);
if (!$project) {
return new Aphront404Response();
}
$profile = $project->loadProfile();
if (!$profile) {
$profile = new PhabricatorProjectProfile();
}
$src_phid = $profile->getProfileImagePHID();
if (!$src_phid) {
$src_phid = $user->getProfileImagePHID();
}
$picture = PhabricatorFileURI::getViewURIForPHID($src_phid);
$pages = array(
/*
'
Active Documents
',
'tasks' => 'Maniphest Tasks',
'revisions' => 'Differential Revisions',
'
',
'Workflow
',
'goals' => 'Goals',
'statistics' => 'Statistics',
'
', */
'Information
',
'edit' => 'Edit Profile',
'affiliation' => 'Edit Affiliation',
);
if (empty($pages[$this->page])) {
$this->page = 'action'; // key($pages);
}
switch ($this->page) {
default:
$content = $this->renderBasicInformation($project, $profile);
break;
}
$profile = new PhabricatorProfileView();
$profile->setProfilePicture($picture);
$profile->setProfileNames($project->getName());
foreach ($pages as $page => $name) {
if (is_integer($page)) {
$profile->addProfileItem(
phutil_render_tag(
'span',
array(),
$name));
} else {
$uri->setPath('/project/'.$page.'/'.$project->getID().'/');
$profile->addProfileItem(
phutil_render_tag(
'a',
array(
'href' => $uri,
'class' => ($this->page == $page)
? 'phabricator-profile-item-selected'
: null,
),
phutil_escape_html($name)));
}
}
$profile->appendChild($content);
return $this->buildStandardPageResponse(
$profile,
array(
'title' => $project->getName(),
));
}
private function renderBasicInformation($project, $profile) {
$blurb = nonempty(
$profile->getBlurb(),
'//Nothing is known about this elusive project.//');
$engine = PhabricatorMarkupEngine::newProfileMarkupEngine();
$blurb = $engine->markupText($blurb);
$affiliations = $project->loadAffiliations();
$phids = array_merge(
array($project->getAuthorPHID()),
mpull($affiliations, 'getUserPHID'));
$handles = id(new PhabricatorObjectHandleData($phids))
->loadHandles();
$affiliated = array();
foreach ($affiliations as $affiliation) {
$user = $handles[$affiliation->getUserPHID()]->renderLink();
$role = phutil_escape_html($affiliation->getRole());
$status = null;
if ($affiliation->getStatus() == 'former') {
$role = 'Former '.$role.'';
}
$affiliated[] = ''.$user.' — '.$role.$status.'';
}
if ($affiliated) {
$affiliated = ''.implode("\n", $affiliated).'
';
} else {
$affiliated = 'No one is affiliated with this project.
';
}
$timestamp = phabricator_format_timestamp($project->getDateCreated());
$status = PhabricatorProjectStatus::getNameForStatus(
$project->getStatus());
$content =
'
Creator |
'.$handles[$project->getAuthorPHID()]->renderLink().' |
Status |
'.phutil_escape_html($status).' |
Created |
'.$timestamp.' |
PHID |
'.phutil_escape_html($project->getPHID()).' |
Blurb |
'.$blurb.' |
';
$content .=
'';
$query = id(new ManiphestTaskQuery())
->withProjects(array($project->getPHID()))
->withStatus(ManiphestTaskQuery::STATUS_OPEN)
->setOrderBy(ManiphestTaskQuery::ORDER_PRIORITY)
->setLimit(10)
->setCalculateRows(true);
$tasks = $query->execute();
$count = $query->getRowCount();
$phids = mpull($tasks, 'getOwnerPHID');
$phids = array_filter($phids);
$handles = id(new PhabricatorObjectHandleData($phids))
->loadHandles();
$task_views = array();
foreach ($tasks as $task) {
$view = id(new ManiphestTaskSummaryView())
->setTask($task)
->setHandles($handles)
->setUser($this->getRequest()->getUser());
$task_views[] = $view->render();
}
if (empty($tasks)) {
$task_views = 'No open tasks.';
} else {
$task_views = implode('', $task_views);
}
$open = number_format($count);
$more_link = phutil_render_tag(
'a',
array(
'href' => '/maniphest/view/all/?projects='.$project->getPHID(),
),
"View All Open Tasks \xC2\xBB");
$content .=
'
'.
'
'.
$task_views.
'
'.
$more_link.
'
'.
'
';
return $content;
}
}