/** * Includes the parsed chunk for the html-code */ function includeChunk() { if ($this->configIsSet() && $this->modx->documentObject['contentType'] == 'text/html') { $username = $this->loggedUserName(); // Check Webgroup if ($this->modx->isMemberOfWebGroup($this->options['piwikGroupTrack'])) { $trackUserName = $username; } if ($this->modx->isMemberOfWebGroup($this->options['piwikGroupExclude'])) { return ''; } // Check User if (in_array($username, $this->options['piwikUserTrack'])) { $trackUserName = $username; } if (in_array($username, $this->options['piwikUserExclude'])) { return ''; } // generate Chunk for the body $params = array(); if ($this->options['piwikTrackerPause'] != '') { $params[] = '_paq.push([ "setLinkTrackingTimer", ' . $this->options['piwikTrackerPause'] . ' ]);'; } if (!empty($this->options['piwikHostsAlias'])) { $params[] = '_paq.push([ "setDomains", ["' . implode(', ', $this->options['piwikHostsAlias']) . '"] ]);'; } if (!empty($this->options['piwikDownloadExtensions'])) { $params[] = '_paq.push([ "setDownloadExtensions", "' . implode('|', $this->options['piwikDownloadExtensions']) . '" ]);'; } if ($this->options['piwikInstallTracker'] == '') { $params[] = '_paq.push(["enableLinkTracking"]);'; } $this->chunkie->setPlaceholder('piwikURL', $this->options['piwikURL']); $this->chunkie->setPlaceholder('piwikSiteId', $this->options['piwikSiteId']); $this->chunkie->setPlaceholder('piwikJsName', $this->options['piwikJsName']); $this->chunkie->setPlaceholder('piwikDocumentTitle', $this->actionName()); $this->chunkie->setPlaceholder('piwikParams', implode("\r\n", $params)); $this->chunkie->setTpl($this->chunkie->getTemplateChunk('@FILE templates/chunk.template.html')); $this->chunkie->prepareTemplate(); $template = $this->chunkie->process(); return $template; } else { return 'nix'; } return; }
function replacePlaceholder($template) { $chunkie = new newChunkie($this->modx, array('basepath' => WLPE_PATH)); $chunkie->setPlaceholder('', $this->Placeholder); $chunkie->setTpl($template); $chunkie->prepareTemplate('', array()); return $chunkie->process(); }
$res = $modx->db->select('*', $modx->getFullTableName($settings['table']), $where, $orderby, $limit); if ($totalDisplayRecords) { $displayRecords = $modx->db->makeArray($res); } else { $displayRecords = array(); } $aaData = array(); $i = 0; foreach ($displayRecords as $record) { $aaData[$i]['id'] = $record['id']; if (!$settings['configuration']['sorting'] && $settings['configuration']['sortindex']) { $aaData[$i]['DT_RowId'] = (string) $i; } if ($settings['configuration']['radioTabs']) { $aaData[$i]['fieldTab'] = isset($record['fieldTab']) ? $record['fieldTab'] : 0; } foreach ($columnNames as $columnName) { $aaData[$i][$columnName] = $record[$columnName]; } foreach ($settings['columns'] as $column) { if (isset($column['render']) && $column['render'] != '') { $parser = new newChunkie($modx); $parser->setPlaceholders($record); $parser->setTpl($column['render']); $parser->prepareTemplate(); $aaData[$i]['mtvRender' . ucfirst($column['fieldname'])] = $parser->process(); } } $i++; } $answer = array('sEcho' => intval($_POST['sEcho']), 'iTotalRecords' => $totalRecords, 'iTotalDisplayRecords' => $totalDisplayRecords, "aaData" => $aaData);
$templateJump = '<form action="" name="jump" id="jump">' . "\n" . '<select name="myjumpbox" onchange="location.href=jump.myjumpbox.options[selectedIndex].value">' . "\n" . '[+wrapper+]' . "\n" . '</select>' . "\n" . '</form>'; $templateJumpOption = '<option value="[+link+]">[+title+]</option>'; $output = ''; if (count($my_array)) { $prev = $current - 1; $next = $current + 1; $total = $y - 1; // Construction of the elements $parser = new newChunkie($modx, array('basepath' => PJN_PATH)); // Total line $parser->setPlaceholder('recordTypeName', $recordTypeName); $parser->setPlaceholder('current', '<span class="' . $currentNumberClass . '">' . $current . '</span>'); $parser->setPlaceholder('total', '<span class="' . $totalNumberClass . '">' . $total . '</span>'); $parser->setTpl($_lang['total']); $parser->prepareTemplate(); $totalPlaceHolder = $parser->process(); // First item if ($useYams && $yams->IsMultilingualDocument($my_array[1]['id'])) { $parser->setPlaceholder('link', $yams->ConstructResolvedURL($langid, $my_array[1]['id'])); } else { $parser->setPlaceholder('link', $modx->makeUrl($my_array[1]['id'])); } $parser->setPlaceholder('class', $firstClass); $parser->setPlaceholder('prefix', $firstSymbol); $parser->setPlaceholder('title', $firstText); $parser->setTpl($templateLink); $parser->prepareTemplate(); $firstPlaceHolder = $parser->process(); // Prev item if ($prev > 0) { $parser->setTpl($templateLink);
function displayMultiValue($tvOutput, $params) { // replace masked placeholder tags (for templates that are set directly set in snippet call by @CODE) $maskedTags = array('((' => '[+', '))' => '+]'); $params['outerTpl'] = str_replace(array_keys($maskedTags), array_values($maskedTags), $params['outerTpl']); $params['rowTpl'] = str_replace(array_keys($maskedTags), array_values($maskedTags), $params['rowTpl']); $countOutput = count($tvOutput); $firstEmpty = true; if ($countOutput) { // check for first item empty foreach (current($tvOutput) as $value) { if ($value != '') { $firstEmpty = false; } } } // stop if there is no output if (!$countOutput || $firstEmpty) { $noResults = ''; if ($params['noResults'] != '') { $parser = new newChunkie($this->modx); $noResults = $parser->getTemplateChunk($params['noResults']); } if ($params['emptyOutput']) { // output nothing return $noResults; } else { // output empty outer template $parser = new newChunkie($this->modx); $parser->setPlaceholder('wrapper', $noResults); $parser->setTpl($parser->getTemplateChunk($params['outerTpl'])); $parser->prepareTemplate(); return $parser->process(); } } // random or sort output if ($params['randomize']) { shuffle($tvOutput); } elseif ($params['reverse']) { $tvOutput = array_reverse($tvOutput); } elseif (!empty($params['sortBy'])) { $this->sort($tvOutput, trim($params['sortBy']), strtolower(trim($params['sortDir']))); } // check for display all regarding selected rows count and offset $countOutput = $params['rows'] === 'all' ? $countOutput : count($params['rows']); $display = $limit = $params['display'] !== 'all' ? intval($params['display']) : $countOutput; $display = $display + $params['offset'] < $countOutput ? $display : $countOutput - $params['offset']; $offset = $params['offset']; // output $wrapper = array(); $i = $iteration = 1; $classes = array($params['firstClass']); // rowTpl output foreach ($tvOutput as $value) { if ($display == 0) { break; } if ($params['rows'] !== 'all' && !in_array($i, $params['rows'])) { // output only selected rows $i++; continue; } if ($offset) { // don't show the offset rows $offset--; $i++; continue; } if (!$params['toJson']) { if ($display == 1) { $classes[] = $params['lastClass']; } if ($iteration % 2) { $classes[] = $params['oddClass']; } else { $classes[] = $params['evenClass']; } $parser = new newChunkie($this->modx); foreach ($value as $key => $fieldvalue) { $fieldname = is_int($key) ? $this->fieldnames[$key] : $key; $parser->setPlaceholder($fieldname, $fieldvalue); } $parser->setPlaceholder('iteration', $iteration); $parser->setPlaceholder('row', array('number' => $i, 'class' => implode(' ', $classes), 'total' => $countOutput)); $parser->setPlaceholder('docid', $params['docid']); $parser->setTpl($parser->getTemplateChunk($params['rowTpl'])); $parser->prepareTemplate(); $placeholder = $parser->process(); if ($params['toPlaceholder']) { $this->modx->setPlaceholder($params['toPlaceholder'] . '.' . $i, $placeholder); } $wrapper[] = $placeholder; $classes = array(); } else { $wrapper[] = $value; } $i++; $iteration++; $display--; } if ($params['emptyOutput'] && !count($wrapper)) { // output nothing $output = ''; } else { if (!$params['toJson']) { // wrap rowTpl output in outerTpl $parser = new newChunkie($this->modx); $parser->setPlaceholder('wrapper', implode($params['outputSeparator'], $wrapper)); $parser->setPlaceholder('rows', array('offset' => $params['offset'], 'total' => $countOutput)); $parser->setPlaceholder('docid', $params['docid']); if ($params['paginate']) { $pagination = new Pagination(array('per_page' => $limit, 'num_links' => 2, 'cur_page' => $params['offset'] / $limit + 1, 'total_rows' => $countOutput, 'page_query_string' => $params['offsetKey'], 'use_page_numbers' => true, 'first_link' => $this->language['paginate.first'], 'prev_link' => $this->language['paginate.prev'], 'next_link' => $this->language['paginate.next'], 'last_link' => $this->language['paginate.last'])); $parser->setPlaceholder('pagination', $pagination->create_links()); } $parser->setTpl($parser->getTemplateChunk($params['outerTpl'])); $parser->prepareTemplate(); $output = $parser->process(); } else { $output = json_encode($wrapper); } } if ($params['toPlaceholder']) { $this->modx->setPlaceholder($params['toPlaceholder'], $output); $output = ''; } return $output; }