예제 #1
0
 public function buildTable($options, $allowEdit = null, $deleteToFirstUnderscore = true, $orderBy = "")
 {
     $retStr = "<form name='postable' action='#' method='post'><table id='" . $this->dbName . "' class='openEditTable' >";
     $rowHeader = "<thead><tr>";
     $rowId = "";
     $createHeader = true;
     $allRowsStr = "<tbody>";
     $this->variables = genericTable::GetVariableArray($this, $options, $deleteToFirstUnderscore);
     while ($this->loadNext('', $orderBy)) {
         $rowStr = "<tr id='{{ROWID}}'>";
         $id = $this->get_variable($this->unique_id);
         foreach ($this->variables as $key => $value) {
             if ($createHeader) {
                 if ($key != $this->unique_id && isset($this->variables[$key])) {
                     $keyVals = split("_", $key);
                     if ($deleteToFirstUnderscore) {
                         array_shift($keyVals);
                     }
                     $rowHeader .= "<th>" . implode($keyVals) . "</th>";
                 }
             }
             if ($key == $this->unique_id) {
                 $rowId = $value;
             } else {
                 if (isset($this->variables[$key]) && isset($allowEdit[$key])) {
                     $rowStr .= "<td><input type='text' name='" . $key . "_" . $id . "' value='" . $value . "'></td>";
                 } else {
                     $rowStr .= "<td class='border'>" . $value . "</td>";
                 }
             }
         }
         $rowStr = str_replace("{{ROWID}}", $rowId, $rowStr);
         $rowStr .= "</tr>";
         $allRowsStr .= $rowStr;
         $createHeader = false;
     }
     $allRowsStr .= "</tbody>";
     $rowHeader .= "</tr></thead>";
     $retStr .= $rowHeader . $allRowsStr . "</table><input type='submit' value='Submit'></form>";
     return $retStr;
 }