Author: p.juanpablo
Date: 2010-03-03 02:49:26 +0100 (Wed, 03 Mar 2010)
New Revision: 28355
Added:
plugins/dcPropelReportsPlugin/trunk/lib/dcPropelReportColumnWrapper.class.php
Modified:
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/actions/actions.class.php
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/_result.php
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/_result_row.php
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/indexSuccess.php
Log:
Se agrega eventos al momento de renderizar los valores, por si el usuario
quiere hacer un cambio sobre el valor
Added:
plugins/dcPropelReportsPlugin/trunk/lib/dcPropelReportColumnWrapper.class.php
===================================================================
---
plugins/dcPropelReportsPlugin/trunk/lib/dcPropelReportColumnWrapper.class.php
(rev 0)
+++
plugins/dcPropelReportsPlugin/trunk/lib/dcPropelReportColumnWrapper.class.php
2010-03-03 01:49:26 UTC (rev 28355)
@@ -0,0 +1,54 @@
+<?php
+/**
+ * dcPropelReportColumnWrapper.
+ *
+ *
+ * @author Lic. Christian A. Rodriguez <[email protected]>
+ * @author AC. Perez, Juan Pablo <[email protected]>
+ */
+
+class dcPropelReportColumnWrapper
+{
+ protected $field = null;
+ protected $value = null;
+
+ public function __construct($dcPropelReportFiled)
+ {
+ $this->field = $dcPropelReportFiled;
+
+ }
+
+ public function setValue($value)
+ {
+ $this->value = $value;
+ }
+
+ public function getValue($emitSignal=false)
+ {
+ $res = $this->value;
+ $event = null;
+ if ($emitSignal)
+ {
+ $event = $this->createEvent();
// Creo el evento
+
sfContext::getInstance()->getConfiguration()->getEventDispatcher()->filter($event,
$this->value); // Levanto la señal
+ $res = $event->getReturnValue();
// Obtengo el valor modificado
+ }
+ if (is_null($event) || (!$event->isProcessed() && !empty($value)))
+ {
+ // Si el evento no se procesó, obtengo el valor normalmente
+ $res = $this->value;
+ }
+ return $res;
+ }
+
+
+ protected function createEvent()
+ {
+ return new sfEvent(
+ $this,
// Objeto que levanto la señal
+ 'dc_propel_report_query_'.$this->field->__toString(),
// Nombre de la señal
+ array('fieldName' => $this->field->__toString())
// Lista de parámetros
+ );
+ }
+
+}
Modified:
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/actions/actions.class.php
===================================================================
---
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/actions/actions.class.php
2010-03-02 23:48:07 UTC (rev 28354)
+++
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/actions/actions.class.php
2010-03-03 01:49:26 UTC (rev 28355)
@@ -108,15 +108,28 @@
$this->setTestPage($request->getParameter('page'));
}
- $this->pager= $this->getPager();
+ $this->pager = $this->getPager();
$this->export_pager= $this->getExportPager();
$this->filters = new dcPropelReportFilter($this->report_query);
$this->filters->setDefaults($this->getFilters());
$this->sort = $this->getTestSort();
+
+ $this->column_wrappers = $this->buildColumnsWrappers();
+
}
+ protected function buildColumnsWrappers()
+ {
+ $ret = array();
+ foreach ($this->report_query->getdcReportFields() as $field)
+ {
+ $ret[] = new dcPropelReportColumnWrapper($field);
+ }
+ return $ret;
+ }
+
protected function getPager()
{
$pager = new
dcPropelReportPager('dcPropelReportPeer',sfConfig::get('app_dc_report_query_list_rows',20));
@@ -196,6 +209,8 @@
$this->sort = $this->getTestSort();
+ $this->column_wrappers = $this->buildColumnsWrappers();
+
$this->setTemplate('index');
}
@@ -255,12 +270,14 @@
$results = $pager->getResults();
}
- $objWriter = new
PHPExcel_Writer_Excel5($this->buildExcel($this->report_query, $results));
+ $objWriter = new
PHPExcel_Writer_Excel5($this->buildExcel($this->report_query, $results,
$this->column_wrappers = $this->buildColumnsWrappers()));
$tmp_dir = '/tmp/';
$file_name = $tmp_dir.'export'.time().'.xls';
$objWriter->save($file_name);
$this->file = $file_name;
+
+
}
@@ -270,12 +287,12 @@
}
}
- private function buildExcel($report_query, $results)
+ private function buildExcel($report_query, $results, $column_wrappers)
{
$objPHPExcel = new sfPhpExcel();
$objPHPExcel->setActiveSheetIndex(0);
$this->writeHeader($report_query, $objPHPExcel);
- $this->writeRows($report_query,$results, $objPHPExcel);
+ $this->writeRows($report_query,$results, $objPHPExcel,
$column_wrappers);
return $objPHPExcel;
}
@@ -290,13 +307,15 @@
}
}
- private function writeRows($report_query, $results, $objPHPExcel)
+ private function writeRows($report_query, $results, $objPHPExcel,
$column_wrappers)
{
$row = 2;
foreach ($results as $data_row) {
$column = 0;
- foreach($data_row as $key=>$value) {
-
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column,
$row,$value);
+ foreach($data_row as $key=>$value) {
+ $wrapper = $column_wrappers[$column];
+ $wrapper->setValue($value);
+
$objPHPExcel->getActiveSheet()->setCellValueByColumnAndRow($column,
$row,$wrapper->getValue(true));
$column++;
}
$row++;
Modified:
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/_result.php
===================================================================
---
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/_result.php
2010-03-02 23:48:07 UTC (rev 28354)
+++
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/_result.php
2010-03-03 01:49:26 UTC (rev 28355)
@@ -26,7 +26,7 @@
<?php $i=0?>
<?php foreach ($pager->getResults() as $key => $row): $odd =
fmod(++$i, 2) ? 'odd' : 'even' ?>
<tr class="sf_admin_row <?php echo $odd ?>">
- <?php include_partial('dc_report_list/result_row', array('row' =>
$row)) ?>
+ <?php include_partial('dc_report_list/result_row', array('row' =>
$row,'column_wrappers'=> $column_wrappers)) ?>
</tr>
<?php endforeach; ?>
</tbody>
Modified:
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/_result_row.php
===================================================================
---
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/_result_row.php
2010-03-02 23:48:07 UTC (rev 28354)
+++
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/_result_row.php
2010-03-03 01:49:26 UTC (rev 28355)
@@ -1,5 +1,9 @@
+<?php $i=0; ?>
<?php foreach($row as $key=>$field): ?>
+<?php $wrapper = $column_wrappers[$i]; ?>
+<?php $wrapper->setValue($field); ?>
<td class="sf_admin_text">
- <?php echo $field ?>
+ <?php echo $wrapper->getValue(true); ?>
</td>
+<?php $i++; ?>
<?php endforeach ?>
Modified:
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/indexSuccess.php
===================================================================
---
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/indexSuccess.php
2010-03-02 23:48:07 UTC (rev 28354)
+++
plugins/dcPropelReportsPlugin/trunk/modules/dc_report_list/templates/indexSuccess.php
2010-03-03 01:49:26 UTC (rev 28355)
@@ -16,7 +16,8 @@
<?php include_partial('dc_report_list/result', array('pager' => $pager,
'export_pager' =>
$export_pager,
'dc_report_query'=>$report_query,
- 'sort' => $sort)) ?>
+ 'sort' => $sort,
+ 'column_wrappers' =>
$column_wrappers)) ?>
</div>
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.