Plugin Directory

Changeset 887078


Ignore:
Timestamp:
04/03/2014 10:00:01 PM (11 years ago)
Author:
faina09
Message:

0.11

  • deprecated mysql_ calls removed, use mysqli
  • wp 3.9 compatible
Location:
wp-fjqgrid/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wp-fjqgrid/trunk/inc/wpf-jqgrid-dbmodel.php

    r878671 r887078  
    11<?php
    22if ( !class_exists( 'FjqGridDbModel' ) ) {
     3    define( 'NOT_NULL_FLAG', '1' );    /* Field can't be NULL */
     4    define( 'PRI_KEY_FLAG', '2' );     /* Field is part of a primary key */
     5    define( 'UNIQUE_KEY_FLAG', '4' );  /* Field is part of a unique key */
     6    define( 'MULTIPLE_KEY_FLAG', '8' );   /* Field is part of a key */
     7    define( 'BLOB_FLAG', '16' );       /* Field is a blob */
     8    define( 'UNSIGNED_FLAG', '32' );   /* Field is unsigned */
     9    define( 'ZEROFILL_FLAG', '64' );   /* Field is zerofill */
     10    define( 'BINARY_FLAG', '128' );    /* Field is binary   */
     11    define( 'ENUM_FLAG', '256' );      /* Field is an enum */
     12    define( 'AUTO_INCREMENT_FLAG', '512' ); /* Field is a autoincrement field */
     13    define( 'TIMESTAMP_FLAG', '1024' );  /* Field is a timestamp */
    314
    415    class FjqGridDbModel
     
    3546            }
    3647
     48            $mysqli = new mysqli( DB_HOST, DB_USER, DB_PASSWORD, DB_NAME );
     49            if ( $mysqli->connect_errno ) {
     50                printf( "Connect failed: %s\n", $mysqli->connect_error );
     51                exit();
     52            }
    3753            $query_cmd = "SELECT * FROM `{$this->tablename}` LIMIT 1 OFFSET 0";
    38             $fetch_recordset = mysql_query( $query_cmd );
    39             if ( $fetch_recordset == null ) {
     54            $result = $mysqli->query( $query_cmd );
     55            $fields_cnt = $mysqli->field_count;
     56            if ( $fields_cnt == 0 ) {
    4057                $wpfjqg->fplugin_log( "Query non valida", mysql_error(), 1 );
    4158                return;
    4259            }
    43             $fields_cnt = mysql_num_fields( $fetch_recordset );
    4460            for ( $cnt = 0; $cnt < $fields_cnt; $cnt++ ) {
    45                 $name = mysql_field_name( $fetch_recordset, $cnt );
    46                 $type = mysql_field_type( $fetch_recordset, $cnt );
    47                 $size = mysql_field_len( $fetch_recordset, $cnt );
    48                 $flag = mysql_field_flags( $fetch_recordset, $cnt );
     61                $finfo = $result->fetch_field_direct( $cnt );
     62                $name = $finfo->name;
     63                $type = $finfo->type;
     64                $size = $finfo->max_length;
     65                $flag = $finfo->flags;
    4966                $column["name"] = $name;
    5067                $column["type"] = $type;
     
    5572                $column["searchoptions"] = "{sopt:['bw','cn','eq','ne','ew','nu','nn']}";
    5673                $column["editable"] = "true";
    57                 $reqrd = ( strpos( $flag, 'not_null' ) !== false ) ? 'required: true,' : '';
     74                $reqrd = ( ( $flag & NOT_NULL_FLAG ) == NOT_NULL_FLAG ) ? 'required: true,' : '';
    5875                if ( !isset( $frm[$name] ) ) {
    5976                    $column["formatter"] = $this->fjqg_format( $type, $size, $reqrd );
     
    6380                $columns[] = $column;
    6481            }
     82            /* free result set */
     83            $result->close();
    6584            $this->columns = $columns;
    6685            if ( $printinfo ) {
     
    7897            $keyfield = $this->fieldsnames[0];
    7998            // search for primary_key
    80             //$wpfjqg->fplugin_log('flags',$this->fieldsflags);
    8199            $keyword = 'primary_key';
    82100            $i = 0;
    83101            foreach ( $this->fieldsflags as $key => $flg ) {
    84                 if ( preg_match( "/{$keyword}/i", $flg ) ) {
     102                if ( ( $flg & PRI_KEY_FLAG ) == PRI_KEY_FLAG ) {
    85103                    $keyfield = $this->fieldsnames[$key];
    86104                    $i++;
     
    148166              ENUM
    149167              SET
     168             *
     169              1=>'tinyint',
     170              2=>'smallint',
     171              3=>'int',
     172              4=>'float',
     173              5=>'double',
     174              7=>'timestamp',
     175              8=>'bigint',
     176              9=>'mediumint',
     177              10=>'date',
     178              11=>'time',
     179              12=>'datetime',
     180              13=>'year',
     181              16=>'bit',
     182              //252 is currently mapped to all text and blob types (MySQL 5.0.51a)
     183              253=>'varchar',
     184              254=>'char',
     185              246=>'decimal'
    150186             */
    151             switch ( strtoupper( $type ) ) {
    152                 case 'TINYINT':
    153                 case 'SMALLINT':
    154                 case 'MEDIUMINT':
    155                 case 'INT':
    156                 case 'INTEGER':
    157                 case 'BIGINT':
     187            switch ( $type ) {
     188                case 1:
     189                case 2:
     190                case 3:
     191                case 8:
     192                case 9:
    158193                    if ( $lung == 1 ) {
    159194                        $frm = "align:'center', formatter: 'checkbox', formatoptions: { disabled: true}, editoptions: { value: '1:0' }";
     
    164199                    }
    165200                    break;
    166                 case 'FLOAT':
    167                 case 'DOUBLE':
    168                 case 'DOUBLE PRECISION':
    169                 case 'REAL':
    170                 case 'DECIMAL':
    171                 case 'NUMERIC':
     201                case 16:
     202                    $frm = "align:'center', formatter: 'checkbox', formatoptions: { disabled: true}, editoptions: { value: '1:0' }";
     203                    $frm .= ", edittype: 'checkbox', editrules: {required: false}, searchoptions: { sopt: ['eq','ne','nu','nn']}, searchrules:{integer:true, minValue:0, maxValue:1}";
     204                    break;
     205                case 4:
     206                case 5:
     207                case 246:
    172208                    $frm = "align:'right', formatter:'number', formatoptions: {decimalSeparator:',', thousandsSeparator: '.', decimalPlaces: 2, defaulValue: 0}";
    173209                    $frm .= ",editoptions:{'size':20}, editrules:{" . $reqrd . "}";
    174210                    break;
    175                 case 'DATE':
     211                case 10:
    176212                    $frm = "align:'right', formatter:'date', formatoptions: {srcformat:'Y-m-d',newformat:'d/m/Y'}";
    177213                    $frm .= ",editoptions:{'size':20}, editrules:{" . $reqrd . "}";
    178214                    break;
    179                 case 'DATETIME':
     215                case 12:
    180216                    $frm = "align:'right', formatter:'date', formatoptions: {srcformat:'Y-m-d H:i:s',newformat:'d/m/Y H:i'}";
    181217                    $frm .= ",editoptions:{'size':20}, editrules:{" . $reqrd . "}";
    182218                    break;
    183                 case 'TIME':
     219                case 11:
    184220                    $frm = "align:'right', formatter:'date', formatoptions: {srcformat:'H:i:s',newformat:'H:i:s'}";
    185221                    $frm .= ",editoptions:{'size':20}, editrules:{" . $reqrd . "}";
    186222                    break;
    187                 case 'CHAR':
    188                 case 'VARCHAR':
    189                 case 'STRING':
     223                case 253:
     224                case 254:
    190225                    $frm = "align:'left'";
    191226                    $frm .= ",editoptions:{'size':20}, editrules:{" . $reqrd . "}";
  • wp-fjqgrid/trunk/index.php

    r878671 r887078  
    44  Plugin URI: http://wordpress.org/extend/plugins/wpf-jqgrid/
    55  Description: jqGrid porting to wordpress
    6   Version: 0.10
     6  Version: 0.11
    77  Author: faina09
    88  Author URI: http://profiles.wordpress.org/faina09
    99  License: GPLv2 or later
    1010 */
    11 $VER = '0.10';
     11$VER = '0.11';
    1212defined( 'ABSPATH' ) OR exit;
    1313
  • wp-fjqgrid/trunk/readme.txt

    r878671 r887078  
    44Donate link: http://goo.gl/QzIZZ
    55Requires at least: 3.5
    6 Tested up to: 3.8
     6Tested up to: 3.9
    77Stable tag: trunk
    88License: GPLv2 or later
     
    7474
    7575== Changelog ==
     76= 0.11 =
     77* deprecated mysql_ calls removed, use mysqli
     78* wp 3.9 compatible
     79
    7680= 0.10 =
    7781* sortby=field,asc|desc into shortcode
Note: See TracChangeset for help on using the changeset viewer.