Development

/plugins/sfDatagridPlugin/lib/sfDatagridFormatter.class.php

You must first sign up to be able to contribute.

root/plugins/sfDatagridPlugin/lib/sfDatagridFormatter.class.php

Revision 15965, 21.8 kB (checked in by lombardot, 4 years ago)

--

Line 
1 <?php
2 /**
3  * This class allow to render a datagrid
4  *
5  * For the good work on the datagrid, you must enable the following
6  * modules :
7  * - Tag
8  * - Url
9  * - Javascript
10  * - Form
11  * - I18N => if you use it.
12  *
13  * You must enable this module in the
14  * applicationConfiguration class with the following line :
15  * sfLoader::loadHelpers(array('Url', 'Javascript', 'Tag', 'I18N', 'Form'));
16  *
17  * @author        David Zeller    <zellerda01@gmail.com>
18  */
19 abstract class sfDatagridFormatter
20 {
21     protected
22         // The datagrid container
23         $datagridContainer = '%loader%%flash%%pager%%actions%<table border="0" cellspadding="0" cellspacing="1" class="grid">%headers%%filters%%rows%</table>',
24         // The datagrid rowCell
25         $datagridRows = '<td %row_options%>%value%</td>',
26         // The datagrid headerCell
27         $datagridHeaders = '<th %header_options%>%value%</th>',
28         // The datagrid headerCell if no sort
29         $datagridHeadersNoSort = '<div>%value%</div>',
30         // The datagrid pager container
31         $datagridPagerContainer = '<table cellspacing="1" cellpadding="0" class="grid-pager"><tr><td valign="middle"><span class="pager">%pager%</span></td><td>%search%</td></table>',
32         // The datagrid pager details
33         $datagridPager = '%pager%&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;%grid_totals%',
34         // The datagrid action bar
35         $datagridActions = '<table cellspacing="0" cellpadding="0" class="grid-actions"><tr><td valign="middle" class="left-actions"><span class="pager">%links%</span></td><td align="right" valign="middle" class="right-actions">%actions%</td></table>';
36         
37     protected
38         $P_ORDER = 'dg_order',
39         $P_SORT = 'dg_sort',
40         $P_PAGE = 'dg_page';
41
42     /**
43      * Get the html output for the global datagrid
44      *
45      * @param sfDatagrid $object The datagrid object
46      * @param string $headers The html of the headers
47      * @param string $rows The html of the rows
48      * @param string $actions The html of the actions
49      * @return string The html output of the datagrid
50      */
51     public function renderDatagrid($object, $headers, $rows, $filters, $pager, $actions)
52     {
53         $formOptions = array(
54                         'action' => '',
55                         'id' => $object->_get('datagridName') . '-form',
56                         'method' => 'post',
57                         'onsubmit' => 'return false;'
58                        );
59         
60         return '<form ' . _tag_options($formOptions) . '>' . strtr($this->datagridContainer, array(
61             '%flash%' => $this->getFlash('datagrid'),
62             '%headers%' => $headers,
63             '%rows%' => $rows,
64             '%pager%' => $pager,
65             '%actions%' => $actions,
66             '%filters%' => $filters,
67             '%loader%' => '<div class="datagrid-loader" id="loader-' . $object->_get('datagridName') . '">' . sfDatagrid::getConfig('text_loading') . '</div>'
68         )) . '</form>';
69     }
70     
71     /**
72      * Render the pager bar
73      *
74      * @param sfDatagrid $object The datagrid object
75      * @param string $suffix The url suffix
76      * @return string The html output
77      */
78     public function renderPagerBar($object, $suffix)
79     {
80         $datagridName = $object->_get('datagridName');
81         $pager = $object->_get('pager');
82         $page = $object->_get('page');
83         $defaultSort= $object->_get('defaultSort');
84         $moduleAction = $object->_get('moduleAction');
85         $sortBy = $object->_get('sortBy');
86         $sortOrder = $object->_get('sortOrder');
87         $request = $object->_get('request');
88         $renderSearch = $object->_get('renderSearch');
89         $renderPager = $object->_get('renderPager');
90         
91         $pagerHtml = '';
92         $searchHtml = '';
93         $gridTotals = '';
94         
95         $suffixWithSorting = $suffix . '&' . $this->P_SORT . '=' . $sortBy . '&' . $this->P_ORDER . '=' . $sortOrder;
96         
97         if(sizeof($defaultSort)>0)
98         $suffixWithDefaultSorting= $suffix . '&' . $this->P_SORT . '=' . $defaultSort['sort'] . '&' . $this->P_ORDER . '=' . $defaultSort['order'];
99         else
100         $suffixWithDefaultSorting=$suffixWithSorting;
101         if($renderPager)
102         {
103             if($pager->haveToPaginate())
104             {
105                 $pagerHtml.= $this->traduct(sfDatagrid::getConfig('text_page')) . ' : ';
106                 
107                 if($page != 1)
108                 {
109                     
110                     $pagerHtml.= link_to_remote(
111                             '<img src="' . sfDatagrid::getConfig('images_dir') . 'pager-arrow-left.gif" alt="" align="absmiddle" />',
112                             array(
113                                 'url' => $moduleAction . '?' . $this->P_PAGE . '=' . $pager->getPreviousPage() . '&' . $suffixWithSorting,
114                                 'update' => $datagridName,
115                                 'script' => true,
116                                 'loading' => 'dg_hide_show(\'' . $datagridName . '\')'
117                                 ));
118                 }
119                 
120                 foreach($pager->getLinks() as $item)
121                 {
122                     if($item == $page)
123                     {
124                         $pagerHtml.= link_to_remote(
125                                 $item,
126                                 array(
127                                     'url' => $moduleAction . '?' . $this->P_PAGE . '=' . $item . '&' . $suffixWithSorting,
128                                     'update' => $datagridName,
129                                     'script' => true,
130                                     'loading' => 'dg_hide_show(\'' . $datagridName . '\')'
131                                     ),
132                                 array('class' => 'selected'));
133                     }
134                     else
135                     {
136                         $pagerHtml.= link_to_remote(
137                                 $item,
138                                 array(
139                                     'url' => $moduleAction . '?' . $this->P_PAGE . '=' . $item . '&' . $suffixWithSorting,
140                                     'update' => $datagridName,
141                                     'script' => true,
142                                     'loading' => 'dg_hide_show(\'' . $datagridName . '\')'
143                                     ));
144                     }
145                 }
146                 
147                 if($page != $pager->getLastPage())
148                 {
149                     
150                     $pagerHtml.= link_to_remote(
151                             '<img src="' . sfDatagrid::getConfig('images_dir') . 'pager-arrow-right.gif" alt="" align="absmiddle" />',
152                             array(
153                                 'url' => $moduleAction . '?' . $this->P_PAGE . '=' . $pager->getNextPage() . '&' . $suffixWithSorting,
154                                 'update' => $datagridName,
155                                 'script' => true,
156                                 'loading' => 'dg_hide_show(\'' . $datagridName . '\')'
157                                 ));
158                 }
159             }
160             else
161             {
162                 $pagerHtml.= $this->traduct(sfDatagrid::getConfig('text_page')) . ' 1';
163             }
164             
165             $gridTotals.= $this->traduct(sfDatagrid::getConfig('text_numberofrecords')) . ' : ' . $pager->getNbResults();
166         }
167         
168         $url = $moduleAction . '?' . $this->P_PAGE . '=1' . $suffixWithSorting;
169         $url2 = $moduleAction.'?' . $this->P_PAGE . '=1'.$suffixWithDefaultSorting;
170         if($renderSearch)
171         {
172             $searchHtml.= content_tag('button', content_tag('span', $this->traduct(sfDatagrid::getConfig('text_search'))), array('type' => 'button', 'class' => 'button', 'name' => 'search_btn', 'onclick' => 'dg_send(\'' . $datagridName . '-form\', \'' . $datagridName . '\', \'search\', \'' . url_for($url) . '\')'));
173         
174             $searchHtml.= content_tag('button', content_tag('span', $this->traduct(sfDatagrid::getConfig('text_reset'))), array('type' => 'button', 'class' => 'button reset', 'name' => 'reset_btn', 'onclick' => 'dg_send(\'' . $datagridName . '-form\', \'' . $datagridName . '\', \'reset\', \'' . url_for($url2) . '\')'));
175     
176         }
177         
178             
179         if($renderPager)
180         {
181             return strtr($this->datagridPagerContainer, array(
182                         '%pager%' => strtr($this->datagridPager, array('%pager%' => $pagerHtml, '%grid_totals%' => $gridTotals)),
183                         '%search%' => $searchHtml,
184                         ));
185         }
186         else
187         {
188             if($renderSearch)
189             {
190                 return strtr($this->datagridPagerContainer, array(
191                             '%pager%' => '',
192                             '%search%' => $searchHtml,
193                             ));
194             }
195             else
196             {
197                 return '';
198             }
199         }
200     }
201     
202     /**
203      * Render the actions bar
204      *
205      * @param sfDatagrid $object The datagrid object
206      * @param string $defaultUrl The default Url
207      * @return string The html output
208      */
209     public function renderActionsBar($object, $defaultUrl)
210     {
211         $datagridName = $object->_get('datagridName');
212         $actions = $object->_get('datagridActions');
213         $keepRefresh = $object->_get('refreshKeeping');
214         
215         $linksHtml = '';
216         $actionSelect = '';
217         
218         if(count($actions) != 0)
219         {
220             $actionSelect.= select_tag('actions', array_flip($actions), array('id' => $datagridName . '_select'));
221             $actionSelect.= '&nbsp';
222             $actionSelect.= '<input type="button" name="actions" value="' . $this->traduct(sfDatagrid::getConfig('text_validate')) . '" onclick="dg_send(\'' . $datagridName . '-form\', \'' . $datagridName . '\', \'action\', \'\')" />';
223         }
224         
225         if($keepRefresh){
226             
227             $linksHtml.= link_to_remote($this->traduct(sfDatagrid::getConfig('text_defaultview')), array('url' => $defaultUrl . '&d_clear=1', 'update' => $datagridName, 'loading' => 'dg_hide_show(\'' . $datagridName . '\')'));
228         }
229         
230         if($actionSelect == '')
231         {
232             $actionSelect = '&nbsp;';
233         }
234         
235         return strtr($this->datagridActions, array(
236             '%links%' => $linksHtml,
237             '%actions%' => $actionSelect
238         ));
239     }
240     
241     /**
242      * Render the column headers
243      *
244      * @param sfDatagrid $object The datagrid object
245      * @param string $url The pre url for column sort
246      * @return string The html output
247      */
248     public function renderHeaders($object, $url)
249     {
250         $columns = $object->_get('columns');
251         $columnsOptions = $object->_get('columnsOptions');
252         $columnsSorting = $object->_get('columnsSort');
253         $datagridName = $object->_get('datagridName');
254         $sortBy = $object->_get('sortBy');
255         $sortOrder = $object->_get('sortOrder');
256         $actions = $object->_get('datagridActions');
257         
258         $htmlOutput = '';
259         $template = '';
260         
261         if(count($actions) != 0)
262         {
263             $htmlOutput.= content_tag('th', '&nbsp;', array('style' => 'width: 30px;'));
264         }
265         
266         foreach($columns as $key => $label)
267         {
268             if(!array_key_exists($key, $columnsOptions))
269             {
270                 $columnsOptions[$key] = array();
271             }
272             
273             if(!array_key_exists($key, $columnsSorting))
274             {
275                 $columnsSorting[$key] = '';
276             }
277
278             if($columnsSorting[$key] == 'nosort')
279             {
280                 $htmlOutput.= strtr($this->datagridHeaders, array(
281                     '%value%' => strtr($this->datagridHeadersNoSort, array('%value%' => $label)),
282                     '%header_options%' => _tag_options($columnsOptions[$key])
283                 ));
284             }
285             else
286             {
287                 if($key == $sortBy)
288                 {
289                     if($sortOrder == 'asc')
290                     {
291                         $order = 'desc';
292                     }
293                     else
294                     {
295                         $order = 'asc';
296                     }
297                 }
298                 else
299                 {
300                     $order = 'asc';
301                 }
302                 
303                 $htmlOutput.= strtr($this->datagridHeaders, array(
304                     '%value%' => $this->getSortingArrow($sortBy, $sortOrder, $key) . link_to_remote($label, array('update' => $datagridName, 'url' => $url . '&' . $this->P_SORT . '=' . $key . '&' . $this->P_ORDER . '=' . $order, 'script' => true, 'loading' => 'dg_hide_show(\'' . $datagridName . '\')'), $this->isSorting($sortBy, $key)),
305                     '%header_options%' => _tag_options($columnsOptions[$key])
306                 ));
307             }
308         }
309         
310         return content_tag('tr', $htmlOutput);
311     }
312     
313     /**
314      * Render the filter bar
315      *
316      * @param sfDatagrid $object The datagrid object
317      * @param string $suffix The url suffix
318      * @return string The html output
319      */
320     public function renderFilters($object, $suffix)
321     {       
322         $columns = array_keys($object->_get('columns'));
323         $columnsOptions = $object->_get('columnsOptions');
324         $filtersTypes = $object->_get('filtersTypes');
325         $actions = $object->_get('datagridActions');
326         $values = $object->_get('search');
327         $datagridName = $object->_get('datagridName');
328         
329         $filterHtml = '';
330         
331         if(count($actions) != 0)
332         {
333             $filterHtml.= content_tag('td', '&nbsp;', array('style' => 'width: 30px;', 'class' => 'filter', 'valign' => 'top'));
334         }
335         
336         foreach($columns as $column)
337         {
338             if(array_key_exists($column, $columnsOptions))
339             {
340                 $options = array_merge(array('class' => 'filter', 'valign' => 'top'), $columnsOptions[$column]);
341             }
342             else
343             {
344                 $options = array('class' => 'filter', 'valign' => 'top');
345             }
346             
347             if(array_key_exists($column, $filtersTypes))
348             {
349                 $type = $filtersTypes[$column];
350             }
351             else
352             {
353                 $type = 'VARCHAR';
354             }
355             
356             $filterHtml.= content_tag('td', $this->getInputFilter($type, $column, @$values[$column], $object, $suffix), $options);
357         }
358         
359         return $filterHtml;
360     }
361     
362     /**
363      * Get the input for the filter
364      *
365      * @param string $type The type of the filter
366      * @param string $column The column name
367      * @param string $value The value of the input
368      * @param sfDatagrid $object The datagrid object
369      * @param string $suffix The url suffix
370      * @return string The html output
371      */
372     protected function getInputFilter($type, $column, $value, $object, $suffix)
373     {
374         
375         $output = '';
376         try
377                     {
378                     /*
379                      * @todo il faudra penser a déplacer ce morceau de code afin de prendre en entrer $mapBuilder pour le
380                      * calculer qu'une fois
381                      */
382                     $tablePeer=$object->_get('peerTable').'Peer';
383                     $builder=$object->_get('peerTable').'MapBuilder';
384                     $mapBuilder=new $builder;
385                     $mapBuilder->doBuild();
386                     $adminrelated = $mapBuilder->getDatabaseMap()->getTable(strtolower($object->_get('peerTable')))->getColumn(strtoupper($column));
387                     }catch(Exception $e)
388                     {
389                         $adminrelated = '';
390                     }
391             switch($type)
392             {
393                 
394                 case 'FOREIGN':
395                     
396                      if(($adminrelated instanceof ColumnMap)&&($adminrelated->isForeignKey()))
397                         {
398                         $c=sfDatagrid::getConfig('class_for_foreign');
399                         $wSelect= new $c(
400                         array('model' => sfInflector::camelize($adminrelated->getRelatedTableName()),  'add_empty' =>true));
401                         $output = $wSelect->render('search[' . $column . ']', $value, array('style' => 'width: 100%;'));
402                         }
403                     break;
404                 case is_array($type):
405                     $choices[''] = '';
406                     
407                     foreach($type as $key => $values)
408                     {
409                         $choices[$key] = $values;
410                     }
411                     
412                     $wSelect = new sfWidgetFormSelect(array('choices' => $choices));
413                     $output = $wSelect->render('search[' . $column . ']', $value, array('style' => 'width: 100%;'));
414                     break;
415                     
416                 case 'NOTYPE':
417                     $output = '';
418                     break;
419                 
420                 case 'BOOLEAN':
421                     $wSelect = new sfWidgetFormSelect(array('choices' => array('' => '', 1 => 'Oui', 0 => 'Non')));
422                     $output = $wSelect->render('search[' . $column . ']', $value, array('style' => 'width: 100%;'));
423                     break;
424                     
425                 case (strtoupper($type) == 'DATE' || strtoupper($type) == 'TIMESTAMP'):
426                     if(@array_key_exists('start_' . $object->_get('datagridName'), $value) && $value['start_' . $object->_get('datagridName')] != '')
427                     {
428                         $value1 = format_date(strtotime($value['start_' . $object->_get('datagridName')]), 'dd.MM.yyyy');
429                     }
430                     else
431                     {
432                         $value1 = '';
433                     }
434                     
435                     if(@array_key_exists('start_' . $object->_get('datagridName'), $value) && $value['stop_' . $object->_get('datagridName')] != '')
436                     {
437                         $value2 = format_date(strtotime($value['stop_' . $object->_get('datagridName')]), 'dd.MM.yyyy');
438                     }
439                     else
440                     {
441                         $value2 = '';
442                     }
443                     if(@array_key_exists('null_' . $object->_get('datagridName'), $value) && $value['null_' . $object->_get('datagridName')] != '')
444                     {
445                         
446                         $value3 = array('null'=>$value['null_' . $object->_get('datagridName')][0]);
447                     }
448                     else
449                     {
450                         $value3 = null;
451                     }
452                     $wDateStart = new sfWidgetFormInput();
453                     $wDateStop = new sfWidgetFormInput();
454                     
455                     $output = '<span style="padding-bottom: 5px; display: block;">';
456                     $output.= $this->traduct(sfDatagrid::getConfig('text_from')) . ' ';
457                     $output.= $wDateStart->render('search[' . $column . '][start_' . $object->_get('datagridName') . ']', $value1, array('onclick' => 'displayDatePicker(this.name)', 'style' => 'width: 75px;'));
458                     $output.= '</span>';
459                     $output.= ' ' .$this->traduct(sfDatagrid::getConfig('text_to')) . ' ';
460                     $output.= $wDateStop->render('search[' . $column . '][stop_' . $object->_get('datagridName') . ']', $value2, array('type' => 'text', 'onclick' => 'displayDatePicker(this.name)', 'style' => 'width: 75px;'));
461                     
462                     if((($adminrelated instanceof ColumnMap)&&(!$adminrelated->isNotNull()))){
463                         $chk = new sfWidgetFormSelectCheckbox(array('choices'=>array('null'=>$this->traduct(sfDatagrid::getConfig('label_null')))));
464                         $output .= $chk->render('search[' . $column . '][null_'. $object->_get('datagridName') . ']',$value3,array());
465                     }
466                     break;
467                     
468                 default:
469                     $wInput = new sfWidgetFormInput();
470                     $url = $object->_get('moduleAction') . '?' . $this->P_PAGE . '=1' . $suffix . '&' . $this->P_SORT . '=' . $object->_get('sortBy') . '&' . $this->P_ORDER . '=' . $object->_get('sortOrder');
471                     $output = $wInput->render('search[' . $column . ']', $value, array('style' => 'width: 100%;', 'onkeydown' => 'dg_keydown(\'' . $object->_get('datagridName') . '-form\', \'' . $object->_get('datagridName') . '\', \'search\', \'' . url_for($url) . '\', event)'));
472                     break;
473             }
474         
475         return content_tag('div', $output);
476     }
477     
478     /**
479      * Check if it's the sorting column
480      *
481      * @param string $sortBy The column now sorting
482      * @param string $column The column name
483      * @return array The array with the class parameter if it's the sorting column
484      */
485     protected function isSorting($sortBy, $column)
486     {
487         if($sortBy == $column)
488         {
489             return array('class' => 'sorting');
490         }
491         else
492         {
493             return array();
494         }
495     }
496     
497     /**
498      * Get the image arrow for sorting indication
499      *
500      * @param string $sortBy The column now sorting
501      * @param string $sortOrder Asc or desc
502      * @param string $column The column name
503      * @return string The html of the image
504      */
505     protected function getSortingArrow($sortBy, $sortOrder, $column)
506     {
507         $html = '';
508         /* On a localhost with alias the arrow not appear so we must set the full path */
509          $request = sfContext::getInstance()->getRequest();
510            $sf_relative_url_root = $request->getRelativeUrlRoot();
511         if ($column == $sortBy){
512             
513             $html = '<span><img src="' .$sf_relative_url_root.sfDatagrid::getConfig('images_dir') . 'header-arrow-' . $sortOrder . '.gif" alt="" /></span>';
514         }
515         
516         return $html;
517     }
518     
519     /**
520      * Get the html output for the row
521      *
522      * @param sfDatagrid $object The datagrid object
523      * @param array $rowValues The array with the values
524      * @param string $rowClass The css class for the row
525      * @param string $rowIndexDefaultValue The RowIndex Default if ! $rowIndex
526      * @return string The html output for the row
527      */
528     public function renderRow($object, $rowValues, $rowClass = null,$rowIndexDefaultValue=null)
529     {
530         $columns = array_keys($object->_get('columns'));
531         $rowOptions = $object->_get('columnsOptions');
532         $rowAction = $object->_get('rowAction');
533         $actions = $object->_get('datagridActions');
534         
535         $htmlOutput = '';
536         $columnIncrement = 0;
537         
538         if(is_array($rowValues))
539         {
540             if(count($actions) != 0)
541             {
542                 $firstColumn = array_shift($rowValues);
543                 $htmlOutput.= content_tag('td', $firstColumn, array('style' => 'width: 30px', 'align' => 'center'));
544             }
545             
546             foreach($rowValues as $value)
547             {
548                 $columnName = $columns[$columnIncrement];
549                 
550                 if(!is_null($rowAction))
551                 {
552                     preg_match('/%(?<param>\w+)%/', $rowAction, $matches);
553                     $rowIndex = array_search($matches['param'], $columns);
554                     if(!$rowIndex){
555                         
556                         if(!is_null($rowIndexDefaultValue)){
557                             $this->addOption('onclick', $rowOptions[$columnName], "document.location.href='" . url_for(strtr($rowAction, array('%' . $matches['param'] . '%' => $rowIndexDefaultValue))) . "'");
558                             $this->addOption('style', $rowOptions[$columnName], 'cursor:pointer;');
559                         }else{
560                             throw new Exception("Impossible to find column ".$matches['param']);
561                         }
562                     }else{
563                         $this->addOption('onclick', $rowOptions[$columnName], "document.location.href='" . url_for(strtr($rowAction, array('%' . $matches['param'] . '%' => $rowValues[$rowIndex]))) . "'");
564                         $this->addOption('style', $rowOptions[$columnName], 'cursor:pointer;');
565                     }
566                 }
567                 
568                 if(!array_key_exists($columnName, $rowOptions))
569                 {               
570                     $rowOptions[$columnName] = '';
571                 }
572                 
573                 $htmlOutput.= strtr($this->datagridRows, array(
574                     '%row_options%' => _tag_options($rowOptions[$columnName]),
575                     '%value%' => $value
576                 ));
577                 
578                 $columnIncrement++;
579             }
580         }
581         else
582         {
583             if(count($actions) != 0)
584             {
585                 $rowOptions = array('colspan' => count($columns) + 1, 'align' => 'center');
586             }
587             else
588             {
589                 $rowOptions = array('colspan' => count($columns), 'align' => 'center');
590             }
591             
592             $htmlOutput.= strtr($this->datagridRows, array(
593                 '%row_options%' => _tag_options($rowOptions),
594                 '%value%' => $this->traduct(sfDatagrid::getConfig('text_novalueinrows'))
595             ));
596         }
597         
598         return content_tag('tr', $htmlOutput, array('class' => $rowClass));
599     }
600     
601     /**
602      * Add a value to an options array
603      *
604      * @param string $optionName The name of the option
605      * @param array $optionsArray    The array of options
606      * @param mixed $value The value
607      */
608     protected function addOption($optionName, &$optionsArray, $value)
609     {
610         if (!is_array($optionsArray))
611         {
612             $optionsArray = array();
613         }
614         
615         if (array_key_exists($optionName, $optionsArray))
616         {
617             $optionsArray[$optionName].= $value;
618         }
619         else
620         {
621             $optionsArray[$optionName] = $value;
622         }
623     }
624
625     /**
626      * Render the flash message
627      *
628      * @param string $name The name of the flash
629      * @param string $additional_classes The additionals classes
630      * @return string The html output
631      */
632     protected function getFlash($name = 'flash', $additional_classes = '')
633     {
634         $html = '';
635         
636         if ($additional_classes != ''){
637             
638             $additional_classes = ' ' . $additional_classes;   
639         }
640
641         if (sfContext::getInstance()->getUser()->hasFlash($name)){
642             
643             $html.= '<div class="flash' . $additional_classes . '">' . sfContext::getInstance()->getUser()->getFlash($name) . '</div>';   
644         }
645         
646         return $html;
647     }
648     
649     /**
650      * Use i18n function (if is active) to traduct a value
651      *
652      * @param string $value The text to traduct
653      * @return string The traducted value
654      */
655     protected function traduct($value)
656     {
657         if (sfConfig::get('sf_i18n'))
658         {
659             $value = __($value);
660         }
661         
662         return $value;
663     }
664 }
665 ?>
Note: See TracBrowser for help on using the browser.