function parseTpl($tpl, $properties = null)
 {
     global $modx;
     static $_tplCache;
     $_validTypes = array('@CHUNK', '@FILE', '@INLINE');
     $output = '';
     $prefix = $modx->getOption('tplPrefix', $properties, '');
     if (!empty($tpl)) {
         $bound = array('type' => '@CHUNK', 'value' => $tpl);
         if (strpos($tpl, '@') === 0) {
             $endPos = strpos($tpl, ' ');
             if ($endPos > 2 && $endPos < 10) {
                 $tt = substr($tpl, 0, $endPos);
                 if (in_array($tt, $_validTypes)) {
                     $bound['type'] = $tt;
                     $bound['value'] = substr($tpl, $endPos + 1);
                 }
             }
         }
         if (is_array($bound) && isset($bound['type']) && isset($bound['value'])) {
             $output = parseTplElement($_tplCache, $_validTypes, $bound['type'], $bound['value'], $properties);
         }
     }
     if (empty($output) && $output !== '0') {
         /* print_r the object fields that were returned if no tpl is provided */
         $chunk = $modx->newObject('modChunk');
         $chunk->setCacheable(false);
         $output = $chunk->process(array("{$prefix}output" => print_r($properties, true)), "<pre>[[+{$prefix}output]]</pre>");
     }
     return $output;
 }
Beispiel #2
0
 function parseTpl($tpl, $properties = null)
 {
     static $_tplCache;
     $_validTypes = array('@CHUNK', '@FILE', '@INLINE');
     $output = false;
     if (!empty($tpl)) {
         $bound = array('type' => '@CHUNK', 'value' => $tpl);
         if (strpos($tpl, '@') === 0) {
             $endPos = strpos($tpl, ' ');
             if ($endPos > 2 && $endPos < 10) {
                 $tt = substr($tpl, 0, $endPos);
                 if (in_array($tt, $_validTypes)) {
                     $bound['type'] = $tt;
                     $bound['value'] = substr($tpl, $endPos + 1);
                 }
             }
         }
         if (is_array($bound) && isset($bound['type']) && isset($bound['value'])) {
             $output = parseTplElement($_tplCache, $_validTypes, $bound['type'], $bound['value'], $properties);
         }
     }
     return $output;
 }