public static function run()
 {
     $objDatabase = \Database::getInstance();
     \Controller::loadDataContainer('tl_extcss');
     $arrFields = array('tl_extcss' => array('bootstrapVariablesSRC', 'observeFolderSRC'), 'tl_extcss_file' => array('src'), 'tl_extjs_file' => array('src'));
     if (version_compare(VERSION, '3.2', '>=')) {
         foreach ($arrFields as $strTable => $arrNames) {
             if (!$objDatabase->tableExists($strTable)) {
                 continue;
             }
             // convert file fields
             foreach ($objDatabase->listFields($strTable) as $arrField) {
                 // with extassets 1.1.1 bootstrapVariablesSRC changed to variablesSRC
                 if ($arrField['name'] == 'bootstrapVariablesSRC') {
                     if (!$objDatabase->fieldExists('variablesSRC', $strTable)) {
                         $sql =& $GLOBALS['TL_DCA']['tl_extcss']['fields']['variablesSRC']['sql'];
                         $objDatabase->query("ALTER TABLE {$strTable} ADD `variablesSRC` {$sql}");
                         $sql =& $GLOBALS['TL_DCA']['tl_extcss']['fields']['variablesOrderSRC']['sql'];
                         $objDatabase->query("ALTER TABLE {$strTable} ADD `variablesOrderSRC` {$sql}");
                     }
                     $objGroups = $objDatabase->execute('SELECT * FROM ' . $strTable . ' WHERE bootstrapVariablesSRC IS NOT NULL AND variablesSRC IS NULL');
                     while ($objGroups->next()) {
                         $variables = serialize(array($objGroups->bootstrapVariablesSRC));
                         $objDatabase->prepare('UPDATE ' . $strTable . ' SET variablesSRC = ?, variablesOrderSRC = ? WHERE id = ?')->execute($variables, $variables, $objGroups->id);
                     }
                     $objDatabase->query("ALTER TABLE {$strTable} DROP `bootstrapVariablesSRC`");
                 }
                 if (in_array($arrField['name'], $arrNames)) {
                     \Database\Updater::convertSingleField($strTable, $arrField['name']);
                 }
             }
         }
     }
     return;
 }
Esempio n. 2
0
 /**
  *
  */
 protected function updateDatabaseFields()
 {
     if (version_compare(VERSION, '3.1', '>')) {
         \Database\Updater::convertSingleField('tl_timelinejs', 'singleSRC');
         \Database\Updater::convertSingleField('tl_timelinejs_entry', 'singleSRC');
         \Database\Updater::convertSingleField('tl_timelinejs_entry', 'thumbnail');
     }
 }
Esempio n. 3
0
 /**
  * Run database migrations
  *
  * @return void
  */
 public static function run()
 {
     $database = \Database::getInstance();
     // Copy license key from extension repository
     if (!\Config::get('rocksolid_slider_license') && $database->tableExists('tl_repository_installs') && $database->fieldExists('lickey', 'tl_repository_installs') && $database->fieldExists('extension', 'tl_repository_installs')) {
         $result = $database->prepare('SELECT lickey FROM tl_repository_installs WHERE extension = \'rocksolid-slider-pro\'')->execute();
         if ($result && Slider::checkLicense((string) $result->lickey)) {
             \Config::getInstance()->add('$GLOBALS[\'TL_CONFIG\'][\'rocksolid_slider_license\']', (string) $result->lickey);
         }
     }
     // Fix the singleSRC data type for Contao 3.1 and below
     if (version_compare(VERSION, '3.2', '<') && $database->tableExists('tl_rocksolid_slide')) {
         $fields = $database->listFields('tl_rocksolid_slide');
         foreach ($fields as $field) {
             if ($field['name'] === 'singleSRC' && $field['type'] !== 'varchar') {
                 $database->query('ALTER TABLE tl_rocksolid_slide CHANGE singleSRC singleSRC varchar(255) NOT NULL default \'\'');
                 $database->query('UPDATE tl_rocksolid_slide SET singleSRC = trim(trailing CHAR(0x00) from singleSRC)');
             }
         }
     }
     // Update the multiSRC and orderSRC field from IDs to UUIDs
     if (version_compare(VERSION, '3.2', '>=') && $database->tableExists('tl_rocksolid_slider')) {
         $needUpdate = true;
         $result = $database->prepare('SELECT multiSRC FROM tl_rocksolid_slider WHERE multiSRC != \'\'')->execute();
         if (!$result->count()) {
             $needUpdate = false;
         }
         while ($result->next()) {
             foreach (deserialize($result->multiSRC, true) as $value) {
                 if (\Validator::isUuid($value)) {
                     $needUpdate = false;
                     break 2;
                 }
             }
         }
         if ($needUpdate) {
             \Database\Updater::convertMultiField('tl_rocksolid_slider', 'multiSRC');
             \Database\Updater::convertOrderField('tl_rocksolid_slider', 'orderSRC');
         }
     }
     // Update the singleSRC field from IDs to UUIDs
     if (version_compare(VERSION, '3.2', '>=') && $database->tableExists('tl_rocksolid_slide')) {
         $fields = $database->listFields('tl_rocksolid_slide');
         foreach ($fields as $field) {
             if ($field['name'] === 'singleSRC' && $field['type'] !== 'binary') {
                 \Database\Updater::convertSingleField('tl_rocksolid_slide', 'singleSRC');
             }
         }
     }
 }
 /**
  * Run the controller
  */
 public static function run()
 {
     $objDatabase = \Database::getInstance();
     $strTable = 'tl_module_coverpicture';
     $arrNames = array('singleSRC');
     if (version_compare(VERSION, '3.2', '>=') && $objDatabase->tableExists($strTable)) {
         foreach ($objDatabase->listFields($strTable) as $arrField) {
             foreach ($arrNames as $strName) {
                 if ($arrField['name'] == $strName && $arrField['type'] != 'binary') {
                     \Database\Updater::convertSingleField($strTable, $strName);
                 }
             }
         }
     }
     return;
 }
Esempio n. 5
0
 public static function run()
 {
     $objDatabase = \Database::getInstance();
     $strTable = 'tl_dlh_googlemaps_elements';
     $arrNames = array('overlaySRC', 'iconSRC', 'shadowSRC');
     if (version_compare(VERSION, '3.2', '>=') && $objDatabase->tableExists($strTable)) {
         // convert file fields
         foreach ($objDatabase->listFields($strTable) as $arrField) {
             foreach ($arrNames as $strName) {
                 if ($arrField['name'] == $strName && $arrField['type'] != 'binary') {
                     \Database\Updater::convertSingleField($strTable, $strName);
                 }
             }
         }
     }
     return;
 }
 /**
  * Run database migrations
  *
  * @return void
  */
 public static function run()
 {
     $database = \Database::getInstance();
     // Copy license key from extension repository
     if (!\Config::get('rocksolid_slider_license') && $database->tableExists('tl_repository_installs') && $database->fieldExists('lickey', 'tl_repository_installs') && $database->fieldExists('extension', 'tl_repository_installs')) {
         $result = $database->prepare('SELECT lickey FROM tl_repository_installs WHERE extension = \'rocksolid-slider-pro\'')->execute();
         if ($result && $result->lickey && class_exists('MadeYourDay\\Contao\\Slider') && Slider::checkLicense((string) $result->lickey)) {
             \Config::getInstance()->add('$GLOBALS[\'TL_CONFIG\'][\'rocksolid_slider_license\']', (string) $result->lickey);
         }
     }
     // Fix the singleSRC data type for Contao 3.1 and below
     if (version_compare(VERSION, '3.2', '<') && $database->tableExists('tl_rocksolid_slide')) {
         $fields = $database->listFields('tl_rocksolid_slide');
         foreach ($fields as $field) {
             if ($field['name'] === 'singleSRC' && $field['type'] !== 'varchar') {
                 $database->query('ALTER TABLE tl_rocksolid_slide CHANGE singleSRC singleSRC varchar(255) NOT NULL default \'\'');
                 $database->query('UPDATE tl_rocksolid_slide SET singleSRC = trim(trailing CHAR(0x00) from singleSRC)');
             }
         }
     }
     // Update the multiSRC and orderSRC field from IDs to UUIDs
     if (version_compare(VERSION, '3.2', '>=') && $database->tableExists('tl_rocksolid_slider')) {
         $needUpdate = true;
         $result = $database->prepare('SELECT multiSRC FROM tl_rocksolid_slider WHERE multiSRC != \'\'')->execute();
         if (!$result->count()) {
             $needUpdate = false;
         }
         while ($result->next()) {
             foreach (deserialize($result->multiSRC, true) as $value) {
                 if (\Validator::isUuid($value)) {
                     $needUpdate = false;
                     break 2;
                 }
             }
         }
         if ($needUpdate) {
             \Database\Updater::convertMultiField('tl_rocksolid_slider', 'multiSRC');
             \Database\Updater::convertOrderField('tl_rocksolid_slider', 'orderSRC');
         }
     }
     // Update the singleSRC field from IDs to UUIDs
     if (version_compare(VERSION, '3.2', '>=') && $database->tableExists('tl_rocksolid_slide')) {
         $fields = $database->listFields('tl_rocksolid_slide');
         foreach ($fields as $field) {
             if ($field['name'] === 'singleSRC' && $field['type'] !== 'binary') {
                 \Database\Updater::convertSingleField('tl_rocksolid_slide', 'singleSRC');
             }
         }
     }
     // Initialize the slider type field
     if ($database->tableExists('tl_rocksolid_slider') && $database->tableExists('tl_rocksolid_slide') && $database->fieldExists('pid', 'tl_rocksolid_slide')) {
         if (!$database->fieldExists('type', 'tl_rocksolid_slider')) {
             $database->query('ALTER TABLE tl_rocksolid_slider ADD type varchar(255) NOT NULL default \'\'');
         }
         if ($database->prepare('SELECT id FROM tl_rocksolid_slider WHERE type = \'\'')->execute()->count()) {
             $database->query("UPDATE tl_rocksolid_slider\n\t\t\t\t\tSET type = CASE\n\t\t\t\t\t\tWHEN EXISTS (SELECT id FROM tl_rocksolid_slide\n\t\t\t\t\t\t\tWHERE tl_rocksolid_slide.pid = tl_rocksolid_slider.id\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tTHEN 'content'\n\t\t\t\t\t\tELSE 'image'\n\t\t\t\t\tEND\n\t\t\t\t\tWHERE type = ''\n\t\t\t\t");
         }
     }
     // Initialize the slide type field
     if ($database->tableExists('tl_rocksolid_slide') && $database->tableExists('tl_content') && $database->fieldExists('pid', 'tl_content') && $database->fieldExists('ptable', 'tl_content')) {
         if (!$database->fieldExists('type', 'tl_rocksolid_slide')) {
             $database->query('ALTER TABLE tl_rocksolid_slide ADD type varchar(255) NOT NULL default \'\'');
         }
         if ($database->prepare('SELECT id FROM tl_rocksolid_slide WHERE type = \'\'')->execute()->count()) {
             $database->query("UPDATE tl_rocksolid_slide\n\t\t\t\t\tSET type = CASE\n\t\t\t\t\t\tWHEN EXISTS (SELECT id FROM tl_content\n\t\t\t\t\t\t\tWHERE tl_content.ptable = 'tl_rocksolid_slide'\n\t\t\t\t\t\t\tAND tl_content.pid = tl_rocksolid_slide.id\n\t\t\t\t\t\t)\n\t\t\t\t\t\t\tTHEN 'content'\n\t\t\t\t\t\tWHEN videoURL != '' OR videos IS NOT NULL\n\t\t\t\t\t\t\tTHEN 'video'\n\t\t\t\t\t\tELSE 'image'\n\t\t\t\t\tEND\n\t\t\t\t\tWHERE type = ''\n\t\t\t\t");
         }
     }
 }
Esempio n. 7
0
 public function run()
 {
     if (version_compare(VERSION, '3.2', '>=') && \Database::getInstance()->fieldExists('pageImage', 'tl_page')) {
         \Database\Updater::convertMultiField('tl_page', 'pageImage');
     }
 }
Esempio n. 8
0
 /**
  * Update UUID fields from old IDs to UUIDs
  */
 public function updateUuidFields()
 {
     // Fix the broken imageSort field (UUID String => UUID binary)
     $this->updatePhotoalbums2AlbumImageSortField();
     \Database\Updater::convertMultiField('tl_photoalbums2_album', 'images');
     \Database\Updater::convertMultiField('tl_photoalbums2_album', 'imageSort');
     \Database\Updater::convertSingleField('tl_photoalbums2_album', 'previewImage');
 }