Skip to content

Pm caption templatization - #5563

Open
rica-carv wants to merge 7 commits into
e107inc:masterfrom
rica-carv:pm_caption-templatization
Open

Pm caption templatization#5563
rica-carv wants to merge 7 commits into
e107inc:masterfrom
rica-carv:pm_caption-templatization

Conversation

@rica-carv

Copy link
Copy Markdown
Member

Motivation and Context

Allow full caption templatization im PM pages...

Description

Changed hardcoded lans inside PHP to template coded lan's, allowing full tempatization of captions is PM pages

How Has This Been Tested?

Tested with latest e107 from github

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (a change to man pages or other documentation)

Checklist

@Deltik
Deltik force-pushed the master branch 3 times, most recently from 241b734 to 4f50dac Compare February 20, 2026 22:44

@e107help e107help Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rica-carv Getting the PM captions out of the four hardcoded LAN_PM call sites and into the template is the right move, and vartrue($PM_TEMPLATE['caption'], LAN_PM) is a sensible fallback shape. One change in here is a backwards-compatibility break, though, and it isn't flagged.

$PM_TEMPLATE['send'] changes from a string to an array

-$PM_TEMPLATE['send'] = "<div id='pm-send-pm'>
+$PM_TEMPLATE['send']['caption'] = "{LAN=LAN_PM}";
+$PM_TEMPLATE['send']['main'] = "<div id='pm-send-pm'>

with the read side updated to match:

$PM_SEND_PM = e107::getTemplate('pm', 'pm', 'send')['main'];

Any theme that overrides $PM_TEMPLATE['send'] as a string, which is the only shape it has ever had (pm_template.php#L90), now has ['main'] read off a string. On PHP 8 that's a TypeError: Cannot access offset of type string on string, so the send-PM page fatals rather than degrading.

The other three keys (inbox, outbox, blocked) are already arrays, so adding caption to them is free. send is the odd one out. Either:

  • keep send a string and hold its caption elsewhere, or
  • normalise it and handle both shapes on read:
$sendTmpl = e107::getTemplate('pm', 'pm', 'send');
$PM_SEND_PM = is_array($sendTmpl) ? varset($sendTmpl['main']) : $sendTmpl;

The second is the better long-term answer, but it needs to be a deliberate, documented change with the shim in place, not a silent one.

pm_caption('') on the show page

$ns->tablerender($this->pm_caption($comeFrom), ...);

$comeFrom is 'inbox', 'outbox' or ''. A default parameter value only applies when the argument is missing, not when it's empty, so the third case calls getTemplate('pm', 'pm', ''). vartrue() catches the fallout and you get LAN_PM, so nothing breaks, but the = 'inbox' default is misleading about what actually happens. $this->pm_caption($comeFrom ?: 'inbox') says what you mean.

Smaller things

  • The pm_caption() body is indented at column 0 while the rest of the class is at one tab, and the interior mixes tabs and spaces. It reads as pasted in.
  • $caption = $pm->pm_caption('inbox');; and the outbox line below it both end with a double semicolon.
  • {LAN=LAN_PM} does resolve, via the elseif(defined($lan)) fallback in lan.php#L17-L20, so it isn't a bug. It's just not how core writes it: the shortcode prepends LAN_ itself, so everywhere else says {LAN=PM}. Worth matching so nobody copies the doubled form into a new template.
  • pm_caption() is declared without a visibility keyword. The methods around it use function too, so it's consistent with the file, but public function would be better in new code.

Sort the send key and this is a good change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant