| 1 |
<?php |
| 2 |
namespace Imagify\ThirdParty\NGG; |
| 3 |
|
| 4 |
defined( 'ABSPATH' ) || die( 'Cheatin’ uh?' ); |
| 5 |
|
| 6 |
/** |
| 7 |
* Imagify NextGen Gallery DB class. |
| 8 |
* |
| 9 |
* @since 1.5 |
| 10 |
* @author Jonathan Buttigieg |
| 11 |
*/ |
| 12 |
class DB extends \Imagify_Abstract_DB { |
| 13 |
|
| 14 |
/** |
| 15 |
* Class version. |
| 16 |
* |
| 17 |
* @var string |
| 18 |
*/ |
| 19 |
const VERSION = '1.1.1'; |
| 20 |
|
| 21 |
/** |
| 22 |
* The single instance of the class. |
| 23 |
* |
| 24 |
* @var object |
| 25 |
* @since 1.5 |
| 26 |
* @access protected |
| 27 |
*/ |
| 28 |
protected static $_instance; |
| 29 |
|
| 30 |
/** |
| 31 |
* The suffix used in the name of the database table (so, without the wpdb prefix). |
| 32 |
* |
| 33 |
* @var string |
| 34 |
* @since 1.7 |
| 35 |
* @access protected |
| 36 |
*/ |
| 37 |
protected $table = 'ngg_imagify_data'; |
| 38 |
|
| 39 |
/** |
| 40 |
* The version of our database table. |
| 41 |
* |
| 42 |
* @var int |
| 43 |
* @since 1.5 |
| 44 |
* @since 1.7 Not public anymore, now an integer. |
| 45 |
* @access protected |
| 46 |
*/ |
| 47 |
protected $table_version = 100; |
| 48 |
|
| 49 |
/** |
| 50 |
* Tell if the table is the same for each site of a Multisite. |
| 51 |
* |
| 52 |
* @var bool |
| 53 |
* @since 1.7 |
| 54 |
* @access protected |
| 55 |
*/ |
| 56 |
protected $table_is_global = false; |
| 57 |
|
| 58 |
/** |
| 59 |
* The name of the primary column. |
| 60 |
* |
| 61 |
* @var string |
| 62 |
* @since 1.5 |
| 63 |
* @since 1.7 Not public anymore. |
| 64 |
* @access protected |
| 65 |
*/ |
| 66 |
protected $primary_key = 'pid'; |
| 67 |
|
| 68 |
/** |
| 69 |
* Get the main Instance. |
| 70 |
* |
| 71 |
* @since 1.6.5 |
| 72 |
* @access public |
| 73 |
* @author Grégory Viguier |
| 74 |
* |
| 75 |
* @return object Main instance. |
| 76 |
*/ |
| 77 |
public static function get_instance() { |
| 78 |
if ( ! isset( self::$_instance ) ) { |
| 79 |
self::$_instance = new self(); |
| 80 |
} |
| 81 |
|
| 82 |
return self::$_instance; |
| 83 |
} |
| 84 |
|
| 85 |
/** |
| 86 |
* Whitelist of columns. |
| 87 |
* |
| 88 |
* @since 1.5 |
| 89 |
* @access public |
| 90 |
* @author Jonathan Buttigieg |
| 91 |
* |
| 92 |
* @return array |
| 93 |
*/ |
| 94 |
public function get_columns() { |
| 95 |
return array( |
| 96 |
'data_id' => '%d', |
| 97 |
'pid' => '%d', |
| 98 |
'optimization_level' => '%s', |
| 99 |
'status' => '%s', |
| 100 |
'data' => '%s', |
| 101 |
); |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Default column values. |
| 106 |
* |
| 107 |
* @since 1.5 |
| 108 |
* @access public |
| 109 |
* @author Jonathan Buttigieg |
| 110 |
* |
| 111 |
* @return array |
| 112 |
*/ |
| 113 |
public function get_column_defaults() { |
| 114 |
return array( |
| 115 |
'data_id' => 0, |
| 116 |
'pid' => 0, |
| 117 |
'optimization_level' => '', |
| 118 |
'status' => '', |
| 119 |
'data' => array(), |
| 120 |
); |
| 121 |
} |
| 122 |
|
| 123 |
/** |
| 124 |
* Get the query to create the table fields. |
| 125 |
* |
| 126 |
* @since 1.7 |
| 127 |
* @access protected |
| 128 |
* @author Grégory Viguier |
| 129 |
* |
| 130 |
* @return string |
| 131 |
*/ |
| 132 |
protected function get_table_schema() { |
| 133 |
return " |
| 134 |
data_id int(11) unsigned NOT NULL AUTO_INCREMENT, |
| 135 |
pid int(11) unsigned NOT NULL default 0, |
| 136 |
optimization_level varchar(1) NOT NULL default '', |
| 137 |
status varchar(30) NOT NULL default '', |
| 138 |
data longtext NOT NULL default '', |
| 139 |
PRIMARY KEY (data_id), |
| 140 |
KEY pid (pid)"; |
| 141 |
} |
| 142 |
} |
| 143 |
|