/** @brief Create a checkbox column in the table header or the body. @details If the $row is in the body section, the $id parameter must also be given. @param row $row Row in the table. Automatically detects if the row is in the head or the body. @param mixed $id The ID of this row. String or int. @return mixed Null if creating a checkbox in the header, else the checkbox input. @since 20131015 **/ public function cb($row, $id = null) { $r = null; $section = get_class($row->section); if ($section == 'plainview\\sdk_broadcast\\table\\head') { // Create a temporary form in order to create a checkbox that is only used by javascript. $temp_form = clone $this->form; // Create the temporary checkbox. $sa_text = __('Select All'); $checkbox = $temp_form->checkbox('cb_select_all_1'); $checkbox->label($sa_text); $checkbox->title($sa_text); // Hide the label $checkbox->label->css_class('screen-reader-text'); $text = sprintf('%s%s', $checkbox->display_label(), $checkbox->display_input()); $row->td('check_column')->css_class('manage-column check-column')->text($text); } if ($section == 'plainview\\sdk_broadcast\\table\\body') { // Create the row checkbox. $cb = $this->form->checkbox($id)->prefix('cb'); $text = $cb->display_input() . '<span class="screen-reader-text">' . $cb->display_label() . '</span>'; $row->th('check_column_' . $row->id)->css_class('check-column')->set_attribute('scope', 'row')->text($text); // Add the checkbox to a quick lookup table $this->checkboxes->append($cb); $r = $cb; } return $r; }
function addRow($id, $values = null, $buttons = null) { $row = new row($this->append(), $this->headers, array_merge(array(row::IDATTR => $id, 'buttons' => $buttons), $values)); if (is_array($b = $this->getButtons())) { foreach ($b as $action => $ar) { $row->setButton($action, $ar); } } return $row; }
/** * Gets the result based on an array of field and * value combinationds. Returns a row object. * * Implmentation: * $tableRow = $obj->getRow(); //Retrieves all rows contained in a row Object * foreach($tableRow as $row){ * foreach($row as $field => $value){ * echo $field ." => ". $value ."</br>"; * } * } * * @param array[feild=>value] * @return array(row) */ public function retrieveStrict($array) { if (!isset($array)) { // Needs to be changed if more parameters are added exit("ERROR: Missing a parameter"); } if (!isset($this->tableName)) { exit("ERROR: Choose a table to preform operations on!"); } //assert: Both parameters are null, or have a value. $queryString = "Select * FROM " . $this->tableName . " WHERE "; $whereClause = ''; foreach ($array as $field => $value) { $whereClause .= "`{$field}` = '{$value}' AND "; } $whereClause = substr($whereClause, 0, -5); $queryString = $queryString . $whereClause; /*Execeute the query string*/ $this->query = $queryString; if (!($result = parent::query($queryString))) { echo 'ERROR: ' . $this->error; } /*We have the result, now create the array of row objects*/ $fields = $result->fetch_fields(); $rowObj = new row(); while ($row = $result->fetch_row()) { $rowArray = array(); for ($i = 0; $i < count($row); $i++) { $rowArray[$fields[$i]->name] = $row[$i]; } $rowObj->addItem($rowArray); } return $rowObj; }