Beispiel #1
0
        $foreign_pk = $foreign_table->get_pk_column()->get_name();
        $foreign_table->add_filter($foreign_column, '=', $row[$this_pk], TRUE);
        //$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 &lsquo;<?php 
        echo WebDB_Text::titlecase($foreign_column);
        ?>
&rsquo;).</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.');
Beispiel #2
0
 public function export()
 {
     $export_dir = Kohana::$cache_dir . DIRECTORY_SEPARATOR . 'exports';
     @mkdir($export_dir);
     $filename = $export_dir . DIRECTORY_SEPARATOR . uniqid() . '.csv';
     if (Kohana::$is_windows) {
         $filename = str_replace('\\', '/', $filename);
     }
     $headers_query = new Database_Query_Builder_Select();
     $data_query = new Database_Query_Builder_Select();
     $headers_query->union($data_query);
     $alias_num = 1;
     foreach ($this->get_columns() as $col) {
         $header = "'" . WebDB_Text::titlecase($col->get_name()) . "'";
         $headers_query->select(DB::expr($header));
         if ($col->is_foreign_key()) {
             $fk1_alias = "e{$alias_num}";
             $alias_num++;
             $fk1_table = $col->get_referenced_table();
             $data_query->join(array($fk1_table->get_name(), $fk1_alias), 'LEFT OUTER');
             $data_query->on($this->get_name() . '.' . $col->get_name(), '=', "{$fk1_alias}.id");
             $select = $fk1_alias . '.' . $fk1_table->get_title_column()->get_name();
             if ($fk1_table->get_title_column()->is_foreign_key()) {
                 $fk2_alias = "e{$alias_num}";
                 $alias_num++;
                 $fk2_table = $fk1_table->get_title_column()->get_referenced_table();
                 $data_query->join(array($fk2_table->get_name(), $fk2_alias), 'LEFT OUTER');
                 $data_query->on($fk1_alias . '.' . $fk1_table->get_title_column()->get_name(), '=', "{$fk2_alias}.id");
                 $select = $fk2_alias . '.' . $fk2_table->get_title_column()->get_name();
             }
         } else {
             $select = $this->get_name() . '.' . $col->get_name();
         }
         $data_query->select(DB::expr("REPLACE(IFNULL({$select}, ''),'\r\n', '\n')"));
     }
     $data_query->from($this->get_name());
     $this->add_get_filters();
     $this->apply_filters($data_query);
     $data_query->outfile($filename);
     $headers_query->outfile();
     $headers_query->execute($this->_db);
     if (!file_exists($filename)) {
         throw new Kohana_Exception("Export file not created: {$filename}");
     }
     return $filename;
 }
Beispiel #3
0
						<th rowspan="2">Error</th>
					</tr>
					<tr>
						<th>Database Column</th><th>Uploaded File Column</th>
					</tr>
				</thead>
			<?php 
        foreach ($errors as $error) {
            ?>
				<tr>
					<td><?php 
            echo $error['row_number'];
            ?>
</td>
					<td><?php 
            echo WebDB_Text::titlecase($error['field_name']);
            ?>
</td>
					<td>
						<?php 
            if (!empty($error['column_name'])) {
                ?>
						Column #<?php 
                echo $error['column_number'] + 1;
                ?>
: <?php 
                echo $error['column_name'];
                ?>
						<?php 
            }
            ?>
Beispiel #4
0
    ?>
.
	</li>
		<?php 
    if (isset($row[$column->get_name() . '_webdb_title'])) {
        // Won't work for default values in new records.
        ?>
	<li>
		<?php 
        $url = "edit/" . $database->get_name() . '/' . $referenced_table->get_name() . '/' . $value;
        $title = 'View ' . $row[$column->get_name() . '_webdb_title'];
        //$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 
} else {
    $attrs = array('id' => $form_field_name, 'size' => min(35, $column->get_size()));
Beispiel #5
0
    }
    ?>
				</ol>
				<?php 
}
?>
			</div>

			<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) {
    ?>
Beispiel #6
0
?>
" alt="Entity Relationship Diagram for <?php 
echo $database->get_name();
?>
" />
</p>

<h2>Change displayed tables</h2>
<?php 
echo Form::open(NULL, array('method' => 'get'));
?>
<ol class="columnar">
	<?php 
foreach ($database->get_tables() as $table) {
    ?>
	<li>
		<label>
		<?php 
    $selected = in_array($table->get_name(), $selected_tables);
    echo Form::checkbox($table->get_name(), '', $selected);
    echo WebDB_Text::titlecase($table->get_name());
    ?>
		</label>
	</li>
	<?php 
}
?>
</ol>
<?php 
echo Form::submit(NULL, 'Show only the selected tables');
echo Form::close();
Beispiel #7
0
_ERD {
	rankdir=LR
	node [shape=none, fontsize=12];
<?php 
foreach ($database->get_tables() as $table) {
    ?>

	<?php 
    if (!in_array($table->get_name(), $selected_tables)) {
        continue;
    }
    echo $table->get_name() . " [label=<<TABLE CELLBORDER=\"1\" CELLSPACING=\"0\" BORDER=\"0\">\n\t\t";
    echo "<TR><TD ALIGN=\"CENTER\"><FONT POINT-SIZE=\"16\"><B>" . WebDB_Text::titlecase($table->get_name()) . "</B></FONT></TD></TR>";
    $cols = array();
    foreach ($table->get_columns() as $col) {
        $c = '<TD PORT="' . $col->get_name() . '" ALIGN="LEFT">' . WebDB_Text::titlecase($col->get_name());
        //.' '.$col->get_type();
        //if ($size = $col->get_size()) $c .= '('.$size.')';
        $cols[] = $c . "</TD>";
    }
    echo "<TR>" . join("</TR>\n\t\t<TR>", $cols) . "</TR>";
    echo "\n\t\t</TABLE>>];\n\t";
    foreach ($table->get_columns() as $col) {
        if ($col->is_foreign_key() and in_array($col->get_referenced_table()->get_name(), $selected_tables)) {
            echo $table->get_name() . ':' . $col->get_name();
            echo ' -> ';
            echo $col->get_referenced_table()->get_name() . ':' . $col->get_referenced_table()->get_pk_column()->get_name();
            echo ";\n\t";
        }
    }
    ?>
Beispiel #8
0
 public function action_index()
 {
     $this->view->columns = array();
     $this->view->filters = array();
     if (!$this->table) {
         $this->template->content = null;
         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' => '');
 }
Beispiel #9
0
    ?>
	</caption>
	<thead>
		<tr>

			<?php 
    if ($the_table->get_pk_column()) {
        ?>
			<th>&nbsp;</th>
			<?php 
    }
    ?>

			<?php 
    foreach ($the_table->get_columns() as $column) {
        $title = WebDB_Text::titlecase($column->get_name());
        $orderdir = $the_table->orderdir;
        $class = '';
        if ($the_table->orderby == $column->get_name()) {
            $title .= "&nbsp;<img src='" . Media::url("img/sort_{$orderdir}.png") . "' alt='Sort-direction icon' />";
            $orderdir = $orderdir == 'desc' ? 'asc' : 'desc';
            $class = 'sorted';
        }
        $url = URL::query(array('orderby' => $column->get_name(), 'orderdir' => $orderdir));
        echo "<th class='{$class}'>" . HTML::anchor(Request::current()->uri() . $url, $title) . "</th>";
    }
    ?>

		</tr>
	</thead>
	<tbody>