Plugin Directory

Changeset 2765122


Ignore:
Timestamp:
08/02/2022 11:25:01 AM (3 years ago)
Author:
tsinf
Message:
  • 2.0.7

Fix "no error message" when submit fails dataset editor
Remember input data when submit fails dataset editor
Add different Page Titles on different locations

Location:
ts-comfort-database
Files:
40 added
3 edited

Legend:

Unmodified
Added
Removed
  • ts-comfort-database/trunk/classes/tsinf_comfort_db.class.php

    r2764341 r2765122  
    9696       
    9797        add_filter('admin_body_class', array('TS_INF_COMFORT_DB', 'modify_admin_body_classes'));
     98        add_filter('admin_title', array('TS_INF_COMFORT_DB', 'modify_admin_title'), 10, 2);
    9899               
    99100        if(!file_exists(TS_INF_COMFORT_DB_UPLOAD_DIR))
     
    178179        return "$classes tscdb_skin_" . self::$skin;
    179180    }
     181
     182    /**
     183     * Change Admin Page Title
     184     *
     185     * @param  String $page_title Modified Page Title
     186     * @param  String $title Original Page Title
     187     * @return String          Modified Page Title
     188     */
     189    public static function modify_admin_title($page_title, $title)
     190    {
     191        if(isset($_GET['page']) && $_GET['page'] === 'tscomfortdb-mainpage')
     192        {
     193            if(isset($_GET['table']))
     194            {
     195                $tablename = htmlentities(strip_tags($_GET['table']), ENT_QUOTES);
     196               
     197                if(isset($_GET['action']) && $_GET['action'] === 'search') {
     198                    // SEARCH
     199                    if(isset($_GET['identifier']))
     200                    {
     201                        $prepend_table = __("Search Results for Table:", "tsinf_comfortdb_plugin_textdomain") . " " . htmlentities(strip_tags($_GET['table']), ENT_QUOTES);
     202                        $new_title = $prepend_table . " - " . $page_title;
     203                        $page_title = $new_title;
     204                    } else {
     205                        $prepend_table = htmlentities(strip_tags($_GET['table']), ENT_QUOTES);
     206                        $new_title = $prepend_table . " - " . $page_title;
     207                        $page_title = $new_title;
     208                    }
     209                } else if(isset($_GET['identifier']))
     210                {                   
     211                    $prepend_table = __("Edit Table:", "tsinf_comfortdb_plugin_textdomain") . " " . htmlentities(strip_tags($_GET['table']), ENT_QUOTES);
     212                    $new_title = $prepend_table . " - " . $page_title;
     213                    $page_title = $new_title;
     214                } else if(isset($_GET['action']) && $_GET['action'] === 'new') {
     215                    // CREATE NEW DATASET
     216                    $prepend_table = __("New Dataset:", "tsinf_comfortdb_plugin_textdomain");
     217                    $new_title = $prepend_table . " - " . $page_title;
     218                    $page_title = $new_title;
     219                } else {
     220                    // TABLE CONTENT
     221                    $prepend_table = htmlentities(strip_tags($_GET['table']), ENT_QUOTES);
     222                    $new_title = $prepend_table . " - " . $page_title;
     223                    $page_title = $new_title;
     224                }
     225            } else if(isset($_GET['tsinf_comfortdb_full_text_search']) && isset($_GET['table_identifier'])) {
     226                $prepend_table = __("Full Text Search Results for Table:", "tsinf_comfortdb_plugin_textdomain") . " " . htmlentities(strip_tags($_GET['table_identifier']), ENT_QUOTES);
     227                $new_title = $prepend_table . " - " . $page_title;
     228                $page_title = $new_title;
     229            } else if(isset($_GET['tsinf_comfortdb_full_text_search'])) {
     230                if(check_admin_referer( 'action_tsinf_comfortdb_plugin_full_text_search_submit', '_wpnonce' ))
     231                {
     232                    $prepend_table = __("Full Text Search Results", "tsinf_comfortdb_plugin_textdomain");
     233                    $new_title = $prepend_table . " - " . $page_title;
     234                    $page_title = $new_title;
     235                }
     236            } else {
     237                $prepend_table = __("Table Overview", "tsinf_comfortdb_plugin_textdomain");
     238                $new_title = $prepend_table . " - " . $page_title;
     239                $page_title = $new_title;
     240            }
     241        }
     242
     243        return $page_title;
     244    }
    180245   
    181246    /**
     
    441506            }
    442507           
     508            $sql_error_returned = (bool) false;
    443509            if(isset($result_array['sql']))
    444510            {
     
    448514                if(isset($result_array['success']) && $result_array['success'] === true)
    449515                {
     516                    $sql_error_returned = (bool) false;
     517
    450518                    $result_message_class = 'success';
    451519                    $result_message_success_additional_information = '<span class="tsinf_comfortdb_plugin_result_additional_information">' . __('Affected Rows','tsinf_comfortdb_plugin_textdomain') . ': ' . $result_array['affected_rows'] . '</span>';
    452520                } else {
     521                    $sql_error_returned = (bool) true;
     522
    453523                    $result_message_class = 'fail';
    454524                    if(isset($result_array['error_message']) && strlen($result_array['error_message']) > 0)
     
    473543               
    474544                $html .= $error_message;
    475                
     545
    476546                $identifier_string = self::helper_decode_identifier_string($identifiers);
    477547               
     
    522592                                }
    523593                               
     594                                $col_value = "";
     595                                if($sql_error_returned === true && isset($_POST['tsinf_comfortdb_plugin_edit_dataset'][$col_name]) && is_string($_POST['tsinf_comfortdb_plugin_edit_dataset'][$col_name]) && strlen($_POST['tsinf_comfortdb_plugin_edit_dataset'][$col_name]) > 0)
     596                                {
     597                                    $col_value = $_POST['tsinf_comfortdb_plugin_edit_dataset'][$col_name];
     598                                } else {
     599                                    $col_value = $col_val;
     600                                }
     601
    524602                                $render_val = '<textarea class="tsinf_comfortdb_plugin_edit_dataset_edit_field" ' . $readonly . ' name="tsinf_comfortdb_plugin_edit_dataset[' . $col_name . ']" id="" class="">' . $col_val . '</textarea>';
    525603                                if(is_null($col_val))
     
    601679                        }
    602680                       
    603                        
    604                         $render_val = '<textarea class="tsinf_comfortdb_plugin_edit_dataset_edit_field" ' . $readonly . ' name="tsinf_comfortdb_plugin_edit_dataset[' . $col_name . ']" id="" class=""></textarea>';
     681                        $col_value = "";
     682                        if($sql_error_returned === true && isset($_POST['tsinf_comfortdb_plugin_edit_dataset'][$col_name]) && is_string($_POST['tsinf_comfortdb_plugin_edit_dataset'][$col_name]) && strlen($_POST['tsinf_comfortdb_plugin_edit_dataset'][$col_name]) > 0)
     683                        {
     684                            $col_value = $_POST['tsinf_comfortdb_plugin_edit_dataset'][$col_name];
     685                        }
     686                       
     687                        $render_val = '<textarea class="tsinf_comfortdb_plugin_edit_dataset_edit_field" ' . $readonly . ' name="tsinf_comfortdb_plugin_edit_dataset[' . $col_name . ']" id="" class="">' . $col_value . '</textarea>';
    605688                       
    606689                        $html .= '<div class="tsinf_comfortdb_plugin_edit_dataset_row ' . $even_odd . '">
     
    726809                $wpdb->query("START TRANSACTION");
    727810                $return = $wpdb->query($sql);
     811                if(is_wp_error($return))
     812                {
     813                    $return_array['error_message'] = $return->get_error_message();
     814                } else if($wpdb->last_error)
     815                {
     816                    $return_array['error_message'] = $wpdb->last_error;
     817                }
     818
    728819                if($return !== FALSE)
    729820                {
     
    735826                    $wpdb->query("ROLLBACK");
    736827                    $return_array['success'] = (bool) false;
    737                     if(is_wp_error($return))
    738                     {
    739                         $return_array['error_message'] = $return->get_error_message();
    740                     }
    741828                }
    742829            }
     
    820907
    821908                    $wpdb->query("START TRANSACTION");
    822 
     909                   
    823910                    $return = $wpdb->query($sql);
     911                    if(is_wp_error($return))
     912                    {
     913                        $return_array['error_message'] = $return->get_error_message();
     914                    } else if($wpdb->last_error)
     915                    {
     916                        $return_array['error_message'] = $wpdb->last_error;
     917                    }
    824918
    825919                    if($return !== FALSE)
     
    829923                        $return_array['affected_rows'] = $return;
    830924                    } else {
     925
    831926                        $wpdb->query("ROLLBACK");
    832                         $return_array['success'] = (bool) false;
    833                         if(is_wp_error($return))
    834                         {
    835                             $return_array['error_message'] = $return->get_error_message();
    836                         }
     927                        $return_array['success'] = (bool) false;                       
    837928                    }
    838929                }
  • ts-comfort-database/trunk/plugin.php

    r2764346 r2765122  
    77 Author: Tobias Spiess
    88 Author URI: https://www.spiess-informatik.de
    9  Version: 2.0.6
     9 Version: 2.0.7
    1010 Text-Domain: tsinf_comfortdb_plugin_textdomain
    1111 Domain Path: /languages
  • ts-comfort-database/trunk/readme.txt

    r2764346 r2765122  
    4040
    4141== Changelog ==
     42* 2.0.7
     43Fix "no error message" when submit fails dataset editor
     44Remember input data when submit fails dataset editor
     45Add different Page Titles on different locations
     46
    4247* 2.0.6
    4348Fix wrong download url in file manager again
Note: See TracChangeset for help on using the changeset viewer.