"; $text .= ""; if (is_array($options)){ foreach(array_keys($options) as $o){ if ($current == $o){ $s = "selected"; } else { $s = ''; } $text .= ""; } } $text .= ""; $this->filters[] = $text; } /** * Creates a Date Form using JS calendar functions * * @param array $current current Date * @param boolean $useTime if the date should also show the time selection */ function dateForm($current=array(), $useTime = false){ if (count($current) == 1){ $startOnly = true; } if ($useTime == true){ if ($current[0] != ''){ $current[0] .= " 00:00"; } else { $current[0] = date("m/d/Y") . " 00:00"; } if ($current[1] != ''){ $current[1] .= " 23:59"; } else { $current[1] = date("m/d/Y") . " 23:59"; } } $text .= ""; $text .= ""; $text .= ""; $text .= "\r\n"; if ($startOnly){ $text .= "Date: "; $text .= " "; $text .= " "; $text .= ""; } else { $text .= "Date from: "; $text .= " "; $text .= ""; $text .= " to "; $text .= " "; $text .= " "; $text .= ""; } $this->dateFormText = $text; } /** * Adds a sort form to the list * * @param mixed $headers * @param mixed $current */ function createOrderForm($headers, $current=''){ $text = ""; $this->filters[] = $text; } /** * Exports the list results to file. Right now only to a CSV * * @param mixed $type type of file * @param array $headers array of column headers * @param array $rows array of the data rows * @param mixed $fileName export file name */ function export($type, $headers, $rows, $fileName){ if ($type == "csv"){ $header1 = "Content-Type: text/csv;"; $header2 = "Content-Disposition: attachment; filename=$fileName" . ".csv"; $delimit = ","; } if (is_array($headers) && count($headers) > 0){ foreach($headers as $h){ $text .= strtoupper($h) . $delimit; } $text = substr($text, 0, -(strlen($delimit))) . "\r\n"; } foreach($rows as $r){ $row = ''; foreach($r as $item){ $row .= $item . $delimit; } $row = substr($row, 0, -(strlen($delimit))) . "\r\n"; $text .= $row; } header($header1); header($header2); print($text); exit(); } /** * Actuall starts the list * * @param array $headers * @param mixed $link * @param mixed $order * @param mixed $sort * @param mixed $rows * @param mixed $limit * @param mixed $number * @param mixed $hidden */ function startList($headers, $link, $order, $sort, $rows, $limit, $number, $hidden=''){ if (is_array($hidden)){ foreach(array_keys($hidden) as $hide){ $h .= "\r\n"; } } if ($this->search){ //if ($this->searchLink){ $searchAction = $this->searchLink; } //else { $searchAction = $link; } $text .= "
"; $text .= "

"; $text .= ""; $text .= $h; $text .= ""; $text .= "searchLabel . "\" class=\"button\" />"; $text .= "

"; $text .= "
"; $text .= "
"; } if ($this->filters || $this->orderForm){ if ($this->orderForm){ $this->createOrderForm($headers, $order); } $text .= "
"; $text .= "
"; $text .= "
"; foreach($this->filters as $f){ $text .= $f . " "; } $text .= $h; if ($this->dateFormText){ $text .= $this->dateFormText; } $text .= "url . "');\" />"; if ($this->setExport != false){ $text .= " url . "&export=" . $this->setExport . "');\" />"; } $text .= "

"; $text .= "
"; } //$text .= ""; //$text .= ""; if ($this->form){ $text .= "
form["method"] . "\" action=\"" . $this->form["action"] . "\" id=\"" . $this->form["name"] . "\" name=\"" . $this->form["name"] . "\" >"; } $text .= "\r\n"; $x=1; $this->colCount = 0; foreach(array_keys($headers) as $h){ $hide = ''; if ($this->hide){ if (in_array($x, array_keys($this->hide))){ $hide = "style=\"color: #0066CC;\" onClick=\"toggleHideCol($x);\""; $expandClass = " expandHeaders"; $currentHide = $x; } else if (is_array($this->hide[$currentHide])){ if (in_array($x, $this->hide[$currentHide])){ $expandClass = ''; $hide = "style=\"display:none;\""; } } } $cols .= ""; $this->colCount++; $x++; } $text .= ""; if ($this->paging){ $pager = "" . $this->paging($limit, $number, $this->url) . ""; $text .= $pager; } $text .= "$cols"; $text .= ""; $text .= "" . str_replace("header", "footer", $cols) . ""; if ($this->paging){ $text .= $pager; } $text .= ""; $text .= ""; if (!is_array($rows)){ $rows = array(); } $x=1; //$plus = get_option('siteurl') . $this->pluginPath . "/plus.gif"; //REVIEW foreach(array_keys($rows) as $id){ if ($x/2){ $class = "class=\"alternate\""; } $x++; $text .= "\r\n"; if ($cb){ $text .= "\r\n"; } //else { die("NO CHECK BOX"); } $j=1; $currentHide = ''; foreach($rows[$id] as $r){ $elemId = ''; $rowspan = ''; if ($j == 1 && $this->fold == true){ $subRowCount = count($rows[$id]["sub"]) + 1; //$rowspan = "rowspan=\"" . $subRowCount . "\""; $fold=1; } if (!is_array($r)){ $tdClass=''; if ($this->styles){ foreach(array_keys($this->styles) as $style){ if (in_array($j, $this->styles[$style])){ $tdClass = "class=\"$style\""; } } } $hide = ''; if ($this->hide){ if (in_array($j, array_keys($this->hide))){ $currentHide = $j; } else if (is_array($this->hide[$currentHide])){ if (in_array($j, $this->hide[$currentHide])){ $hide = "style=\"display:none;\""; $elemId = "id=\"" . $x . "_" . "$j\""; } } } if ($j == 1){ $text .= "\r\n"; $j++; } } $text .= "\r\n"; if ($fold == 1){ $f=0; foreach($rows[$id]["sub"] as $sub){ $currentHide = ''; $k=1; $text .= "foldName . "_$id" . "_$f\">"; if ($this->foldName == "subber"){ $text .= ""; } foreach($sub as $s){ $tdClass=''; if ($this->styles){ foreach(array_keys($this->styles) as $style){ $l = $k + 1; if (in_array($l, $this->styles[$style])){ $tdClass = "class=\"$style\""; } } } $hide = ''; $elemId = ''; if ($this->hide){ if (in_array($l, array_keys($this->hide))){ $currentHide = $l; } else if (is_array($this->hide[$currentHide])){ if (in_array($l, $this->hide[$currentHide])){ $hide = "style=\"display:none;\""; $elemId = "id=\"$x" . "_" . $f . "_" . $l . "\""; } } } $text .= ""; $k++; } $text .= "\r\n"; $f++; if ($f > $maxSub || !$maxSub){ $maxSub = $f; } } $fold = 0; } } $text .= "
" . $headers[$h] . "
 "; if ($k == 1){ $text .= "$s"; } //else if ($k == 2){ $text .= "$s"; } else { $text .= $s; } $text .= "
\r\n"; if ($this->form){ $text .= "
"; } $text .= ""; $this->text = $text; } /** * Creates the paging * * @param mixed $limit * @param mixed $number * @param mixed $url */ function paging($limit, $number, $url){ $more = "Page: "; $show = $limit + $this->setNum; if ($show > $number){ $show = $number; } if (!$number){ $limit1 = 0; $more = ''; } elseif (!$limit){ $limit1 = 1; } else { $limit1 = $limit; } $showing = "Showing $limit1 - $show ($number Total)"; if ($limit){ $new = $limit - $this->setNum; if ($new < 0){ $new = 0; } $more .= "<< "; $more .= " Previous Page"; } $y=0; for($x=0; $x < $number; $x += $this->setNum){ if ($x == $limit){ $save = $y; break; } $y++; } $a=1; $stopFlag=0; for($x=0; $x < $number; $x += $this->setNum){ if ($save < 5){ $st = 0; $en = 10; } else { $st = $save - 4; $en = $save + 6; } if ($limit == $x){ $more .= " $a "; $stopFlag=1; } else if ($x > ($number - $this->setNum) && $stopFlag == 0){ $more .= " $a"; } else if ($a > $st && $a < $en){ $more .= " $a "; } $a++; } if ($number > ($limit + $this->setNum)){ $new = $limit + $this->setNum; $check = $number/$this->setNum; if (substr_count($check, ".") > 0){ $pages = substr($check, 0, strpos($check, ".")) + 1; } $end = $pages * $this->setNum - $this->setNum; $more .= " Next Page"; $more .= " >>"; } $more = "colCount . "\">" . $showing . " " . $more . ""; return $more; } } ?>