Skip to content

Instantly share code, notes, and snippets.

@ryandemmer
Created December 6, 2019 10:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryandemmer/92209c15f6da6beaee6a8ab75e177a71 to your computer and use it in GitHub Desktop.
Save ryandemmer/92209c15f6da6beaee6a8ab75e177a71 to your computer and use it in GitHub Desktop.
install.pkg.php modification
$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