/** * Checks for presence of configuration for ca_editor_uis and ca_editor_ui_screens editors, and if not * present, loads a default configuration. Since these editors are used to configure themselves, lack of * configuration (the case with all pre-version 1.1 installations), will effectively make it impossible to * change the setup for any editor in the installation. * * @return bool Returns true on success (either UI already exists or was created successfully), false on error (UI does not exist and could not be created) * */ public function checkConfiguration() { global $g_ui_locale_id; $t_ui = new ca_editor_uis(); if (!$t_ui->load(array('editor_type' => 101))) { $t_ui->setMode(ACCESS_WRITE); $t_ui->set('user_id', null); $t_ui->set('is_system_ui', 1); $t_ui->set('editor_type', 101); $t_ui->set('editor_code', 'ui_editor'); $t_ui->set('color', '000000'); $t_ui->insert(); if ($t_ui->numErrors()) { return false; } $t_ui->addLabel(array('name' => 'UI Editor'), $g_ui_locale_id, null, true); if ($t_ui->numErrors()) { return false; } $vn_ui_id = $t_ui->getPrimaryKey(); $t_screen = new ca_editor_ui_screens(); $t_screen->setMode(ACCESS_WRITE); $t_screen->set('ui_id', $vn_ui_id); $t_screen->set('idno', 'basic_' . $vn_ui_id); $t_screen->set('rank', 1); $t_screen->set('default', 1); $t_screen->insert(); if ($t_screen->numErrors()) { return false; } $t_screen->addLabel(array('name' => 'Basic'), $g_ui_locale_id, null, true); if ($t_screen->numErrors()) { return false; } $vn_i = 1; foreach (array('preferred_labels', 'editor_code', 'color', 'editor_type', 'ca_editor_ui_type_restrictions', 'ca_editor_ui_screens', 'is_system_ui', 'ca_users', 'ca_user_groups', 'ca_user_roles') as $vs_bundle_name) { $t_screen->addPlacement($vs_bundle_name, $vs_bundle_name, array(), $vn_i); $vn_i++; } } if (!$t_ui->load(array('editor_type' => 100))) { $t_ui->setMode(ACCESS_WRITE); $t_ui->set('user_id', null); $t_ui->set('is_system_ui', 1); $t_ui->set('editor_type', 100); $t_ui->set('color', 'CC0000'); $t_ui->set('editor_code', 'ui_screen_editor'); $t_ui->insert(); if ($t_ui->numErrors()) { return false; } $t_ui->addLabel(array('name' => 'UI Screen Editor'), $g_ui_locale_id, null, true); if ($t_ui->numErrors()) { return false; } $vn_ui_id = $t_ui->getPrimaryKey(); $t_screen = new ca_editor_ui_screens(); $t_screen->setMode(ACCESS_WRITE); $t_screen->set('ui_id', $vn_ui_id); $t_screen->set('idno', 'basic_' . $vn_ui_id); $t_screen->set('rank', 1); $t_screen->set('default', 1); $t_screen->insert(); if ($t_screen->numErrors()) { return false; } $t_screen->addLabel(array('name' => 'Basic'), $g_ui_locale_id, null, true); if ($t_screen->numErrors()) { return false; } $vn_i = 1; foreach (array('preferred_labels', 'idno', 'color', 'is_default', 'ca_editor_ui_screen_type_restrictions', 'ca_editor_ui_bundle_placements', 'ca_users', 'ca_user_groups', 'ca_user_roles') as $vs_bundle_name) { $t_screen->addPlacement($vs_bundle_name, $vs_bundle_name, array(), $vn_i); $vn_i++; } } return true; }