Commit 98df4e4a authored by jcnventura's avatar jcnventura

Fix #365041: node-specific settings not initialized when adding new content

Fix #364535: move custom text strings to separate form to prevent conflicts with the translation mechanism
parent 85cce36d
......@@ -135,38 +135,6 @@ function print_main_settings() {
'#description' => t("Drupal will attempt to use the page's defined alias in case there is one. To force the use of the fixed URL, activate this option."),
);
$form['settings']['print_text'] = array(
'#type' => 'fieldset',
'#title' => t('Text strings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['settings']['print_text']['print_text_published'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_published', t('Published on %site_name')),
);
$form['settings']['print_text']['print_text_by'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_by', t('By %author')),
);
$form['settings']['print_text']['print_text_created'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_created', t('Created %date')),
);
$form['settings']['print_text']['print_text_source_url'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_source_url', t('Source URL')),
);
$form['settings']['print_text']['print_text_retrieved'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_retrieved', t('retrieved on %date')),
);
$form['settings']['print_text']['print_text_links'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_links', t('Links')),
);
$form['#attributes'] = array('enctype' => 'multipart/form-data');
$form['#validate'][] = '_print_main_settings_validate';
......@@ -226,13 +194,6 @@ function print_html_settings() {
'#description' => t('Select the visual style of the link.'),
);
$form['settings']['adv_link']['print_html_link_text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#default_value' => variable_get('print_html_link_text', t('Printer-friendly version')),
'#description' => t("Text used in the link to the printer-friendly version."),
);
$form['settings']['adv_link']['print_html_link_use_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Use URL alias instead of node ID'),
......@@ -349,3 +310,63 @@ function print_html_settings() {
return system_settings_form($form);
}
/**
* Menu callback for the Printer-friendly pages module text strings settings form.
*
* @ingroup forms
*/
function print_main_strings_settings() {
$form['print_main_text'] = array(
'#type' => 'fieldset',
'#title' => t('Text strings'),
);
$form['print_main_text']['print_text_published'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_published', t('Published on %site_name')),
);
$form['print_main_text']['print_text_by'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_by', t('By %author')),
);
$form['print_main_text']['print_text_created'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_created', t('Created %date')),
);
$form['print_main_text']['print_text_source_url'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_source_url', t('Source URL')),
);
$form['print_main_text']['print_text_retrieved'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_retrieved', t('retrieved on %date')),
);
$form['print_main_text']['print_text_links'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('print_text_links', t('Links')),
);
return system_settings_form($form);
}
/**
* Menu callback for the Printer-friendly pages module text strings settings form.
*
* @ingroup forms
*/
function print_html_strings_settings() {
$form['print_html_text'] = array(
'#type' => 'fieldset',
'#title' => t('Text strings'),
);
$form['print_html_text']['print_html_link_text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#default_value' => variable_get('print_html_link_text', t('Printer-friendly version')),
'#description' => t('Text used in the link to the printer-friendly version.'),
);
return system_settings_form($form);
}
......@@ -97,7 +97,7 @@ function print_menu() {
'type' => MENU_CALLBACK,
);
$items['admin/settings/print'] = array(
'title' => 'Printer-friendly pages',
'title' => 'Printer, e-mail and PDF versions',
'description' => 'Adds a printer-friendly version link to content and administrative pages.',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_html_settings'),
......@@ -108,6 +108,19 @@ function print_menu() {
'weight' => 1,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/settings/print/html/options'] = array(
'title' => 'Options',
'weight' => 1,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/settings/print/html/strings'] = array(
'title' => 'Text strings',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_html_strings_settings'),
'access arguments' => array('administer print'),
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
$items['admin/settings/print/common'] = array(
'title' => 'Settings',
'page callback' => 'drupal_get_form',
......@@ -116,6 +129,19 @@ function print_menu() {
'weight' => 10,
'type' => MENU_LOCAL_TASK,
);
$items['admin/settings/print/common/options'] = array(
'title' => 'Options',
'weight' => 1,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/settings/print/common/strings'] = array(
'title' => 'Text strings',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_main_strings_settings'),
'access arguments' => array('administer print'),
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
return $items;
}
......@@ -346,9 +372,10 @@ function print_form_alter(&$form, $form_state, $form_id) {
$form['print']['print_display_urllist']['#default_value'] = variable_get('print_display_urllist_'. $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT);
}
else {
$form['print']['print_display']['#default_value'] = $form['#node']->print_display;
$form['print']['print_display_comment']['#default_value'] = $form['#node']->print_display_comment;
$form['print']['print_display_urllist']['#default_value'] = $form['#node']->print_display_urllist;
$node = $form['#node'];
$form['print']['print_display']['#default_value'] = isset($node->print_display) ? $node->print_display : PRINT_TYPE_SHOW_LINK_DEFAULT;
$form['print']['print_display_comment']['#default_value'] = isset($node->print_display_comment) ? $node->print_display_comment : PRINT_TYPE_COMMENT_LINK_DEFAULT;
$form['print']['print_display_urllist']['#default_value'] = isset($node->print_display_urllist) ? $node->print_display_urllist : PRINT_TYPE_URLLIST_DEFAULT;
}
}
}
......
......@@ -43,13 +43,6 @@ function print_mail_settings() {
'#description' => t('Select the visual style of the link.'),
);
$form['settings']['adv_link']['print_mail_link_text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#default_value' => variable_get('print_mail_link_text', t('Send to friend')),
'#description' => t("Text used in the link to the send by-email form."),
);
$form['settings']['adv_link']['print_mail_link_use_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Use URL alias instead of node ID'),
......@@ -144,32 +137,46 @@ function print_mail_settings() {
'#description' => t('If checked, the user will be able to choose between sending the full content or only the teaser at send time.'),
);
$form['settings']['print_mail_text'] = array(
return system_settings_form($form);
}
/**
* Menu callback for the send by e-mail module text strings settings form.
*
* @ingroup forms
*/
function print_mail_strings_settings() {
$form['print_mail_text'] = array(
'#type' => 'fieldset',
'#title' => t('Text strings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['settings']['print_mail_text']['print_mail_text_subject'] = array(
$form['print_mail_text']['print_mail_link_text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#default_value' => variable_get('print_mail_link_text', t('Send to friend')),
'#description' => t('Text used in the link to the send by-email form.'),
);
$form['print_mail_text']['print_mail_text_subject'] = array(
'#type' => 'textfield',
'#title' => t('Message Subject'),
'#default_value' => variable_get('print_mail_text_subject', t('!user has sent you a message from !site')),
'#description' => t("e-mail subject line. The sender's name will appear in place of !user in the subject. The web site name will be inserted in place of !site."),
);
$form['settings']['print_mail_text']['print_mail_text_message'] = array(
$form['print_mail_text']['print_mail_text_message'] = array(
'#type' => 'textfield',
'#title' => t('Message Preamble'),
'#default_value' => variable_get('print_mail_text_message', t('Message from sender')),
'#description' => t('e-mail message preamble. The sender will be able to add their own message after this.'),
);
$form['settings']['print_mail_text']['print_mail_text_content'] = array(
$form['print_mail_text']['print_mail_text_content'] = array(
'#type' => 'textfield',
'#title' => t('Message Content'),
'#default_value' => variable_get('print_mail_text_content', ''),
'#description' => t('Set the default contents of the message.'),
);
$form['settings']['print_mail_text']['print_mail_text_confirmation'] = array(
$form['print_mail_text']['print_mail_text_confirmation'] = array(
'#type' => 'textfield',
'#title' => t('Thank You Message'),
'#default_value' => variable_get('print_mail_text_confirmation', t('Thank you for spreading the word about !site.')),
......
......@@ -58,6 +58,19 @@ function print_mail_menu() {
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
$items['admin/settings/print/email/options'] = array(
'title' => 'Options',
'weight' => 1,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/settings/print/email/strings'] = array(
'title' => 'Text strings',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_mail_strings_settings'),
'access arguments' => array('administer print'),
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
return $items;
}
......@@ -232,9 +245,10 @@ function print_mail_form_alter(&$form, $form_state, $form_id) {
$form['print']['print_mail_display_urllist']['#default_value'] = variable_get('print_mail_display_urllist_'. $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT);
}
else {
$form['print']['print_mail_display']['#default_value'] = $form['#node']->print_mail_display;
$form['print']['print_mail_display_comment']['#default_value'] = $form['#node']->print_mail_display_comment;
$form['print']['print_mail_display_urllist']['#default_value'] = $form['#node']->print_mail_display_urllist;
$node = $form['#node'];
$form['print']['print_mail_display']['#default_value'] = isset($node->print_mail_display) ? $node->print_mail_display : PRINT_TYPE_SHOW_LINK_DEFAULT;
$form['print']['print_mail_display_comment']['#default_value'] = isset($node->print_mail_display_comment) ? $node->print_mail_display_comment : PRINT_TYPE_COMMENT_LINK_DEFAULT;
$form['print']['print_mail_display_urllist']['#default_value'] = isset($node->print_mail_display_urllist) ? $node->print_mail_display_urllist : PRINT_TYPE_URLLIST_DEFAULT;
}
}
}
......
......@@ -55,13 +55,6 @@ function print_pdf_settings() {
'#description' => t('Select the visual style of the link.'),
);
$form['settings']['adv_link']['print_pdf_link_text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#default_value' => variable_get('print_pdf_link_text', t('PDF version')),
'#description' => t("Text used in the link to the PDF version."),
);
$form['settings']['adv_link']['print_pdf_link_use_alias'] = array(
'#type' => 'checkbox',
'#title' => t('Use URL alias instead of node ID'),
......@@ -263,3 +256,24 @@ function _print_pdf_tools() {
return $tools2;
}
}
/**
* Menu callback for the PDF version module text strings settings form.
*
* @ingroup forms
*/
function print_pdf_strings_settings() {
$form['print_pdf_text'] = array(
'#type' => 'fieldset',
'#title' => t('Text strings'),
);
$form['print_pdf_text']['print_pdf_link_text'] = array(
'#type' => 'textfield',
'#title' => t('Link text'),
'#default_value' => variable_get('print_pdf_link_text', t('PDF version')),
'#description' => t('Text used in the link to the PDF version.'),
);
return system_settings_form($form);
}
......@@ -76,6 +76,19 @@ function print_pdf_menu() {
'weight' => 3,
'type' => MENU_LOCAL_TASK,
);
$items['admin/settings/print/pdf/options'] = array(
'title' => 'Options',
'weight' => 1,
'type' => MENU_DEFAULT_LOCAL_TASK,
);
$items['admin/settings/print/pdf/strings'] = array(
'title' => 'Text strings',
'page callback' => 'drupal_get_form',
'page arguments' => array('print_pdf_strings_settings'),
'access arguments' => array('administer print'),
'weight' => 2,
'type' => MENU_LOCAL_TASK,
);
return $items;
}
......@@ -272,9 +285,10 @@ function print_pdf_form_alter(&$form, $form_state, $form_id) {
$form['print']['print_pdf_display_urllist']['#default_value'] = variable_get('print_pdf_display_urllist_'. $form['#node_type']->type, PRINT_TYPE_URLLIST_DEFAULT);
}
else {
$form['print']['print_pdf_display']['#default_value'] = $form['#node']->print_pdf_display;
$form['print']['print_pdf_display_comment']['#default_value'] = $form['#node']->print_pdf_display_comment;
$form['print']['print_pdf_display_urllist']['#default_value'] = $form['#node']->print_pdf_display_urllist;
$node = $form['#node'];
$form['print']['print_pdf_display']['#default_value'] = isset($node->print_pdf_display) ? $node->print_pdf_display : PRINT_TYPE_SHOW_LINK_DEFAULT;
$form['print']['print_pdf_display_comment']['#default_value'] = isset($node->print_pdf_display_comment) ? $node->print_pdf_display_comment : PRINT_TYPE_COMMENT_LINK_DEFAULT;
$form['print']['print_pdf_display_urllist']['#default_value'] = isset($node->print_pdf_display_urllist) ? $node->print_pdf_display_urllist : PRINT_TYPE_URLLIST_DEFAULT;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment