Skip to content

Commit 6231a73

Browse files
committed
modxcms#187 Fix - Merge placeholders in Ditto
1 parent fa2f1ce commit 6231a73

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

Diff for: assets/snippets/ditto/classes/ditto.class.inc.php

+33-9
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,7 @@ function render($doc, $template, $removeChunk,$dateSource,$dateFormat,$customPla
321321
function parseModifiers($tpl,$ph,$contentVars){
322322
global $modx;
323323
if ($modx->config['enable_filter']) {
324-
$content = $tpl;
325-
$i = 0;
326-
while($i<10) {
327-
$bt = $content;
328-
if(strpos($content,'[+')!==false) $content = $modx->parseText($content,$ph);
329-
else $content = $modx->parseDocumentSource($content);
330-
if($bt===$content) break;
331-
$i++;
332-
}
324+
$content = $this->parseDocumentSource($tpl,$ph);
333325
}
334326
else {
335327
foreach($ph as $key=>$content) {
@@ -342,6 +334,38 @@ function parseModifiers($tpl,$ph,$contentVars){
342334
return $content;
343335
}
344336

337+
function parseDocumentSource($content='',$ph)
338+
{
339+
global $modx;
340+
341+
if(strpos($content,'[')===false && strpos($content,'{')===false) return $content;
342+
343+
$loopLimit = @ $modx->maxParserPasses ?: 10;
344+
$bt='';
345+
$i=0;
346+
while($bt!==$content)
347+
{
348+
$bt = $content;
349+
if(strpos($content,'[+')!==false) $content = $modx->parseText($content,$ph);
350+
if(strpos($content,'[+')!==false) continue;
351+
352+
if(strpos($content,'[*')!==false && $modx->documentIdentifier)
353+
$content = $modx->mergeDocumentContent($content);
354+
if(strpos($content,'[+')!==false && $content!==$bt) continue;
355+
if(strpos($content,'[(')!==false) $content = $modx->mergeSettingsContent($content);
356+
if(strpos($content,'[+')!==false && $content!==$bt) continue;
357+
if(strpos($content,'{{')!==false) $content = $modx->mergeChunkContent($content);
358+
if(strpos($content,'[+')!==false && $content!==$bt) continue;
359+
if(strpos($content,'[!')!==false) $content = str_replace(array('[!','!]'),array('[[',']]'),$content);
360+
if(strpos($content,'[[')!==false) $content = $modx->evalSnippets($content);
361+
362+
if($content===$bt) break;
363+
if($loopLimit < $i) break;
364+
$i++;
365+
}
366+
return $content;
367+
}
368+
345369
// ---------------------------------------------------
346370
// Function: parseFields
347371
// Find the fields that are contained in the custom placeholders or those that are needed in other functions

0 commit comments

Comments
 (0)