Example #1
0
 function query($stmt, $wpdb, $table_name)
 {
     $this->wpdb = $wpdb;
     $this->table_name = $table_name;
     //Parse for WP variables and replace with actual values
     $statement = $this->parse_variables($stmt);
     //Initializes variables
     $dao_vars = new dao_vars($this->wpdb, $this->table_name);
     $vo_vars = $dao_vars->select();
     foreach ($vo_vars as $vo_var) {
         if (isset($_GET[$vo_var->var_name])) {
             ${$vo_var->var_name} = $_GET[$vo_var->var_name];
         } else {
             if (isset($_POST[$vo_var->var_name])) {
                 ${$vo_var->var_name} = $_POST[$vo_var->var_name];
             } else {
                 ${$vo_var->var_name} = $vo_var->var_value;
             }
         }
         //set the default value
         $statement = str_replace('$' . $vo_var->var_name, ${$vo_var->var_name}, $statement);
     }
     $this->stmt = $statement;
 }
Example #2
0
    $dao_vars = new dao_vars($wpdb, $wpbi_sql['tname']['vars']);
    $tgt_var = new vo_vars($var_id, NULL, NULL);
    $vo_vars = $dao_vars->select($tgt_var);
    $vo_vars = $vo_vars[0];
    //Prepare output
    $template_site->assign_vars(array('PG_TITLE' => $wpbi_dialog['page']['variables']['title'], 'PG_DESCRIPTION' => $wpbi_dialog['action']['variables']['edit'], 'VAR_EDIT_NAME' => $wpbi_dialog['field']['variables']['name'], 'VAR_EDIT_VALUE' => $wpbi_dialog['field']['variables']['value'], 'P_VAR_ID' => $wpbi_settings['parameter']['var_id'], 'V_VAR_ID' => $var_id, 'P_VAR_NAME' => $wpbi_settings['parameter']['var_name'], 'V_VAR_NAME' => isset($_POST[$wpbi_settings['parameter']['var_name']]) ? $_POST[$wpbi_settings['parameter']['var_name']] : $vo_vars->var_name, 'P_VAR_VALUE' => $wpbi_settings['parameter']['var_value'], 'V_VAR_VALUE' => isset($_POST[$wpbi_settings['parameter']['var_value']]) ? $_POST[$wpbi_settings['parameter']['var_value']] : $vo_vars->var_value, 'P_VAR_ACTION' => $wpbi_settings['parameter']['action'], 'V_EDIT_ACTION' => $wpbi_settings['value']['edit'], 'LBL_BTN_EDIT' => $wpbi_dialog['label']['button']['add'], 'VAR_EDIT_FORM_ACTION' => substr(substr(strrchr($_SERVER['REQUEST_URI'], '/'), 1), 0, strpos(substr(strrchr($_SERVER['REQUEST_URI'], '/'), 1), '&'))));
    //output page header and database form
    $template_site->pparse('header');
    $template_site->pparse('variables-edit');
}
/**** Edit variable: save modifications ***/
if ($_POST[$wpbi_settings['parameter']['action']] == $wpbi_settings['value']['edit'] && isset($_POST[$wpbi_settings['parameter']['var_id']])) {
    $selected_var = $_POST[$wpbi_settings['parameter']['var_id']];
    $old_var = new vo_vars($selected_var, NULL, NULL);
    $new_var = new vo_vars($selected_var, $_POST[$wpbi_settings['parameter']['var_name']], $_POST[$wpbi_settings['parameter']['var_value']]);
    $dao_vars = new dao_vars($wpdb, $wpbi_sql['tname']['vars']);
    $dao_vars->edit($old_var, $new_var);
}
?>

<?php 
/***********************/
/***     DEFAULT     ***/
/***********************/
if ($_GET[$wpbi_settings['parameter']['action']] != $wpbi_settings['value']['edit']) {
    //Prepare output
    $template_site->assign_vars(array('PG_TITLE' => $wpbi_dialog['page']['variables']['title'], 'PG_DESCRIPTION' => $wpbi_dialog['page']['variables']['description'], 'VAR_NEW_NAME' => $wpbi_dialog['field']['variables']['name'], 'VAR_NEW_VALUE' => $wpbi_dialog['field']['variables']['value'], 'P_VAR_NAME' => $wpbi_settings['parameter']['var_name'], 'V_VAR_NAME' => $_POST[$wpbi_settings['parameter']['var_name']], 'P_VAR_VALUE' => $wpbi_settings['parameter']['var_value'], 'V_VAR_VALUE' => $_POST[$wpbi_settings['parameter']['var_value']], 'P_VAR_ACTION' => $wpbi_settings['parameter']['action'], 'V_ADD_ACTION' => $wpbi_settings['value']['add'], 'V_TEST_ACTION' => $wpbi_settings['value']['test'], 'LBL_BTN_ADD' => $wpbi_dialog['label']['button']['add']));
    //output page header and query form
    $template_site->pparse('header');
    $template_site->pparse('variables-new');
    //Get saved variables
Example #3
0
 function get_vars()
 {
     $dao_vars = new dao_vars($wpdb, $wpbi_sql['tname']['vars']);
     $vo_vars = $dao_vars->select(NULL);
     return $vo_vars;
 }