Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to CRM_Core_Form::setTitle() instead of CRM_Utils_System::setTitle() part 4 #21368

Merged
merged 1 commit into from
Sep 5, 2021

Conversation

mattwire
Copy link
Contributor

@mattwire mattwire commented Sep 4, 2021

Overview

Follows on from some work that @eileenmcnaughton started in 2019. Forms should use $this->setTitle() instead of CRM_Utils_System::setTitle() because it allows you to use $this->getTitle() on a form to get the title of the form that the user will see.

Before

Calls to CRM_Utils_System::setTitle()

After

Calls to $this->setTitle()

Technical Details

As can be observed CRM_Core_Form::setTitle() calls CRM_Utils_System::setTitle() internally after setting $this->_title showing that this function is a drop-in replacement. There are just over 200 instances that need converting and (for ease of review) this is the final 43.
I would suggest that r-run testing could be done with a few forms only instead of all of them - what needs to be verified is that it is a form that inherits from CRM_Core_Form (and not eg. a Page).

Comments

This is the final one

@civibot
Copy link

civibot bot commented Sep 4, 2021

(Standard links)

@civibot civibot bot added the master label Sep 4, 2021
@@ -366,10 +366,10 @@ public function templateFile() {
*/
public function setTitle($title) {
if ($title) {
CRM_Utils_System::setTitle($title);
$this->setTitle($title);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will cause a loop

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved title changes for legacycustomsearches to #21375 and taken them out of this PR

@@ -162,7 +162,7 @@ public function preProcess() {
CRM_Custom_Form_CustomData::setDefaultValues($this);
}

CRM_Utils_System::setTitle(ts('Renew Membership'));
$this->setTitle(ts('Renew Membership'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK - checked

@@ -341,7 +341,7 @@ public function preProcess() {
}

// omitting contactImage from title for now since the summary overlay css doesn't work outside crm-container
CRM_Utils_System::setTitle(ts('View Membership for') . ' ' . $displayName);
$this->setTitle(ts('View Membership for') . ' ' . $displayName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -77,7 +77,7 @@ public function buildQuickForm() {
CRM_Core_Error::statusBounce(ts('ufGroupId is missing'));
}
$this->_title = ts('Update multiple memberships') . ' - ' . CRM_Core_BAO_UFGroup::getTitle($ufGroupId);
CRM_Utils_System::setTitle($this->_title);
$this->setTitle($this->_title);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -50,7 +50,7 @@ public function preProcess() {
$session = CRM_Core_Session::singleton();
$this->_userContext = $session->readUserContext();

CRM_Utils_System::setTitle(ts('Update multiple memberships'));
$this->setTitle(ts('Update multiple memberships'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -44,7 +44,7 @@ public function preProcess() {
$title = ts('Edit Your Personal Campaign Page');
}

CRM_Utils_System::setTitle($title);
$this->setTitle($title);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok - checked

@@ -42,7 +42,7 @@ public function setDefaultValues() {
$defaults = [];
if (isset($this->_id)) {
$title = CRM_Core_DAO::getFieldValue('CRM_Event_DAO_Event', $this->_id, 'title');
CRM_Utils_System::setTitle(ts('Personal Campaign Page Settings (%1)', [1 => $title]));
$this->setTitle(ts('Personal Campaign Page Settings (%1)', [1 => $title]));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -100,7 +100,7 @@ public function preProcess() {
$this->assign('pcpComponent', $this->_component);

if ($this->_single) {
CRM_Utils_System::setTitle(ts('Update Contact Information'));
$this->setTitle(ts('Update Contact Information'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -54,7 +54,7 @@ public function preProcess() {

$this->_id = CRM_Utils_Request::retrieve('ppId', 'Positive', $this);

CRM_Utils_System::setTitle(ts('Edit Scheduled Pledge Payment'));
$this->setTitle(ts('Edit Scheduled Pledge Payment'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@eileenmcnaughton
Copy link
Contributor

I've noted the ones I've checked so they dont need to be rechecked. Test fails relate

@mattwire mattwire force-pushed the settitle branch 2 times, most recently from 4b6b11d to 91e8134 Compare September 5, 2021 19:40
@mattwire
Copy link
Contributor Author

mattwire commented Sep 5, 2021

Thanks @eileenmcnaughton I've moved title changes for legacycustomsearches to #21375 and taken them out of this PR as they need a slightly different approach.

@@ -99,7 +99,7 @@ public function preProcess() {
$displayName .= ' (' . ts('default organization') . ')';
}
// omitting contactImage from title for now since the summary overlay css doesn't work outside of our crm-container
CRM_Utils_System::setTitle(ts('View Pledge by') . ' ' . $displayName);
$this->setTitle(ts('View Pledge by') . ' ' . $displayName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -50,7 +50,7 @@ public function preProcess() {

$this->assign('title', $this->_title);

CRM_Utils_System::setTitle(ts('Confirm Price Field Delete'));
$this->setTitle(ts('Confirm Price Field Delete'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -108,7 +108,7 @@ public function preProcess() {
elseif ($this->_action & CRM_Core_Action::VIEW) {
$title = ts('Preview %1', [1 => $title]);
}
CRM_Utils_System::setTitle($title);
$this->setTitle($title);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -22,7 +22,7 @@ public function preProcess() {
$this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
$this->_id = CRM_Utils_Request::retrieve('id', 'String', $this, FALSE);

CRM_Utils_System::setTitle(ts('Report Template'));
$this->setTitle(ts('Report Template'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -124,7 +124,7 @@ public function preProcess() {

// setting title for html page
if ($this->_action & CRM_Core_Action::UPDATE) {
CRM_Utils_System::setTitle(ts('Profile Settings') . " - $title");
$this->setTitle(ts('Profile Settings') . " - $title");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -149,7 +149,7 @@ public function preProcess() {
$this->assign('message', $message);
}
else {
CRM_Utils_System::setTitle(ts('New CiviCRM Profile'));
$this->setTitle(ts('New CiviCRM Profile'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -187,7 +187,7 @@ public function source($fileName, $isQueryString = FALSE) {
}

public function preProcess() {
CRM_Utils_System::setTitle($this->getTitle());
$this->setTitle($this->getTitle());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checked

@@ -22,7 +22,7 @@ public function __construct(&$formValues) {
* @return void
*/
public function buildForm(&$form) {
CRM_Utils_System::setTitle(ts('My Search Title'));
$form->setTitle(ts('My Search Title'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok checkedish & it's not live code anyway

@eileenmcnaughton
Copy link
Contributor

these all look good

@eileenmcnaughton eileenmcnaughton merged commit 15f57ff into civicrm:master Sep 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants