Created
December 6, 2019 10:29
-
-
Save ryandemmer/92209c15f6da6beaee6a8ab75e177a71 to your computer and use it in GitHub Desktop.
install.pkg.php modification
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$version = (string) $parent->manifest->version; | |
$current_version = (string) $parent->get('current_version'); | |
$theme = 'modern'; | |
// update toolbar_theme | |
if ($theme) { | |
$table = JTable::getInstance('Profiles', 'JceTable'); | |
$db = JFactory::getDBO(); | |
$query = $db->getQuery(true); | |
$query->select('*')->from('#__wf_profiles'); | |
$db->setQuery($query); | |
$profiles = $db->loadObjectList(); | |
foreach ($profiles as $profile) { | |
if (empty($profile->params)) { | |
$profile->params = '{}'; | |
} | |
$data = json_decode($profile->params, true); | |
if (false !== $data) { | |
if (empty($data)) { | |
$data = array(); | |
} | |
// no editor parameters set at all! | |
if (!isset($data['editor'])) { | |
$data['editor'] = array(); | |
} | |
$param = array( | |
'toolbar_theme' => $theme, | |
); | |
// add variant for "mobile" profile | |
if ($profile->name === "Mobile") { | |
$param['toolbar_theme'] .= '.touch'; | |
} | |
$data['editor']['toolbar_theme'] = $param['toolbar_theme']; | |
if (!$table->load($profile->id)) { | |
throw new Exception('Unable to update profile - ' . $profile->name); | |
} | |
$table->params = json_encode($data); | |
if (!$table->store()) { | |
throw new Exception('Unable to update profile - ' . $profile->name); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment