public function render() { if (!count($this->_items)) { return '<div class="span4"><div class="alert alert-info"><button type="button" class="close" data-dismiss="alert">×</button>' . $this->_config['noResultMessage'] . '</div></div>'; } $pagination = $this->_config['pagination']; $fields = $this->_config['fields']; $addable = $this->_config['addable']; $viewable = $this->_config['viewable']; $editable = $this->_config['editable']; $deletable = $this->_config['deletable']; $duplicable = $this->_config['duplicable']; if (\Thin\Arrays::exists('export', $this->_config)) { $export = $this->_config['export']; if (count($export)) { $this->_export = $export; } } $order = !strlen($this->_request->getCrudOrder()) ? $this->_config['defaultOrder'] : $this->_request->getCrudOrder(); $orderDirection = !strlen($this->_request->getCrudOrderDirection()) ? $this->_config['defaultOrderDirection'] : $this->_request->getCrudOrderDirection(); $sorted = true === $this->_config['order'] ? 'tablesorter' : ''; $html = '<table class="table table-striped ' . $sorted . ' table-bordered table-condensed">' . NL; $html .= '<thead>' . NL; $html .= '<tr>' . NL; foreach ($fields as $field => $infosField) { if (true === $infosField['onList']) { if (true !== $infosField['sortable']) { $html .= '<th class="no-sorter">' . \Thin\Html\Helper::display($infosField['label']) . '</th>' . NL; } else { if ($field == $order) { $directionJs = 'ASC' == $orderDirection ? 'DESC' : 'ASC'; $js = 'orderGoPage(\'' . $field . '\', \'' . $directionJs . '\');'; $html .= '<th> <div onclick="' . $js . '" class="text-left field-sorting ' . \Thin\Inflector::lower($orderDirection) . '" rel="' . $field . '"> ' . \Thin\Html\Helper::display($infosField['label']) . ' </div> </th>'; } else { $js = 'orderGoPage(\'' . $field . '\', \'ASC\');'; $html .= '<th> <div onclick="' . $js . '" class="text-left field-sorting" rel="' . $field . '"> ' . \Thin\Html\Helper::display($infosField['label']) . ' </div> </th>'; } } } } $html .= '<th class="no-sorter">Actions</th>' . NL; $html .= '</tr>' . NL; $html .= '</thead>' . NL; $html .= '<tbody>' . NL; foreach ($this->_items as $item) { $html .= '<tr>' . NL; foreach ($fields as $field => $infosField) { if (true === $infosField['onList']) { $content = $infosField['content']; $options = \Thin\Arrays::exists('options', $infosField) ? $infosField['options'] : array(); if (empty($options)) { $options = array(); } if (!in_array('nosql', $options)) { $getter = 'get' . \Thin\Inflector::camelize($field); $value = $item->{$getter}(); } else { $value = $content; } if (strstr($content, '##self##') || strstr($content, '##em##') || strstr($content, '##field##') || strstr($content, '##id##')) { $content = repl(array('##self##', '##em##', '##field##', '##id##'), array($value, $this->_em, $field, $item->getId()), $content); $value = \Thin\Crud::internalFunction($content); } if (empty($value)) { $value = ' '; } $html .= '<td>' . \Thin\Html\Helper::display($value) . '</td>' . NL; } } $actions = ''; if (true === $viewable) { $actions .= '<a href="' . \Thin\Crud::getRoute('view', array('id' => $item->getId(), 'entity' => $item->_getEntity(), 'table' => $item->_getTable())) . '"><i title="afficher" class="icon-file"></i></a> '; } if (true === $editable) { $actions .= '<a href="' . \Thin\Crud::getRoute('edit', array('id' => $item->getId(), 'entity' => $item->_getEntity(), 'table' => $item->_getTable())) . '"><i title="éditer" class="icon-edit"></i></a> '; } if (true === $duplicable) { $actions .= '<a href="' . \Thin\Crud::getRoute('duplicate', array('id' => $item->getId(), 'entity' => $item->_getEntity(), 'table' => $item->_getTable())) . '"><i title="dupliquer" class="icon-plus"></i></a> '; } if (true === $deletable) { $actions .= '<a href="#" onclick="if (confirm(\'Confirmez-vous la suppression de cet élément ?\')) document.location.href = \'' . \Thin\Crud::getRoute('delete', array('id' => $item->getId(), 'entity' => $item->_getEntity(), 'table' => $item->_getTable())) . '\';"><i title="supprimer" class="icon-trash"></i></a> '; } $html .= '<td class="col_plus">' . $actions . '</td>' . NL; $html .= '</tr>' . NL; } $html .= '</tbody>' . NL; $html .= '</table>' . NL; return $html; }