Skip to content

Commit

Permalink
Merge pull request #14484 from seamuslee001/l18n_improved_schema
Browse files Browse the repository at this point in the history
Improve I18n schema by including comments and default and NOT NULL or…
  • Loading branch information
eileenmcnaughton authored Jun 13, 2019
2 parents aadcf38 + b2f1ab2 commit 43574a3
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 100 deletions.
5 changes: 4 additions & 1 deletion CRM/Core/CodeGen/I18n.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,11 @@ public function generateSchemaStructure() {
continue;
}
foreach ($table['fields'] as $field) {
$required = $field['required'] ? ' NOT NULL' : '';
$default = $field['default'] ? ' DEFAULT ' . $field['default'] : '';
$comment = $field['comment'] ? " COMMENT '" . $field['comment'] . "'" : '';
if ($field['localizable']) {
$columns[$table['name']][$field['name']] = $field['sqlType'];
$columns[$table['name']][$field['name']] = $field['sqlType'] . $required . $default . $comment;
$widgets[$table['name']][$field['name']] = $field['widget'];
}
}
Expand Down
198 changes: 99 additions & 99 deletions CRM/Core/I18n/SchemaStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,161 +46,161 @@ public static function &columns() {
if (!$result) {
$result = [
'civicrm_location_type' => [
'display_name' => "varchar(64)",
'display_name' => "varchar(64) COMMENT 'Location Type Display Name.'",
],
'civicrm_option_group' => [
'title' => "varchar(255)",
'description' => "varchar(255)",
'title' => "varchar(255) COMMENT 'Option Group title.'",
'description' => "varchar(255) COMMENT 'Option group description.'",
],
'civicrm_relationship_type' => [
'label_a_b' => "varchar(64)",
'label_b_a' => "varchar(64)",
'description' => "varchar(255)",
'label_a_b' => "varchar(64) COMMENT 'label for relationship of contact_a to contact_b.'",
'label_b_a' => "varchar(64) COMMENT 'Optional label for relationship of contact_b to contact_a.'",
'description' => "varchar(255) COMMENT 'Optional verbose description of the relationship type.'",
],
'civicrm_contact_type' => [
'label' => "varchar(64)",
'description' => "text",
'label' => "varchar(64) COMMENT 'localized Name of Contact Type.'",
'description' => "text COMMENT 'localized Optional verbose description of the type.'",
],
'civicrm_batch' => [
'title' => "varchar(255)",
'description' => "text",
'title' => "varchar(255) COMMENT 'Friendly Name.'",
'description' => "text COMMENT 'Description of this batch set.'",
],
'civicrm_premiums' => [
'premiums_intro_title' => "varchar(255)",
'premiums_intro_text' => "text",
'premiums_nothankyou_label' => "varchar(255)",
'premiums_intro_title' => "varchar(255) COMMENT 'Title for Premiums section.'",
'premiums_intro_text' => "text COMMENT 'Displayed in <div> at top of Premiums section of page. Text and HTML allowed.'",
'premiums_nothankyou_label' => "varchar(255) COMMENT 'Label displayed for No Thank-you option in premiums block (e.g. No thank you)'",
],
'civicrm_membership_status' => [
'label' => "varchar(128)",
'label' => "varchar(128) COMMENT 'Label for Membership Status'",
],
'civicrm_survey' => [
'title' => "varchar(255)",
'instructions' => "text",
'thankyou_title' => "varchar(255)",
'thankyou_text' => "text",
'title' => "varchar(255) NOT NULL COMMENT 'Title of the Survey.'",
'instructions' => "text COMMENT 'Script instructions for volunteers to use for the survey.'",
'thankyou_title' => "varchar(255) COMMENT 'Title for Thank-you page (header title tag, and display at the top of the page).'",
'thankyou_text' => "text COMMENT 'text and html allowed. displayed above result on success page'",
],
'civicrm_participant_status_type' => [
'label' => "varchar(255)",
'label' => "varchar(255) COMMENT 'localized label for display of this status type'",
],
'civicrm_case_type' => [
'title' => "varchar(64)",
'description' => "varchar(255)",
'title' => "varchar(64) NOT NULL COMMENT 'Natural language name for Case Type'",
'description' => "varchar(255) COMMENT 'Description of the Case Type'",
],
'civicrm_tell_friend' => [
'title' => "varchar(255)",
'intro' => "text",
'suggested_message' => "text",
'thankyou_title' => "varchar(255)",
'thankyou_text' => "text",
'intro' => "text COMMENT 'Introductory message to contributor or participant displayed on the Tell a Friend form.'",
'suggested_message' => "text COMMENT 'Suggested message to friends, provided as default on the Tell A Friend form.'",
'thankyou_title' => "varchar(255) COMMENT 'Text for Tell a Friend thank you page header and HTML title.'",
'thankyou_text' => "text COMMENT 'Thank you message displayed on success page.'",
],
'civicrm_custom_group' => [
'title' => "varchar(64)",
'help_pre' => "text",
'help_post' => "text",
'title' => "varchar(64) NOT NULL COMMENT 'Friendly Name.'",
'help_pre' => "text COMMENT 'Description and/or help text to display before fields in form.'",
'help_post' => "text COMMENT 'Description and/or help text to display after fields in form.'",
],
'civicrm_custom_field' => [
'label' => "varchar(255)",
'help_pre' => "text",
'help_post' => "text",
'label' => "varchar(255) NOT NULL COMMENT 'Text for form field label (also friendly name for administering this custom property).'",
'help_pre' => "text COMMENT 'Description and/or help text to display before this field.'",
'help_post' => "text COMMENT 'Description and/or help text to display after this field.'",
],
'civicrm_option_value' => [
'label' => "varchar(512)",
'description' => "text",
'label' => "varchar(512) NOT NULL COMMENT 'Option string as displayed to users - e.g. the label in an HTML OPTION tag.'",
'description' => "text COMMENT 'Optional description.'",
],
'civicrm_group' => [
'title' => "varchar(64)",
'title' => "varchar(64) COMMENT 'Name of Group.'",
],
'civicrm_contribution_page' => [
'title' => "varchar(255)",
'intro_text' => "text",
'pay_later_text' => "text",
'pay_later_receipt' => "text",
'initial_amount_label' => "varchar(255)",
'initial_amount_help_text' => "text",
'thankyou_title' => "varchar(255)",
'thankyou_text' => "text",
'thankyou_footer' => "text",
'receipt_from_name' => "varchar(255)",
'receipt_text' => "text",
'footer_text' => "text",
'title' => "varchar(255) COMMENT 'Contribution Page title. For top of page display'",
'intro_text' => "text COMMENT 'Text and html allowed. Displayed below title.'",
'pay_later_text' => "text COMMENT 'The text displayed to the user in the main form'",
'pay_later_receipt' => "text COMMENT 'The receipt sent to the user instead of the normal receipt text'",
'initial_amount_label' => "varchar(255) COMMENT 'Initial amount label for partial payment'",
'initial_amount_help_text' => "text COMMENT 'Initial amount help text for partial payment'",
'thankyou_title' => "varchar(255) COMMENT 'Title for Thank-you page (header title tag, and display at the top of the page).'",
'thankyou_text' => "text COMMENT 'text and html allowed. displayed above result on success page'",
'thankyou_footer' => "text COMMENT 'Text and html allowed. displayed at the bottom of the success page. Common usage is to include link(s) to other pages such as tell-a-friend, etc.'",
'receipt_from_name' => "varchar(255) COMMENT 'FROM email name used for receipts generated by contributions to this contribution page.'",
'receipt_text' => "text COMMENT 'text to include above standard receipt info on receipt email. emails are text-only, so do not allow html for now'",
'footer_text' => "text COMMENT 'Text and html allowed. Displayed at the bottom of the first page of the contribution wizard.'",
],
'civicrm_product' => [
'name' => "varchar(255)",
'description' => "text",
'options' => "text",
'name' => "varchar(255) NOT NULL COMMENT 'Required product/premium name'",
'description' => "text COMMENT 'Optional description of the product/premium.'",
'options' => "text COMMENT 'Store comma-delimited list of color, size, etc. options for the product.'",
],
'civicrm_payment_processor' => [
'title' => "varchar(127)",
'title' => "varchar(127) COMMENT 'Payment Processor Descriptive Name.'",
],
'civicrm_membership_type' => [
'name' => "varchar(128)",
'description' => "varchar(255)",
'name' => "varchar(128) COMMENT 'Name of Membership Type'",
'description' => "varchar(255) COMMENT 'Description of Membership Type'",
],
'civicrm_membership_block' => [
'new_title' => "varchar(255)",
'new_text' => "text",
'renewal_title' => "varchar(255)",
'renewal_text' => "text",
'new_title' => "varchar(255) COMMENT 'Title to display at top of block'",
'new_text' => "text COMMENT 'Text to display below title'",
'renewal_title' => "varchar(255) COMMENT 'Title for renewal'",
'renewal_text' => "text COMMENT 'Text to display for member renewal'",
],
'civicrm_price_set' => [
'title' => "varchar(255)",
'help_pre' => "text",
'help_post' => "text",
'title' => "varchar(255) NOT NULL COMMENT 'Displayed title for the Price Set.'",
'help_pre' => "text COMMENT 'Description and/or help text to display before fields in form.'",
'help_post' => "text COMMENT 'Description and/or help text to display after fields in form.'",
],
'civicrm_dashboard' => [
'label' => "varchar(255)",
'label' => "varchar(255) COMMENT 'dashlet title'",
],
'civicrm_uf_group' => [
'title' => "varchar(64)",
'frontend_title' => "varchar(64)",
'help_pre' => "text",
'help_post' => "text",
'cancel_button_text' => "varchar(64)",
'submit_button_text' => "varchar(64)",
'title' => "varchar(64) NOT NULL COMMENT 'Form title.'",
'frontend_title' => "varchar(64) COMMENT 'Profile Form Public title'",
'help_pre' => "text COMMENT 'Description and/or help text to display before fields in form.'",
'help_post' => "text COMMENT 'Description and/or help text to display after fields in form.'",
'cancel_button_text' => "varchar(64) DEFAULT NULL COMMENT 'Custom Text to display on the Cancel button when used in create or edit mode'",
'submit_button_text' => "varchar(64) DEFAULT NULL COMMENT 'Custom Text to display on the submit button on profile edit/create screens'",
],
'civicrm_uf_field' => [
'help_post' => "text",
'help_pre' => "text",
'label' => "varchar(255)",
'help_post' => "text COMMENT 'Description and/or help text to display after this field.'",
'help_pre' => "text COMMENT 'Description and/or help text to display before this field.'",
'label' => "varchar(255) NOT NULL COMMENT 'To save label for fields.'",
],
'civicrm_price_field' => [
'label' => "varchar(255)",
'help_pre' => "text",
'help_post' => "text",
'label' => "varchar(255) NOT NULL COMMENT 'Text for form field label (also friendly name for administering this field).'",
'help_pre' => "text COMMENT 'Description and/or help text to display before this field.'",
'help_post' => "text COMMENT 'Description and/or help text to display after this field.'",
],
'civicrm_price_field_value' => [
'label' => "varchar(255)",
'description' => "text",
'help_pre' => "text",
'help_post' => "text",
'label' => "varchar(255) COMMENT 'Price field option label'",
'description' => "text DEFAULT NULL COMMENT 'Price field option description.'",
'help_pre' => "text DEFAULT NULL COMMENT 'Price field option pre help text.'",
'help_post' => "text DEFAULT NULL COMMENT 'Price field option post field help.'",
],
'civicrm_pcp_block' => [
'link_text' => "varchar(255)",
'link_text' => "varchar(255) DEFAULT NULL COMMENT 'Link text for PCP.'",
],
'civicrm_event' => [
'title' => "varchar(255)",
'summary' => "text",
'description' => "text",
'registration_link_text' => "varchar(255)",
'event_full_text' => "text",
'title' => "varchar(255) COMMENT 'Event Title (e.g. Fall Fundraiser Dinner)'",
'summary' => "text COMMENT 'Brief summary of event. Text and html allowed. Displayed on Event Registration form and can be used on other CMS pages which need an event summary.'",
'description' => "text COMMENT 'Full description of event. Text and html allowed. Displayed on built-in Event Information screens.'",
'registration_link_text' => "varchar(255) COMMENT 'Text for link to Event Registration form which is displayed on Event Information screen when is_online_registration is true.'",
'event_full_text' => "text COMMENT 'Message to display on Event Information page and INSTEAD OF Event Registration form if maximum participants are signed up. Can include email address/info about getting on a waiting list, etc. Text and html allowed.'",
'fee_label' => "varchar(255)",
'intro_text' => "text",
'footer_text' => "text",
'confirm_title' => "varchar(255)",
'confirm_text' => "text",
'confirm_footer_text' => "text",
'confirm_email_text' => "text",
'confirm_from_name' => "varchar(255)",
'thankyou_title' => "varchar(255)",
'thankyou_text' => "text",
'thankyou_footer_text' => "text",
'pay_later_text' => "text",
'pay_later_receipt' => "text",
'initial_amount_label' => "varchar(255)",
'initial_amount_help_text' => "text",
'waitlist_text' => "text",
'approval_req_text' => "text",
'template_title' => "varchar(255)",
'intro_text' => "text COMMENT 'Introductory message for Event Registration page. Text and html allowed. Displayed at the top of Event Registration form.'",
'footer_text' => "text COMMENT 'Footer message for Event Registration page. Text and html allowed. Displayed at the bottom of Event Registration form.'",
'confirm_title' => "varchar(255) DEFAULT NULL COMMENT 'Title for Confirmation page.'",
'confirm_text' => "text COMMENT 'Introductory message for Event Registration page. Text and html allowed. Displayed at the top of Event Registration form.'",
'confirm_footer_text' => "text COMMENT 'Footer message for Event Registration page. Text and html allowed. Displayed at the bottom of Event Registration form.'",
'confirm_email_text' => "text COMMENT 'text to include above standard event info on confirmation email. emails are text-only, so do not allow html for now'",
'confirm_from_name' => "varchar(255) COMMENT 'FROM email name used for confirmation emails.'",
'thankyou_title' => "varchar(255) DEFAULT NULL COMMENT 'Title for ThankYou page.'",
'thankyou_text' => "text COMMENT 'ThankYou Text.'",
'thankyou_footer_text' => "text COMMENT 'Footer message.'",
'pay_later_text' => "text COMMENT 'The text displayed to the user in the main form'",
'pay_later_receipt' => "text COMMENT 'The receipt sent to the user instead of the normal receipt text'",
'initial_amount_label' => "varchar(255) COMMENT 'Initial amount label for partial payment'",
'initial_amount_help_text' => "text COMMENT 'Initial amount help text for partial payment'",
'waitlist_text' => "text COMMENT 'Text to display when the event is full, but participants can signup for a waitlist.'",
'approval_req_text' => "text COMMENT 'Text to display when the approval is required to complete registration for an event.'",
'template_title' => "varchar(255) COMMENT 'Event Template Title'",
],
];
}
Expand Down
9 changes: 9 additions & 0 deletions tests/phpunit/CRM/Core/I18n/SchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,4 +111,13 @@ public function testI18nSchemaRewrite($table, $expectedRewrite) {
}
}

public function testSchemaBuild() {
CRM_Core_I18n_Schema::makeMultilingual('en_US');
$testCreateTable = CRM_Core_DAO::executeQuery("show create table civicrm_price_set", [], TRUE, NULL, FALSE, FALSE);
while ($testCreateTable->fetch()) {
$this->assertContains("`title_en_US` varchar(255) COLLATE utf8_unicode_ci NOT NULL COMMENT 'Displayed title for the Price Set.'", $testCreateTable->Create_Table);
$this->assertContains("`help_pre_en_US` text COLLATE utf8_unicode_ci COMMENT 'Description and/or help text to display before fields in form.'", $testCreateTable->Create_Table);
}
}

}

0 comments on commit 43574a3

Please sign in to comment.