Skip to content

Commit

Permalink
bug fix in smarty to not modify translation parameters before they ar…
Browse files Browse the repository at this point in the history
…e translated (openemr#2160)

And a bunch of other related smarty stuff
  • Loading branch information
bradymiller committed Jan 24, 2019
1 parent c49c451 commit 0a815cd
Show file tree
Hide file tree
Showing 27 changed files with 533 additions and 397 deletions.
4 changes: 2 additions & 2 deletions contrib/util/language_translations/collectConstants.pl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
$traditionalXL = 1;
}

if ($fileString =~ /\{\s*xl\s*t\s*=\s*/i) {
if ($fileString =~ /\{\s*xl[atj]?\s*t\s*=\s*/i) {
# line contains a smarty xl function
$smartyXL = 1;
}
Expand All @@ -172,7 +172,7 @@
# break apart each xl function statement if exist
my @xlInstances;
if ($smartyXL) {
@xlInstances = split(/\{\s*xl\s*t\s*=\s*/i, $fileString);
@xlInstances = split(/\{\s*xl[atj]?\s*t\s*=\s*/i, $fileString);
}
elsif ($traditionalXL) {
@xlInstances = split(/xl[astj]?\s*\(+/i, $fileString);
Expand Down
110 changes: 55 additions & 55 deletions interface/forms/vitals/templates/vitals/general_new.html

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions library/smarty/plugins/function.xl.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,15 @@
* Smarty plugin
* @package Smarty
* @subpackage plugins
* simplified xl() version for smarty templates
* Christian Navalici 2007
* xl() version for smarty templates
*
* Copyright (C) 2007 Christian Navalici
* Copyright (C) 2019 Brady Miller <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*/


Expand Down Expand Up @@ -33,7 +40,5 @@ function smarty_function_xl($params, &$smarty)
$translate = $params['t'];
}

xl($translate, 'e');
echo xl($translate);
}

/* vim: set expandtab: */
43 changes: 43 additions & 0 deletions library/smarty/plugins/function.xla.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
* xla() version for smarty templates
*
* Copyright (C) 2007 Christian Navalici
* Copyright (C) 2019 Brady Miller <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*/

/**
* Smarty {xla} function plugin
*
* Type: function<br>
* Name: xla<br>
* Purpose: translate in OpenEMR and escape for html attr - Smarty templates<br>
*
* Examples:
*
* {xla t="some words"}
*
* @param array
* @param Smarty
*/


function smarty_function_xla($params, &$smarty)
{
if (empty($params['t'])) {
$smarty->trigger_error("xk: missing 't' parameter");
return;
} else {
$translate = $params['t'];
}

echo xla($translate);
}
44 changes: 44 additions & 0 deletions library/smarty/plugins/function.xlj.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
* xlj() version for smarty templates
*
* Copyright (C) 2007 Christian Navalici
* Copyright (C) 2019 Brady Miller <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*/


/**
* Smarty {xlj} function plugin
*
* Type: function<br>
* Name: xlj<br>
* Purpose: translate in OpenEMR and escape for js - Smarty templates<br>
*
* Examples:
*
* {xlj t="some words"}
*
* @param array
* @param Smarty
*/


function smarty_function_xlj($params, &$smarty)
{
if (empty($params['t'])) {
$smarty->trigger_error("xk: missing 't' parameter");
return;
} else {
$translate = $params['t'];
}

echo xlj($translate);
}
44 changes: 44 additions & 0 deletions library/smarty/plugins/function.xlt.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
* xlt() version for smarty templates
*
* Copyright (C) 2007 Christian Navalici
* Copyright (C) 2019 Brady Miller <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*/


/**
* Smarty {xlt} function plugin
*
* Type: function<br>
* Name: xlt<br>
* Purpose: translate in OpenEMR - Smarty templates<br>
*
* Examples:
*
* {xlt t="some words"}
*
* @param array
* @param Smarty
*/


function smarty_function_xlt($params, &$smarty)
{
if (empty($params['t'])) {
$smarty->trigger_error("xk: missing 't' parameter");
return;
} else {
$translate = $params['t'];
}

echo xlt($translate);
}
24 changes: 12 additions & 12 deletions templates/document_categories/general_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
</style>
{/literal}
<script type="text/javascript">
var deleteLabel="{xl t="Delete"|escape:'html'}";
var editLabel="{xl t="Edit"|escape:'html'}";
var deleteLabel={xlj t="Delete"};
var editLabel={xlj t="Edit"};
</script>
<script type="text/javascript" src="{$GLOBALS.webroot}/library/js/CategoryTreeMenu.js?v={$V_JS_INCLUDES}"></script>
<table>
<tr>
<td height="20" valign="top">{xl t="Document Categories"|escape:'html'}</td>
<td height="20" valign="top">{xlt t="Document Categories"}</td>
</tr>
<tr>
<td valign="top">{$tree_html}</td>
Expand All @@ -31,29 +31,29 @@
<td width="25"></td>
<td valign="top">
{if $add_node eq true}
{xl t="This new category will be a sub-category of "|escape:'html'} {$parent_name|escape:'html'}<br>
{xlt t="This new category will be a sub-category of "} {$parent_name|text}<br>
{/if}
<form method="post" action="{$FORM_ACTION}" onsubmit="return top.restoreSession()">

<table>
<tr>
<td>{xl t="Category Name"|escape:'html'}&nbsp;</td>
<td><input type="text" name="name" value="{$NAME|escape:'html'}" onKeyDown="PreventIt(event)" /></td>
<td>{xlt t="Category Name"}&nbsp;</td>
<td><input type="text" name="name" value="{$NAME|attr}" onKeyDown="PreventIt(event)" /></td>
</tr>
<tr>
<td>{xl t="Value"|escape:'html'}&nbsp;</td>
<td><input type="text" name="value" value="{$VALUE|escape:'html'}" onKeyDown="PreventIt(event)" ></td>
<td>{xlt t="Value"}&nbsp;</td>
<td><input type="text" name="value" value="{$VALUE|attr}" onKeyDown="PreventIt(event)" ></td>
</tr>
<tr>
<td>{xl t="Access Control"|escape:'html'}&nbsp;</td>
<td>{xlt t="Access Control"}&nbsp;</td>
<td><select name="aco_spec">{$ACO_OPTIONS}</select></td>
</tr>
</table>
&nbsp;<br />

<button type="submit" name="Add Category" class="btn btn-default btn-save">{xl t='Save Category'|escape:'html'}</button>
<input type="hidden" name="parent_is" value="{$parent_is|escape:'html'}">
<input type="hidden" name="process" value="{$PROCESS|escape:'html'}" />
<button type="submit" name="Add Category" class="btn btn-default btn-save">{xlt t='Save Category'}</button>
<input type="hidden" name="parent_is" value="{$parent_is|attr}">
<input type="hidden" name="process" value="{$PROCESS|attr}" />
</form>
</td>
{/if}
Expand Down
12 changes: 6 additions & 6 deletions templates/document_categories/general_upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,30 @@
<input type="hidden" name="MAX_FILE_SIZE" value="64000000" />
<table>
<tr>
<td>{xl t="Upload Document"}</td>
<td>{xlt t="Upload Document"}</td>
</tr>
<tr>
<td><input type="file" name="file"></td>
</tr>
<tr>
<td><input type="submit" value="{xl t='Upload'}"></td>
<td><input type="submit" value="{xla t='Upload'}"></td>
</tr>
{if !empty($file)}
<tr>
<td><br><br></td>
</tr>
<tr>
<td>{xl t='Upload Report'}</td>
<td>{xlt t='Upload Report'}</td>
</tr>
<tr>
<td>{$error}</td>
<td>{$error|text}</td>
</tr>
<tr>
<td><pre>{$file}</pre></td>
<td><pre>{$file|text}</pre></td>
</tr>
{/if}
</table>
<input type="hidden" name="process" value="{$PROCESS}" />
<input type="hidden" name="process" value="{$PROCESS|attr}" />
</form>
</body>
</html>
20 changes: 10 additions & 10 deletions templates/documents/general_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@

<script type="text/javascript">
// dropzone javascript asset translation(s)
Dropzone.prototype.defaultOptions.dictDefaultMessage = {xl t='Drop files here to upload'|js_escape};
Dropzone.prototype.defaultOptions.dictDefaultMessage = {xlj t='Drop files here to upload'};
</script>
<title>{xl t='Documents'|text}</title>
<title>{xlt t='Documents'}</title>
</head>
<!-- ViSolve - Call expandAll function on loading of the page if global value 'expand_document' is set -->
{if $GLOBALS.expand_document_tree}
Expand All @@ -56,21 +56,21 @@
<div class="row">
<div class="col-sm-12">
<div class="page-header">
<h2>{xl t='Documents'|text}&nbsp;&nbsp; <a href='interface/patient_file/summary/demographics.php' onclick='top.restoreSession()' title="{xl t='Go Back'|attr}" ><i id='advanced-tooltip' class='fa fa-undo fa-2x small' aria-hidden='true'></i></a></h2>
<h2>{xlt t='Documents'}&nbsp;&nbsp; <a href='interface/patient_file/summary/demographics.php' onclick='top.restoreSession()' title="{xla t='Go Back'}" ><i id='advanced-tooltip' class='fa fa-undo fa-2x small' aria-hidden='true'></i></a></h2>
</div>
</div>
</div>
<div class="row">
<div class="col-sm-3">
<div id="documents_list">
<fieldset>
<legend>{xl t='Documents List'|text}</legend>
<legend>{xlt t='Documents List'}</legend>
<div style="padding: 0 10px">
<div class="ui-widget"style="float:right;">
<button id='pid' class="pBtn" type="button" style="float:right;">0</button>
<input id="selectPatient" type="text" placeholder="{$place_hld|attr}">
</div>
<a id="list_collapse" href="#" onclick="javascript:objTreeMenu_1.collapseAll();return false;">&nbsp;({xl t='Collapse all'|text})</a>
<a id="list_collapse" href="#" onclick="javascript:objTreeMenu_1.collapseAll();return false;">&nbsp;({xlt t='Collapse all'})</a>
{$tree_html}
</div>
</div>
Expand All @@ -82,7 +82,7 @@ <h2>{xl t='Documents'|text}&nbsp;&nbsp; <a href='interface/patient_file/summary

<fieldset>

<legend>{xl t='Document Uploader/Viewer'|text}</legend>
<legend>{xlt t='Document Uploader/Viewer'}</legend>
<div style="padding: 0 10px">
{if $message}
<div class='text' style="margin-bottom:-10px; margin-top:-8px; padding:10px;"><i>{$message|text}</i></div><br>
Expand Down Expand Up @@ -118,7 +118,7 @@ <h2>{xl t='Documents'|text}&nbsp;&nbsp; <a href='interface/patient_file/summary
},
select: function(event, sel) {
event.preventDefault();
if (sel.item.value == '00' && ! sel.item.label.match({/literal}{xl t="Reset"|js_escape}{literal})){
if (sel.item.value == '00' && ! sel.item.label.match({/literal}{xlj t="Reset"}{literal})){
alert(inUseMsg);
return false;
}
Expand All @@ -142,7 +142,7 @@ <h2>{xl t='Documents'|text}&nbsp;&nbsp; <a href='interface/patient_file/summary
$(function () {
$("img[id^='icon_objTreeMenu_']").tooltip({
items: $("img[src*='file3.png']"),
content: {/literal}{xl t="Double Click on this icon to pop up document in a new viewer."|js_escape}{literal}
content: {/literal}{xlj t="Double Click on this icon to pop up document in a new viewer."}{literal}
});

$("img[id^='icon_objTreeMenu_']").on('dblclick', function (e) {
Expand All @@ -162,8 +162,8 @@ <h2>{xl t='Documents'|text}&nbsp;&nbsp; <a href='interface/patient_file/summary
window.open(popsrc, wname, opt);
};

let btnText = {/literal}{xl t="Full Screen"|js_escape}{literal};
let btnClose = {/literal}{xl t="Close"|js_escape}{literal};
let btnText = {/literal}{xlj t="Full Screen"}{literal};
let btnClose = {/literal}{xlj t="Close"}{literal};
let size = 'modal-xl';
let sizeHeight = 'full';
if (dflg) {
Expand Down
Loading

0 comments on commit 0a815cd

Please sign in to comment.