Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/tabulate/tabulate
Browse files Browse the repository at this point in the history
  • Loading branch information
samwilson committed Jul 14, 2016
2 parents ca21003 + 621c45e commit 4452cc3
Show file tree
Hide file tree
Showing 27 changed files with 166 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ php:

# WordPress versions to be tested against.
env:
- WP_VERSION=4.4
- WP_VERSION=4.4.2
- WP_VERSION=master

# Clones WordPress and configures our testing environment.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Donate link: https://www.bushheritage.org.au/donatenow
* Tags: MySQL, databases, tables, data, CRUD, import, export, CSV, shortcode, OpenStreetMap, KML
* Requires at least: 4.2
* Tested up to: 4.4
* Tested up to: 4.5
* Stable tag: trunk
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down
1 change: 1 addition & 0 deletions assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ form.tabulate-record .foreign-key label { text-align:left }
form.tabulate-record .foreign-key input.form-control { width:83% }
form.tabulate-record .foreign-key span.input-group-addon { color:#555 }
form.tabulate-record .point-column .map { width:450px; height:200px; border:1px solid #ddd }
form.tabulate-record tr.column-type-tinyint td.form-field label { display:inline-block; margin-right:1em }

.tabulate .postbox-container.record-meta { float:none }
.tabulate .postbox-container .related-records .hndle { cursor:pointer }
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
},
"require-dev": {
"squizlabs/php_codesniffer": "dev-master",
"wp-coding-standards/wpcs": "dev-master"
"wp-coding-standards/wpcs": "dev-develop"
}
}
14 changes: 7 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 51 additions & 48 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,48 +1,51 @@
<?xml version="1.0"?>
<ruleset name="WordPress-Tabulate">
<!--
This file adapted from https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#standards-subsets
Use this ruleset by running e.g. phpcs - - standard=phpcs.xml src
Run `phpcs` with the '-s' flag to see the names of the sniffs.
-->
<description>Sniffs for the coding standards of the Tabulate plugin</description>
<config name="installed_paths" value="../../wp-coding-standards/wpcs/" />

<!-- What files should be sniffed. -->
<file>./</file>
<exclude-pattern>./vendor/*</exclude-pattern>
<exclude-pattern>./assets/*</exclude-pattern>
<exclude-pattern>./docs/*</exclude-pattern>
<file>./assets/scripts.js</file>
<file>./assets/style.css</file>

<!-- Some coding standards above and beyond WordPress. -->
<rule ref="Squiz.PHP.CommentedOutCode" />
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
<!--rule ref="Squiz.Strings.ConcatenationSpacing" /-->
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter" />
<rule ref="Generic.ControlStructures.InlineControlStructure" />

<!-- Use *most* of WordPress' coding standards. -->
<rule ref="WordPress">
<exclude name="Generic.Files.LowercasedFilename.NotFound" />
<exclude name="Generic.Strings.UnnecessaryStringConcat.Found" />
<exclude name="Squiz.Strings.DoubleQuoteUsage.NotRequired" />
<exclude name="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing" />
<exclude name="WordPress.CSRF.NonceVerification.NoNonceVerification" />
<exclude name="WordPress.WP.PreparedSQL.NotPrepared" />
<exclude name="WordPress.XSS.EscapeOutput" />
<exclude name="WordPress.VIP" />
</rule>

<!-- Tests have a 'setUp' method, which is part of PHPUnit. -->
<rule ref="WordPress.NamingConventions.ValidFunctionName">
<exclude-pattern>./tests/*</exclude-pattern>
</rule>

<!-- The main plugin file has a special file-level docblock. -->
<rule ref="Squiz.Commenting.FileComment.MissingPackageTag">
<exclude-pattern>./tabulate.php</exclude-pattern>
</rule>

</ruleset>
<?xml version="1.0"?>
<ruleset name="WordPress-Tabulate">
<!--
This file adapted from https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards#standards-subsets
Use this ruleset by running e.g. phpcs - - standard=phpcs.xml src
Run `phpcs` with the '-s' flag to see the names of the sniffs.
-->
<description>Sniffs for the coding standards of the Tabulate plugin</description>
<config name="installed_paths" value="../../wp-coding-standards/wpcs/" />

<!-- What files should be sniffed. -->
<file>./</file>
<exclude-pattern>./vendor/*</exclude-pattern>
<exclude-pattern>./assets/*</exclude-pattern>
<exclude-pattern>./docs/*</exclude-pattern>
<file>./assets/scripts.js</file>
<file>./assets/style.css</file>

<!-- Some coding standards above and beyond WordPress. -->
<rule ref="Squiz.PHP.CommentedOutCode" />
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace" />
<rule ref="Generic.CodeAnalysis.UnusedFunctionParameter" />
<rule ref="Generic.ControlStructures.InlineControlStructure" />

<!-- Use *most* of WordPress' coding standards. -->
<rule ref="WordPress">
<exclude name="Generic.Files.LowercasedFilename.NotFound" />
<exclude name="Generic.Strings.UnnecessaryStringConcat.Found" />
<exclude name="Squiz.Strings.DoubleQuoteUsage.NotRequired" />
<exclude name="WordPress.CSRF.NonceVerification.NoNonceVerification" />
<exclude name="WordPress.WP.PreparedSQL.NotPrepared" />
<exclude name="WordPress.XSS.EscapeOutput" />
<exclude name="WordPress.VIP" />
</rule>

<!-- For some reason, this isn't excluded when added under the WordPress rule. -->
<rule ref="Squiz.Commenting.FunctionComment.ScalarTypeHintMissing">
<severity>0</severity>
</rule>

<!-- Tests have a 'setUp' method, which is part of PHPUnit. -->
<rule ref="WordPress.NamingConventions.ValidFunctionName">
<exclude-pattern>./tests/*</exclude-pattern>
</rule>

<!-- The main plugin file has a special file-level docblock. -->
<rule ref="Squiz.Commenting.FileComment.MissingPackageTag">
<exclude-pattern>./tabulate.php</exclude-pattern>
</rule>

</ruleset>
2 changes: 1 addition & 1 deletion src/Controllers/MapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function gpx( $args ) {
$fktitle = $col->get_name() . \WordPress\Tabulate\DB\Record::FKTITLE;
$value = $record->$fktitle();
$categories->addChild( 'gpxx:Categories', $col->get_title() . ": $value", 'gpxx' );
$waypoint_extension->addChild( 'gpxx:'.$col->get_name(), $value, 'gpxx' );
$waypoint_extension->addChild( 'gpxx:' . $col->get_name(), $value, 'gpxx' );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/RecordController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ public function delete( $args ) {
wp_safe_redirect( $table->get_url() );
exit;
}
check_admin_referer( 'tabulate-record-' . $record_ident );

// Ask for confirmation.
if ( ! isset( $_POST['confirm_deletion'] ) ) {
Expand All @@ -152,6 +151,7 @@ public function delete( $args ) {
}

// Delete the record.
check_admin_referer( 'tabulate-record-delete-' . $record_ident );
try {
$this->wpdb->query( 'BEGIN' );
$table->delete_record( $record_ident );
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/SchemaController.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function newtable( $args ) {
// Redirect user with message.
$template = new Template( 'table/schema.html' );
$template->add_notice( 'updated', 'New table created' );
$url = 'admin.php?page=tabulate&controller=schema&table='.$table->get_name();
$url = 'admin.php?page=tabulate&controller=schema&table=' . $table->get_name();
wp_safe_redirect( admin_url( $url ) );
exit;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controllers/ShortcodeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function run( $atts ) {
}
return $this->error();
}
$format_method = $attrs['format'].'_format';
$format_method = $attrs['format'] . '_format';
if ( is_callable( array( $this, $format_method ) ) ) {
wp_enqueue_script( 'tabulate-scripts' );
return $this->$format_method( $table, $attrs, $_REQUEST );
Expand Down Expand Up @@ -140,7 +140,7 @@ protected function form_format( Table $table, $attrs ) {
*/
protected function count_format( Table $table ) {
$count = number_format( $table->count_records() );
return '<span class="tabulate count-format">'.$count.'</span>';
return '<span class="tabulate count-format">' . $count . '</span>';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/TableController.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public function import( $args ) {
/*
* Stage 1 of 4: Uploading.
*/
require_once ABSPATH.'/wp-admin/includes/file.php';
require_once ABSPATH . '/wp-admin/includes/file.php';
$template->form_action = $table->get_url( 'import' );
try {
$hash = isset( $_GET['hash'] ) ? $_GET['hash'] : false;
Expand Down
2 changes: 1 addition & 1 deletion src/DB/ChangeTracker.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public function after_save( Table $table, Record $new_record ) {

// Save a change for each changed column.
foreach ( $table->get_columns() as $column ) {
$col_name = ( $column->is_foreign_key() ) ? $column->get_name().Record::FKTITLE : $column->get_name();
$col_name = ( $column->is_foreign_key() ) ? $column->get_name() . Record::FKTITLE : $column->get_name();
$old_val = ( is_callable( array( $this->old_record, $col_name ) ) ) ? $this->old_record->$col_name() : null;
$new_val = $new_record->$col_name();
if ( $new_val === $old_val ) {
Expand Down
10 changes: 5 additions & 5 deletions src/DB/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ public function alter( $new_name = null, $xtype_name = null, $size = null, $null
$table = $this->get_table();
$wpdb = $table->get_database()->get_wpdb();
if ( $this->is_unique() ) {
$sql = 'SHOW INDEXES FROM `' . $table->get_name() .'` WHERE Column_name LIKE "' . $this->get_name() . '"';
$sql = 'SHOW INDEXES FROM `' . $table->get_name() . '` WHERE Column_name LIKE "' . $this->get_name() . '"';
foreach ( $wpdb->get_results( $sql, ARRAY_A ) as $index ) {
$sql = "DROP INDEX `" . $index['Key_name'] . "` ON `" . $table->get_name() . "`";
$wpdb->query( $sql );
Expand All @@ -615,14 +615,14 @@ public function alter( $new_name = null, $xtype_name = null, $size = null, $null
. ' AND CONSTRAINT_TYPE = "FOREIGN KEY" ';
$fks = $wpdb->get_results( $fks_sql );
foreach ( $fks as $key ) {
$sql = 'ALTER TABLE `' . $table->get_name() .'` DROP FOREIGN KEY `' . $key->fk_name . '`';
$sql = 'ALTER TABLE `' . $table->get_name() . '` DROP FOREIGN KEY `' . $key->fk_name . '`';
$wpdb->query( $sql );
}
$this->references = false;
}

// Alter the column.
$sql = "ALTER TABLE `".$table->get_name()."` CHANGE COLUMN `".$this->get_name()."` $col_def";
$sql = "ALTER TABLE `" . $table->get_name() . "` CHANGE COLUMN `" . $this->get_name() . "` $col_def";
$wpdb->hide_errors();
$altered = $wpdb->query( $sql );
if ( false === $altered ) {
Expand Down Expand Up @@ -694,9 +694,9 @@ public static function get_column_definition( $name, $xtype_name = null, $size =
$ref_str = ', ADD CONSTRAINT `' . $name . '_fk_to_' . $target_table->get_name() . '`'
. ' FOREIGN KEY (`' . $name . '`) '
. ' REFERENCES `' . $target_table->get_name() . '` '
. ' (`'.$pk_col->get_name().'`)';
. ' (`' . $pk_col->get_name() . '`)';
$type_str = $pk_col->get_type();
$size_str = '('.$pk_col->get_size().')';
$size_str = '(' . $pk_col->get_size() . ')';
$sign_str = ($pk_col->is_unsigned()) ? 'UNSIGNED' : '';
}

Expand Down
4 changes: 2 additions & 2 deletions src/DB/Record.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ public function get_title() {
} else {
$title_parts = array();
foreach ( $this->table->get_columns() as $col ) {
$col_name = $col->get_name().self::FKTITLE;
$col_name = $col->get_name() . self::FKTITLE;
$title_parts[] = $this->$col_name();
}
return '[ ' . join( ' | ', $title_parts ) .' ]';
return '[ ' . join( ' | ', $title_parts ) . ' ]';
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/DB/Reports.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function get_template( $report_id ) {
$template->mime_type = $report->mime_type();

// Populate with source data.
$sql = "SELECT * FROM `".self::report_sources_table_name()."` WHERE report = " . $report_id;
$sql = "SELECT * FROM `" . self::report_sources_table_name() . "` WHERE report = " . $report_id;
$sources = $this->db->get_wpdb()->get_results( $sql );
foreach ( $sources as $source ) {
$data = $this->db->get_wpdb()->get_results( $source->query );
Expand Down Expand Up @@ -129,15 +129,15 @@ public static function activate() {
. "{% endfor %}\n"
. "</dl>";
$sql1 = "INSERT INTO `" . self::reports_table_name() . "` SET"
. " id = ".self::DEFAULT_REPORT_ID.", "
. " id = " . self::DEFAULT_REPORT_ID . ", "
. " title = 'Reports', "
. " description = 'List of all Reports.',"
. " template = %s;";
$wpdb->query( $wpdb->prepare( $sql1, array( $template_string ) ) );
// And the query for the above report.
$query = "SELECT * FROM ".self::reports_table_name();
$query = "SELECT * FROM " . self::reports_table_name();
$sql2 = "INSERT INTO `" . self::report_sources_table_name() . "` SET "
. " report = ".self::DEFAULT_REPORT_ID.","
. " report = " . self::DEFAULT_REPORT_ID . ","
. " name = 'reports',"
. " query = %s;";
$wpdb->query( $wpdb->prepare( $sql2, array( $query ) ) );
Expand Down

0 comments on commit 4452cc3

Please sign in to comment.