当前位置: 首页>>代码示例>>PHP>>正文


PHP PhabricatorFile::loadBuiltin方法代码示例

本文整理汇总了PHP中PhabricatorFile::loadBuiltin方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorFile::loadBuiltin方法的具体用法?PHP PhabricatorFile::loadBuiltin怎么用?PHP PhabricatorFile::loadBuiltin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhabricatorFile的用法示例。


在下文中一共展示了PhabricatorFile::loadBuiltin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: didFilterPage

 protected function didFilterPage(array $blogs)
 {
     if ($this->needProfileImage) {
         $default = null;
         $file_phids = mpull($blogs, 'getProfileImagePHID');
         $file_phids = array_filter($file_phids);
         if ($file_phids) {
             $files = id(new PhabricatorFileQuery())->setParentQuery($this)->setViewer($this->getViewer())->withPHIDs($file_phids)->execute();
             $files = mpull($files, null, 'getPHID');
         } else {
             $files = array();
         }
         foreach ($blogs as $blog) {
             $file = idx($files, $blog->getProfileImagePHID());
             if (!$file) {
                 if (!$default) {
                     $default = PhabricatorFile::loadBuiltin($this->getViewer(), 'blog.png');
                 }
                 $file = $default;
             }
             $blog->attachProfileImageFile($file);
         }
     }
     return $blogs;
 }
开发者ID:truSense,项目名称:phabricator,代码行数:25,代码来源:PhameBlogQuery.php

示例2: willFilterPage

 protected function willFilterPage(array $merchants)
 {
     $query = id(new PhabricatorEdgeQuery())->withSourcePHIDs(mpull($merchants, 'getPHID'))->withEdgeTypes(array(PhortuneMerchantHasMemberEdgeType::EDGECONST));
     $query->execute();
     foreach ($merchants as $merchant) {
         $member_phids = $query->getDestinationPHIDs(array($merchant->getPHID()));
         $member_phids = array_reverse($member_phids);
         $merchant->attachMemberPHIDs($member_phids);
     }
     if ($this->needProfileImage) {
         $default = null;
         $file_phids = mpull($merchants, 'getProfileImagePHID');
         $file_phids = array_filter($file_phids);
         if ($file_phids) {
             $files = id(new PhabricatorFileQuery())->setParentQuery($this)->setViewer($this->getViewer())->withPHIDs($file_phids)->execute();
             $files = mpull($files, null, 'getPHID');
         } else {
             $files = array();
         }
         foreach ($merchants as $merchant) {
             $file = idx($files, $merchant->getProfileImagePHID());
             if (!$file) {
                 if (!$default) {
                     $default = PhabricatorFile::loadBuiltin($this->getViewer(), 'merchant.png');
                 }
                 $file = $default;
             }
             $merchant->attachProfileImageFile($file);
         }
     }
     return $merchants;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:32,代码来源:PhortuneMerchantQuery.php

示例3: generateImages

 public function generateImages()
 {
     $images = newv('PhabricatorFile', array())->loadAllWhere('mimeType = %s', 'image/jpeg');
     $rand_images = array();
     $quantity = rand(2, 10);
     $quantity = min($quantity, count($images));
     foreach (array_rand($images, $quantity) as $random) {
         $rand_images[] = $images[$random]->getPHID();
     }
     // this means you don't have any jpegs yet. we'll
     // just use a builtin image
     if (empty($rand_images)) {
         $default = PhabricatorFile::loadBuiltin(PhabricatorUser::getOmnipotentUser(), 'profile.png');
         $rand_images[] = $default->getPHID();
     }
     return $rand_images;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:17,代码来源:PhabricatorPholioMockTestDataGenerator.php

示例4: calculateBehaviorConfig

 private function calculateBehaviorConfig()
 {
     $mock = $this->getMock();
     // TODO: We could maybe do a better job with tailoring this, which is the
     // image shown on the review stage.
     $viewer = $this->getUser();
     $default = PhabricatorFile::loadBuiltin($viewer, 'image-100x100.png');
     $engine = id(new PhabricatorMarkupEngine())->setViewer($this->getUser());
     foreach ($mock->getAllImages() as $image) {
         $engine->addObject($image, 'default');
     }
     $engine->process();
     $images = array();
     $current_set = 0;
     foreach ($mock->getAllImages() as $image) {
         $file = $image->getFile();
         $metadata = $file->getMetadata();
         $x = idx($metadata, PhabricatorFile::METADATA_IMAGE_WIDTH);
         $y = idx($metadata, PhabricatorFile::METADATA_IMAGE_HEIGHT);
         $is_obs = (bool) $image->getIsObsolete();
         if (!$is_obs) {
             $current_set++;
         }
         $description = $engine->getOutput($image, 'default');
         if (strlen($description)) {
             $description = phutil_tag('div', array('class' => 'phabricator-remarkup'), $description);
         }
         $history_uri = '/pholio/image/history/' . $image->getID() . '/';
         $images[] = array('id' => $image->getID(), 'fullURI' => $file->getBestURI(), 'stageURI' => $file->isViewableImage() ? $file->getBestURI() : $default->getBestURI(), 'pageURI' => $this->getImagePageURI($image, $mock), 'downloadURI' => $file->getDownloadURI(), 'historyURI' => $history_uri, 'width' => $x, 'height' => $y, 'title' => $image->getName(), 'descriptionMarkup' => $description, 'isObsolete' => (bool) $image->getIsObsolete(), 'isImage' => $file->isViewableImage(), 'isViewable' => $file->isViewableInBrowser());
     }
     $ids = mpull($mock->getImages(), 'getID');
     if ($this->imageID && isset($ids[$this->imageID])) {
         $selected_id = $this->imageID;
     } else {
         $selected_id = head_key($ids);
     }
     $navsequence = array();
     foreach ($mock->getImages() as $image) {
         $navsequence[] = $image->getID();
     }
     $full_icon = array(javelin_tag('span', array('aural' => true), pht('View Raw File')), id(new PHUIIconView())->setIcon('fa-file-image-o'));
     $download_icon = array(javelin_tag('span', array('aural' => true), pht('Download File')), id(new PHUIIconView())->setIcon('fa-download'));
     $login_uri = id(new PhutilURI('/login/'))->setQueryParam('next', (string) $this->getRequestURI());
     $config = array('mockID' => $mock->getID(), 'panelID' => $this->panelID, 'viewportID' => $this->viewportID, 'commentFormID' => $this->getCommentFormID(), 'images' => $images, 'selectedID' => $selected_id, 'loggedIn' => $this->getUser()->isLoggedIn(), 'logInLink' => (string) $login_uri, 'navsequence' => $navsequence, 'fullIcon' => hsprintf('%s', $full_icon), 'downloadIcon' => hsprintf('%s', $download_icon), 'currentSetSize' => $current_set);
     return $config;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:46,代码来源:PholioMockImagesView.php

示例5: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $this->getViewer();
     $id = $request->getURIData('id');
     $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withIDs(array($id))->needProfileImage(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$user) {
         return new Aphront404Response();
     }
     $this->setUser($user);
     $done_uri = $this->getApplicationURI("manage/{$id}/");
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $phid = $request->getStr('phid');
         $is_default = false;
         if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
             $phid = null;
             $is_default = true;
         } else {
             if ($phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             } else {
                 if ($request->getFileExists('picture')) {
                     $file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
                 } else {
                     $e_file = pht('Required');
                     $errors[] = pht('You must choose a file when uploading a new profile picture.');
                 }
             }
         }
         if (!$errors && !$is_default) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             } else {
                 $xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
                 $xformed = $xform->executeTransform($file);
             }
         }
         if (!$errors) {
             if ($is_default) {
                 $user->setProfileImagePHID(null);
             } else {
                 $user->setProfileImagePHID($xformed->getPHID());
                 $xformed->attachToObject($user->getPHID());
             }
             $user->save();
             return id(new AphrontRedirectResponse())->setURI($done_uri);
         }
     }
     $title = pht('Edit Profile Picture');
     $form = id(new PHUIFormLayoutView())->setUser($viewer);
     $default_image = PhabricatorFile::loadBuiltin($viewer, 'profile.png');
     $images = array();
     $current = $user->getProfileImagePHID();
     $has_current = false;
     if ($current) {
         $files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->execute();
         if ($files) {
             $file = head($files);
             if ($file->isTransformableImage()) {
                 $has_current = true;
                 $images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
             }
         }
     }
     $builtins = array('user1.png', 'user2.png', 'user3.png', 'user4.png', 'user5.png', 'user6.png', 'user7.png', 'user8.png', 'user9.png');
     foreach ($builtins as $builtin) {
         $file = PhabricatorFile::loadBuiltin($viewer, $builtin);
         $images[$file->getPHID()] = array('uri' => $file->getBestURI(), 'tip' => pht('Builtin Image'));
     }
     // Try to add external account images for any associated external accounts.
     $accounts = id(new PhabricatorExternalAccountQuery())->setViewer($viewer)->withUserPHIDs(array($user->getPHID()))->needImages(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
     foreach ($accounts as $account) {
         $file = $account->getProfileImageFile();
         if ($account->getProfileImagePHID() != $file->getPHID()) {
             // This is a default image, just skip it.
             continue;
         }
         $provider = PhabricatorAuthProvider::getEnabledProviderByKey($account->getProviderKey());
         if ($provider) {
             $tip = pht('Picture From %s', $provider->getProviderName());
         } else {
             $tip = pht('Picture From External Account');
         }
         if ($file->isTransformableImage()) {
             $images[$file->getPHID()] = array('uri' => $file->getBestURI(), 'tip' => $tip);
         }
     }
     $images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
     require_celerity_resource('people-profile-css');
     Javelin::initBehavior('phabricator-tooltips', array());
     $buttons = array();
     foreach ($images as $phid => $spec) {
         $button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
         $button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
         $button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
         $buttons[] = $button;
     }
//.........这里部分代码省略.........
开发者ID:chirag-goel,项目名称:phabricator,代码行数:101,代码来源:PhabricatorPeopleProfilePictureController.php

示例6: didFilterPage

 protected function didFilterPage(array $images)
 {
     assert_instances_of($images, 'PholioImage');
     $file_phids = mpull($images, 'getFilePHID');
     $all_files = id(new PhabricatorFileQuery())->setParentQuery($this)->setViewer($this->getViewer())->withPHIDs($file_phids)->execute();
     $all_files = mpull($all_files, null, 'getPHID');
     if ($this->needInlineComments) {
         // Only load inline comments the viewer has permission to see.
         $all_inline_comments = id(new PholioTransactionComment())->loadAllWhere('imageID IN (%Ld)
       AND (transactionPHID IS NOT NULL OR authorPHID = %s)', mpull($images, 'getID'), $this->getViewer()->getPHID());
         $all_inline_comments = mgroup($all_inline_comments, 'getImageID');
     }
     foreach ($images as $image) {
         $file = idx($all_files, $image->getFilePHID());
         if (!$file) {
             $file = PhabricatorFile::loadBuiltin($this->getViewer(), 'missing.png');
         }
         $image->attachFile($file);
         if ($this->needInlineComments) {
             $inlines = idx($all_inline_comments, $image->getID(), array());
             $image->attachInlineComments($inlines);
         }
     }
     return $images;
 }
开发者ID:rchicoli,项目名称:phabricator,代码行数:25,代码来源:PholioImageQuery.php

示例7: renderExample

 public function renderExample()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $handle = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(array($user->getPHID()))->executeOne();
     $out = array();
     $head = id(new PHUIHeaderView())->setHeader(pht('Basic List'));
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('FRUIT1')->setHeader(pht('Apple'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('FRUIT2')->setHeader(pht('Banana'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('FRUIT3')->setHeader(pht('Cherry'))->setHref('#'));
     $out[] = array($head, $list);
     $head = id(new PHUIHeaderView())->setHeader(pht('Empty List'));
     $list = new PHUIObjectItemListView();
     $list->setNoDataString(pht('This list is empty.'));
     $out[] = array($head, $list);
     $head = id(new PHUIHeaderView())->setHeader(pht('Stacked List'));
     $list = new PHUIObjectItemListView();
     $list->setStackable(true);
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Monday'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Tuesday'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Wednesday'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Thursday'))->setHref('#'));
     $out[] = array($head, $list);
     $head = id(new PHUIHeaderView())->setHeader(pht('Plain List'));
     $list = new PHUIObjectItemListView();
     $list->setPlain(true);
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Monday'))->setSubHead('I love cats')->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Tuesday'))->setSubHead('Cat, cats, cats')->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Wednesday'))->setSubHead('Meow, meow, meow')->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Thursday'))->setSubHead('Every single day')->setHref('#'));
     $out[] = array($head, $list);
     $head = id(new PHUIHeaderView())->setHeader(pht('Card List'));
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Business Card'))->setBarColor('red'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Playing Card'))->setBarColor('orange')->addIcon('fa-comment', pht('Royal Flush!')));
     $owner = phutil_tag('a', array('href' => '#'), pht('jackofclubs'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('House of Cards'))->setBarColor('yellow')->setDisabled(true)->addByline(pht('Owner: %s', $owner)));
     $author = phutil_tag('a', array('href' => '#'), pht('agoat'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Cardigan'))->setBarColor('green')->addIcon('fa-star', pht('Warm!'))->addByline(pht('Author: %s', $author)));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Cardamom'))->addFootIcon('fa-shield white', 'Spice')->setBarColor('blue'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('The human cardiovascular system includes the heart, lungs, and ' . 'some other parts; most of these parts are pretty squishy'))->addFootIcon('fa-search white', pht('Respiration!'))->addHandleIcon($handle, pht('You have a cardiovascular system!'))->setBarColor('indigo'));
     $out[] = array($head, $list);
     $head = id(new PHUIHeaderView())->setHeader(pht('Grippable List'));
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Grab ahold!'))->setHref('#')->setGrippable(true)->setBarColor('red'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Hold on tight!'))->setHref('#')->setGrippable(true)->setBarColor('yellow'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht("Don't let go!"))->setHref('#')->setGrippable(true)->setBarColor('green')->addAction(id(new PHUIListItemView())->setHref('#')->setIcon('fa-times')));
     $out[] = array($head, $list);
     $head = id(new PHUIHeaderView())->setHeader(pht('List With Actions'));
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('You Have The Power'))->setHref('#')->setBarColor('blue')->addAction(id(new PHUIListItemView())->setHref('#')->setName(pht('Moo'))->setIcon('fa-pencil')));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Believe In Yourself'))->setHref('#')->setBarColor('violet')->addAction(id(new PHUIListItemView())->setHref('#')->setName(pht('Quack'))->setIcon('fa-pencil'))->addAction(id(new PHUIListItemView())->setHref('#')->setName(pht('Oink'))->setIcon('fa-times')));
     $out[] = array($head, $list);
     $head = id(new PHUIHeaderView())->setHeader(pht('Extras'));
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Ace of Hearts'))->setSubHead(pht('This is a powerful card in the game "Hearts".'))->setHref('#')->addAttribute(pht('Suit: Hearts'))->addAttribute(pht('Rank: Ace'))->addIcon('fa-heart', pht('Ace'))->addIcon('fa-heart red', pht('Hearts'))->addFootIcon('fa-heart white', pht('Ace'))->addFootIcon('fa-heart white', pht('Heart'))->addHandleIcon($handle, pht('You hold all the cards.'))->addHandleIcon($handle, pht('You make all the rules.')));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Just A Handle'))->setHref('#')->addHandleIcon($handle, pht('Handle Here')));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Poor Use of Space'))->setHref('#')->addAttribute('North West')->addHandleIcon($handle, pht('South East')));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Crowded Eastern Edge'))->setHref('#')->addIcon('fa-circle red', pht('Stuff'))->addIcon('fa-circle yellow', pht('Stuff'))->addIcon('fa-circle green', pht('Stuff'))->addHandleIcon($handle, pht('More Stuff')));
     $out[] = array($head, $list);
     $head = id(new PHUIHeaderView())->setHeader(pht('Effects'));
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X1')->setHeader(pht('Normal'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X2')->setHeader(pht('Highlighted'))->setEffect('highlighted')->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X3')->setHeader(pht('Selected'))->setEffect('selected')->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X4')->setHeader(pht('Disabled'))->setDisabled(true)->setHref('#'));
     $out[] = array($head, $list);
     $head = id(new PHUIHeaderView())->setHeader(pht('Colors'));
     $list = new PHUIObjectItemListView();
     $bar_colors = array(null => pht('None'), 'red' => pht('Red'), 'orange' => pht('Orange'), 'yellow' => pht('Yellow'), 'green' => pht('Green'), 'sky' => pht('Sky'), 'blue' => pht('Blue'), 'indigo' => pht('Indigo'), 'violet' => pht('Violet'), 'grey' => pht('Grey'), 'black' => pht('Black'));
     foreach ($bar_colors as $bar_color => $bar_label) {
         $list->addItem(id(new PHUIObjectItemView())->setHeader($bar_label)->setBarColor($bar_color));
     }
     $out[] = array($head, $list);
     $head = id(new PHUIHeaderView())->setHeader(pht('Images'));
     $list = new PHUIObjectItemListView();
     $default_profile = PhabricatorFile::loadBuiltin($user, 'profile.png');
     $default_project = PhabricatorFile::loadBuiltin($user, 'project.png');
     $list->addItem(id(new PHUIObjectItemView())->setImageURI($default_profile->getViewURI())->setHeader(pht('Default User Profile Image'))->setBarColor('violet')->addAction(id(new PHUIListItemView())->setHref('#')->setIcon('fa-plus-square')));
     $list->addItem(id(new PHUIObjectItemView())->setImageURI($default_project->getViewURI())->setHeader(pht('Default Project Profile Image'))->setGrippable(true)->addAttribute(pht('This is the default project profile image.')));
     $out[] = array($head, $list);
     $head = id(new PHUIHeaderView())->setHeader(pht('States'));
     $list = id(new PHUIObjectItemListView())->setStates(true);
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X1200')->setHeader(pht('Action Passed'))->addAttribute(pht('That went swimmingly, go you'))->setHref('#')->setState(PHUIObjectItemView::STATE_SUCCESS));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X1201')->setHeader(pht('Action Failed'))->addAttribute(pht('Whoopsies, might want to fix that'))->setHref('#')->setState(PHUIObjectItemView::STATE_FAIL));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X1202')->setHeader(pht('Action Warning'))->addAttribute(pht('We need to talk about things'))->setHref('#')->setState(PHUIObjectItemView::STATE_WARN));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X1203')->setHeader(pht('Action Noted'))->addAttribute(pht('The weather seems nice today'))->setHref('#')->setState(PHUIObjectItemView::STATE_NOTE));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X1203')->setHeader(pht('Action In Progress'))->addAttribute(pht('Outlook fuzzy, try again later'))->setHref('#')->setState(PHUIObjectItemView::STATE_BUILD));
     $box = id(new PHUIObjectBoxView())->setHeaderText('Test Things')->appendChild($list);
     $out[] = array($head, $box);
     return $out;
 }
开发者ID:denghp,项目名称:phabricator,代码行数:93,代码来源:PHUIObjectItemListExample.php

示例8: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $project = id(new PhabricatorProjectQuery())->setViewer($viewer)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$project) {
         return new Aphront404Response();
     }
     $edit_uri = $this->getApplicationURI('edit/' . $project->getID() . '/');
     $view_uri = $this->getApplicationURI('view/' . $project->getID() . '/');
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $phid = $request->getStr('phid');
         $is_default = false;
         if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
             $phid = null;
             $is_default = true;
         } else {
             if ($phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             } else {
                 if ($request->getFileExists('picture')) {
                     $file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
                 } else {
                     $e_file = pht('Required');
                     $errors[] = pht('You must choose a file when uploading a new project picture.');
                 }
             }
         }
         if (!$errors && !$is_default) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             } else {
                 $xformer = new PhabricatorImageTransformer();
                 $xformed = $xformer->executeProfileTransform($file, $width = 50, $min_height = 50, $max_height = 50);
             }
         }
         if (!$errors) {
             if ($is_default) {
                 $new_value = null;
             } else {
                 $new_value = $xformed->getPHID();
             }
             $xactions = array();
             $xactions[] = id(new PhabricatorProjectTransaction())->setTransactionType(PhabricatorProjectTransaction::TYPE_IMAGE)->setNewValue($new_value);
             $editor = id(new PhabricatorProjectTransactionEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
             $editor->applyTransactions($project, $xactions);
             return id(new AphrontRedirectResponse())->setURI($edit_uri);
         }
     }
     $title = pht('Edit Project Picture');
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($project->getName(), $view_uri);
     $crumbs->addTextCrumb(pht('Edit'), $edit_uri);
     $crumbs->addTextCrumb(pht('Picture'));
     $form = id(new PHUIFormLayoutView())->setUser($viewer);
     $default_image = PhabricatorFile::loadBuiltin($viewer, 'project.png');
     $images = array();
     $current = $project->getProfileImagePHID();
     $has_current = false;
     if ($current) {
         $files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->execute();
         if ($files) {
             $file = head($files);
             if ($file->isTransformableImage()) {
                 $has_current = true;
                 $images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
             }
         }
     }
     $images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
     require_celerity_resource('people-profile-css');
     Javelin::initBehavior('phabricator-tooltips', array());
     $buttons = array();
     foreach ($images as $phid => $spec) {
         $button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
         $button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
         $button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
         $buttons[] = $button;
     }
     if ($has_current) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Current Picture'))->setValue(array_shift($buttons)));
     }
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Use Picture'))->setValue($buttons));
     $launch_id = celerity_generate_unique_node_id();
     $input_id = celerity_generate_unique_node_id();
     Javelin::initBehavior('launch-icon-composer', array('launchID' => $launch_id, 'inputID' => $input_id));
     $compose_button = javelin_tag('button', array('class' => 'grey', 'id' => $launch_id, 'sigil' => 'icon-composer'), pht('Choose Icon and Color...'));
     $compose_input = javelin_tag('input', array('type' => 'hidden', 'id' => $input_id, 'name' => 'phid'));
     $compose_form = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), array($compose_input, $compose_button));
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Quick Create'))->setValue($compose_form));
     $upload_form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setName('picture')->setLabel(pht('Upload Picture'))->setError($e_file)->setCaption(pht('Supported formats: %s', implode(', ', $supported_formats))))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton($edit_uri)->setValue(pht('Upload Picture')));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setForm($form);
     $upload_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Picture'))->setForm($upload_form);
     return $this->buildApplicationPage(array($crumbs, $form_box, $upload_box), array('title' => $title));
 }
开发者ID:denghp,项目名称:phabricator,代码行数:99,代码来源:PhabricatorProjectEditPictureController.php

示例9: loadCoverFiles

 private function loadCoverFiles(array $mocks)
 {
     assert_instances_of($mocks, 'PholioMock');
     $cover_file_phids = mpull($mocks, 'getCoverPHID');
     $cover_files = id(new PhabricatorFileQuery())->setViewer($this->getViewer())->withPHIDs($cover_file_phids)->execute();
     $cover_files = mpull($cover_files, null, 'getPHID');
     foreach ($mocks as $mock) {
         $file = idx($cover_files, $mock->getCoverPHID());
         if (!$file) {
             $file = PhabricatorFile::loadBuiltin($this->getViewer(), 'missing.png');
         }
         $mock->attachCoverFile($file);
     }
 }
开发者ID:denghp,项目名称:phabricator,代码行数:14,代码来源:PholioMockQuery.php

示例10: handleRequest

 public function handleRequest(AphrontRequest $request)
 {
     $viewer = $request->getViewer();
     $id = $request->getURIData('id');
     $conpherence = id(new ConpherenceThreadQuery())->setViewer($viewer)->withIDs(array($id))->needProfileImage(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$conpherence) {
         return new Aphront404Response();
     }
     $monogram = $conpherence->getMonogram();
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $phid = $request->getStr('phid');
         $is_default = false;
         if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
             $phid = null;
             $is_default = true;
         } else {
             if ($phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             } else {
                 if ($request->getFileExists('picture')) {
                     $file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
                 } else {
                     $e_file = pht('Required');
                     $errors[] = pht('You must choose a file when uploading a new room picture.');
                 }
             }
         }
         if (!$errors && !$is_default) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             } else {
                 $xform = PhabricatorFileTransform::getTransformByKey(PhabricatorFileThumbnailTransform::TRANSFORM_PROFILE);
                 $xformed = $xform->executeTransform($file);
             }
         }
         if (!$errors) {
             if ($is_default) {
                 $new_value = null;
             } else {
                 $xformed->attachToObject($conpherence->getPHID());
                 $new_value = $xformed->getPHID();
             }
             $xactions = array();
             $xactions[] = id(new ConpherenceTransaction())->setTransactionType(ConpherenceTransaction::TYPE_PICTURE)->setNewValue($new_value);
             $editor = id(new ConpherenceEditor())->setActor($viewer)->setContentSourceFromRequest($request)->setContinueOnMissingFields(true)->setContinueOnNoEffect(true);
             $editor->applyTransactions($conpherence, $xactions);
             return id(new AphrontRedirectResponse())->setURI('/' . $monogram);
         }
     }
     $title = pht('Edit Room Picture');
     $form = id(new PHUIFormLayoutView())->setUser($viewer);
     $default_image = PhabricatorFile::loadBuiltin($viewer, 'conpherence.png');
     $images = array();
     $current = $conpherence->getProfileImagePHID();
     $has_current = false;
     if ($current) {
         $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->executeOne();
         if ($file) {
             if ($file->isTransformableImage()) {
                 $has_current = true;
                 $images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
             }
         }
     }
     $images[PhabricatorPHIDConstants::PHID_VOID] = array('uri' => $default_image->getBestURI(), 'tip' => pht('Default Picture'));
     require_celerity_resource('people-profile-css');
     Javelin::initBehavior('phabricator-tooltips', array());
     $buttons = array();
     foreach ($images as $phid => $spec) {
         $button = javelin_tag('button', array('class' => 'grey profile-image-button', 'sigil' => 'has-tooltip', 'meta' => array('tip' => $spec['tip'], 'size' => 300)), phutil_tag('img', array('height' => 50, 'width' => 50, 'src' => $spec['uri'])));
         $button = array(phutil_tag('input', array('type' => 'hidden', 'name' => 'phid', 'value' => $phid)), $button);
         $button = phabricator_form($viewer, array('class' => 'profile-image-form', 'method' => 'POST'), $button);
         $buttons[] = $button;
     }
     if ($has_current) {
         $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Current Picture'))->setValue(array_shift($buttons)));
     }
     $form->appendChild(id(new AphrontFormMarkupControl())->setLabel(pht('Use Picture'))->setValue($buttons));
     $form_box = id(new PHUIObjectBoxView())->setHeaderText($title)->setFormErrors($errors)->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($form);
     $upload_form = id(new AphrontFormView())->setUser($viewer)->setEncType('multipart/form-data')->appendChild(id(new AphrontFormFileControl())->setName('picture')->setLabel(pht('Upload Picture'))->setError($e_file)->setCaption(pht('Supported formats: %s', implode(', ', $supported_formats))))->appendChild(id(new AphrontFormSubmitControl())->addCancelButton('/' . $monogram)->setValue(pht('Upload Picture')));
     $upload_box = id(new PHUIObjectBoxView())->setHeaderText(pht('Upload New Picture'))->setBackground(PHUIObjectBoxView::BLUE_PROPERTY)->setForm($upload_form);
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($conpherence->getTitle(), '/' . $monogram);
     $crumbs->addTextCrumb(pht('Room Picture'));
     $crumbs->setBorder(true);
     $header = id(new PHUIHeaderView())->setHeader(pht('Edit Room Picture'))->setHeaderIcon('fa-camera');
     $view = id(new PHUITwoColumnView())->setHeader($header)->setFooter(array($form_box, $upload_box));
     return $this->newPage()->setTitle($title)->setCrumbs($crumbs)->appendChild(array($view));
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:93,代码来源:ConpherenceRoomPictureController.php

示例11: willFilterPage

 protected function willFilterPage(array $accounts)
 {
     if ($this->needImages) {
         $file_phids = mpull($accounts, 'getProfileImagePHID');
         $file_phids = array_filter($file_phids);
         if ($file_phids) {
             // NOTE: We use the omnipotent viewer here because these files are
             // usually created during registration and can't be associated with
             // the correct policies, since the relevant user account does not exist
             // yet. In effect, if you can see an ExternalAccount, you can see its
             // profile image.
             $files = id(new PhabricatorFileQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withPHIDs($file_phids)->execute();
             $files = mpull($files, null, 'getPHID');
         } else {
             $files = array();
         }
         $default_file = null;
         foreach ($accounts as $account) {
             $image_phid = $account->getProfileImagePHID();
             if ($image_phid && isset($files[$image_phid])) {
                 $account->attachProfileImageFile($files[$image_phid]);
             } else {
                 if ($default_file === null) {
                     $default_file = PhabricatorFile::loadBuiltin($this->getViewer(), 'profile.png');
                 }
                 $account->attachProfileImageFile($default_file);
             }
         }
     }
     return $accounts;
 }
开发者ID:pugong,项目名称:phabricator,代码行数:31,代码来源:PhabricatorExternalAccountQuery.php

示例12: renderExample

 public function renderExample()
 {
     $request = $this->getRequest();
     $user = $request->getUser();
     $handle = id(new PhabricatorHandleQuery())->setViewer($user)->withPHIDs(array($user->getPHID()))->executeOne();
     $out = array();
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('FRUIT1')->setStatusIcon('fa-apple')->setHeader(pht('Apple'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('FRUIT2')->setHeader(pht('Banana'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('FRUIT3')->setHeader(pht('Cherry'))->setHref('#'));
     $box = id(new PHUIObjectBoxView())->setHeaderText('Basic List')->setObjectList($list);
     $out[] = $box;
     $list = new PHUIObjectItemListView();
     $list->setNoDataString(pht('This list is empty.'));
     $box = id(new PHUIObjectBoxView())->setHeaderText('Empty List')->setObjectList($list);
     $out[] = $box;
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Monday'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Tuesday'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Wednesday'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Thursday'))->setHref('#'));
     $box = id(new PHUIObjectBoxView())->setHeaderText('Stacked List')->setObjectList($list);
     $out[] = $box;
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Business Card'))->setStatusIcon('fa-warning red'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Playing Card'))->setStatusIcon('fa-warning orange')->addIcon('fa-comment', pht('Royal Flush!')));
     $owner = phutil_tag('a', array('href' => '#'), pht('jackofclubs'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('House of Cards'))->setStatusIcon('fa-warning yellow')->setDisabled(true)->addByline(pht('Owner: %s', $owner)));
     $author = phutil_tag('a', array('href' => '#'), pht('agoat'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Cardigan'))->setStatusIcon('fa-check green')->addIcon('fa-star', pht('Warm!'))->addByline(pht('Author: %s', $author)));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Cardamom'))->setStatusIcon('fa-check blue'));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('The human cardiovascular system includes the heart, lungs, and ' . 'some other parts; most of these parts are pretty squishy.'))->addHandleIcon($handle, pht('You have a cardiovascular system!'))->setStatusIcon('fa-check indigo'));
     $box = id(new PHUIObjectBoxView())->setHeaderText('Card List')->setObjectList($list);
     $out[] = $box;
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Grab ahold!'))->setHref('#')->setGrippable(true));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Hold on tight!'))->setHref('#')->setGrippable(true));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht("Don't let go!"))->setHref('#')->setGrippable(true)->addAction(id(new PHUIListItemView())->setHref('#')->setIcon('fa-times')));
     $box = id(new PHUIObjectBoxView())->setHeaderText('Grippable List')->setObjectList($list);
     $out[] = $box;
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('You Have The Power'))->setHref('#')->setStatusIcon('fa-circle-o blue')->addAction(id(new PHUIListItemView())->setHref('#')->setName(pht('Moo'))->setIcon('fa-pencil')));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Believe In Yourself'))->setHref('#')->setStatusIcon('fa-circle-o violet')->addAction(id(new PHUIListItemView())->setHref('#')->setName(pht('Quack'))->setIcon('fa-pencil'))->addAction(id(new PHUIListItemView())->setHref('#')->setName(pht('Oink'))->setIcon('fa-times')));
     $box = id(new PHUIObjectBoxView())->setHeaderText('Action Link List')->setObjectList($list);
     $head = id(new PHUIHeaderView())->setHeader(pht('Extras'));
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Ace of Hearts'))->setSubHead(pht('This is a powerful card in the game "Hearts".'))->setHref('#')->addAttribute(pht('Suit: Hearts'))->addAttribute(pht('Rank: Ace'))->addIcon('fa-heart', pht('Ace'))->addIcon('fa-heart red', pht('Hearts'))->addHandleIcon($handle, pht('You hold all the cards.'))->addHandleIcon($handle, pht('You make all the rules.')));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Just A Handle'))->setHref('#')->addHandleIcon($handle, pht('Handle Here')));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Poor Use of Space'))->setHref('#')->addAttribute('North West')->addHandleIcon($handle, pht('South East')));
     $list->addItem(id(new PHUIObjectItemView())->setHeader(pht('Crowded Eastern Edge'))->setHref('#')->addIcon('fa-circle red', pht('Stuff'))->addIcon('fa-circle yellow', pht('Stuff'))->addIcon('fa-circle green', pht('Stuff'))->addHandleIcon($handle, pht('More Stuff')));
     $box = id(new PHUIObjectBoxView())->setHeaderText('Action List')->setObjectList($list);
     $out[] = $box;
     $list = new PHUIObjectItemListView();
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X1')->setHeader(pht('Normal'))->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X2')->setHeader(pht('Highlighted'))->setEffect('highlighted')->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X3')->setHeader(pht('Selected'))->setEffect('selected')->setHref('#'));
     $list->addItem(id(new PHUIObjectItemView())->setObjectName('X4')->setHeader(pht('Disabled'))->setDisabled(true)->setHref('#'));
     $box = id(new PHUIObjectBoxView())->setHeaderText('Extra Things and Stuff')->setObjectList($list);
     $out[] = $box;
     $list = new PHUIObjectItemListView();
     $bar_colors = array(null => pht('None'), 'red' => pht('Red'), 'orange' => pht('Orange'), 'yellow' => pht('Yellow'), 'green' => pht('Green'), 'sky' => pht('Sky'), 'blue' => pht('Blue'), 'indigo' => pht('Indigo'), 'violet' => pht('Violet'), 'grey' => pht('Grey'), 'black' => pht('Black'));
     foreach ($bar_colors as $bar_color => $bar_label) {
         $list->addItem(id(new PHUIObjectItemView())->setHeader($bar_label)->setStatusIcon('fa-bell ' . $bar_color));
     }
     $box = id(new PHUIObjectBoxView())->setHeaderText('Color Icons')->setObjectList($list);
     $out[] = $box;
     $list = new PHUIObjectItemListView();
     $list->setFlush(true);
     $default_profile = PhabricatorFile::loadBuiltin($user, 'profile.png');
     $default_project = PhabricatorFile::loadBuiltin($user, 'project.png');
     $list->addItem(id(new PHUIObjectItemView())->setImageURI($default_profile->getViewURI())->setHeader(pht('Default User Profile Image'))->addAction(id(new PHUIListItemView())->setHref('#')->setIcon('fa-pencil-square'))->addAction(id(new PHUIListItemView())->setHref('#')->setIcon('fa-plus-square'))->addAction(id(new PHUIListItemView())->setHref('#')->setIcon('fa-minus-square')));
     $list->addItem(id(new PHUIObjectItemView())->setImageURI($default_project->getViewURI())->setHeader(pht('Default Project Profile Image'))->setGrippable(true)->addAttribute(pht('This is the default project profile image.')));
     $box = id(new PHUIObjectBoxView())->setHeaderText('Profile Images')->setObjectList($list);
     $out[] = $box;
     return $out;
 }
开发者ID:endlessm,项目名称:phabricator,代码行数:76,代码来源:PHUIObjectItemListExample.php

示例13: loadPage

 protected function loadPage()
 {
     $table = new ConpherenceThread();
     $conn_r = $table->establishConnection('r');
     $data = queryfx_all($conn_r, 'SELECT thread.* FROM %T thread %Q %Q %Q %Q %Q', $table->getTableName(), $this->buildJoinClause($conn_r), $this->buildWhereClause($conn_r), $this->buildGroupClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r));
     $conpherences = $table->loadAllFromArray($data);
     if ($conpherences) {
         $conpherences = mpull($conpherences, null, 'getPHID');
         $this->loadParticipantsAndInitHandles($conpherences);
         if ($this->needParticipantCache) {
             $this->loadCoreHandles($conpherences, 'getRecentParticipantPHIDs');
         }
         if ($this->needParticipants) {
             $this->loadCoreHandles($conpherences, 'getParticipantPHIDs');
         }
         if ($this->needTransactions) {
             $this->loadTransactionsAndHandles($conpherences);
         }
         if ($this->needProfileImage) {
             $default = null;
             $file_phids = mpull($conpherences, 'getProfileImagePHID');
             $file_phids = array_filter($file_phids);
             if ($file_phids) {
                 $files = id(new PhabricatorFileQuery())->setParentQuery($this)->setViewer($this->getViewer())->withPHIDs($file_phids)->execute();
                 $files = mpull($files, null, 'getPHID');
             } else {
                 $files = array();
             }
             foreach ($conpherences as $conpherence) {
                 $file = idx($files, $conpherence->getProfileImagePHID());
                 if (!$file) {
                     if (!$default) {
                         $default = PhabricatorFile::loadBuiltin($this->getViewer(), 'conpherence.png');
                     }
                     $file = $default;
                 }
                 $conpherence->attachProfileImageFile($file);
             }
         }
     }
     return $conpherences;
 }
开发者ID:NeoArmageddon,项目名称:phabricator,代码行数:42,代码来源:ConpherenceThreadQuery.php

示例14: didFilterPage

 protected function didFilterPage(array $projects)
 {
     if ($this->needImages) {
         $default = null;
         $file_phids = mpull($projects, 'getProfileImagePHID');
         $file_phids = array_filter($file_phids);
         if ($file_phids) {
             $files = id(new PhabricatorFileQuery())->setParentQuery($this)->setViewer($this->getViewer())->withPHIDs($file_phids)->execute();
             $files = mpull($files, null, 'getPHID');
         } else {
             $files = array();
         }
         foreach ($projects as $project) {
             $file = idx($files, $project->getProfileImagePHID());
             if (!$file) {
                 if (!$default) {
                     $default = PhabricatorFile::loadBuiltin($this->getViewer(), 'project.png');
                 }
                 $file = $default;
             }
             $project->attachProfileImageFile($file);
         }
     }
     if ($this->needSlugs) {
         $slugs = id(new PhabricatorProjectSlug())->loadAllWhere('projectPHID IN (%Ls)', mpull($projects, 'getPHID'));
         $slugs = mgroup($slugs, 'getProjectPHID');
         foreach ($projects as $project) {
             $project_slugs = idx($slugs, $project->getPHID(), array());
             $project->attachSlugs($project_slugs);
         }
     }
     return $projects;
 }
开发者ID:patelhardik,项目名称:phabricator,代码行数:33,代码来源:PhabricatorProjectQuery.php

示例15: processRequest

 public function processRequest()
 {
     $request = $this->getRequest();
     $viewer = $request->getUser();
     $user = id(new PhabricatorPeopleQuery())->setViewer($viewer)->withIDs(array($this->id))->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->executeOne();
     if (!$user) {
         return new Aphront404Response();
     }
     $profile_uri = '/p/' . $user->getUsername() . '/';
     $supported_formats = PhabricatorFile::getTransformableImageFormats();
     $e_file = true;
     $errors = array();
     if ($request->isFormPost()) {
         $phid = $request->getStr('phid');
         $is_default = false;
         if ($phid == PhabricatorPHIDConstants::PHID_VOID) {
             $phid = null;
             $is_default = true;
         } else {
             if ($phid) {
                 $file = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($phid))->executeOne();
             } else {
                 if ($request->getFileExists('picture')) {
                     $file = PhabricatorFile::newFromPHPUpload($_FILES['picture'], array('authorPHID' => $viewer->getPHID(), 'canCDN' => true));
                 } else {
                     $e_file = pht('Required');
                     $errors[] = pht('You must choose a file when uploading a new profile picture.');
                 }
             }
         }
         if (!$errors && !$is_default) {
             if (!$file->isTransformableImage()) {
                 $e_file = pht('Not Supported');
                 $errors[] = pht('This server only supports these image formats: %s.', implode(', ', $supported_formats));
             } else {
                 $xformer = new PhabricatorImageTransformer();
                 $xformed = $xformer->executeProfileTransform($file, $width = 50, $min_height = 50, $max_height = 50);
             }
         }
         if (!$errors) {
             if ($is_default) {
                 $user->setProfileImagePHID(null);
             } else {
                 $user->setProfileImagePHID($xformed->getPHID());
                 $xformed->attachToObject($user->getPHID());
             }
             $user->save();
             return id(new AphrontRedirectResponse())->setURI($profile_uri);
         }
     }
     $title = pht('Edit Profile Picture');
     $crumbs = $this->buildApplicationCrumbs();
     $crumbs->addTextCrumb($user->getUsername(), $profile_uri);
     $crumbs->addTextCrumb($title);
     $form = id(new PHUIFormLayoutView())->setUser($viewer);
     $default_image = PhabricatorFile::loadBuiltin($viewer, 'profile.png');
     $images = array();
     $current = $user->getProfileImagePHID();
     $has_current = false;
     if ($current) {
         $files = id(new PhabricatorFileQuery())->setViewer($viewer)->withPHIDs(array($current))->execute();
         if ($files) {
             $file = head($files);
             if ($file->isTransformableImage()) {
                 $has_current = true;
                 $images[$current] = array('uri' => $file->getBestURI(), 'tip' => pht('Current Picture'));
             }
         }
     }
     // Try to add external account images for any associated external accounts.
     $accounts = id(new PhabricatorExternalAccountQuery())->setViewer($viewer)->withUserPHIDs(array($user->getPHID()))->needImages(true)->requireCapabilities(array(PhabricatorPolicyCapability::CAN_VIEW, PhabricatorPolicyCapability::CAN_EDIT))->execute();
     foreach ($accounts as $account) {
         $file = $account->getProfileImageFile();
         if ($account->getProfileImagePHID() != $file->getPHID()) {
             // This is a default image, just skip it.
             continue;
         }
         $provider = PhabricatorAuthProvider::getEnabledProviderByKey($account->getProviderKey());
         if ($provider) {
             $tip = pht('Picture From %s', $provider->getProviderName());
         } else {
             $tip = pht('Picture From External Account');
         }
         if ($file->isTransformableImage()) {
             $images[$file->getPHID()] = array('uri' => $file->getBestURI(), 'tip' => $tip);
         }
     }
     // Try to add Gravatar images for any email addresses associated with the
     // account.
     if (PhabricatorEnv::getEnvConfig('security.allow-outbound-http')) {
         $emails = id(new PhabricatorUserEmail())->loadAllWhere('userPHID = %s ORDER BY address', $user->getPHID());
         $futures = array();
         foreach ($emails as $email_object) {
             $email = $email_object->getAddress();
             $hash = md5(strtolower(trim($email)));
             $uri = id(new PhutilURI("https://secure.gravatar.com/avatar/{$hash}"))->setQueryParams(array('size' => 200, 'default' => '404', 'rating' => 'x'));
             $futures[$email] = new HTTPSFuture($uri);
         }
         $unguarded = AphrontWriteGuard::beginScopedUnguardedWrites();
         foreach (Futures($futures) as $email => $future) {
//.........这里部分代码省略.........
开发者ID:denghp,项目名称:phabricator,代码行数:101,代码来源:PhabricatorPeopleProfilePictureController.php


注:本文中的PhabricatorFile::loadBuiltin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。