public static function row(array $row, $table, $fields, $foreign = null, $link = true, $database = null) { /* polymorphism */ $fields = !Arrays::is($fields) ? strstr($fields, ',') ? explode(',', repl(' ', '', $fields)) : [$fields] : $fields; if (fnmatch('*:*', $table)) { list($database, $table) = explode(':', $table, 2); } else { $database = is_null($database) ? SITE_NAME : $database; } $foreign = !strlen($foreign) ? $table . '_id' : $foreign; $val = isAke($row, $foreign, false); if (!Arrays::is($val) && (false === $val || strlen($val) == 0)) { return ''; } if (!Arrays::is($val)) { $db = Db::instance($database, $table); $target = $db->find($val, false); $value = []; foreach ($fields as $field) { if (!$field instanceof Closure) { $value[] = isAke($target, $field, $field); } else { $value[] = $field($target); } } $value = implode(' ', $value); if (true === $link) { return '<a target="_blank" href="' . urlAction('update') . '/database/' . $database . '/table/' . $table . '/id/' . $val . '">' . $value . '</a>'; } else { return $value; } } else { $vals = $val; $return = []; foreach ($vals as $val) { $db = Db::instance($database, $table); $target = $db->find($val, false); $value = []; foreach ($fields as $field) { if (!$field instanceof Closure) { $value[] = isAke($target, $field, $field); } else { $value[] = $field($target); } } $value = implode(' ', $value); if (true === $link) { $return[] = '<a target="_blank" href="' . urlAction('update') . '/database/' . $database . '/table/' . $table . '/id/' . $val . '">' . $value . '</a>'; } else { $return[] = $value; } } return implode(' <i class="fa fa-caret-right"></i> ', $return); } }
public static function row(array $row, $table, $fields, $link = true) { /* polymorphism */ $fields = !Arrays::is($fields) ? strstr($fields, ',') ? explode(',', repl(' ', '', $fields)) : array($fields) : $fields; $db = model($table); $target = $db->find($row[$table . '_id'], false); $value = array(); foreach ($fields as $field) { $value[] = isAke($target, $field, ' '); } $value = implode(' ', $value); if (true === $link) { return '<a target="_blank" href="' . urlAction('update') . '/table/' . $table . '/id/' . $row[$table . '_id'] . '">' . $value . '</a>'; } else { return $value; } }
public function redirect($action = 'index', $args = [], $controller = null, $module = null) { if (is_null($controller) && is_null($module)) { $url = urlAction($action); } elseif (is_null($module) && !is_null($controller)) { $url = URLSITE . $controller . '/' . $action; } elseif (!is_null($module) && !is_null($controller)) { $url = URLSITE . $module . '/' . $controller . '/' . $action; } else { $url = URLSITE; } if (count($args)) { foreach ($args as $key => $value) { $url .= "/{$key}/{$value}"; } } Utils::go($url); }
private function options($id, $config, $plus = '') { if (is_callable($plus)) { $plus = call_user_func_array($plus, [$id]); } $options = ''; $deletable = isAke($config, 'deletable', true); $updatable = isAke($config, 'updatable', true); $readable = isAke($config, 'readable', true); $duplicatable = isAke($config, 'duplicatable', true); $options .= '<td style="text-align: center;"><select class="form-control input-sm m-bot15" onchange="if ($(this).val().length > 0) { if ($(this).val().match(\'delete\')) {if (confirm(\'Confirmez-vous la suppression de cet élément ?\')) document.location.href = $(this).val();} else {document.location.href = $(this).val();}}"><option value="">Choisir</option>'; if (true === $updatable) { $options .= '<option value="' . urlAction('update') . '/table/' . $this->model->table . '/database/' . $this->model->db . '/id/' . $id . '">Mettre à jour</option>'; } if (true === $duplicatable) { $options .= '<option value="' . urlAction('duplicate') . '/table/' . $this->model->table . '/database/' . $this->model->db . '/id/' . $id . '">Dupliquer</option>'; } if (true === $deletable) { $options .= '<option value="' . urlAction('delete') . '/table/' . $this->model->table . '/database/' . $this->model->db . '/id/' . $id . '">Effacer</option>'; } if (true === $readable) { $options .= '<option value="' . urlAction('read') . '/table/' . $this->model->table . '/database/' . $this->model->db . '/id/' . $id . '">Voir</option>'; } $options .= '</select>' . $plus . '</td>'; return $options; }
private function options($id, $plus = '') { $options = ''; $options .= '<td style="text-align: center;"><ul class="list-inline">'; $options .= '<li><a rel="tooltip" title="éditer" class="btn btn-xs btn-success" href="' . urlAction('update') . '/table/' . $this->model->table . '/id/' . $id . '"><i class="fa fa-edit"></i></a></li>'; $options .= '<li><a rel="tooltip" title="dupliquer" class="btn btn-xs btn-warning" href="' . urlAction('duplicate') . '/table/' . $this->model->table . '/id/' . $id . '"><i class="fa fa-copy"></i></a></li>'; $options .= '<li><a rel="tooltip" title="afficher" class="btn btn-xs btn-info" href="' . urlAction('read') . '/table/' . $this->model->table . '/id/' . $id . '"><i class="fa fa-file"></i></a></li>'; $options .= '<li><a rel="tooltip" title="supprimer" class="btn btn-xs btn-danger" href="#" onclick="if (confirm(\'Confirmez-vous la suppression de cet élément ?\')) document.location.href = \'' . urlAction('delete') . '/table/' . $this->model->table . '/id/' . $id . '\'; return false;"><i class="fa fa-trash-o"></i></a></li>' . $plus; $options .= '</ul></td>'; return $options; }