Пример #1
0
 /**
  * create tables
  */
 public static function createTable($tableName)
 {
     global $wpdb;
     $parseCssToDb = false;
     $checkForTablesOneTime = get_option('revslider_checktables', '0');
     if ($checkForTablesOneTime == '0') {
         update_option('revslider_checktables', '1');
         if (RevSliderFunctionsWP::isDBTableExists(self::$table_prefix . RevSliderGlobals::TABLE_CSS_NAME)) {
             //$wpdb->tables( 'global' )
             //check if database is empty
             $result = $wpdb->get_row("SELECT COUNT( DISTINCT id ) AS NumberOfEntrys FROM " . self::$table_prefix . RevSliderGlobals::TABLE_CSS_NAME);
             if ($result->NumberOfEntrys == 0) {
                 $parseCssToDb = true;
             }
         }
     }
     if ($parseCssToDb) {
         $RevSliderOperations = new RevSliderOperations();
         $RevSliderOperations->importCaptionsCssContentArray();
         $RevSliderOperations->moveOldCaptionsCss();
     }
     //if table exists - don't create it.
     $tableRealName = self::$table_prefix . $tableName;
     if (RevSliderFunctionsWP::isDBTableExists($tableRealName)) {
         return false;
     }
     switch ($tableName) {
         case RevSliderGlobals::TABLE_SLIDERS_NAME:
             $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\r\r\n\t\t\t\t\t\t  id int(9) NOT NULL AUTO_INCREMENT,\r\r\n\t\t\t\t\t\t  title tinytext NOT NULL,\r\r\n\t\t\t\t\t\t  alias tinytext,\r\r\n\t\t\t\t\t\t  params MEDIUMTEXT NOT NULL,\r\r\n\t\t\t\t\t\t  UNIQUE KEY id (id)\r\r\n\t\t\t\t\t\t);";
             break;
         case RevSliderGlobals::TABLE_SLIDES_NAME:
             $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\r\r\n\t\t\t\t\t\t\t  id int(9) NOT NULL AUTO_INCREMENT,\r\r\n\t\t\t\t\t\t\t  slider_id int(9) NOT NULL,\r\r\n\t\t\t\t\t\t\t  slide_order int not NULL,\r\r\n\t\t\t\t\t\t\t  params MEDIUMTEXT NOT NULL,\r\r\n\t\t\t\t\t\t\t  layers MEDIUMTEXT NOT NULL,\r\r\n\t\t\t\t\t\t\t  UNIQUE KEY id (id)\r\r\n\t\t\t\t\t\t\t);";
             break;
         case RevSliderGlobals::TABLE_STATIC_SLIDES_NAME:
             $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\r\r\n\t\t\t\t\t\t\t  id int(9) NOT NULL AUTO_INCREMENT,\r\r\n\t\t\t\t\t\t\t  slider_id int(9) NOT NULL,\r\r\n\t\t\t\t\t\t\t  params MEDIUMTEXT NOT NULL,\r\r\n\t\t\t\t\t\t\t  layers MEDIUMTEXT NOT NULL,\r\r\n\t\t\t\t\t\t\t  UNIQUE KEY id (id)\r\r\n\t\t\t\t\t\t\t);";
             break;
         case RevSliderGlobals::TABLE_CSS_NAME:
             $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\r\r\n\t\t\t\t\t\t\t  id int(9) NOT NULL AUTO_INCREMENT,\r\r\n\t\t\t\t\t\t\t  handle TEXT NOT NULL,\r\r\n\t\t\t\t\t\t\t  settings MEDIUMTEXT,\r\r\n\t\t\t\t\t\t\t  hover MEDIUMTEXT,\r\r\n\t\t\t\t\t\t\t  params MEDIUMTEXT NOT NULL,\r\r\n\t\t\t\t\t\t\t  UNIQUE KEY id (id)\r\r\n\t\t\t\t\t\t\t);";
             $parseCssToDb = true;
             break;
         case RevSliderGlobals::TABLE_LAYER_ANIMS_NAME:
             $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\r\r\n\t\t\t\t\t\t\t  id int(9) NOT NULL AUTO_INCREMENT,\r\r\n\t\t\t\t\t\t\t  handle TEXT NOT NULL,\r\r\n\t\t\t\t\t\t\t  params TEXT NOT NULL,\r\r\n\t\t\t\t\t\t\t  UNIQUE KEY id (id)\r\r\n\t\t\t\t\t\t\t);";
             break;
         case RevSliderGlobals::TABLE_NAVIGATION_NAME:
             $sql = "CREATE TABLE " . self::$table_prefix . $tableName . " (\r\r\n\t\t\t\t\t\t\t  id int(9) NOT NULL AUTO_INCREMENT,\r\r\n\t\t\t\t\t\t\t  name VARCHAR(191) NOT NULL,\r\r\n\t\t\t\t\t\t\t  handle VARCHAR(191) NOT NULL,\r\r\n\t\t\t\t\t\t\t  css MEDIUMTEXT NOT NULL,\r\r\n\t\t\t\t\t\t\t  markup MEDIUMTEXT NOT NULL,\r\r\n\t\t\t\t\t\t\t  settings MEDIUMTEXT NULL,\r\r\n\t\t\t\t\t\t\t  UNIQUE KEY id (id)\r\r\n\t\t\t\t\t\t\t);";
             break;
         default:
             RevSliderFunctions::throwError("table: {$tableName} not found");
             break;
     }
     require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     dbDelta($sql);
     if ($parseCssToDb) {
         $RevSliderOperations = new RevSliderOperations();
         $RevSliderOperations->importCaptionsCssContentArray();
         $RevSliderOperations->moveOldCaptionsCss();
     }
 }