Exemplo n.º 1
0
 /**
  * Set row class
  *
  * @param   array  &$data  row data to set class for
  *
  * @return  null
  */
 public function setRowClass(&$data)
 {
     $rowclass = $this->getParams()->get('use_as_row_class');
     if ($rowclass == 1) {
         $col = $this->getFullName(false, true, false);
         $rawcol = $col . '_raw';
         foreach ($data as $groupk => $group) {
             for ($i = 0; $i < count($group); $i++) {
                 $c = false;
                 if (isset($data[$groupk][$i]->data->{$rawcol})) {
                     $c = $data[$groupk][$i]->data->{$rawcol};
                 } elseif (isset($data[$groupk][$i]->data->{$col})) {
                     $c = $data[$groupk][$i]->data->{$col};
                 }
                 if ($c !== false) {
                     $c = preg_replace('/[^A-Z|a-z|0-9]/', '-', $c);
                     $c = FabrikString::ltrim($c, '-');
                     $c = FabrikString::rtrim($c, '-');
                     // $$$ rob 24/02/2011 can't have numeric class names so prefix with element name
                     if (is_numeric($c)) {
                         $c = $this->getElement()->name . $c;
                     }
                     $data[$groupk][$i]->class .= ' ' . $c;
                 }
             }
         }
     }
 }