public function processRequest() { $request = $this->getRequest(); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $pastes = id(new PhabricatorPaste())->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $pastes = $pager->sliceResults($pastes); $pager->setURI($request->getRequestURI(), 'page'); $phids = mpull($pastes, 'getAuthorPHID'); $handles = array(); if ($phids) { $handles = id(new PhabricatorObjectHandleData($phids))->loadHandles(); } $rows = array(); foreach ($pastes as $paste) { $handle = $handles[$paste->getAuthorPHID()]; $rows[] = array(phutil_escape_html('P' . $paste->getID()), phutil_render_tag('a', array('href' => '/p/' . $handle->getName() . '/'), phutil_escape_html($handle->getName())), phutil_escape_html($paste->getLanguage()), phutil_render_tag('a', array('href' => '/P' . $paste->getID()), phutil_escape_html(nonempty($paste->getTitle(), 'Untitled Masterwork P' . $paste->getID()))), phutil_render_tag('a', array('href' => PhabricatorFileURI::getViewURIForPHID($paste->getFilePHID())), phutil_escape_html($paste->getFilePHID()))); } $table = new AphrontTableView($rows); $table->setHeaders(array('Paste ID', 'Author', 'Language', 'Title', 'File')); $table->setColumnClasses(array(null, null, null, 'wide pri', null)); $panel = new AphrontPanelView(); $panel->setWidth(AphrontPanelView::WIDTH_FULL); $panel->setHeader("Paste"); $panel->setCreateButton('Paste Something', '/paste/'); $panel->appendChild($table); $panel->appendChild($pager); return $this->buildStandardPageResponse($panel, array('title' => 'Paste List', 'tab' => 'list')); }
public function processRequest() { if (!PhabricatorEnv::getEnvConfig('files.enable-proxy')) { return new Aphront400Response(); } $request = $this->getRequest(); $uri = $request->getStr('uri'); $proxy = id(new PhabricatorFileProxyImage())->loadOneWhere('uri = %s', $uri); if (!$proxy) { // This write is fine to skip CSRF checks for, we're just building a // cache of some remote image. $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites(); $file = PhabricatorFile::newFromFileDownload($uri, nonempty(basename($uri), 'proxied-file')); if ($file) { $proxy = new PhabricatorFileProxyImage(); $proxy->setURI($uri); $proxy->setFilePHID($file->getPHID()); $proxy->save(); } unset($unguarded); } if ($proxy) { $view_uri = PhabricatorFileURI::getViewURIForPHID($proxy->getFilePHID()); return id(new AphrontRedirectResponse())->setURI($view_uri); } return new Aphront400Response(); }
public function processRequest() { $request = $this->getRequest(); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $macro_table = new PhabricatorFileImageMacro(); $macros = $macro_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize()); // Get an exact count since the size here is reasonably going to be a few // thousand at most in any reasonable case. $count = queryfx_one($macro_table->establishConnection('r'), 'SELECT COUNT(*) N FROM %T', $macro_table->getTableName()); $count = $count['N']; $pager->setCount($count); $pager->setURI($request->getRequestURI(), 'page'); $rows = array(); foreach ($macros as $macro) { $src = PhabricatorFileURI::getViewURIForPHID($macro->getFilePHID()); $rows[] = array(phutil_render_tag('a', array('href' => '/file/macro/edit/' . $macro->getID() . '/'), phutil_escape_html($macro->getName())), phutil_render_tag('a', array('href' => $src, 'target' => '_blank'), phutil_render_tag('img', array('src' => $src))), javelin_render_tag('a', array('href' => '/file/macro/delete/' . $macro->getID() . '/', 'sigil' => 'workflow', 'class' => 'grey small button'), 'Delete')); } $table = new AphrontTableView($rows); $table->setHeaders(array('Name', 'Image', '')); $table->setColumnClasses(array('pri', 'wide thumb', 'action')); $panel = new AphrontPanelView(); $panel->appendChild($table); $panel->setHeader('Image Macros'); $panel->setCreateButton('New Image Macro', '/file/macro/edit/'); $panel->appendChild($pager); return $this->buildStandardPageResponse($panel, array('title' => 'Image Macros', 'tab' => 'macros')); }
public function renderView() { $data = $this->getStoryData(); $handles = $this->getHandles(); $author_phid = $data->getAuthorPHID(); $document_phid = $data->getValue('phid'); $objects = $this->getObjects(); $view = new PhabricatorFeedStoryView(); $action = $data->getValue('action'); $verb = PhrictionActionConstants::getActionPastTenseVerb($action); $view->setTitle('<strong>' . $handles[$author_phid]->renderLink() . '</strong>' . ' ' . $verb . ' the document ' . '<strong>' . $handles[$document_phid]->renderLink() . '</strong>.'); $view->setEpoch($data->getEpoch()); $action = $data->getValue('action'); switch ($action) { case PhrictionActionConstants::ACTION_CREATE: $full_size = true; break; default: $full_size = false; break; } if ($full_size) { if (!empty($objects[$author_phid])) { $image_phid = $objects[$author_phid]->getProfileImagePHID(); $image_uri = PhabricatorFileURI::getViewURIForPHID($image_phid); $view->setImage($image_uri); } $content = phutil_escape_html($data->getValue('content')); $content = str_replace("\n", '<br />', $content); $view->appendChild($content); } else { $view->setOneLineStory(true); } return $view; }
public function renderView() { $data = $this->getStoryData(); $author_phid = $data->getAuthorPHID(); $owner_phid = $data->getValue('ownerPHID'); $task_phid = $data->getValue('taskPHID'); $objects = $this->getObjects(); $action = $data->getValue('action'); $view = new PhabricatorFeedStoryView(); $verb = ManiphestAction::getActionPastTenseVerb($action); $extra = null; switch ($action) { case ManiphestAction::ACTION_ASSIGN: if ($owner_phid) { $extra = ' to ' . '<strong>' . $this->getHandle($owner_phid)->renderLink() . '</strong>'; } else { $verb = 'placed'; $extra = ' up for grabs'; } break; } $title = '<strong>' . $this->getHandle($author_phid)->renderLink() . '</strong>' . " {$verb} task " . '<strong>' . $this->getHandle($task_phid)->renderLink() . '</strong>'; $title .= $extra; $title .= '.'; $view->setTitle($title); switch ($action) { case ManiphestAction::ACTION_CREATE: $full_size = true; break; default: $full_size = false; break; } $view->setEpoch($data->getEpoch()); if ($full_size) { if (!empty($objects[$author_phid])) { $image_phid = $objects[$author_phid]->getProfileImagePHID(); $image_uri = PhabricatorFileURI::getViewURIForPHID($image_phid); $view->setImage($image_uri); } $content = phutil_escape_html(phutil_utf8_shorten($data->getValue('description'), 128)); $content = str_replace("\n", '<br />', $content); $view->appendChild($content); } else { $view->setOneLineStory(true); } return $view; }
public function renderView() { $data = $this->getStoryData(); $handles = $this->getHandles(); $author_phid = $data->getAuthorPHID(); $objects = $this->getObjects(); $view = new PhabricatorFeedStoryView(); $view->setTitle('<strong>' . $handles[$author_phid]->renderLink() . '</strong>'); $view->setEpoch($data->getEpoch()); if (!empty($objects[$author_phid])) { $image_phid = $objects[$author_phid]->getProfileImagePHID(); $image_uri = PhabricatorFileURI::getViewURIForPHID($image_phid); $view->setImage($image_uri); } $content = phutil_escape_html($data->getValue('content')); $content = str_replace("\n", '<br />', $content); $view->appendChild($content); return $view; }
public function markupImageMacro($matches) { // Update the hash that is used for defining each 'randomon' image. This way // each 'randomon' image will be different, but they won't change when the // text is updated. $this->updateHash($matches[1]); if (array_key_exists($matches[1], $this->images)) { if ($matches[1] === self::RANDOM_IMAGE_NAME) { $keys = array_keys($this->images); $phid = $this->images[$keys[$this->hash % count($this->images)]]; } else { $phid = $this->images[$matches[1]]; } $img = phutil_render_tag('img', array('src' => PhabricatorFileURI::getViewURIForPHID($phid), 'alt' => $matches[1], 'title' => $matches[1]), null); return $this->getEngine()->storeText($img); } else { return $matches[1]; } }
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('<h2>Information</h2>', 'edit' => 'Edit Project', 'affiliation' => 'Edit Affiliation'); if (empty($pages[$this->page])) { $this->page = 'action'; } 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())); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $paste = id(new PhabricatorPaste())->load($this->id); if (!$paste) { return new Aphront404Response(); } $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $paste->getFilePHID()); if (!$file) { return new Aphront400Response(); } $corpus = $this->buildCorpus($paste, $file); $paste_panel = new AphrontPanelView(); if (strlen($paste->getTitle())) { $paste_panel->setHeader('Viewing Paste ' . $paste->getID() . ' - ' . phutil_escape_html($paste->getTitle())); } else { $paste_panel->setHeader('Viewing Paste ' . $paste->getID()); } $paste_panel->setWidth(AphrontPanelView::WIDTH_FULL); $paste_panel->addButton(phutil_render_tag('a', array('href' => '/paste/?fork=' . $paste->getID(), 'class' => 'green button'), 'Fork This')); $raw_uri = PhabricatorFileURI::getViewURIForPHID($paste->getFilePHID()); $paste_panel->addButton(phutil_render_tag('a', array('href' => $raw_uri, 'class' => 'button'), 'View Raw Text')); $paste_panel->appendChild($corpus); $forks_panel = null; $forks_of_this_paste = id(new PhabricatorPaste())->loadAllWhere('parentPHID = %s', $paste->getPHID()); if ($forks_of_this_paste) { $forks_panel = new AphrontPanelView(); $forks_panel->setHeader("Forks of this paste"); $forks = array(); foreach ($forks_of_this_paste as $fork) { $forks[] = array($fork->getID(), phutil_render_tag('a', array('href' => '/P' . $fork->getID()), phutil_escape_html($fork->getTitle()))); } $forks_table = new AphrontTableView($forks); $forks_table->setHeaders(array('Paste ID', 'Title')); $forks_table->setColumnClasses(array(null, 'wide pri')); $forks_panel->appendChild($forks_table); } return $this->buildStandardPageResponse(array($paste_panel, $forks_panel), array('title' => 'Paste: ' . nonempty($paste->getTitle(), 'P' . $paste->getID()), 'tab' => 'view')); }
public function processRequest() { if (!PhabricatorEnv::getEnvConfig('files.enable-proxy')) { return new Aphront400Response(); } $request = $this->getRequest(); $uri = $request->getStr('uri'); $proxy = id(new PhabricatorFileProxyImage())->loadOneWhere('uri = %s', $uri); if (!$proxy) { $file = PhabricatorFile::newFromFileDownload($uri, nonempty(basename($uri), 'proxied-file')); if ($file) { $proxy = new PhabricatorFileProxyImage(); $proxy->setURI($uri); $proxy->setFilePHID($file->getPHID()); $proxy->save(); } } if ($proxy) { $view_uri = PhabricatorFileURI::getViewURIForPHID($proxy->getFilePHID()); return id(new AphrontRedirectResponse())->setURI($view_uri); } return new Aphront400Response(); }
public function render() { $handle = $this->handle; $type_name = nonempty($handle->getTypeName(), 'Document'); require_celerity_resource('phabricator-search-results-css'); $link = phutil_render_tag('a', array('href' => $handle->getURI()), PhabricatorEnv::getProductionURI($handle->getURI())); switch ($handle->getType()) { case PhabricatorPHIDConstants::PHID_TYPE_USER: if ($this->object) { $img_phid = $this->object->getProfileImagePHID(); $img = PhabricatorFileURI::getViewURIForPHID($img_phid); } break; default: $img = null; break; } if ($img) { $img = phutil_render_tag('div', array('class' => 'result-image', 'style' => "background-image: url('{$img}');"), ''); } switch ($handle->getType()) { case PhabricatorPHIDConstants::PHID_TYPE_CMIT: $object_name = $handle->getName(); if ($this->object) { $data = $this->object->getCommitData(); $summary = $data->getSummary(); if (strlen($summary)) { $object_name = $handle->getName() . ': ' . $data->getSummary(); } } break; default: $object_name = $handle->getFullName(); break; } return '<div class="phabricator-search-result">' . $img . '<div class="result-desc">' . phutil_render_tag('a', array('class' => 'result-name', 'href' => $handle->getURI()), $this->emboldenQuery($object_name)) . '<div class="result-type">' . $type_name . ' · ' . $link . '</div>' . '</div>' . '<div style="clear: both;"></div>' . '</div>'; }
public function loadHandles() { $types = array(); foreach ($this->phids as $phid) { $type = $this->lookupType($phid); $types[$type][] = $phid; } $handles = array(); $external_loaders = PhabricatorEnv::getEnvConfig('phid.external-loaders'); foreach ($types as $type => $phids) { switch ($type) { case PhabricatorPHIDConstants::PHID_TYPE_MAGIC: // Black magic! foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); switch ($phid) { case ManiphestTaskOwner::OWNER_UP_FOR_GRABS: $handle->setName('Up For Grabs'); $handle->setFullName('upforgrabs (Up For Grabs)'); break; default: $handle->setName('Foul Magicks'); break; } $handles[$phid] = $handle; } break; case PhabricatorPHIDConstants::PHID_TYPE_USER: $class = 'PhabricatorUser'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); $users = $object->loadAllWhere('phid IN (%Ls)', $phids); $users = mpull($users, null, 'getPHID'); foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); if (empty($users[$phid])) { $handle->setName('Unknown User'); } else { $user = $users[$phid]; $handle->setName($user->getUsername()); $handle->setURI('/p/' . $user->getUsername() . '/'); $handle->setEmail($user->getEmail()); $handle->setFullName($user->getUsername() . ' (' . $user->getRealName() . ')'); $handle->setAlternateID($user->getID()); $img_phid = $user->getProfileImagePHID(); if ($img_phid) { $handle->setImageURI(PhabricatorFileURI::getViewURIForPHID($img_phid)); } } $handles[$phid] = $handle; } break; case PhabricatorPHIDConstants::PHID_TYPE_MLST: $class = 'PhabricatorMetaMTAMailingList'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); $lists = $object->loadAllWhere('phid IN (%Ls)', $phids); $lists = mpull($lists, null, 'getPHID'); foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); if (empty($lists[$phid])) { $handle->setName('Unknown Mailing List'); } else { $list = $lists[$phid]; $handle->setEmail($list->getEmail()); $handle->setName($list->getName()); $handle->setURI($list->getURI()); $handle->setFullName($list->getName()); } $handles[$phid] = $handle; } break; case PhabricatorPHIDConstants::PHID_TYPE_DREV: $class = 'DifferentialRevision'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); $revs = $object->loadAllWhere('phid in (%Ls)', $phids); $revs = mpull($revs, null, 'getPHID'); foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); if (empty($revs[$phid])) { $handle->setName('Unknown Revision'); } else { $rev = $revs[$phid]; $handle->setName($rev->getTitle()); $handle->setURI('/D' . $rev->getID()); $handle->setFullName('D' . $rev->getID() . ': ' . $rev->getTitle()); } $handles[$phid] = $handle; } break; case PhabricatorPHIDConstants::PHID_TYPE_CMIT: $class = 'PhabricatorRepositoryCommit'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); $commits = $object->loadAllWhere('phid in (%Ls)', $phids); $commits = mpull($commits, null, 'getPHID'); $repository_ids = mpull($commits, 'getRepositoryID'); $repositories = id(new PhabricatorRepository())->loadAllWhere('id in (%Ld)', array_unique($repository_ids)); $callsigns = mpull($repositories, 'getCallsign'); foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); if (empty($commits[$phid]) || !isset($callsigns[$repository_ids[$phid]])) { $handle->setName('Unknown Commit'); } else { $commit = $commits[$phid]; $callsign = $callsigns[$repository_ids[$phid]]; $repository = $repositories[$repository_ids[$phid]]; $commit_identifier = $commit->getCommitIdentifier(); // In case where the repository for the commit was deleted, // we don't have have info about the repository anymore. if ($repository) { $vcs = $repository->getVersionControlSystem(); if ($vcs == PhabricatorRepositoryType::REPOSITORY_TYPE_GIT) { $short_identifier = substr($commit_identifier, 0, 16); } else { $short_identifier = $commit_identifier; } $handle->setName('r' . $callsign . $short_identifier); } else { $handle->setName('Commit ' . 'r' . $callsign . $commit_identifier); } $handle->setURI('/r' . $callsign . $commit_identifier); $handle->setFullName('r' . $callsign . $commit_identifier); $handle->setTimestamp($commit->getEpoch()); } $handles[$phid] = $handle; } break; case PhabricatorPHIDConstants::PHID_TYPE_TASK: $class = 'ManiphestTask'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); $tasks = $object->loadAllWhere('phid in (%Ls)', $phids); $tasks = mpull($tasks, null, 'getPHID'); foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); if (empty($tasks[$phid])) { $handle->setName('Unknown Revision'); } else { $task = $tasks[$phid]; $handle->setName($task->getTitle()); $handle->setURI('/T' . $task->getID()); $handle->setFullName('T' . $task->getID() . ': ' . $task->getTitle()); } $handles[$phid] = $handle; } break; case PhabricatorPHIDConstants::PHID_TYPE_FILE: $class = 'PhabricatorFile'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); $files = $object->loadAllWhere('phid IN (%Ls)', $phids); $files = mpull($files, null, 'getPHID'); foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); if (empty($files[$phid])) { $handle->setName('Unknown File'); } else { $file = $files[$phid]; $handle->setName($file->getName()); $handle->setURI($file->getViewURI()); } $handles[$phid] = $handle; } break; case PhabricatorPHIDConstants::PHID_TYPE_PROJ: $class = 'PhabricatorProject'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); $projects = $object->loadAllWhere('phid IN (%Ls)', $phids); $projects = mpull($projects, null, 'getPHID'); foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); if (empty($projects[$phid])) { $handle->setName('Unknown Project'); } else { $project = $projects[$phid]; $handle->setName($project->getName()); $handle->setURI('/project/view/' . $project->getID() . '/'); } $handles[$phid] = $handle; } break; case PhabricatorPHIDConstants::PHID_TYPE_REPO: $class = 'PhabricatorRepository'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); $repositories = $object->loadAllWhere('phid in (%Ls)', $phids); $repositories = mpull($repositories, null, 'getPHID'); foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); if (empty($repositories[$phid])) { $handle->setName('Unknown Repository'); } else { $repository = $repositories[$phid]; $handle->setName($repository->getCallsign()); $handle->setURI('/diffusion/' . $repository->getCallsign() . '/'); } $handles[$phid] = $handle; } break; case PhabricatorPHIDConstants::PHID_TYPE_OPKG: $class = 'PhabricatorOwnersPackage'; PhutilSymbolLoader::loadClass($class); $object = newv($class, array()); $packages = $object->loadAllWhere('phid in (%Ls)', $phids); $packages = mpull($packages, null, 'getPHID'); foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); if (empty($packages[$phid])) { $handle->setName('Unknown Package'); } else { $package = $packages[$phid]; $handle->setName($package->getName()); $handle->setURI('/owners/package/' . $package->getID() . '/'); } $handles[$phid] = $handle; } break; case PhabricatorPHIDConstants::PHID_TYPE_APRJ: $project_dao = newv('PhabricatorRepositoryArcanistProject', array()); $projects = $project_dao->loadAllWhere('phid IN (%Ls)', $phids); $projects = mpull($projects, null, 'getPHID'); foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); if (empty($projects[$phid])) { $handle->setName('Unknown Arcanist Project'); } else { $project = $projects[$phid]; $handle->setName($project->getName()); } $handles[$phid] = $handle; } break; case PhabricatorPHIDConstants::PHID_TYPE_WIKI: $document_dao = newv('PhrictionDocument', array()); $content_dao = newv('PhrictionContent', array()); $conn = $document_dao->establishConnection('r'); $documents = queryfx_all($conn, 'SELECT * FROM %T document JOIN %T content ON document.contentID = content.id WHERE document.phid IN (%Ls)', $document_dao->getTableName(), $content_dao->getTableName(), $phids); $documents = ipull($documents, null, 'phid'); foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setPHID($phid); $handle->setType($type); if (empty($documents[$phid])) { $handle->setName('Unknown Document'); } else { $info = $documents[$phid]; $handle->setName($info['title']); $handle->setURI(PhrictionDocument::getSlugURI($info['slug'])); } $handles[$phid] = $handle; } break; default: $loader = null; if (isset($external_loaders[$type])) { $loader = $external_loaders[$type]; } else { if (isset($external_loaders['*'])) { $loader = $external_loaders['*']; } } if ($loader) { PhutilSymbolLoader::loadClass($loader); $object = newv($loader, array()); $handles += $object->loadHandles($phids); break; } foreach ($phids as $phid) { $handle = new PhabricatorObjectHandle(); $handle->setType($type); $handle->setPHID($phid); $handle->setName('Unknown Object'); $handle->setFullName('An Unknown Object'); $handles[$phid] = $handle; } break; } } return $handles; }
public function processRequest() { $viewer = $this->getRequest()->getUser(); $user = id(new PhabricatorUser())->loadOneWhere('userName = %s', $this->username); if (!$user) { return new Aphront404Response(); } $profile = id(new PhabricatorUserProfile())->loadOneWhere('userPHID = %s', $user->getPHID()); if (!$profile) { $profile = new PhabricatorUserProfile(); } $links = array(); if ($user->getPHID() == $viewer->getPHID()) { $links[] = phutil_render_tag('a', array('href' => '/settings/page/profile/'), 'Edit Profile'); } $oauths = id(new PhabricatorUserOAuthInfo())->loadAllWhere('userID = %d', $user->getID()); $oauths = mpull($oauths, null, 'getOAuthProvider'); $providers = PhabricatorOAuthProvider::getAllProviders(); foreach ($providers as $provider) { if (!$provider->isProviderEnabled()) { continue; } $provider_key = $provider->getProviderKey(); if (!isset($oauths[$provider_key])) { continue; } $name = $provider->getProviderName() . ' Profile'; $href = $oauths[$provider_key]->getAccountURI(); if ($href) { $links[] = phutil_render_tag('a', array('href' => $href), phutil_escape_html($name)); } } // TODO: perhaps, if someone wants to add to the profile of the user the // ability to show the task/revisions where he is working/commenting // on, this has to be changed to something like // |$this->page = key($pages)|, since the "page" regexp was added to // the aphrontconfiguration. if (empty($links[$this->page])) { $this->page = 'action'; } switch ($this->page) { default: $content = $this->renderBasicInformation($user, $profile); break; } $src_phid = $profile->getProfileImagePHID(); if (!$src_phid) { $src_phid = $user->getProfileImagePHID(); } $picture = PhabricatorFileURI::getViewURIForPHID($src_phid); $title = nonempty($profile->getTitle(), 'Untitled Document'); $realname = '(' . $user->getRealName() . ')'; $profile = new PhabricatorProfileView(); $profile->setProfilePicture($picture); $profile->setProfileNames($user->getUserName(), $realname, $title); foreach ($links as $page => $name) { if (is_integer($page)) { $profile->addProfileItem(phutil_render_tag('span', array(), $name)); } else { $profile->addProfileItem($page); } } $profile->appendChild($content); return $this->buildStandardPageResponse($profile, array('title' => $user->getUsername())); }
public function render($range_start = null, $range_len = null, $mask_force = array()) { // "Top level" renders are initial requests for the whole file, versus // requests for a specific range generated by clicking "show more". We // generate property changes and "shield" UI elements only for toplevel // requests. $this->isTopLevel = $range_start === null && $range_len === null; $this->highlightEngine = PhabricatorSyntaxHighlighter::newEngine(); $this->tryCacheStuff(); $feedback_mask = array(); switch ($this->changeset->getFileType()) { case DifferentialChangeType::FILE_IMAGE: $old = null; $cur = null; $metadata = $this->changeset->getMetadata(); $data = idx($metadata, 'attachment-data'); $old_phid = idx($metadata, 'old:binary-phid'); $new_phid = idx($metadata, 'new:binary-phid'); if ($old_phid || $new_phid) { if ($old_phid) { $old_uri = PhabricatorFileURI::getViewURIForPHID($old_phid); $old = phutil_render_tag('img', array('src' => $old_uri)); } if ($new_phid) { $new_uri = PhabricatorFileURI::getViewURIForPHID($new_phid); $cur = phutil_render_tag('img', array('src' => $new_uri)); } } $output = $this->renderChangesetTable($this->changeset, '<tr>' . '<th></th>' . '<td class="differential-old-image">' . '<div class="differential-image-stage">' . $old . '</div>' . '</td>' . '<th></th>' . '<td class="differential-new-image">' . '<div class="differential-image-stage">' . $cur . '</div>' . '</td>' . '</tr>'); return $output; case DifferentialChangeType::FILE_DIRECTORY: case DifferentialChangeType::FILE_BINARY: $output = $this->renderChangesetTable($this->changeset, null); return $output; } $shield = null; if ($this->isTopLevel && !$this->comments) { if ($this->isGenerated()) { $shield = $this->renderShield("This file contains generated code, which does not normally need " . "to be reviewed.", true); } else { if ($this->isUnchanged()) { if ($this->isWhitespaceOnly()) { $shield = $this->renderShield("This file was changed only by adding or removing trailing " . "whitespace.", false); } else { $shield = $this->renderShield("The contents of this file were not changed.", false); } } else { if ($this->isDeleted()) { $shield = $this->renderShield("This file was completely deleted.", true); } else { if ($this->changeset->getAffectedLineCount() > 2500) { $lines = number_format($this->changeset->getAffectedLineCount()); $shield = $this->renderShield("This file has a very large number of changes ({$lines} lines).", true); } } } } } if ($shield) { return $this->renderChangesetTable($this->changeset, $shield); } $old_comments = array(); $new_comments = array(); $old_mask = array(); $new_mask = array(); $feedback_mask = array(); if ($this->comments) { foreach ($this->comments as $comment) { $start = max($comment->getLineNumber() - self::LINES_CONTEXT, 0); $end = $comment->getLineNumber() + $comment->getLineLength() + self::LINES_CONTEXT; $new = $this->isCommentOnRightSideWhenDisplayed($comment); for ($ii = $start; $ii <= $end; $ii++) { if ($new) { $new_mask[$ii] = true; } else { $old_mask[$ii] = true; } } } foreach ($this->old as $ii => $old) { if (isset($old['line']) && isset($old_mask[$old['line']])) { $feedback_mask[$ii] = true; } } foreach ($this->new as $ii => $new) { if (isset($new['line']) && isset($new_mask[$new['line']])) { $feedback_mask[$ii] = true; } } $this->comments = msort($this->comments, 'getID'); foreach ($this->comments as $comment) { $final = $comment->getLineNumber() + $comment->getLineLength(); if ($this->isCommentOnRightSideWhenDisplayed($comment)) { $new_comments[$final][] = $comment; } else { $old_comments[$final][] = $comment; } } } $html = $this->renderTextChange($range_start, $range_len, $mask_force, $feedback_mask, $old_comments, $new_comments); return $this->renderChangesetTable($this->changeset, $html); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $this->phid); if (!$file) { return new Aphront404Response(); } switch ($this->view) { case 'download': case 'view': $data = $file->loadFileData(); $response = new AphrontFileResponse(); $response->setContent($data); $response->setCacheDurationInSeconds(60 * 60 * 24 * 30); if ($this->view == 'view') { if (!$file->isViewableInBrowser()) { return new Aphront400Response(); } $download = false; } else { $download = true; } if ($download) { $mime_type = $file->getMimeType(); } else { $mime_type = $file->getViewableMimeType(); } $response->setMimeType($mime_type); if ($download) { $response->setDownload($file->getName()); } return $response; default: break; } $author_child = null; if ($file->getAuthorPHID()) { $author = id(new PhabricatorUser())->loadOneWhere('phid = %s', $file->getAuthorPHID()); if ($author) { $author_child = id(new AphrontFormStaticControl())->setLabel('Author')->setName('author')->setValue($author->getUserName()); } } $form = new AphrontFormView(); if ($file->isViewableInBrowser()) { $form->setAction('/file/view/' . $file->getPHID() . '/'); $button_name = 'View File'; } else { $form->setAction('/file/download/' . $file->getPHID() . '/'); $button_name = 'Download File'; } $file_id = 'F' . $file->getID(); $form->setUser($user); $form->appendChild(id(new AphrontFormStaticControl())->setLabel('Name')->setName('name')->setValue($file->getName()))->appendChild(id(new AphrontFormStaticControl())->setLabel('ID')->setName('id')->setValue($file_id)->setCaption('Download this file with: <tt>arc download ' . phutil_escape_html($file_id) . '</tt>'))->appendChild(id(new AphrontFormStaticControl())->setLabel('PHID')->setName('phid')->setValue($file->getPHID()))->appendChild($author_child)->appendChild(id(new AphrontFormStaticControl())->setLabel('Created')->setName('created')->setValue(phabricator_datetime($file->getDateCreated(), $user)))->appendChild(id(new AphrontFormStaticControl())->setLabel('Mime Type')->setName('mime')->setValue($file->getMimeType()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Size')->setName('size')->setValue($file->getByteSize() . ' bytes'))->appendChild(id(new AphrontFormStaticControl())->setLabel('Engine')->setName('storageEngine')->setValue($file->getStorageEngine()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Format')->setName('storageFormat')->setValue($file->getStorageFormat()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Handle')->setName('storageHandle')->setValue($file->getStorageHandle()))->appendChild(id(new AphrontFormSubmitControl())->setValue($button_name)); $panel = new AphrontPanelView(); $panel->setHeader('File Info - ' . $file->getName()); $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $transformations = id(new PhabricatorTransformedFile())->loadAllWhere('originalPHID = %s', $file->getPHID()); $rows = array(); foreach ($transformations as $transformed) { $phid = $transformed->getTransformedPHID(); $rows[] = array(phutil_escape_html($transformed->getTransform()), phutil_render_tag('a', array('href' => PhabricatorFileURI::getViewURIForPHID($phid)), $phid)); } $table = new AphrontTableView($rows); $table->setHeaders(array('Transform', 'File')); $xform_panel = new AphrontPanelView(); $xform_panel->appendChild($table); $xform_panel->setWidth(AphrontPanelView::WIDTH_FORM); $xform_panel->setHeader('Transformations'); return $this->buildStandardPageResponse(array($panel, $xform_panel), array('title' => 'File Info - ' . $file->getName())); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $file = id(new PhabricatorFile())->loadOneWhere('phid = %s', $this->phid); if (!$file) { return new Aphront404Response(); } switch ($this->view) { case 'download': case 'view': $data = $file->loadFileData(); $response = new AphrontFileResponse(); $response->setContent($data); $response->setCacheDurationInSeconds(60 * 60 * 24 * 30); if ($this->view == 'view') { if (!$file->isViewableInBrowser()) { return new Aphront400Response(); } $download = false; } else { $download = true; } if ($download) { if (!$request->isFormPost()) { // Require a POST to download files to hinder attacks where you // <applet src="http://phabricator.example.com/file/..." /> on some // other domain. return id(new AphrontRedirectResponse())->setURI($file->getInfoURI()); } } if ($download) { $mime_type = $file->getMimeType(); } else { $mime_type = $file->getViewableMimeType(); } // If an alternate file domain is configured, forbid all views which // don't originate from it. if (!$download) { $alt = PhabricatorEnv::getEnvConfig('security.alternate-file-domain'); if ($alt) { $domain = id(new PhutilURI($alt))->getDomain(); if ($domain != $request->getHost()) { return new Aphront400Response(); } } } $response->setMimeType($mime_type); if ($download) { $response->setDownload($file->getName()); } return $response; default: break; } $author_child = null; if ($file->getAuthorPHID()) { $author = id(new PhabricatorUser())->loadOneWhere('phid = %s', $file->getAuthorPHID()); if ($author) { $author_child = id(new AphrontFormStaticControl())->setLabel('Author')->setName('author')->setValue($author->getUserName()); } } $form = new AphrontFormView(); if ($file->isViewableInBrowser()) { $form->setAction($file->getViewURI()); $button_name = 'View File'; } else { $form->setAction('/file/download/' . $file->getPHID() . '/'); $button_name = 'Download File'; } $file_id = 'F' . $file->getID(); $form->setUser($user); $form->appendChild(id(new AphrontFormStaticControl())->setLabel('Name')->setName('name')->setValue($file->getName()))->appendChild(id(new AphrontFormStaticControl())->setLabel('ID')->setName('id')->setValue($file_id)->setCaption('Download this file with: <tt>arc download ' . phutil_escape_html($file_id) . '</tt>'))->appendChild(id(new AphrontFormStaticControl())->setLabel('PHID')->setName('phid')->setValue($file->getPHID()))->appendChild($author_child)->appendChild(id(new AphrontFormStaticControl())->setLabel('Created')->setName('created')->setValue(phabricator_datetime($file->getDateCreated(), $user)))->appendChild(id(new AphrontFormStaticControl())->setLabel('Mime Type')->setName('mime')->setValue($file->getMimeType()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Size')->setName('size')->setValue($file->getByteSize() . ' bytes'))->appendChild(id(new AphrontFormStaticControl())->setLabel('Engine')->setName('storageEngine')->setValue($file->getStorageEngine()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Format')->setName('storageFormat')->setValue($file->getStorageFormat()))->appendChild(id(new AphrontFormStaticControl())->setLabel('Handle')->setName('storageHandle')->setValue($file->getStorageHandle()))->appendChild(id(new AphrontFormSubmitControl())->setValue($button_name)); $panel = new AphrontPanelView(); $panel->setHeader('File Info - ' . $file->getName()); $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FORM); $transformations = id(new PhabricatorTransformedFile())->loadAllWhere('originalPHID = %s', $file->getPHID()); $rows = array(); foreach ($transformations as $transformed) { $phid = $transformed->getTransformedPHID(); $rows[] = array(phutil_escape_html($transformed->getTransform()), phutil_render_tag('a', array('href' => PhabricatorFileURI::getViewURIForPHID($phid)), $phid)); } $table = new AphrontTableView($rows); $table->setHeaders(array('Transform', 'File')); $xform_panel = new AphrontPanelView(); $xform_panel->appendChild($table); $xform_panel->setWidth(AphrontPanelView::WIDTH_FORM); $xform_panel->setHeader('Transformations'); return $this->buildStandardPageResponse(array($panel, $xform_panel), array('title' => 'File Info - ' . $file->getName())); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $profile = id(new PhabricatorUserProfile())->loadOneWhere('userPHID = %s', $user->getPHID()); if (!$profile) { $profile = new PhabricatorUserProfile(); $profile->setUserPHID($user->getPHID()); } $errors = array(); if ($request->isFormPost()) { $profile->setTitle($request->getStr('title')); $profile->setBlurb($request->getStr('blurb')); if (!empty($_FILES['image'])) { $err = idx($_FILES['image'], 'error'); if ($err != UPLOAD_ERR_NO_FILE) { $file = PhabricatorFile::newFromPHPUpload($_FILES['image'], array('authorPHID' => $user->getPHID())); $okay = $file->isTransformableImage(); if ($okay) { $xformer = new PhabricatorImageTransformer(); // Generate the large picture for the profile page. $large_xformed = $xformer->executeProfileTransform($file, $width = 280, $min_height = 140, $max_height = 420); $profile->setProfileImagePHID($large_xformed->getPHID()); // Generate the small picture for comments, etc. $small_xformed = $xformer->executeProfileTransform($file, $width = 50, $min_height = 50, $max_height = 50); $user->setProfileImagePHID($small_xformed->getPHID()); } else { $errors[] = 'Only valid image files (jpg, jpeg, png or gif) ' . 'will be accepted.'; } } } if (!$errors) { $user->save(); $profile->save(); $response = id(new AphrontRedirectResponse())->setURI('/settings/page/profile/?saved=true'); return $response; } } $error_view = null; if ($errors) { $error_view = new AphrontErrorView(); $error_view->setTitle('Form Errors'); $error_view->setErrors($errors); } else { if ($request->getStr('saved')) { $error_view = new AphrontErrorView(); $error_view->setSeverity(AphrontErrorView::SEVERITY_NOTICE); $error_view->setTitle('Changes Saved'); $error_view->appendChild('<p>Your changes have been saved.</p>'); $error_view = $error_view->render(); } } $img_src = PhabricatorFileURI::getViewURIForPHID($user->getProfileImagePHID()); $profile_uri = PhabricatorEnv::getURI('/p/' . $user->getUsername() . '/'); $form = new AphrontFormView(); $form->setUser($request->getUser())->setAction('/settings/page/profile/')->setEncType('multipart/form-data')->appendChild(id(new AphrontFormTextControl())->setLabel('Title')->setName('title')->setValue($profile->getTitle())->setCaption('Serious business title.'))->appendChild(id(new AphrontFormMarkupControl())->setLabel('Profile URI')->setValue(phutil_render_tag('a', array('href' => $profile_uri), phutil_escape_html($profile_uri))))->appendChild('<p class="aphront-form-instructions">Write something about yourself! ' . 'Make sure to include <strong>important information</strong> like ' . 'your favorite pokemon and which Starcraft race you play.</p>')->appendChild(id(new AphrontFormTextAreaControl())->setLabel('Blurb')->setName('blurb')->setValue($profile->getBlurb()))->appendChild(id(new AphrontFormMarkupControl())->setLabel('Profile Image')->setValue(phutil_render_tag('img', array('src' => $img_src))))->appendChild(id(new AphrontFormFileControl())->setLabel('Change Image')->setName('image'))->appendChild(id(new AphrontFormSubmitControl())->setValue('Save')->addCancelButton('/p/' . $user->getUsername() . '/')); $panel = new AphrontPanelView(); $panel->setHeader('Edit Profile Details'); $panel->appendChild($form); $panel->setWidth(AphrontPanelView::WIDTH_FORM); return id(new AphrontNullView())->appendChild(array($error_view, $panel)); }
private function buildTransformedFileResponse(PhabricatorTransformedFile $xform) { // TODO: We could just delegate to the file view controller instead, // which would save the client a roundtrip, but is slightly more complex. return id(new AphrontRedirectResponse())->setURI(PhabricatorFileURI::getViewURIForPHID($xform->getTransformedPHID())); }
public function processRequest() { $viewer = $this->getRequest()->getUser(); $user = id(new PhabricatorUser())->loadOneWhere('userName = %s', $this->username); if (!$user) { return new Aphront404Response(); } require_celerity_resource('phabricator-profile-css'); $profile = id(new PhabricatorUserProfile())->loadOneWhere('userPHID = %s', $user->getPHID()); if (!$profile) { $profile = new PhabricatorUserProfile(); } $nav = new AphrontSideNavFilterView(); $nav->setBaseURI(new PhutilURI('/p/' . $user->getUserName() . '/')); $nav->addFilter('feed', 'Feed'); $nav->addFilter('about', 'About'); $nav->addSpacer(); $nav->addLabel('Activity'); $external_arrow = "↗"; $nav->addFilter(null, "Revisions {$external_arrow}", '/differential/filter/revisions/?phid=' . $user->getPHID()); $nav->addFilter(null, "Tasks {$external_arrow}", '/maniphest/view/action/?users=' . $user->getPHID()); $nav->addFilter(null, "Commits {$external_arrow}", '/diffusion/author/' . $user->getUserName() . '/'); $oauths = id(new PhabricatorUserOAuthInfo())->loadAllWhere('userID = %d', $user->getID()); $oauths = mpull($oauths, null, 'getOAuthProvider'); $providers = PhabricatorOAuthProvider::getAllProviders(); $added_spacer = false; foreach ($providers as $provider) { if (!$provider->isProviderEnabled()) { continue; } $provider_key = $provider->getProviderKey(); if (!isset($oauths[$provider_key])) { continue; } $name = $provider->getProviderName() . ' Profile'; $href = $oauths[$provider_key]->getAccountURI(); if ($href) { if (!$added_spacer) { $nav->addSpacer(); $nav->addLabel('Linked Accounts'); $added_spacer = true; } $nav->addFilter(null, $name . ' ' . $external_arrow, $href); } } $this->page = $nav->selectFilter($this->page, 'feed'); switch ($this->page) { case 'feed': $content = $this->renderUserFeed($user); break; case 'about': $content = $this->renderBasicInformation($user, $profile); break; default: throw new Exception("Unknown page '{$this->page}'!"); } $src_phid = $user->getProfileImagePHID(); $picture = PhabricatorFileURI::getViewURIForPHID($src_phid); $header = new PhabricatorProfileHeaderView(); $header->setProfilePicture($picture)->setName($user->getUserName() . ' (' . $user->getRealName() . ')')->setDescription($profile->getTitle()); $header->appendChild($nav); $nav->appendChild('<div style="padding: 1em;">' . $content . '</div>'); if ($user->getPHID() == $viewer->getPHID()) { $nav->addSpacer(); $nav->addFilter(null, 'Edit Profile...', '/settings/page/profile/'); } return $this->buildStandardPageResponse($header, array('title' => $user->getUsername())); }
public function getViewURI() { return PhabricatorFileURI::getViewURIForPHID($this->getPHID()); }
private function renderResultMarkup(PhabricatorSlowvotePoll $poll, array $options, array $choices, array $comments, array $viewer_choices, array $choices_by_option, array $comments_by_option, array $handles, array $objects) { $viewer_phid = $this->getRequest()->getUser()->getPHID(); $can_see_responses = false; $need_vote = false; switch ($poll->getResponseVisibility()) { case PhabricatorSlowvotePoll::RESPONSES_VISIBLE: $can_see_responses = true; break; case PhabricatorSlowvotePoll::RESPONSES_VOTERS: $can_see_responses = (bool) $viewer_choices; $need_vote = true; break; case PhabricatorSlowvotePoll::RESPONSES_OWNER: $can_see_responses = $viewer_phid == $poll->getAuthorPHID(); break; } $result_markup = id(new AphrontFormLayoutView())->appendChild('<h1>Ongoing Deliberation</h1>'); if (!$can_see_responses) { if ($need_vote) { $reason = "You must vote to see the results."; } else { $reason = "The results are not public."; } $result_markup->appendChild('<p class="aphront-form-instructions"><em>' . $reason . '</em></p>'); return $result_markup; } foreach ($options as $option) { $id = $option->getID(); $chosen = idx($choices_by_option, $id, array()); $users = array_select_keys($handles, mpull($chosen, 'getAuthorPHID')); if ($users) { $user_markup = array(); foreach ($users as $handle) { $object = idx($objects, $handle->getPHID()); if (!$object) { continue; } $profile_image = PhabricatorFileURI::getViewURIForPHID($object->getProfileImagePHID()); $user_markup[] = phutil_render_tag('a', array('href' => $handle->getURI(), 'class' => 'phabricator-slowvote-facepile'), phutil_render_tag('img', array('src' => $profile_image))); } $user_markup = implode('', $user_markup); } else { $user_markup = 'This option has failed to appeal to anyone.'; } $comment_markup = $this->renderComments(idx($comments_by_option, $id, array()), $handles); $vote_count = $this->renderVoteCount($poll, $choices, $chosen); $result_markup->appendChild('<div>' . '<div class="phabricator-slowvote-count">' . $vote_count . '</div>' . '<h1>' . phutil_escape_html($option->getName()) . '</h1>' . '<hr class="phabricator-slowvote-hr" />' . $user_markup . '<div style="clear: both;">' . '<hr class="phabricator-slowvote-hr" />' . $comment_markup . '</div>'); } if ($poll->getMethod() == PhabricatorSlowvotePoll::METHOD_APPROVAL && $comments) { $comment_markup = $this->renderComments($comments, $handles); $result_markup->appendChild('<h1>Motions Proposed for Consideration</h1>'); $result_markup->appendChild($comment_markup); } return $result_markup; }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $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); $nav_view = new AphrontSideNavFilterView(); $uri = new PhutilURI('/project/view/' . $project->getID() . '/'); $nav_view->setBaseURI($uri); $external_arrow = "↗"; $tasks_uri = '/maniphest/view/all/?projects=' . $project->getPHID(); $slug = PhrictionDocument::normalizeSlug($project->getName()); $phriction_uri = '/w/projects/' . $slug . '/'; $edit_uri = '/project/edit/' . $project->getID() . '/'; $nav_view->addFilter('dashboard', 'Dashboard'); $nav_view->addSpacer(); $nav_view->addFilter('feed', 'Feed'); $nav_view->addFilter(null, 'Tasks ' . $external_arrow, $tasks_uri); $nav_view->addFilter(null, 'Wiki ' . $external_arrow, $phriction_uri); $nav_view->addFilter('people', 'People'); $nav_view->addFilter('about', 'About'); $nav_view->addSpacer(); $nav_view->addFilter(null, "Edit Project…", $edit_uri); $this->page = $nav_view->selectFilter($this->page, 'dashboard'); require_celerity_resource('phabricator-profile-css'); switch ($this->page) { case 'dashboard': $content = $this->renderTasksPage($project, $profile); $query = new PhabricatorFeedQuery(); $query->setFilterPHIDs(array($project->getPHID())); $stories = $query->execute(); $content .= $this->renderStories($stories); break; case 'about': $content = $this->renderAboutPage($project, $profile); break; case 'people': $content = $this->renderPeoplePage($project, $profile); break; case 'feed': $content = $this->renderFeedPage($project, $profile); break; default: throw new Exception("Unimplemented filter '{$this->page}'."); } $content = '<div style="padding: 1em;">' . $content . '</div>'; $nav_view->appendChild($content); $header = new PhabricatorProfileHeaderView(); $header->setName($project->getName()); $header->setDescription(phutil_utf8_shorten($profile->getBlurb(), 1024)); $header->setProfilePicture($picture); $header->appendChild($nav_view); return $this->buildStandardPageResponse($header, array('title' => $project->getName() . ' Project')); }