Esempio n. 1
0
 public function listing()
 {
     $fields = $this->fields();
     $fieldInfos = isAke($this->config, 'fields');
     $defaultOrder = isAke($this->config, 'default_order', $this->model->pk());
     $defaultDir = isAke($this->config, 'default_order_direction', 'ASC');
     $limit = isAke($this->config, 'items_by_page', Config::get('crud.items.number', 25));
     $many = isAke($this->config, 'many');
     $where = isAke($_REQUEST, 'crud_where', null);
     $page = isAke($_REQUEST, 'crud_page', 1);
     $order = isAke($_REQUEST, 'crud_order', $defaultOrder);
     $orderDirection = isAke($_REQUEST, 'crud_order_direction', $defaultDir);
     $export = isAke($_REQUEST, 'crud_type_export', false);
     $export = !strlen($export) ? false : $export;
     $offset = $page * $limit - $limit;
     $whereData = '';
     if (!empty($where)) {
         $whereData = $this->parseQuery($where);
     }
     $db = call_user_func_array(array('\\Thin\\Database', 'instance'), $this->model->args);
     if (strstr($whereData, ' && ')) {
         $wheres = explode(' && ', $whereData);
         foreach ($wheres as $tmpWhere) {
             $db = $this->model->where($tmpWhere);
         }
     } else {
         if (strlen($whereData)) {
             $db = $this->model->where($whereData);
         } else {
             $db = $this->model->rows();
         }
     }
     $results = $db->order($order, $orderDirection)->exec();
     if (count($results) < 1) {
         if (strlen($where)) {
             return '<div class="alert alert-danger col-md-4 col-md-pull-4 col-md-push-4">La requête ne remonte aucun résultat.</div>';
         } else {
             return '<div class="alert alert-info col-md-4 col-md-pull-4 col-md-push-4">Aucune donnée à afficher..</div>';
         }
     }
     if (false !== $export) {
         return $this->export($export, $results);
     }
     $total = count($results);
     $last = ceil($total / $limit);
     $paginator = new Paginator($results, $page, $total, $limit, $last);
     $data = $paginator->getItemsByPage();
     $pagination = $paginator->links();
     $pagination = '<div class="row">
         <div class="col-md-12">
         ' . $pagination . '
         </div>
         </div>';
     $html = $pagination . '<div class="row"><div class="col-md-12"><form action="/crud/static/list/table/' . $this->model->table . '" id="listForm" method="post">
         <input type="hidden" name="crud_page" id="crud_page" value="' . $page . '" /><input type="hidden" name="crud_order" id="crud_order" value="' . $order . '" /><input type="hidden" name="crud_order_direction" id="crud_order_direction"  value="' . $orderDirection . '" /><input type="hidden" id="crud_where" name="crud_where" value="' . \Thin\Crud::checkEmpty('crud_where') . '" /><input type="hidden" id="crud_type_export" name="crud_type_export" value="" />
         <table style="clear: both;" class="table table-striped tablesorter table-bordered table-condensed table-hover">
                     <thead>
                     <tr>';
     foreach ($fields as $field) {
         $fieldSettings = isAke($fieldInfos, $field);
         $label = isAke($fieldSettings, 'label', ucfirst($field));
         $listable = isAke($fieldSettings, 'is_listable', true);
         $sortable = isAke($fieldSettings, 'is_sortable', true);
         if (!$listable || $field == $this->model->pk()) {
             continue;
         }
         if (!$sortable) {
             $html .= '<th>' . \Thin\Html\Helper::display($label) . '</th>';
         } else {
             if ($field == $order) {
                 $directionJs = 'ASC' == $orderDirection ? 'DESC' : 'ASC';
                 $js = 'orderGoPage(\'' . $field . '\', \'' . $directionJs . '\');';
                 $html .= '<th><div onclick="' . $js . '" class="text-left field-sorting ' . Inflector::lower($orderDirection) . '" rel="' . $field . '">' . \Thin\Html\Helper::display($label) . '</div></th>';
             } else {
                 $js = 'orderGoPage(\'' . $field . '\', \'ASC\');';
                 $html .= '<th><div onclick="' . $js . '" class="text-left field-sorting" rel="' . $field . '">' . \Thin\Html\Helper::display($label) . '</div></th>';
             }
         }
     }
     if (count($many)) {
         $html .= '<th>Rel.</th>';
     }
     $html .= '<th style="text-align: center;">Action</th>
                     </tr>
                     </thead>
                     <tbody>';
     foreach ($data as $item) {
         $id = isAke($item, $this->model->pk(), null);
         $html .= '<tr ondblclick="document.location.href = \'/crud/static/update/table/' . $this->model->table . '/id/' . $id . '\';">';
         foreach ($fields as $field) {
             $fieldSettings = isAke($fieldInfos, $field);
             $listable = isAke($fieldSettings, 'is_listable', true);
             if (!$listable || $field == $this->model->pk()) {
                 continue;
             }
             $value = isAke($item, $field, null);
             $closure = isAke($fieldSettings, 'content_view', false);
             if (false === $closure || !is_callable($closure)) {
                 $continue = true;
                 if (ake('form_type', $fieldSettings)) {
                     if ($fieldSettings['form_type'] == 'image' && strlen($value)) {
                         $html .= '<td><img src="' . $value . '" style="max-width: 200px;" /></td>';
                         $continue = false;
                     }
                     if ($fieldSettings['form_type'] == 'email' && strlen($value)) {
                         $html .= '<td><a href="mailto:' . $value . '">' . \Thin\Html\Helper::display($this->truncate($value)) . '</a></td>';
                         $continue = false;
                     }
                     if ($fieldSettings['form_type'] == 'file' && strlen($value)) {
                         $html .= '<td><a class="btn btn-small btn-success" href="' . $value . '"><i class="fa fa-download"></i></td>';
                         $continue = false;
                     }
                 }
                 if (true === $continue) {
                     if ('email' == $field) {
                         $html .= '<td><a href="mailto:' . $value . '">' . \Thin\Html\Helper::display($this->truncate($value)) . '</a></td>';
                     } else {
                         $html .= '<td>' . \Thin\Html\Helper::display($this->truncate($value)) . '</td>';
                     }
                 }
             } else {
                 $value = call_user_func_array($closure, array($item));
                 $html .= '<td>' . \Thin\Html\Helper::display($value) . '</td>';
             }
         }
         if (count($many)) {
             $html .= '<td><ul class="list-inline">';
             foreach ($many as $rel) {
                 $foreignCrud = new self(model($rel));
                 $nameRel = isAke($foreignCrud->config(), 'plural', $rel . 's');
                 $html .= '<li><a class="btn btn-primary" target="_blank" href="/crud/static/many/table/' . $rel . '/foreign/' . $this->model->table . '_id/id/' . $id . '"><i class="fa fa-chain"></i> ' . $nameRel . '</a></li>';
             }
             $html .= '</ul></td>';
         }
         $html .= $this->options($id);
         $html .= '</tr>';
     }
     $html .= '</tbody>
                 </table></form>' . $pagination . '</div></div>';
     return $html;
 }
Esempio n. 2
0
 public function listing($customFields = false)
 {
     $fields = $this->fields();
     $fieldInfos = isAke($this->config, 'fields');
     $before_list = isAke($this->config, 'before_list', false);
     if (false !== $before_list) {
         $before_list([]);
     }
     $fieldsSettings = Db::instance('core', 'datafieldssettings')->where("table = " . $this->model->table)->where("database = " . $this->model->db)->where('user_id = ' . auth()->user()->getId())->exec();
     $userSettings = [];
     if (count($fieldsSettings)) {
         foreach ($fieldsSettings as $fieldSettings) {
             foreach ($fieldSettings as $k => $v) {
                 if (strstr($k, 'is_')) {
                     $userSettings[$fieldSettings['field']][$k] = 1 == $v ? true : false;
                 }
             }
         }
     }
     $tableSettings = Db::instance('core', 'datatablesettings')->where("table = " . $this->model->table)->where('database = ' . $this->model->db)->where('user_id = ' . auth()->user()->getId())->first();
     if (request()->getKill() == 1) {
         session('dataTableCrudRedis::' . $this->model->table)->setPage(null)->setOrder(null)->setOrderDirection(null)->setWhere(null);
     }
     $limit = isAke($tableSettings, 'rows', isAke($this->config, 'items_by_page', Config::get('crud.items.number', 25)));
     $defaultOrder = isAke($tableSettings, 'sort', isAke($this->config, 'default_order', $this->model->pk()));
     $defaultDir = isAke($this->config, 'default_order_direction', 'ASC');
     $many = isAke($this->config, 'many');
     $plus = isAke($this->config, 'options_form', '');
     $readable = isAke($this->config, 'readable', true);
     $updatable = isAke($this->config, 'updatable', true);
     $duplicatable = isAke($this->config, 'duplicatable', true);
     $deletable = isAke($this->config, 'deletable', true);
     $optionsConfig = ['readable' => $readable, 'updatable' => $updatable, 'duplicatable' => $duplicatable, 'deletable' => $deletable];
     $where = isAke($_REQUEST, 'crud_where', null);
     $page = isAke($_REQUEST, 'crud_page', 1);
     $order = isAke($_REQUEST, 'crud_order', $defaultOrder);
     $orderDirection = isAke($_REQUEST, 'crud_order_direction', $defaultDir);
     $export = isAke($_REQUEST, 'crud_type_export', false);
     $updated_at = isAke($this->config, 'updated_at', false);
     $created_at = isAke($this->config, 'created_at', false);
     $export = !strlen($export) ? false : $export;
     $offset = $page * $limit - $limit;
     if (!count($_POST)) {
         $sessionWhere = session('dataTableCrudRedis::' . $this->model->table)->getWhere();
         $sessionPage = session('dataTableCrudRedis::' . $this->model->table)->getPage();
         $sessionOrder = session('dataTableCrudRedis::' . $this->model->table)->getOrder();
         $sessionOrderDirection = session('dataTableCrudRedis::' . $this->model->table)->getOrderDirection();
         $where = !strlen($sessionWhere) ? $where : $sessionWhere;
         $page = !strlen($sessionPage) ? $where : $sessionPage;
         $order = !strlen($sessionOrder) ? $order : $sessionOrder;
         $orderDirection = !strlen($sessionOrderDirection) ? $orderDirection : $sessionOrderDirection;
     }
     $page = !is_numeric($page) ? 1 : $page;
     session('dataTableCrudRedis::' . $this->model->table)->setPage($page)->setOrder($order)->setOrderDirection($orderDirection)->setWhere($where);
     $whereData = '';
     if (!empty($where)) {
         $whereData = $this->parseQuery($where);
     }
     $db = call_user_func_array(['\\Dbredis\\Db', 'instance'], [$this->model->db, $this->model->table]);
     if (strstr($whereData, ' && ') || strstr($whereData, ' || ')) {
         $db = $this->model->query($whereData);
     } else {
         if (strlen($whereData)) {
             $db = $this->model->where($whereData);
         } else {
             $db = $this->model->full();
         }
     }
     $results = $db->order($order, $orderDirection)->exec();
     if (count($results) < 1) {
         if (strlen($where)) {
             return '<div class="alert alert-danger col-md-4 col-md-pull-4 col-md-push-4">La requête ne remonte aucun résultat.</div>';
         } else {
             return '<div class="alert alert-info col-md-4 col-md-pull-4 col-md-push-4">Aucune donnée à afficher..</div>';
         }
     }
     if (false !== $export) {
         return $this->export($export, $results);
     }
     $total = count($results);
     $last = ceil($total / $limit);
     $paginator = new Paginator($results, $page, $total, $limit, $last);
     $data = $paginator->getItemsByPage();
     $pagination = $paginator->links();
     $start = $limit * $page - ($limit - 1);
     $end = $limit * $page;
     $end = $end > $total ? $total : $end;
     if (strlen($pagination)) {
         $pagination = '<div class="row">
             <div class="col-md-3">
             Enregistrements ' . $start . ' à ' . $end . ' sur ' . $total . '
             </div>
             <div class="col-md-9">
             ' . $pagination . '
             </div>
             </div>';
     } else {
         $pagination = '<div class="row"><div class="col-md-12">' . $total . ' enregistrements<br /><br /></div></div>';
     }
     $html = $pagination . '<div class="row"><div class="col-md-12"><form action="' . urlAction('list') . '/table/' . $this->model->table . '/database/' . $this->model->db . '" id="listForm" method="post">
         <input type="hidden" name="crud_page" id="crud_page" value="' . $page . '" /><input type="hidden" name="crud_order" id="crud_order" value="' . $order . '" /><input type="hidden" name="crud_order_direction" id="crud_order_direction"  value="' . $orderDirection . '" /><input type="hidden" id="crud_where" name="crud_where" value="' . \Thin\Crud::checkEmpty('crud_where') . '" /><input type="hidden" id="crud_type_export" name="crud_type_export" value="" />';
     if ($order != 'updated_at') {
         $html .= '<a rel="tooltip" title="Classer du plus récent au plus ancien" href="#" class="btn btn-default" onclick="recent(); return false;"><i class="fa fa-plus"></i> <i class="fa fa-clock-o"></i></a>&nbsp;&nbsp;<a rel="tooltip" title="Classer du plus ancien au plus récent" href="#" class="btn btn-default" onclick="old(); return false;"><i class="fa fa-minus"></i> <i class="fa fa-clock-o"></i></a><br><br>';
     } else {
         if ($orderDirection == 'ASC') {
             $html .= '<a rel="tooltip" title="Classer du plus récent au plus ancien" href="#" class="btn btn-default" onclick="recent(); return false;"><i class="fa fa-plus"></i> <i class="fa fa-clock-o"></i></a><br><br>';
         } else {
             $html .= '<a rel="tooltip" title="Classer du plus ancien au plus récent" href="#" class="btn btn-default" onclick="old(); return false;"><i class="fa fa-minus"></i> <i class="fa fa-clock-o"></i></a><br><br>';
         }
     }
     $html .= '<table style="clear: both;" class="table table-striped tablesorter table-bordered table-condensed table-hover">
                     <thead>
                     <tr>';
     if (Arrays::is($created_at)) {
         $label = isAke($created_at, 'label', 'Créé');
         if ('created_at' == $order) {
             $directionJs = 'ASC' == $orderDirection ? 'DESC' : 'ASC';
             $js = 'orderGoPage(\'created_at\', \'' . $directionJs . '\');';
             $html .= '<th><div onclick="' . $js . '" class="text-left field-sorting ' . Inflector::lower($orderDirection) . '" rel="created_at">' . \Thin\Html\Helper::display($label) . '</div></th>';
         } else {
             $js = 'orderGoPage(\'created_at\', \'ASC\');';
             $html .= '<th><div onclick="' . $js . '" class="text-left field-sorting" rel="created_at">' . \Thin\Html\Helper::display($label) . '</div></th>';
         }
     }
     if (Arrays::is($updated_at)) {
         $label = isAke($updated_at, 'label', 'MAJ');
         if ('updated_at' == $order) {
             $directionJs = 'ASC' == $orderDirection ? 'DESC' : 'ASC';
             $js = 'orderGoPage(\'updated_at\', \'' . $directionJs . '\');';
             $html .= '<th><div onclick="' . $js . '" class="text-left field-sorting ' . Inflector::lower($orderDirection) . '" rel="updated_at">' . \Thin\Html\Helper::display($label) . '</div></th>';
         } else {
             $js = 'orderGoPage(\'updated_at\', \'ASC\');';
             $html .= '<th><div onclick="' . $js . '" class="text-left field-sorting" rel="updated_at">' . \Thin\Html\Helper::display($label) . '</div></th>';
         }
     }
     foreach ($fields as $field) {
         $userInfos = isAke($userSettings, $field, []);
         $fieldSettings = isAke($fieldInfos, $field);
         $listable = isAke($userInfos, 'is_listable', isAke($fieldSettings, 'is_listable', false));
         $sortable = isAke($userInfos, 'is_sortable', isAke($fieldSettings, 'is_sortable', false));
         $fieldSettings = isAke($fieldInfos, $field);
         $label = isAke($fieldSettings, 'label', ucfirst($field));
         if (!$listable || $field == $this->model->pk()) {
             continue;
         }
         if (!$sortable) {
             $html .= '<th>' . \Thin\Html\Helper::display($label) . '</th>';
         } else {
             if ($field == $order) {
                 $directionJs = 'ASC' == $orderDirection ? 'DESC' : 'ASC';
                 $js = 'orderGoPage(\'' . $field . '\', \'' . $directionJs . '\');';
                 $html .= '<th><div onclick="' . $js . '" class="text-left field-sorting ' . Inflector::lower($orderDirection) . '" rel="' . $field . '">' . \Thin\Html\Helper::display($label) . '</div></th>';
             } else {
                 $js = 'orderGoPage(\'' . $field . '\', \'ASC\');';
                 $html .= '<th><div onclick="' . $js . '" class="text-left field-sorting" rel="' . $field . '">' . \Thin\Html\Helper::display($label) . '</div></th>';
             }
         }
     }
     if (true === $customFields) {
         $html .= '<th style="text-align: center;">Attr.</th>';
     }
     if (count($many)) {
         $html .= '<th style="text-align: center;">Rel.</th>';
     }
     $html .= '<th style="text-align: center;">Action</th></tr></thead><tbody>';
     foreach ($data as $item) {
         $id = isAke($item, $this->model->pk(), null);
         $html .= '<tr ondblclick="document.location.href = \'' . urlAction('update') . '/table/' . $this->model->table . '/database/' . $this->model->db . '/id/' . $id . '\';">';
         if (Arrays::is($created_at)) {
             $format = isAke($created_at, 'format', 'd/m/Y H:i:s');
             $value = date($format, isAke($item, 'created_at', time()));
             $html .= '<td>' . \Thin\Html\Helper::display($value) . '</td>';
         }
         if (Arrays::is($updated_at)) {
             $format = isAke($updated_at, 'format', 'd/m/Y H:i:s');
             $value = date($format, isAke($item, 'updated_at', time()));
             $html .= '<td>' . \Thin\Html\Helper::display($value) . '</td>';
         }
         foreach ($fields as $field) {
             $userInfos = isAke($userSettings, $field, []);
             $fieldSettings = isAke($fieldInfos, $field);
             $listable = isAke($userInfos, 'is_listable', isAke($fieldSettings, 'is_listable', false));
             $languages = isAke($fieldSettings, 'languages');
             if (!$listable || $field == $this->model->pk()) {
                 continue;
             }
             $value = !count($languages) ? isAke($item, $field, null) : isAke($item, $field . '_' . Arrays::first($languages), null);
             $closure = isAke($fieldSettings, 'content_view', false);
             if (false === $closure || !is_callable($closure)) {
                 $continue = true;
                 if (ake('form_type', $fieldSettings)) {
                     if ($fieldSettings['form_type'] == 'image' && strlen($value)) {
                         $html .= '<td><img src="' . $value . '" style="max-width: 200px;" /></td>';
                         $continue = false;
                     }
                     if ($fieldSettings['form_type'] == 'email' && strlen($value)) {
                         $html .= '<td><a href="mailto:' . $value . '">' . \Thin\Html\Helper::display($this->truncate($value)) . '</a></td>';
                         $continue = false;
                     }
                     if ($fieldSettings['form_type'] == 'file' && strlen($value)) {
                         $html .= '<td><a class="btn btn-small btn-success" href="' . $value . '"><i class="fa fa-download"></i></td>';
                         $continue = false;
                     }
                 }
                 if (true === $continue) {
                     if ('email' == $field) {
                         $html .= '<td><a href="mailto:' . $value . '">' . \Thin\Html\Helper::display($this->truncate($value)) . '</a></td>';
                     } else {
                         $html .= '<td>';
                         if (is_array($value)) {
                             $value = 'array';
                         }
                         if (strlen($value) >= 20) {
                             $html .= '<span rel="tooltip" title="' . \Thin\Html\Helper::display($value) . '">';
                         }
                         $html .= \Thin\Html\Helper::display($this->truncate($value));
                         if (strlen($value) >= 20) {
                             $html .= '</span>';
                         }
                         $html .= '</td>';
                     }
                 }
             } else {
                 $value = call_user_func_array($closure, array($item));
                 $html .= '<td>' . \Thin\Html\Helper::display($value) . '</td>';
             }
         }
         if (true === $customFields) {
             $html .= '<td style="text-align: center;"><a href="' . urlAction('customfields') . '/type/' . $this->model->table . '/row_id/' . $id . '" target="_blank" rel="tooltip" title="Gestion des attributs supplémentaires" class="btn btn-success"><i class="fa fa-tags"></i></a></td>';
         }
         if (count($many)) {
             $html .= '<td style="text-align: center;"><ul class="list-inline">';
             foreach ($many as $rel) {
                 $foreignCrud = new self(Db::instance($this->model->db, $rel));
                 $nameRel = isAke($foreignCrud->config(), 'plural', $rel . 's');
                 $html .= '<li style="margin-right: 5px;"><a rel="tooltip" title="Afficher les ' . strtolower($nameRel) . ' en relation" class="btn btn-primary" target="_blank" href="' . urlAction('many') . '/table/' . $rel . '/foreign/' . $this->model->table . '_id/id/' . $id . '/database/' . $this->model->db . '"><i class="fa fa-chain"></i></a></li>';
             }
             $html .= '</ul></td>';
         }
         $html .= $this->options($id, $optionsConfig, $plus);
         $html .= '</tr>';
     }
     $html .= '</tbody></table></form>' . $pagination . '</div></div>';
     return $html;
 }
Esempio n. 3
0
 protected function makeSearch()
 {
     $where = !strlen($this->_request->getCrudWhere()) ? '' : \Thin\Crud::makeQueryDisplay($this->_request->getCrudWhere(), $this->_em);
     $search = '<div class="span10">' . NL;
     if (!empty($where)) {
         $search .= '<span class="badge badge-success">Recherche en cours : ' . $where . '</span>';
         $search .= '&nbsp;&nbsp;<a class="btn btn-warning" href="#" onclick="document.location.href = document.URL;"><i class="icon-trash icon-white"></i> Supprimer cette recherche</a>&nbsp;&nbsp;';
     }
     $search .= '<button id="newCrudSearch" type="button" class="btn btn-info" onclick="$(\'#crudSearchDiv\').slideDown();$(\'#newCrudSearch\').hide();$(\'#hideCrudSearch\').show();"><i class="icon-search icon-white"></i> Effectuer une nouvelle recherche</button>';
     $search .= '&nbsp;&nbsp;<button id="hideCrudSearch" type="button" style="display: none;" class="btn btn-danger" onclick="$(\'#crudSearchDiv\').slideUp();$(\'#newCrudSearch\').show();$(\'#hideCrudSearch\').hide();">Masquer la recherche</button>';
     $search .= '<fieldset id="crudSearchDiv" style="display:none;">' . NL;
     $search .= '<hr />' . NL;
     $i = 0;
     $fieldsJs = array();
     $js = '<script type="text/javascript">' . NL;
     foreach ($this->_config['fields'] as $field => $infosField) {
         if (true === $infosField['searchable']) {
             $fieldsJs[] = "'{$field}'";
             $search .= '<div class="control-group">' . NL;
             $search .= '<label class="control-label">' . \Thin\Html\Helper::display($infosField['label']) . '</label>' . NL;
             $search .= '<div class="controls" id="crudControl_' . $i . '">' . NL;
             $search .= '<select id="crudSearchOperator_' . $i . '">
                 <option value="=">=</option>
                 <option value="LIKE">Contient</option>
                 <option value="NOT LIKE">Ne contient pas</option>
                 <option value="START">Commence par</option>
                 <option value="END">Finit par</option>
                 <option value="<">&lt;</option>
                 <option value=">">&gt;</option>
                 <option value="<=">&le;</option>
                 <option value=">=">&ge;</option>
                 </select>' . NL;
             $content = $infosField['contentSearch'];
             if (empty($content)) {
                 $search .= '<input type="text" id="crudSearchValue_' . $i . '" value="" />';
             } else {
                 $content = repl(array('##field##', '##em##', '##i##'), array($field, $this->_em, $i), $content);
                 $search .= \Thin\Crud::internalFunction($content);
             }
             $search .= '&nbsp;&nbsp;<a class="btn" href="#" onclick="addRowSearch(\'' . $field . '\', ' . $i . '); return false;"><i class="icon-plus"></i></a>';
             $search .= '</div>' . NL;
             $search .= '</div>' . NL;
             $i++;
         }
     }
     $js .= 'var searchFields = [' . implode(', ', $fieldsJs) . ']; var numFieldsSearch = ' . ($i - 1) . ';';
     $js .= '</script>' . NL;
     $search .= '<div class="control-group">
             <div class="controls">
                 <button type="submit" class="btn btn-primary" name="Rechercher" onclick="makeCrudSearch();">Rechercher</button>
             </div>
         </div>' . NL;
     $search .= '</fieldset>' . NL;
     $search .= '</div>
     <div class="span2"></div>' . NL . $js . NL;
     $this->_search = $search;
 }