Page MenuHomePhabricator

camilorojas (Camilo Rojas)
UserEmail Not Verified

Projects

User does not belong to any projects.

Today

  • Clear sailing ahead.

Tomorrow

  • Clear sailing ahead.

Monday

  • Clear sailing ahead.

User Details

User Since
Mar 21 2016, 8:57 PM (193 w, 4 d)
Availability
Available

Recent Activity

Mar 28 2016

camilorojas added a comment to T5391: Support custom fields in 'Export to Excel'.

@camilorojas That's because you haven't defined the custom field std:maniphest:vendor:field. Checkout the docs to see how to do that!

Mar 28 2016, 1:06 PM · Data Exporters
camilorojas added a comment to T5391: Support custom fields in 'Export to Excel'.

@camilorojas I think I just added the following file

src/applications/maniphest/export/ManiphestExcelCustomFormat.php
<?php
final class ManiphestExcelCustomFormat extends ManiphestExcelFormat {
  public function getName() {
    return pht('Custom');
  }
  public function getFileName() {
    return 'maniphest_tasks_'.date('Ymd');
  }
  /**
   * @phutil-external-symbol class PHPExcel
   * @phutil-external-symbol class PHPExcel_IOFactory
   * @phutil-external-symbol class PHPExcel_Style_NumberFormat
   * @phutil-external-symbol class PHPExcel_Cell_DataType
   */
  public function buildWorkbook(
    PHPExcel $workbook,
    array $tasks,
    array $handles,
    PhabricatorUser $user) {
    $sheet = $workbook->setActiveSheetIndex(0);
    $sheet->setTitle(pht('Tasks'));
    $widths = array(
      null,
      15,
      null,
      10,
      15,
      15,
      60,
      30,
      20,
      100,
    );
    foreach ($widths as $col => $width) {
      if ($width !== null) {
        $sheet->getColumnDimension($this->col($col))->setWidth($width);
      }
    }
    $status_map = ManiphestTaskStatus::getTaskStatusMap();
    $pri_map = ManiphestTaskPriority::getTaskPriorityMap();
    $date_format = null;
    $rows = array();
    $rows[] = array(
      pht('ID'),
      pht('Owner'),
      pht('Status'),
      pht('Priority'),
      pht('Date Created'),
      pht('Date Updated'),
      pht('Title'),
      pht('Projects'),
      pht('URI'),
      pht('Description'),
      pht('Custom Field'),
    );
    $is_date = array(
      false,
      false,
      false,
      false,
      true,
      true,
      false,
      false,
      false,
      false,
      false,
    );
    $header_format = array(
      'font'  => array(
        'bold' => true,
      ),
    );
    foreach ($tasks as $task) {
      $task_owner = null;
      if ($task->getOwnerPHID()) {
        $task_owner = $handles[$task->getOwnerPHID()]->getName();
      }
      $custom_fields = PhabricatorCustomField::getObjectFields(
        $task,
        PhabricatorCustomField::ROLE_VIEW);
      $custom_fields
        ->setViewer($user)
        ->readFieldsFromStorage($task);
      $custom_fields = $custom_fields->getFields();
      $projects = array();
      foreach ($task->getProjectPHIDs() as $phid) {
        $projects[] = $handles[$phid]->getName();
      }
      $projects = implode(', ', $projects);
      $rows[] = array(
        'T'.$task->getID(),
        $task_owner,
        idx($status_map, $task->getStatus(), '?'),
        idx($pri_map, $task->getPriority(), '?'),
        $this->computeExcelDate($task->getDateCreated()),
        $this->computeExcelDate($task->getDateModified()),
        $task->getTitle(),
        $projects,
        PhabricatorEnv::getProductionURI('/T'.$task->getID()),
        phutil_utf8_shorten($task->getDescription(), 512),
        $custom_fields['std:maniphest:vendor:field']->getValueForStorage(),
      );
    }
    foreach ($rows as $row => $cols) {
      foreach ($cols as $col => $spec) {
        $cell_name = $this->col($col).($row + 1);
        $cell = $sheet
          ->setCellValue($cell_name, $spec, $return_cell = true);
        if ($row == 0) {
          $sheet->getStyle($cell_name)->applyFromArray($header_format);
        }
        if ($is_date[$col]) {
          $code = PHPExcel_Style_NumberFormat::FORMAT_DATE_YYYYMMDD2;
          $sheet
            ->getStyle($cell_name)
            ->getNumberFormat()
            ->setFormatCode($code);
        } else {
          $cell->setDataType(PHPExcel_Cell_DataType::TYPE_STRING);
        }
      }
    }
  }
  private function col($n) {
    return chr(ord('A') + $n);
  }
}

Don't forget to update your class map:

$ cd webroot/phabricator
$ ../arcanist/bin/arc liberate src
Mar 28 2016, 12:31 PM · Data Exporters

Mar 24 2016

camilorojas added a comment to T5391: Support custom fields in 'Export to Excel'.
In T5391#78626, @witrin wrote:

Problem solved:

$custom_fields = PhabricatorCustomField::getObjectFields(
        $task,
        PhabricatorCustomField::ROLE_VIEW);
$custom_fields
        ->setViewer($user)
        ->readFieldsFromStorage($task);
$custom_fields->getFields()['std:maniphest:company:field']->getValueForStorage();
Mar 24 2016, 8:35 PM · Data Exporters

Mar 21 2016

camilorojas added a comment to T10635: Loading differential revision slow when lots of unit test messages exist.
Mar 21 2016, 9:07 PM · Restricted Project, Haskell.org, Harbormaster, Performance, Bug Report
camilorojas created T10636: Custom Field.
Mar 21 2016, 9:01 PM · Bug Report