">Doc

ADMIN FORM (ADFO) CLASS

To use the ADFO class write admin_form\ADFO::function_name(); or

use admin_form\ADFO as ADFO;
ADFO::function_name();


ADFO::get_list($dbp_id, $only_table = false, $params=[], $prefix = "")

Load a list from an id and return the html. Pretty much the same thing that the shortcode does!

Parameters

Return

Html

ADFO::get_single($dbp_id, $ids)

Returns the html of a single record.

Parameters

Return

Html

ADFO::get_total($dbp_id, $filter = false)

Load a list from an id and return the html defined in the frontend view

Parameters

Return

Int | -1 if he fails to count

ADFO::get_lists_names()

Load all dbp lists

Return

Array

get_list_columns($dbp_id, $searchable = true, $extend = false)

Estrae l'elenco delle colonne di una lista.

Parameters

Return

ADFO_list_setting[]|array

ADFO::get_primaries_id($dbp_id)

Returns the list of primary keys of a list. The extracted fields are the aliases!

Parameters

Return

@return array [table=>primary_name, ...]

ADFO::get_data($dbp_id, $return = "items", $add_where = null, $limit = null, $order_field = null, $order="ASC", $raw_data = false)

Return the data or the model of a list

Parameters

The difference between $return = "raw" and $raw_data = true is that with $return = $raw all the data from the tables concerned are extracted, while with $raw_data = true the raw data is always extracted, but only from columns extracted from the query.

Return

Mixed

ADFO::get_detail($dbp_id, $dbp_ids, $raw_data = true)

Returns the data of a single record unchanged from the list settings. This data can be passed to save_data after being modified to be saved.

Parameters

Example

Edit a record

use admin_form\ADFO as ADFO;
$list_id = 'insert_the_id_of_your_list';
$record_id = 'insert_the_id_of_a_record';
$item = ADFO::get_detail($list_id, $record_id);
$item->my_column = "new_value";
$ris = ADFO::save_data($list_id, $item);

Return

\stdClass|false

ADFO::get_clone_detail($dbp_id, $dbp_ids)

Returns the data of a single record unchanged from the list settings. This data can be passed to save_data after being modified to generate a new record from data in another record. Unlike get_detail, clone_detail removes any primary keys and calculated fields from the extracted results.

Parameters

Example

Clone a record

use admin_form\ADFO as ADFO;
$list_id = 'insert_the_id_of_your_list';
$record_id = 'insert_the_id_of_a_record';
$item = ADFO::get_clone_detail($list_id, $record_id);
$ris = ADFO::save_data($list_id, $item);

Return

\stdClass|false

ADFO::save_data($dbp_id, $data)

Save the data of one or more lines in a list.

Parameters

Example

Create a new record

use admin_form\ADFO as ADFO;
$list_id = 'insert_the_id_of_your_list';
$item = (object)['my_column'=>'val'];
$ris = ADFO::save_data($list_id, $item);

If all fields are empty (and they are all configured) remove the record

use admin_form\ADFO as ADFO;
$item = ADFO::get_detail('77', 5);
foreach ($item as $k=>&$i) {
    // if primary key == "dbp_id"
    if ($k == "dbp_id") continue;
    $i = '';
}
// remove record 5
$ris = ADFO::save_data('77', $item);

Return

array

ADFO::render($dbp_id, $mode)

Restituisce la classe ADFO_render_list

Parameters

Return

ADFO_render_list

Example

$list =  admin_form\ADFO::render(6, 'get'); // ($list_id:int, $mode:string); $mode is optional
$list->set_color('pink'); // Change the color of the list from the one you choose
$list->table("", false); // (custom_class:string, table_sort:bool)
$list->search(false); // optional (show_button:bool)
$list->single_field_search('column_name'); // Adds a text field to search in a single column 
$list->submit(); // Adds buttons for search
$list->pagination('select');
$list->end(); // Required!

ADFO::draw_export_btn($dbp_id, $title, $format, $btn_class)

Print a link to export data

Parameters

  • $dbp_id
    (integer) The list id
  • $title
    (string) The text of the button
  • $format
    (string) csv/sql
  • $btn_class
    (string) The class to edit the graphics
  • Return

    Void

    Example

      // Print the link to download the $id list.
        ADFO::draw_export_btn($dbp_id);

    ADFO::get_ids_value_from_list($dbp_id, $row, $return = 'string'

    Given a row in a list of data ($row) returns the id(s) to extract the details of the record. The string version is used in links.

    Parameters

  • $dbp_id
    (integer) The list id
  • $row
    (Object) A single record in a list
  • $return
    (string) string|array|object
  • Return

    Mixed

    Example

      // Generate the link for a popup
        $id = ADFO::get_ids_value_from_list($dbp_id, $row);
        popup link'); ?>

    Template engine

    set get variable

    <?php 
        PinaCode::set_var("myvar","foobar"); 
        echo PinaCode::get_var("myvar","default"); 
    ?>

    Execute shortcode

    <?php 
        PinaCode::execute_shortcode('...'); 
    ?>

    Returns the result of a mathematical or logical expression

    <?php 
        PinaCode::math_and_logic('3 > 6'); 
    ?>

    Set a new function

    function pinacode_fn_hello_world($short_code_name, $attributes) {
        return 'HELLO WORLD';	
    }
    pinacode_set_functions('hello_world', 'pinacode_fn_hello_world');

    Set a new attributes

    function pinacode_attr_fn_new_upper($gvalue, $param, $shortcode_obj) {
        if (is_string($gvalue)) {
        $gvalue = strtoupper($gvalue);
        }
        return $gvalue;
    }
    pinacode_set_attribute(['new_upper'], 'pinacode_attr_fn_new_upper');