public function listRows($in) { $wo = $this->wo; $tableName = $this->tableName; if (!WOOOF::hasContent($tableName)) { return array('contentTop' => '<h1>Please select a table</h1>'); //$wo->log(WOOOF_loggingLevels::WOOOF_ERROR, "1000 No tableName was provided!" ); //return false; } $timers = array(); $tplContentTop = ''; $tplContent = ''; $tplContentDataHeaders = ''; $tplContentData = ''; $tplErrorMessage = ''; $tplMessage = ''; $extraWhere = $wo->getFromArray($in, '_where'); $orderBy = $wo->getFromArray($in, '_orderBy', 'id asc'); $fragmentsFile = $wo->getFromArray($in, '_fragmentsFile', ''); $cudFormURL = $wo->getFromArray($in, '_cudFormURL', "_genericEdit.php"); $wo->debug("Generic.show for '{$tableName}'. fragmentFile is [{$fragmentsFile}]. Form is [{$cudFormURL}]."); $table = new WOOOF_dataBaseTable($wo->db, $tableName); if (!$table->constructedOk) { $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, "1010 Failed to init '{$tableName}'!"); return false; } $wheres = array(); // TODO: will not be available to all tables // $wheres['isDeleted!']='1'; $noOfRowsArr = $table->getResult($wheres, $orderBy, 0, 20, $extraWhere); if ($noOfRowsArr === FALSE) { $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, "1020 Failed to get '{$tableName}'!"); return false; } $tplContentTop .= "<h1>'{$tableName}' List</h1>"; $tplContentTop .= "<h2>[where: {$extraWhere}] [orderBy: {$orderBy}]</h2>"; $tplContent .= <<<SOMEHTMLSTRING \t\t<a href="{$cudFormURL}?_action=insert&_tableName={$tableName}">Create new...</a> \t\t<form method="POST" action="_genericEdit.php"> \t\t\t<input type="hidden" name="_tableName" value="{$tableName}"> \t\t\t<input type="text" name="_id" size="10"> \t\t\t<input class="btn btn-medium" type="submit" name="_viewButton" \t\tvalue="View" > \t\t\t<input class="btn btn-medium" type="submit" name="_editButton" \t\tvalue="Edit" > \t\t\t<input class="btn btn-medium" type="submit" name="_deleteButton" \tvalue="Delete" > \t\t\t<br> \t\t</form> \t\t<br> \t\t<form method="POST" action="_genericList.php"> \t\t\t<input type="hidden" name="_tableName" value="{$tableName}"> \t\t\t<input type="hidden" name="_fragmentsFile" value="{$fragmentsFile}"> \t\t\t<input type="hidden" name="_cudFormURL" value="{$cudFormURL}"> \t\t\t\t\t\t\t\t \t\t\t<label>Where</label><input type="text" name="_where" size="120" value="{$extraWhere}"> \t\t\t<br> \t\t\t<label>Order by</label><input type="text" name="_orderBy" size="120" value="{$orderBy}"> \t\t\t<br> \t\t\t<input class="btn btn-medium" type="submit" name="_searchButton" value="Search" > \t\t</form> \t\t<br><br> SOMEHTMLSTRING; if (WOOOF::hasContent($fragmentsFile)) { $htmlParts = $wo->fetchApplicationFragment($fragmentsFile); } else { $htmlParts = array('htmlListHead' => '', 'htmlFragment' => ''); } $tplContentDataHeaders .= $htmlParts['htmlListHead']; $tplContentData .= $table->presentResults($htmlParts['htmlFragment']); if ($tplContentData === FALSE) { $wo->log(WOOOF_loggingLevels::WOOOF_ERROR, "1030 Failed to presentResults"); return false; } $tplContent .= $tplContentDataHeaders . $tplContentData; return array('contentTop' => $tplContentTop, 'content' => $tplContent, 'contentDataHeaders' => $tplContentDataHeaders, 'contentData' => $tplContentData, 'errorMessage' => $tplErrorMessage, 'message' => $tplMessage); }