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

(accessibility/misc-core-fixes/issues/3) Remove CMS specific print header templates that share same code #11944

Merged
merged 1 commit into from
May 21, 2018

Conversation

monishdeb
Copy link
Member

@monishdeb monishdeb commented Apr 5, 2018

Overview

While working for https://lab.civicrm.org/accessibility/misc-core-fixes/issues/3 about making labels accessible I noticed that the files under templates/CRM/common/{UserFramework}.tpl share the same code and thus this patch replaces all those with a new file CMSPrint.tpl and contain other changes at the server end to accept the new file.

@monishdeb
Copy link
Member Author

ping @eileenmcnaughton @seamuslee001

@@ -35,14 +35,14 @@
{if isset($browserPrint) and $browserPrint}
{* Javascript window.print link. Used for public pages where we can't do printer-friendly view. *}
<div id="printer-friendly">
<a href="#" onclick="window.print(); return false;" title="{ts}Print this page.{/ts}">
<a href="#" onclick="window.print(); return false;" title="{ts}Print this page.{/ts}" aria-label="{ts}Print this page.{/ts}">
Copy link
Contributor

Choose a reason for hiding this comment

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

@monishdeb this has other changes in it as well though? I was hoping just to merge the file duplication clean up since I haven't formed an opinion on the other changes as yet

@eileenmcnaughton
Copy link
Contributor

I worked through this myself doing the following

  1. checkout master
  2. apply this patch
  3. revert this patch (so code is the same as master)
  4. reset HEAD~1 - ie reset the revert but code is per master
  5. check git is not clean :-)
  6. a series of moves like
 mv templates/CRM/common/backdrop.tpl templates/CRM/common/CMSPrint.tpl
  1. grep CRM/common/ & replace appropriately with the ref to the new file
  2. check git is now clean (only one difference - I removed a now redundant $config =

So, I feel confident this is a clean amalgamation of duplicate code, merge on pass

@seamuslee001
Copy link
Contributor

@monishdeb @eileenmcnaughton the only code i don't think has been brought across is

{* Joomla-only container to hold the civicrm menu *}
<div id="crm-nav-menu-container"></div>
{crmNavigationMenu is_default=1}

<table border="0" cellpadding="0" cellspacing="0" id="crm-content">
  <tr>
{if $sidebarLeft}
    <td id="sidebar-left" valign="top">
        <div id="civi-sidebar-logo" style="margin: 0 0 .25em .25em"><img src="{$config-resourceBase}i/logo_words_small.png" title="{ts}CiviCRM{/ts}"/></div><div class="spacer"></div>
       {$sidebarLeft}
    </td>
{/if}
    <td id="content-right" valign="top">
    {if $breadcrumb}
    <div class="breadcrumb">
      {foreach from=$breadcrumb item=crumb key=key}
        {if $key != 0}
           &raquo;
        {/if}
        <a href="{$crumb.url}">{$crumb.title}</a>
      {/foreach}
    </div>
    {/if}
``` which is from the joomla template

@eileenmcnaughton
Copy link
Contributor

how odd - how did I mess that? Perhaps we had better keep the files & put in

{include "CRM/common/CMSPrint.tpl"}

@monishdeb monishdeb force-pushed the access-3-1 branch 2 times, most recently from 7d23d48 to 80a3926 Compare April 5, 2018 11:27
@monishdeb
Copy link
Member Author

Thanks @seamuslee001 for pointing that out and made the changes in CMSPrint.tpl itself https://github.com/civicrm/civicrm-core/pull/11944/files#diff-262551485634c80891f7f7ae1e804c30R32

or should I still keep the files? @eileenmcnaughton

@eileenmcnaughton
Copy link
Contributor

@monishdeb yeah - I think I would keep all files (but replace the contents with an include) rather than have references to a specific cms in a generic file

@monishdeb
Copy link
Member Author

@eileenmcnaughton done, please have a look!

@eileenmcnaughton
Copy link
Contributor

I think we still need to move the joomla specific parts back to the joomla tpl.

We wouldn't need the joomla if them either

{if $config->userFramework|lower eq 'joomla'}

Not sure if we should move the outer div back to the cms specific ones so joomla can share the inner part - perhaps

@JoeMurray
Copy link
Contributor

@eileenmcnaughton I believe @monishdeb has updated the PR for you to review.

</div>
{/if}

{*{include file="CRM/common/langSwitch.tpl"}*}
Copy link
Contributor

Choose a reason for hiding this comment

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

So this line is removed from the final tpl - but as it is commented out that seems fine


{crmNavigationMenu is_default=1}

{if $breadcrumb}
Copy link
Contributor

Choose a reason for hiding this comment

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

This chunk here is missing from the final tpl - was that deliberate?

@@ -0,0 +1,82 @@
{*
+--------------------------------------------------------------------+
| CiviCRM version 4.7 |
Copy link
Contributor

Choose a reason for hiding this comment

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

Opps - we are on 5.x now

@eileenmcnaughton
Copy link
Contributor

Thanks @JoeMurray. @monishdeb there is one piece of code in the Wordpress.tpl that is omitted relating to the breadcrumb. Can you comment on that.

Also, either this PR or a follow up PR needs to fix the version in the new tpl

{$crumb}
{/foreach}
</div>
{/if}
Copy link
Member Author

Choose a reason for hiding this comment

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

@eileenmcnaughton thanks for notifying it, restored the breadcrumb block and ensure that this variable is exclusively available for wordpress as per

$ grep -irn "('breadcrumb'" CRM
CRM/Utils/System/Joomla.php:187:    $bc = $template->get_template_vars('breadcrumb');
CRM/Utils/System/Joomla.php:205:    $template->assign_by_ref('breadcrumb', $bc);
CRM/Utils/System/WordPress.php:147:    $template->assign_by_ref('breadcrumb', $breadCrumb);

@monishdeb
Copy link
Member Author

monishdeb commented May 21, 2018

@eileenmcnaughton fixed both the issues, please have a look. I was earlier thinking of including this chunk of code https://github.com/civicrm/civicrm-core/blob/master/templates/CRM/common/joomla.tpl#L56L98 in CMSprint.tpl as shared by all CMS tpl which allow us to keep the CMS specific code in respective tpl and include the shared code via CMSprint.tpl

@eileenmcnaughton
Copy link
Contributor

@monishdeb I added merge on pass as I'm happy this makes sense now - I think extracting that block to a tpl which both Joomla.tpl & CMSPrint.tpl include makes sense - is that what you mean? We can cover in a follow up PR

@monishdeb
Copy link
Member Author

Yes not only Joomla but all other CMSs tpl can share too, say for drupal.tpl it would be like

{if $config->debug}
{include file="CRM/common/debug.tpl"}
{/if}

<div id="crm-container" class="crm-container{if $urlIsPublic} crm-public{/if}" lang="{$config->lcMessages|truncate:2:"":true}" xml:lang="{$config->lcMessages|truncate:2:"":true}">

{include file="CRM/common/CMSPrint.tpl"}

</div>

but then it will still have few duplicate code which is the outer div structure and $config->debug chunk

@eileenmcnaughton
Copy link
Contributor

@monishdeb that doesn't seem too bad in terms of duplication

@monishdeb
Copy link
Member Author

Merging as per tag.

@monishdeb monishdeb merged commit 9e1dde3 into civicrm:master May 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants