Add ImageHref attribute for PHUIObjectItemListView
Summary: In some cases we may want a different URI for the image on an item than the header/title of the item (like user / title). This prioritizes ImageHref over Href. Test Plan: uiexamples Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin Differential Revision: https://secure.phabricator.com/D18016
This commit is contained in:
		@@ -330,6 +330,8 @@ final class PHUIObjectItemListExample extends PhabricatorUIExample {
 | 
			
		||||
    $list->addItem(
 | 
			
		||||
      id(new PHUIObjectItemView())
 | 
			
		||||
        ->setImageURI($default_project->getViewURI())
 | 
			
		||||
        ->setImageHref('#')
 | 
			
		||||
        ->setHref('$$$')
 | 
			
		||||
        ->setHeader(pht('Default Project Profile Image'))
 | 
			
		||||
        ->setGrippable(true)
 | 
			
		||||
        ->addAttribute(pht('This is the default project profile image.')));
 | 
			
		||||
 
 | 
			
		||||
@@ -19,6 +19,7 @@ final class PHUIObjectItemView extends AphrontTagView {
 | 
			
		||||
  private $headIcons = array();
 | 
			
		||||
  private $disabled;
 | 
			
		||||
  private $imageURI;
 | 
			
		||||
  private $imageHref;
 | 
			
		||||
  private $imageIcon;
 | 
			
		||||
  private $titleText;
 | 
			
		||||
  private $badge;
 | 
			
		||||
@@ -127,6 +128,11 @@ final class PHUIObjectItemView extends AphrontTagView {
 | 
			
		||||
    return $this;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public function setImageHref($image_href) {
 | 
			
		||||
    $this->imageHref = $image_href;
 | 
			
		||||
    return $this;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public function getImageURI() {
 | 
			
		||||
    return $this->imageURI;
 | 
			
		||||
  }
 | 
			
		||||
@@ -575,11 +581,12 @@ final class PHUIObjectItemView extends AphrontTagView {
 | 
			
		||||
        $this->getImageIcon());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if ($image && $this->href) {
 | 
			
		||||
    if ($image && (strlen($this->href) || strlen($this->imageHref))) {
 | 
			
		||||
      $image_href = ($this->imageHref) ? $this->imageHref : $this->href;
 | 
			
		||||
      $image = phutil_tag(
 | 
			
		||||
        'a',
 | 
			
		||||
        array(
 | 
			
		||||
          'href' => $this->href,
 | 
			
		||||
          'href' => $image_href,
 | 
			
		||||
        ),
 | 
			
		||||
        $image);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user