/** * * @param <type> $dbname * @param <type> $tablename * @return void */ public function action_index() { $this->view->columns = array(); $this->view->filters = array(); if (!$this->table) { return; } // The permitted filter operators. $this->view->operators = $this->table->get_operators(); foreach ($this->table->get_columns() as $col) { $this->view->columns[$col->get_name()] = Webdb_Text::titlecase($col->get_name()); } $this->table->add_GET_filters(); $this->view->filters = $this->table->get_filters(); // Add new filter $this->view->filters[] = array('column' => $this->table->get_title_column()->get_name(), 'operator' => 'like', 'value' => ''); }
/** * Determine whether a given value is valid for a foreign key (i.e. is the * title of a foreign row). * * @param Webdb_DBMS_Column $column * @param integer $col_num * @param integer $row_num * @param string $value * @return FALSE if the value is valid * @return array error array if the value is not valid */ public function validate_foreign_key($column, $col_num, $row_num, $value) { $foreign_table = $column->get_referenced_table(); if (!$this->get_fk_rows($foreign_table, $value)->valid()) { $route_params = array('action' => 'index', 'dbname' => $foreign_table->get_database()->get_name(), 'tablename' => $foreign_table->get_name()); $uri = Route::url('default', $route_params, TRUE); $a_params = array('target' => '_blank', 'title' => 'Opens in a new tab or window'); $link = HTML::anchor($uri, Webdb_Text::titlecase($foreign_table->get_name()), $a_params); return 'Value (' . $value . ') not found in ' . $link; } return FALSE; }
echo '</ol></li>'; } ?> </ol> <?php } ?> <div class="content"> <?php if ($table) { ?> <div class="title"> <h1><?php echo HTML::anchor('index/' . $database->get_name() . '/' . $table->get_name(), Webdb_Text::titlecase($table->get_name())); ?> </h1> <?php if ($table->get_comment()) { echo '<p>' . $table->get_comment() . '</p>'; } ?> </div> <?php } ?> <?php if ($database && $table && count($actions) > 0) { ?>
<?php echo Webdb_Text::titlecase($column->get_name()); ?> <?php if ($column->is_required()) { ?> <span class="required">(required)</span> <?php } ?> </td> <td> <?php $options = array('' => '') + $file->headers; $options = array_combine(array_map('strtolower', $options), $options); echo Form::select('columns[' . $column->get_name() . ']', $options, strtolower(Webdb_Text::titlecase($column->get_name()))); ?> </td> </tr> <?php } ?> </tbody> </table> <p><input type="submit" name="preview" value="Preview →"/></p> </fieldset> </form> <?php
$foreign_table = $foreign['table']; $foreign_table->reset_filters(); $foreign_table->add_filter($foreign_column, '=', $table->get_title($row[$table->get_pk_column()->get_name()])); $num_foreign_records = $foreign_table->count_records(); $class = $num_foreign_records > 0 ? '' : 'no-records'; ?> <li> <h3 title="Show or hide these related records" class="anchor <?php echo $class; ?> "> <?php echo Webdb_Text::titlecase($foreign_table->get_name()); ?> <span class="smaller">(as ‘<?php echo Webdb_Text::titlecase($foreign_column); ?> ’).</span> <?php echo $num_foreign_records; ?> record<?php echo $num_foreign_records != 1 ? 's' : ''; ?> . </h3> <div> <p class="new-record"> <?php $url = 'edit/' . $database->get_name() . '/' . $foreign_table->get_name() . '?' . $foreign_column . '=' . $row[$table->get_pk_column()->get_name()]; echo HTML::anchor($url, 'Add a new record here.');
<form action="<?php echo url::site('webdb/import/' . $database->get_name() . '/' . $table->get_name() . '/' . $file->hash); ?> " method="post"> <table> <caption> <p>The following data will be imported. You can edit fields here, if you need to.</p> </caption> <thead> <tr> <?php foreach ($table->get_columns() as $column) { ?> <th><?php echo Webdb_Text::titlecase($column->get_name()); ?> </th> <?php } ?> </tr> </thead> <tbody> <?php $new_row_ident = 0; foreach ($file->data as $row) { $new_row_ident++; ?> <tr> <?php
$title = Webdb_Text::titlecase($referenced_table->get_name()); echo html::anchor($url, $title); ?> . </li> <?php if ($value) { ?> <li> <?php $url = "edit/" . $database->get_name() . '/' . $referenced_table->get_name() . '/' . $value; $title = 'View ' . $referenced_table->get_title($value); echo HTML::anchor($url, $title); ?> (<?php echo Webdb_Text::titlecase($referenced_table->get_name()); ?> record #<?php echo $value; ?> ). </li> <?php } ?> </ul> <?php /** * Everything else