yf_form2_tbl_funcs class| File | plugins/form2/classes/form2/yf_form2_tbl_funcs.class.php |
|---|---|
| Use | _class('form2_tbl_funcs', 'classes/form2/') |
| Property | Default | Description |
|---|---|---|
| None declared in this class. | ||
public function tbl_link($name, $link, $extra = [], $replace = [], $form = null)
For use inside table item template.
public function tbl_link($name, $link, $extra = [], $replace = [], $form = null)
{
if (is_array($name)) {
$extra = (array) $extra + $name;
$name = $extra['name'];
}
$extra['name'] = ($extra['name'] ?? null) ?: $name;
$extra['link'] = ($extra['link'] ?? null) ?: $link;
$func = function ($extra, $r, $form) {
$link = $extra['link'];
if ( ! $link && $extra['link_variants']) {
foreach ((array) $extra['link_variants'] as $link_variant) {
if (isset($r[$link_variant])) {
$link = $link_variant;
}
}
}
$link_url = isset($r[$link]) ? $r[$link] : $link;
if ($link_url) {
if (MAIN_TYPE_ADMIN && main()->ADMIN_GROUP != 1 && ! _class('admin_methods')->_admin_link_is_allowed($link_url)) {
return '';
}
}
if ($extra['rewrite'] ?? null) {
$link_url = url($link_url);
}
$icon = ($extra['icon'] ?? null) ? $extra['icon'] : _class('table2')->CLASS_ICON_BTN;
$extra['href'] = $link_url;
$extra['class'] = ($extra['class'] ?? null) ?: (($extra['class_add'] ?? null) ? $form->_bs5_btn_class($form->CLASS_BTN_MINI, $extra['class_add']) : $form->CLASS_BTN_MINI);
$attrs_names = ['id', 'name', 'href', 'class', 'style', 'target', 'alt', 'title'];
return ' <a' . _attrs($extra, $attrs_names) . '><i class="' . $icon . '"></i>' . ( ! ($extra['hide_text'] ?? null) ? ' ' . t($extra['name'] ?? null) : '') . '</a> ';
};
if ($form->_chained_mode) {
$form->_body[] = ['func' => $func, 'extra' => $extra, 'replace' => $replace, 'name' => __FUNCTION__];
return $form;
}
return $func((array) $extra + (array) $form->_extra, (array) $replace + (array) $form->_replace, $form);
}
public function tbl_link_active($name = '', $link = '', $extra = [], $replace = [], $form = null)
For use inside table item template.
public function tbl_link_active($name = '', $link = '', $extra = [], $replace = [], $form = null)
{
if (is_array($name)) {
$extra = (array) $extra + $name;
$name = $extra['name'];
}
$extra['name'] = ($extra['name'] ?? null) ?: ($name ?: 'active');
$extra['link'] = ($extra['link'] ?? null) ?: $link;
$extra['desc'] = $form->_prepare_desc($extra, null);
$func = function ($extra, $r, $form) {
$link = $extra['link'];
if ( ! $link) {
$link = 'active_link';
if ( ! isset($r['active_link']) && isset($r['active_url'])) {
$link = 'active_url';
}
}
$link_url = isset($r[$link]) ? $r[$link] : $link;
if ($link_url) {
if (MAIN_TYPE_ADMIN && main()->ADMIN_GROUP != 1 && ! _class('admin_methods')->_admin_link_is_allowed($link_url)) {
return '';
}
}
if ($extra['rewrite'] ?? null) {
$link_url = url($link_url);
}
$is_active = (bool) ($r[$extra['name']] ?? null);
if ( ! ($extra['items'] ?? null)) {
if ( ! isset($form->_pair_active_buttons)) {
$form->_pair_active_buttons = $form->_bs5_pair(main()->get_data('pair_active_buttons'));
}
$extra['items'] = $form->_pair_active_buttons;
}
return ' <a href="' . $link_url . '" class="' . _class('table2')->CLASS_CHANGE_ACTIVE . '">' . $extra['items'][$is_active] . '</a> ';
};
if ($form->_chained_mode) {
$form->_body[] = ['func' => $func, 'extra' => $extra, 'replace' => $replace, 'name' => __FUNCTION__];
return $form;
}
return $func((array) $extra + (array) $form->_extra, (array) $replace + (array) $form->_replace, $form);
}
public function tbl_link_add($name = '', $link = '', $extra = [], $replace = [], $form = null)
For use inside table item template.
public function tbl_link_add($name = '', $link = '', $extra = [], $replace = [], $form = null)
{
if (is_array($name)) {
$extra = (array) $extra + $name;
$name = $extra['name'];
}
if ( ! $name) {
$name = 'Add';
}
$extra['link_variants'] = ['add_link', 'add_url'];
if ( ! isset($extra['icon'])) {
$extra['icon'] = _class('table2')->CLASS_ICON_ADD;
}
return $form->tbl_link($name, $link, $extra, $replace);
}
public function tbl_link_clone($name = '', $link = '', $extra = [], $replace = [], $form = null)
For use inside table item template.
public function tbl_link_clone($name = '', $link = '', $extra = [], $replace = [], $form = null)
{
if (is_array($name)) {
$extra = (array) $extra + $name;
$name = $extra['name'];
}
if ( ! $name) {
$name = 'Clone';
}
$extra['link_variants'] = ['clone_link', 'clone_url'];
if ( ! isset($extra['icon'])) {
$extra['icon'] = _class('table2')->CLASS_ICON_CLONE;
}
if ( ! isset($extra['class_add']) && ! ($extra['no_ajax'] ?? null)) {
$extra['class_add'] = _class('table2')->CLASS_AJAX_CLONE;
}
return $form->tbl_link($name, $link, $extra, $replace);
}
public function tbl_link_delete($name = '', $link = '', $extra = [], $replace = [], $form = null)
For use inside table item template.
public function tbl_link_delete($name = '', $link = '', $extra = [], $replace = [], $form = null)
{
if (is_array($name)) {
$extra = (array) $extra + $name;
$name = $extra['name'];
}
if ( ! $name) {
$name = 'Delete';
}
$extra['link_variants'] = ['delete_link', 'delete_url'];
if ( ! isset($extra['icon'])) {
$extra['icon'] = _class('table2')->CLASS_ICON_DELETE;
}
if ( ! isset($extra['class_add']) && ! ($extra['no_ajax'] ?? null)) {
$extra['class_add'] = _class('table2')->CLASS_AJAX_DELETE;
}
return $form->tbl_link($name, $link, $extra, $replace);
}
public function tbl_link_edit($name = '', $link = '', $extra = [], $replace = [], $form = null)
For use inside table item template.
public function tbl_link_edit($name = '', $link = '', $extra = [], $replace = [], $form = null)
{
if (is_array($name)) {
$extra = (array) $extra + $name;
$name = $extra['name'];
}
if ( ! $name) {
$name = 'Edit';
}
$extra['link_variants'] = ['edit_link', 'edit_url'];
if ( ! isset($extra['icon'])) {
$extra['icon'] = _class('table2')->CLASS_ICON_EDIT;
}
if ( ! isset($extra['class_add']) && ! ($extra['no_ajax'] ?? null)) {
$extra['class_add'] = _class('table2')->CLASS_AJAX_EDIT;
}
return $form->tbl_link($name, $link, $extra, $replace);
}
public function tbl_link_view($name = '', $link = '', $extra = [], $replace = [], $form = null)
For use inside table item template.
public function tbl_link_view($name = '', $link = '', $extra = [], $replace = [], $form = null)
{
if (is_array($name)) {
$extra = (array) $extra + $name;
$name = $extra['name'];
}
if ( ! $name) {
$name = 'View';
}
$extra['link_variants'] = ['view_link', 'view_url'];
if ( ! isset($extra['icon'])) {
$extra['icon'] = _class('table2')->CLASS_ICON_VIEW;
}
if ( ! isset($extra['class_add']) && ! ($extra['no_ajax'] ?? null)) {
$extra['class_add'] = _class('table2')->CLASS_AJAX_VIEW;
}
return $form->tbl_link($name, $link, $extra, $replace);
}