Lines Matching defs:data

16      * will hold the data helper plugin
29 $this->dthlp = plugin_load('helper', 'data');
69 * Handle the match - parse the data
78 * @return bool|array Return an array with all data you want to use in render, false don't add an instruction
88 $class = preg_replace('/^----+ *data[a-z]+/', '', $class);
91 $data = [
125 $data['cols'][$column['key']] = $column;
129 $data['title'] = $line[1];
135 $data['headers'] = array_merge($data['headers'], $cols);
148 $data['align'][] = $col;
155 $data['widths'][] = $col;
159 $data['min'] = abs((int)$line[1]);
163 $data['limit'] = abs((int)$line[1]);
170 $data['sort'] = [substr($sort, 1), 'DESC'];
172 $data['sort'] = [$sort, 'ASC'];
188 $data['filter'][] = $flt;
193 $data['page'] = cleanID($line[1]);
196 $data['dynfilters'] = (bool)$line[1];
199 $data['rownumbers'] = (bool)$line[1];
202 $data['summarize'] = (bool)$line[1];
205 $data['sepbyheaders'] = (bool)$line[1];
208 msg("data plugin: unknown option '" . hsc($line[0]) . "'", -1);
213 if (!is_array($data['cols']) || $data['cols'] === []) {
214 msg('data plugin: no columns selected', -1);
219 $data['headers'] = (array)$data['headers'];
220 $cnth = count($data['headers']);
221 $cntf = count($data['cols']);
223 $column = array_slice($data['cols'], $i, 1);
225 $data['headers'][] = $columnprops['title'];
228 $data['sql'] = $this->buildSQL($data);
231 $data['cur_param'] = $this->dthlp->getPurrentParam(false);
232 return $data;
245 * @param array $data data created by handler()
248 public function render($format, Doku_Renderer $renderer, $data)
251 if (is_null($data)) return false;
262 $this->updateSQLwithQuery($data); // handles request params
264 $this->dthlp->replacePlaceholdersInSQL($data);
267 $clist = array_keys($data['cols']);
268 $rows = $sqlite->queryAll($data['sql']);
272 $this->nullList($data, $clist, $renderer);
276 if ($data['limit'] && $cnt > $data['limit']) {
277 $rows = array_slice($rows, 0, $data['limit']);
284 if ($data['rownumbers']) {
286 $classes[] = $data['align'][0] . 'align rownumbers';
290 if (isset($data['align'])) {
291 $class .= $data['align'][$index + $offset];
298 $renderer->doc .= $this->preList($clist, $data);
301 // build data rows
304 if ($data['rownumbers']) {
313 $renderer->doc .= sprintf($this->beforeVal($data, $num_rn), 'class="' . $classes[$num_rn] . '"');
315 $data['cols'][$clist[$num]],
319 $renderer->doc .= $this->afterVal($data, $num_rn);
328 if ($data['summarize'] && is_numeric($nval)) {
337 $renderer->doc .= $this->postList($data, $cnt);
345 * @param array $data instructions by handler
349 protected function beforeVal(&$data, $colno)
357 * @param array $data
361 protected function afterVal(&$data, $colno)
370 * @param array $data instruction by handler
373 public function preList($clist, $data)
407 $text .= '<table class="inline dataplugin_table ' . $data['classes'] . '">';
411 if ($data['rownumbers']) {
415 foreach ($data['headers'] as $num => $head) {
419 if (isset($data['widths'][$num]) && $data['widths'][$num] != '-') {
420 $width = ' style="width: ' . $data['widths'][$num] . ';"';
425 if (isset($data['sort']) && $ckey == $data['sort'][0]) {
426 if ($data['sort'][1] == 'ASC') {
442 if ($data['dynfilters']) {
445 if ($data['rownumbers']) {
449 foreach ($data['headers'] as $num => $head) {
457 $key = 'dataflt[' . $data['cols'][$clist[$num]]['colname'] . '*~' . ']';
480 * @param array $data instruction by handler()
484 public function nullList($data, $clist, $R)
486 $R->doc .= $this->preList($clist, $data);
498 * @param array $data instruction by handler()
502 public function postList($data, $rowcnt)
507 if ($data['summarize']) {
509 $len = count($data['cols']);
511 if ($data['rownumbers']) $text .= '<td></td>';
514 $text .= '<td class="' . $data['align'][$i] . 'align">';
526 if ($data['limit']) {
527 $text .= '<tr><th colspan="' . (count($data['cols']) + ($data['rownumbers'] ? 1 : 0)) . '">';
530 $prev = $offset - $data['limit'];
549 if ($rowcnt > $data['limit']) {
550 $next = $offset + $data['limit'];
571 * Builds the SQL query from the given data
573 * @param array &$data instruction by handler
576 public function buildSQL(&$data)
590 foreach ($data['cols'] as &$col) {
605 $from .= ' LEFT JOIN data AS ' . $tables[$key] . ' ON ' . $tables[$key] . '.pid = W1.pid';
627 if (isset($data['sort'])) {
628 $col = $data['sort'][0];
631 $order = 'ORDER BY pages.page ' . $data['sort'][1];
633 $order = 'ORDER BY pages.class ' . $data['sort'][1];
635 $order = 'ORDER BY pages.title ' . $data['sort'][1];
637 $order = 'ORDER BY pages.lastmod ' . $data['sort'][1];
642 $from .= ' LEFT JOIN data AS ' . $tables[$col] . ' ON ' . $tables[$col] . '.pid = W1.pid';
646 $order = 'ORDER BY ' . $tables[$col] . '.value ' . $data['sort'][1];
657 if (is_array($data['filter']) && count($data['filter'])) {
658 foreach ($data['filter'] as $filter) {
679 $from2 .= ' LEFT JOIN data AS ' . $table . ' ON ' . $table . '.pid = pages.pid';
682 // apply data resolving?
709 if ($data['limit']) {
710 $sql .= ' LIMIT ' . ($data['limit'] + 1);
720 * @param array $data instruction by handler()
722 public function updateSQLwithQuery(&$data)
727 $data['sort'] = [substr($_REQUEST['datasrt'], 1), 'DESC'];
729 $data['sort'] = [$_REQUEST['datasrt'], 'ASC'];
734 $data['filter'] = array_merge($data['filter'], $this->dthlp->getFilters());
737 $data['sql'] = $this->buildSQL($data);
740 if ($data['limit'] && (int)$_REQUEST['dataofs']) {
741 $data['sql'] .= ' OFFSET ' . ((int)$_REQUEST['dataofs']);