Merge branch 'fix-markdown-in-previews' into 'develop'
Properly handle markdown choices inside titles, if no text as fallback, use the… Closes #326 See merge request framasoft/framadate!323
This commit is contained in:
commit
f656c790d0
@ -45,7 +45,7 @@ if (defined('FAVICON')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Dev Mode
|
// Dev Mode
|
||||||
if (isset($_SERVER['FRAMADATE_DEVMODE']) && $_SERVER['FRAMADATE_DEVMODE']) {
|
if (isset($_SERVER['FRAMADATE_DEVMODE']) && $_SERVER['FRAMADATE_DEVMODE'] || php_sapi_name() === 'cli-server') {
|
||||||
$smarty->force_compile = true;
|
$smarty->force_compile = true;
|
||||||
$smarty->compile_check = true;
|
$smarty->compile_check = true;
|
||||||
} else {
|
} else {
|
||||||
@ -80,6 +80,21 @@ function smarty_modifier_html($html) {
|
|||||||
return Utils::htmlEscape($html);
|
return Utils::htmlEscape($html);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* markdown_to_text
|
||||||
|
* Retrieves a markdown string and tries to make a plain text value
|
||||||
|
*
|
||||||
|
* @param array $options
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function smarty_function_markdown_to_text($options, Smarty_Internal_Template $template)
|
||||||
|
{
|
||||||
|
$locale = \o80\i18n\I18N::instance()->getLoadedLang();
|
||||||
|
$text = strip_tags(Parsedown::instance()->text($options['markdown']));
|
||||||
|
$number_letters = (new NumberFormatter($locale, NumberFormatter::ORDINAL))->format($options['id'] + 1);
|
||||||
|
return $text !== '' ? $text : __f('Poll results', '%s option', $number_letters);
|
||||||
|
}
|
||||||
|
|
||||||
function smarty_modifier_datepicker_path($lang) {
|
function smarty_modifier_datepicker_path($lang) {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
while (!is_file(path_for_datepicker_locale($lang)) && $i < 3) {
|
while (!is_file(path_for_datepicker_locale($lang)) && $i < 3) {
|
||||||
|
@ -290,6 +290,7 @@
|
|||||||
"You have to provide a password to access the poll.": "You have to provide a password to access the poll."
|
"You have to provide a password to access the poll.": "You have to provide a password to access the poll."
|
||||||
},
|
},
|
||||||
"Poll results": {
|
"Poll results": {
|
||||||
|
"%s option": "%s option",
|
||||||
"Addition": "Total",
|
"Addition": "Total",
|
||||||
"Anyone will be able to access your email address after your vote": "Anyone will be able to see your email address after you voted",
|
"Anyone will be able to access your email address after your vote": "Anyone will be able to see your email address after you voted",
|
||||||
"Best choice": "Best choice",
|
"Best choice": "Best choice",
|
||||||
|
@ -82,19 +82,19 @@
|
|||||||
<ul class="list-unstyled choice">
|
<ul class="list-unstyled choice">
|
||||||
<li class="yes">
|
<li class="yes">
|
||||||
<input type="radio" id="y-choice-{$id}" name="choices[{$id}]" value="2" {if $choice=='2'}checked {/if}/>
|
<input type="radio" id="y-choice-{$id}" name="choices[{$id}]" value="2" {if $choice=='2'}checked {/if}/>
|
||||||
<label class="btn btn-default btn-xs" for="y-choice-{$id}" title="{__('Poll results', 'Vote yes for')|html} {$slots[$id]->title|html}">
|
<label class="btn btn-default btn-xs" for="y-choice-{$id}" title="{__('Poll results', 'Vote yes for')|html} {markdown_to_text markdown=$slots[$id]->title id=$id|html}">
|
||||||
<i class="glyphicon glyphicon-ok"></i><span class="sr-only">{__('Generic', 'Yes')}</span>
|
<i class="glyphicon glyphicon-ok"></i><span class="sr-only">{__('Generic', 'Yes')}</span>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li class="ifneedbe">
|
<li class="ifneedbe">
|
||||||
<input type="radio" id="i-choice-{$id}" name="choices[{$id}]" value="1" {if $choice=='1'}checked {/if}/>
|
<input type="radio" id="i-choice-{$id}" name="choices[{$id}]" value="1" {if $choice=='1'}checked {/if}/>
|
||||||
<label class="btn btn-default btn-xs" for="i-choice-{$id}" title="{__('Poll results', 'Vote ifneedbe for')|html} {$slots[$id]->title|html}">
|
<label class="btn btn-default btn-xs" for="i-choice-{$id}" title="{__('Poll results', 'Vote ifneedbe for')|html} {markdown_to_text markdown=$slots[$id]->title id=$id|html}">
|
||||||
(<i class="glyphicon glyphicon-ok"></i>)<span class="sr-only">{__('Generic', 'Ifneedbe')}</span>
|
(<i class="glyphicon glyphicon-ok"></i>)<span class="sr-only">{__('Generic', 'Ifneedbe')}</span>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li class="no">
|
<li class="no">
|
||||||
<input type="radio" id="n-choice-{$id}" name="choices[{$id}]" value="0" {if $choice=='0'}checked {/if}/>
|
<input type="radio" id="n-choice-{$id}" name="choices[{$id}]" value="0" {if $choice=='0'}checked {/if}/>
|
||||||
<label class="btn btn-default btn-xs" for="n-choice-{$id}" title="{__('Poll results', 'Vote no for')|html} {$slots[$id]->title|html}">
|
<label class="btn btn-default btn-xs" for="n-choice-{$id}" title="{__('Poll results', 'Vote no for')|html} {markdown_to_text markdown=$slots[$id]->title id=$id|html}">
|
||||||
<i class="glyphicon glyphicon-ban-circle"></i><span class="sr-only">{__('Generic', 'No')}</span>
|
<i class="glyphicon glyphicon-ban-circle"></i><span class="sr-only">{__('Generic', 'No')}</span>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
@ -204,24 +204,24 @@
|
|||||||
<input type="radio" id="y-choice-{$id}" name="choices[{$id}]" value="2"
|
<input type="radio" id="y-choice-{$id}" name="choices[{$id}]" value="2"
|
||||||
{(!isset($selectedNewVotes[$id]) || ("2" !== $selectedNewVotes[$id])) ? "" : " checked"}
|
{(!isset($selectedNewVotes[$id]) || ("2" !== $selectedNewVotes[$id])) ? "" : " checked"}
|
||||||
/>
|
/>
|
||||||
<label class="btn btn-default btn-xs" for="y-choice-{$id}" title="{__('Poll results', 'Vote yes for')|html} {$slot->title|html}">
|
<label class="btn btn-default btn-xs" for="y-choice-{$id}" title="{__('Poll results', 'Vote yes for')|html} {markdown_to_text markdown=$slot->title id=$id|html}">
|
||||||
<i class="glyphicon glyphicon-ok"></i><span class="sr-only">{__('Generic', 'Yes')}</span>
|
<i class="glyphicon glyphicon-ok"></i><span class="sr-only">{__('Generic', 'Yes')}</span>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
<li class="ifneedbe">
|
<li class="ifneedbe">
|
||||||
<input type="radio" id="i-choice-{$id}" name="choices[{$id}]" value="1"
|
<input type="radio" id="i-choice-{$id}" name="choices[{$id}]" value="1"
|
||||||
{(!isset($selectedNewVotes[$id]) || ("1" !== $selectedNewVotes[$id])) ? "" : " checked"}
|
{(!isset($selectedNewVotes[$id]) || ("1" !== $selectedNewVotes[$id])) ? "" : " checked"}
|
||||||
/>
|
/>
|
||||||
<label class="btn btn-default btn-xs" for="i-choice-{$id}" title="{__('Poll results', 'Vote ifneedbe for')|html} {$slot->title|html}">
|
<label class="btn btn-default btn-xs" for="i-choice-{$id}" title="{__('Poll results', 'Vote ifneedbe for')|html} {markdown_to_text markdown=$slot->title id=$id|html}">
|
||||||
(<i class="glyphicon glyphicon-ok"></i>)<span class="sr-only">{__('Generic', 'Ifneedbe')}</span>
|
(<i class="glyphicon glyphicon-ok"></i>)<span class="sr-only">{__('Generic', 'Ifneedbe')}</span>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
{/if}
|
{/if}
|
||||||
<li class="no">
|
<li class="no">
|
||||||
<input type="radio" id="n-choice-{$id}" name="choices[{$id}]" value="0"
|
<input type="radio" id="n-choice-{$id}" name="choices[{$id}]" value="0"
|
||||||
{(!isset($selectedNewVotes[$id]) || ("0" !== $selectedNewVotes[$id])) ? "" : " checked"}
|
{(!isset($selectedNewVotes[$id]) || ("0" !== $selectedNewVotes[$id])) ? "" : " checked"}
|
||||||
/>
|
/>
|
||||||
<label class="btn btn-default btn-xs {(!isset($selectedNewVotes[$id]) || ("0" !== $selectedNewVotes[$id])) ? "startunchecked" : ""}" for="n-choice-{$id}" title="{__('Poll results', 'Vote no for')|html} {$slot->title|html}">
|
<label class="btn btn-default btn-xs {(!isset($selectedNewVotes[$id]) || ("0" !== $selectedNewVotes[$id])) ? "startunchecked" : ""}" for="n-choice-{$id}" title="{__('Poll results', 'Vote no for')|html} {markdown_to_text markdown=$slot->title id=$id|html}">
|
||||||
<i class="glyphicon glyphicon-ban-circle"></i><span class="sr-only">{__('Generic', 'No')}</span>
|
<i class="glyphicon glyphicon-ban-circle"></i><span class="sr-only">{__('Generic', 'No')}</span>
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
@ -361,9 +361,9 @@
|
|||||||
|
|
||||||
{$i = 0}
|
{$i = 0}
|
||||||
<ul class="list-unstyled">
|
<ul class="list-unstyled">
|
||||||
{foreach $slots as $slot}
|
{foreach $slots as $i => $slot}
|
||||||
{if $best_choices['y'][$i] == $max}
|
{if $best_choices['y'][$i] == $max}
|
||||||
<li><strong>{$slot->title|markdown:true}</strong></li>
|
<li><strong>{markdown_to_text markdown=$slot->title id=$i}</strong></li>
|
||||||
{/if}
|
{/if}
|
||||||
{$i = $i+1}
|
{$i = $i+1}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
|
Loading…
Reference in New Issue
Block a user