$columnNames = isset($settings['columnNames']) && $settings['columnNames'] != '' ? $settings['columnNames'] : $columnNames; } $maskedTags = array('((' => '[+', '))' => '+]', '{+' => '[+', '+}' => '+]'); $outerTpl = str_replace(array_keys($maskedTags), array_values($maskedTags), $outerTpl); $rowTpl = str_replace(array_keys($maskedTags), array_values($maskedTags), $rowTpl); $columns = explode(',', $columnNames); $columnCount = count($columns); $tvOutput = $modx->getTemplateVarOutput(array($tvName), $docid); $tvOutput = $tvOutput[$tvName]; $tvOutput = json_decode($tvOutput); // stop if there is no output if (!count($tvOutput)) { return; } // parse the output chunks if (!class_exists('gridChunkie')) { include MODX_BASE_PATH . $pluginPath . '/includes/chunkie.class.inc.php'; } $wrapper = ''; foreach ($tvOutput as $num => $value) { $parser = new gridChunkie($rowTpl); for ($i = 0; $i < $columnCount; $i++) { $parser->AddVar($columns[$i], $value[$i]); } $parser->AddVar('num', $num); $wrapper .= $parser->Render(); } $parser = new gridChunkie($outerTpl); $parser->AddVar('wrapper', $wrapper); $output = $parser->Render(); return $output;
// if the current template has not to be processed or the manager user is not allowed to use the plugin if ($tplids && !in_array($curTpl, $tplids) || $roles && !in_array($curRole, $roles)) { continue; } foreach ($tvids as $tvid) { $templateVarsIds[] = "'tv" . $tvid . "'"; $columnName = array(); foreach ($columns as $i => $column) { $columnName[$i] = trim($column); } $columnNames[] = "new Array('" . implode("','", $columnName) . "')"; } } // parse the javascript and css chunks $templateVarsIds = 'new Array(' . implode(',', $templateVarsIds) . ')'; $columnNames = 'new Array(' . implode(',', $columnNames) . ')'; $script = '<style type="text/css">' . "\r\n"; $parser = new gridChunkie('@FILE:' . $pluginPath . 'MultiGrid.template.css'); $script .= $parser->Render(); $script .= '</style>' . "\r\n"; $script .= '<script type="text/javascript">' . "\r\n"; $parser = new gridChunkie('@FILE:' . $pluginPath . 'MultiGrid.template.js'); $parser->AddVar('tvids', $templateVarsIds); $parser->AddVar('columnNames', $columnNames); $script .= $parser->Render(); $script .= '</script>' . "\r\n"; $e =& $modx->Event; if ($e->name == 'OnDocFormRender') { $output = $script; $e->output($output); }