From 134cdb58d8dd2bb122e61955bc1ca4bf7cc006d0 Mon Sep 17 00:00:00 2001 From: "vincent@cubedesigners.com" Date: Fri, 13 Dec 2019 18:52:02 +0000 Subject: [PATCH] fix #3271 @0.75 --- inc/ws/Controlleur/class.ws.url.php | 48 ++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) diff --git a/inc/ws/Controlleur/class.ws.url.php b/inc/ws/Controlleur/class.ws.url.php index a5785f8a6..774b38939 100644 --- a/inc/ws/Controlleur/class.ws.url.php +++ b/inc/ws/Controlleur/class.ws.url.php @@ -2221,14 +2221,25 @@ html.tall{height:150%}' . "\n"; $xls = new PHPExcel(); $sheet = $xls->getActiveSheet(); $sheet->freezePane('B2'); - $standardSettings = ['book_id' => 'book_id', 'lang' => 'lang', 'theme' => 'theme', 'status' => 'status', 'proprietaire_id' => 'owner', 'date' => 'date', 'changedate' => 'changedate', 'exportdatas' => 'exportdata']; + $standardSettings = ['book_id' => 'book_id', 'lang' => 'lang', 'theme' => 'theme', 'status' => 'status', 'proprietaire_id' => 'owner', 'date' => 'date', 'changedate' => 'changedate', 'hosting' => 'hosting', 'exportdatas' => 'exportdata']; $j = 0; foreach ($standardSettings as $column => $label) { + $readonly = false; if ($label === 'exportdata') { - + $readonly = true; } else { $sheet->getColumnDimensionByColumn($j)->setAutoSize(true); } + if ($label === 'hosting') { + $readonly = true; + } + + if (strpos($column, 'date') !== false) { + $readonly = true; + } + if ($readonly) { + self::_readonlyStyle($sheet->getStyle(PHPExcel_Cell::stringFromColumnIndex($j))); + } $sheet->setCellValueByColumnAndRow($j, 1, $label); $j++; } @@ -2236,13 +2247,18 @@ html.tall{height:150%}' . "\n"; foreach ($p->getForms() as $form) { $form = $p->getForm($form, true); foreach ($form['fields'] as $k => $field) { + $readonly = false; if (!$field['editable']) { - continue; + $readonly = true; } + if ($readonly) { + self::_readonlyStyle($sheet->getStyle(PHPExcel_Cell::stringFromColumnIndex($j))); + } $sheet->getCommentByColumnAndRow($j, 1)->getText()->createTextRun($field['label']); $sheet->getColumnDimensionByColumn($j)->setAutoSize(true); $sheet->setCellValueByColumnAndRow($j, 1, $k); + $paramCols[] = $k; $j++; } @@ -2252,11 +2268,26 @@ html.tall{height:150%}' . "\n"; foreach ($books as $id => $book) { $j = 0; foreach ($standardSettings as $column => $label) { - $val = $book->$column; + $url = false; + if ($column === 'hosting') { + $export = json_decode($book->exportdatas, true); + if (isset($export['install_hosting']['online']['dir']) && $export['install_hosting']['online']['dir']) { + $val = 'https://hosting.fluidbook.com/' . $export['install_hosting']['online']['dir']; + $url = $val; + } else { + $val = '-'; + } + } else { + $val = $book->$column; + } if (strpos($column, 'date') !== false) { $val = date('Y-m-d', $val); } $sheet->setCellValueByColumnAndRow($j, $i, $val); + if ($url) { + $sheet->getCellByColumnAndRow($j, $i)->getHyperlink()->setUrl($url); + } + $j++; } foreach ($paramCols as $col) { @@ -2272,4 +2303,13 @@ html.tall{height:150%}' . "\n"; $writer->save('php://output'); exit; } + + /** + * @param $style PHPExcel_Style + */ + protected static function _readonlyStyle($style) + { + $style->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID)->getStartColor()->setRGB('dddddd'); + $style->getFont()->getColor()->setRGB('666666'); + } } -- 2.39.5