diff --git a/.gitignore b/.gitignore index 2a6e0905..bcb8f980 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,34 @@ +/composer.lock /db/log/*.log /db/ruckusing.conf.local.php /db/sql/*.bak -/composer.lock /js/vendor/evercookie /js/vendor/uuid-js /phpunit.xml -/tests/mocha/node_modules/ -/tests/integration-environment/cache/*.* -/tests/integration-environment/wordpress/ -/tests/integration-environment/wordpress-*.tar.gz -/tests/integration-environment/*.zip /tests/integration-environment/*.log /tests/integration-environment/*.pid +/tests/integration-environment/*.zip +/tests/integration-environment/cache/*.* +/tests/integration-environment/wordpress-*.tar.gz +/tests/integration-environment/wordpress/ +/tests/mocha/node_modules/ +/tools/intro-video/*.mp4 +/tools/intro-video/.backup/ +/tools/intro-video/Wp-testing-Intro.mp4.txt +/tools/intro-video/aifc/ +/tools/intro-video/background/ +/tools/intro-video/mkv/ +/tools/intro-video/mp3/ +/tools/intro-video/node_modules/ +/tools/intro-video/ogv/ +/tools/intro-video/thumbnail/ +/tools/intro-video/thumbs/ +/tools/refactoring/*.sql +/tools/refactoring/*.svg +/tools/screenshots/decorated/*.png /tools/screenshots/node_modules/ /tools/screenshots/raw/*.png -/tools/screenshots/decorated/*.png -/tools/support/*.txt /tools/support/*.md +/tools/support/*.txt /tools/support/wordpress-support-mirror/ /vendor/ diff --git a/CHANGELOG.md b/CHANGELOG.md index e0291037..058b61bb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,18 @@ ## Changelog ## +### 0.17.2 ### + +Internal improvements and intro-video + +Add intro-video with plugin description, howto concepts and explanations: http://www.youtube.com/watch?v=tT3d8Jdm7kY + +Internal improvements: + +* Improve code quality and avoid duplicates +* Improve test rendering + + ### 0.17.1 ### Fix incorrect content processing diff --git a/README.md b/README.md index d644b9c8..aedc4f08 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ **Tags:** psychological, testing, test, quiz **Requires at least:** 3.2 **Tested up to:** 4.3.1 -**Stable tag:** 0.17.1 +**Stable tag:** 0.17.2 **License:** GPLv3 **License URI:** http://www.gnu.org/licenses/gpl-3.0.html @@ -23,6 +23,8 @@ We didn't invent anything new — all this has been already invented in 19th cen > If you like the plugin, feel free to [donate via PayPal](https://goo.gl/igulor) or rate it (on the right side of this page). Thanks a lot! :) +http://www.youtube.com/watch?v=tT3d8Jdm7kY + Test answers, scales, results and categories are edited through **wordpress standard editors**, similar to categories editor. You can associate them in sidebar. Whether test questions, answers and formulas are edited with standard wordpress metaboxes, behind content. You can even reorder them if you like by drag-n-drop. At the top of content editor you have **button for quick access** to those metaboxes: Add New Questions, Edit Questions and Scores, Edit Formulas. If you want more control then you are allowed to add to them not allowed out-of-the box HTML tags like: headers, lists, images, hr and "read more" tag taken from post editor. **Answers** can be global to test — when all questions have the same answers. For example: "Yes", "No", "I'm not sure". Or you can use **individual answers** to add individual answer to each question. And the third option is to use global answers, but individualize their titles: not just "Yes", but "Yes, I do so and so", when you use it for the particular question. Some tests have this pattern. @@ -116,11 +118,11 @@ Sorry, I dont' have too much time for custom paid development. WordPress as plat Most giant are **[feature](https://wordpress.org/tags/wp-testing-feature)**, **[bug](https://wordpress.org/tags/wp-testing-bug)** and **[support](https://wordpress.org/tags/wp-testing-support)**. Other are groupped under them. -**Feature**: [alert required questions](https://wordpress.org/tags/wp-testing-alert-required-questions), [answer rate](https://wordpress.org/tags/wp-testing-answer-rate), [answer type number](https://wordpress.org/tags/wp-testing-answer-type-number), [author](https://wordpress.org/tags/wp-testing-author), [chained steps strategy](https://wordpress.org/tags/wp-testing-chained-steps-strategy), [conflict plugin](https://wordpress.org/tags/wp-testing-conflict-plugin), [custom template](https://wordpress.org/tags/wp-testing-custom-template), [diagram settings](https://wordpress.org/tags/wp-testing-diagram-settings), [diagram type](https://wordpress.org/tags/wp-testing-diagram-type), **[email results](https://wordpress.org/tags/wp-testing-email-results)**, [export import tests](https://wordpress.org/tags/wp-testing-export-import-tests), **[export results](https://wordpress.org/tags/wp-testing-export-results)**, [for users](https://wordpress.org/tags/wp-testing-for-users), [formula absolute](https://wordpress.org/tags/wp-testing-formula-absolute), [formula division](https://wordpress.org/tags/wp-testing-formula-division), [formula not](https://wordpress.org/tags/wp-testing-formula-not), **[hide scales](https://wordpress.org/tags/wp-testing-hide-scales)**, [hide test description](https://wordpress.org/tags/wp-testing-hide-test-description), [individual answers](https://wordpress.org/tags/wp-testing-individual-answers), **[low memory](https://wordpress.org/tags/wp-testing-low-memory)**, [multiline questions](https://wordpress.org/tags/wp-testing-multiline-questions), [multiple answers](https://wordpress.org/tags/wp-testing-multiple-answers), [negative scales sum](https://wordpress.org/tags/wp-testing-negative-scales-sum), [paid results](https://wordpress.org/tags/wp-testing-paid-results), [paid test](https://wordpress.org/tags/wp-testing-paid-test), [passing counter](https://wordpress.org/tags/wp-testing-passing-counter), [pdf results](https://wordpress.org/tags/wp-testing-pdf-results), [postprocess results](https://wordpress.org/tags/wp-testing-postprocess-results), [public scale names](https://wordpress.org/tags/wp-testing-public-scale-names), [publish homepage](https://wordpress.org/tags/wp-testing-publish-homepage), [question per page](https://wordpress.org/tags/wp-testing-question-per-page), [random question answer order](https://wordpress.org/tags/wp-testing-random-question-answer-order), [redirect](https://wordpress.org/tags/wp-testing-redirect), [reorder questions](https://wordpress.org/tags/wp-testing-reorder-questions), [reorder scales results answers](https://wordpress.org/tags/wp-testing-reorder-scales-results-answers), **[respondents results](https://wordpress.org/tags/wp-testing-respondents-results)**, **[results page](https://wordpress.org/tags/wp-testing-results-page)**, **[rich scales results](https://wordpress.org/tags/wp-testing-rich-scales-results)**, [scale bar orientation](https://wordpress.org/tags/wp-testing-scale-bar-orientation), **[scores decimal](https://wordpress.org/tags/wp-testing-scores-decimal)**, [sections](https://wordpress.org/tags/wp-testing-sections), [share results](https://wordpress.org/tags/wp-testing-share-results), **[shortcode](https://wordpress.org/tags/wp-testing-shortcode)**, [sort results](https://wordpress.org/tags/wp-testing-sort-results), [sort scales](https://wordpress.org/tags/wp-testing-sort-scales), **[styling](https://wordpress.org/tags/wp-testing-styling)**, [test page answers](https://wordpress.org/tags/wp-testing-test-page-answers), [time limit](https://wordpress.org/tags/wp-testing-time-limit), [use post category](https://wordpress.org/tags/wp-testing-use-post-category), [user to results](https://wordpress.org/tags/wp-testing-user-to-results), [variable question answer](https://wordpress.org/tags/wp-testing-variable-question-answer). +**Feature**: [alert required questions](https://wordpress.org/tags/wp-testing-alert-required-questions), [answer rate](https://wordpress.org/tags/wp-testing-answer-rate), [answer type number](https://wordpress.org/tags/wp-testing-answer-type-number), [author](https://wordpress.org/tags/wp-testing-author), [chained steps strategy](https://wordpress.org/tags/wp-testing-chained-steps-strategy), [conflict plugin](https://wordpress.org/tags/wp-testing-conflict-plugin), [custom template](https://wordpress.org/tags/wp-testing-custom-template), [diagram settings](https://wordpress.org/tags/wp-testing-diagram-settings), **[diagram type](https://wordpress.org/tags/wp-testing-diagram-type)**, **[email results](https://wordpress.org/tags/wp-testing-email-results)**, [export import tests](https://wordpress.org/tags/wp-testing-export-import-tests), **[export results](https://wordpress.org/tags/wp-testing-export-results)**, [for users](https://wordpress.org/tags/wp-testing-for-users), [formula absolute](https://wordpress.org/tags/wp-testing-formula-absolute), [formula division](https://wordpress.org/tags/wp-testing-formula-division), [formula not](https://wordpress.org/tags/wp-testing-formula-not), [hide scales](https://wordpress.org/tags/wp-testing-hide-scales), [hide test description](https://wordpress.org/tags/wp-testing-hide-test-description), [individual answers](https://wordpress.org/tags/wp-testing-individual-answers), **[low memory](https://wordpress.org/tags/wp-testing-low-memory)**, [multiline questions](https://wordpress.org/tags/wp-testing-multiline-questions), [multiple answers](https://wordpress.org/tags/wp-testing-multiple-answers), [negative scales sum](https://wordpress.org/tags/wp-testing-negative-scales-sum), [paid results](https://wordpress.org/tags/wp-testing-paid-results), [paid test](https://wordpress.org/tags/wp-testing-paid-test), [passing counter](https://wordpress.org/tags/wp-testing-passing-counter), [pdf results](https://wordpress.org/tags/wp-testing-pdf-results), [postprocess results](https://wordpress.org/tags/wp-testing-postprocess-results), [public scale names](https://wordpress.org/tags/wp-testing-public-scale-names), [publish homepage](https://wordpress.org/tags/wp-testing-publish-homepage), [question per page](https://wordpress.org/tags/wp-testing-question-per-page), [random question answer order](https://wordpress.org/tags/wp-testing-random-question-answer-order), [redirect](https://wordpress.org/tags/wp-testing-redirect), [reorder questions](https://wordpress.org/tags/wp-testing-reorder-questions), [reorder scales results answers](https://wordpress.org/tags/wp-testing-reorder-scales-results-answers), **[respondents results](https://wordpress.org/tags/wp-testing-respondents-results)**, **[results page](https://wordpress.org/tags/wp-testing-results-page)**, [rich scales results](https://wordpress.org/tags/wp-testing-rich-scales-results), [scale bar orientation](https://wordpress.org/tags/wp-testing-scale-bar-orientation), **[scores decimal](https://wordpress.org/tags/wp-testing-scores-decimal)**, [sections](https://wordpress.org/tags/wp-testing-sections), [share results](https://wordpress.org/tags/wp-testing-share-results), **[shortcode](https://wordpress.org/tags/wp-testing-shortcode)**, [sort results](https://wordpress.org/tags/wp-testing-sort-results), [sort scales](https://wordpress.org/tags/wp-testing-sort-scales), **[styling](https://wordpress.org/tags/wp-testing-styling)**, **[test page answers](https://wordpress.org/tags/wp-testing-test-page-answers)**, [time limit](https://wordpress.org/tags/wp-testing-time-limit), [use post category](https://wordpress.org/tags/wp-testing-use-post-category), [user to results](https://wordpress.org/tags/wp-testing-user-to-results), [variable question answer](https://wordpress.org/tags/wp-testing-variable-question-answer). -**Bug**: [answer order](https://wordpress.org/tags/wp-testing-answer-order), [answers disappears](https://wordpress.org/tags/wp-testing-answers-disappears), [apostrophe](https://wordpress.org/tags/wp-testing-apostrophe), **[conflict plugin](https://wordpress.org/tags/wp-testing-conflict-plugin)**, **[conflict theme](https://wordpress.org/tags/wp-testing-conflict-theme)**, [cpu limit](https://wordpress.org/tags/wp-testing-cpu-limit), **[database collation](https://wordpress.org/tags/wp-testing-database-collation)**, [database engine](https://wordpress.org/tags/wp-testing-database-engine), [database old password format](https://wordpress.org/tags/wp-testing-database-old-password-format), [database prefix case](https://wordpress.org/tags/wp-testing-database-prefix-case), [form multipart](https://wordpress.org/tags/wp-testing-form-multipart), [formulas](https://wordpress.org/tags/wp-testing-formulas), [individual answers](https://wordpress.org/tags/wp-testing-individual-answers), **[migration](https://wordpress.org/tags/wp-testing-migration)**, [minimal score](https://wordpress.org/tags/wp-testing-minimal-score), [missing mysqli](https://wordpress.org/tags/wp-testing-missing-mysqli), [missing tokenizer](https://wordpress.org/tags/wp-testing-missing-tokenizer), [multiple answers](https://wordpress.org/tags/wp-testing-multiple-answers), [multisite](https://wordpress.org/tags/wp-testing-multisite), [page 404](https://wordpress.org/tags/wp-testing-page-404), [php strict](https://wordpress.org/tags/wp-testing-php-strict), [test description limited](https://wordpress.org/tags/wp-testing-test-description-limited), [uninstall](https://wordpress.org/tags/wp-testing-uninstall), [value names required](https://wordpress.org/tags/wp-testing-value-names-required), **[virus](https://wordpress.org/tags/wp-testing-virus)**. +**Bug**: [answer order](https://wordpress.org/tags/wp-testing-answer-order), [answers disappears](https://wordpress.org/tags/wp-testing-answers-disappears), [apostrophe](https://wordpress.org/tags/wp-testing-apostrophe), **[conflict plugin](https://wordpress.org/tags/wp-testing-conflict-plugin)**, **[conflict theme](https://wordpress.org/tags/wp-testing-conflict-theme)**, [cpu limit](https://wordpress.org/tags/wp-testing-cpu-limit), **[database collation](https://wordpress.org/tags/wp-testing-database-collation)**, [database engine](https://wordpress.org/tags/wp-testing-database-engine), [database old password format](https://wordpress.org/tags/wp-testing-database-old-password-format), [database prefix case](https://wordpress.org/tags/wp-testing-database-prefix-case), [form multipart](https://wordpress.org/tags/wp-testing-form-multipart), [formulas](https://wordpress.org/tags/wp-testing-formulas), [individual answers](https://wordpress.org/tags/wp-testing-individual-answers), **[migration](https://wordpress.org/tags/wp-testing-migration)**, [minimal score](https://wordpress.org/tags/wp-testing-minimal-score), [missing mysqli](https://wordpress.org/tags/wp-testing-missing-mysqli), [missing tokenizer](https://wordpress.org/tags/wp-testing-missing-tokenizer), [multiple answers](https://wordpress.org/tags/wp-testing-multiple-answers), [multisite](https://wordpress.org/tags/wp-testing-multisite), [page 404](https://wordpress.org/tags/wp-testing-page-404), [php strict](https://wordpress.org/tags/wp-testing-php-strict), [roles](https://wordpress.org/tags/wp-testing-roles), [shortcode](https://wordpress.org/tags/wp-testing-shortcode), [test description limited](https://wordpress.org/tags/wp-testing-test-description-limited), [uninstall](https://wordpress.org/tags/wp-testing-uninstall), [value names required](https://wordpress.org/tags/wp-testing-value-names-required), **[virus](https://wordpress.org/tags/wp-testing-virus)**. -**Support**: [conflict plugin](https://wordpress.org/tags/wp-testing-conflict-plugin), **[conflict theme](https://wordpress.org/tags/wp-testing-conflict-theme)**, [database config](https://wordpress.org/tags/wp-testing-database-config), [demo](https://wordpress.org/tags/wp-testing-demo), [fields](https://wordpress.org/tags/wp-testing-fields), **[formula misprint](https://wordpress.org/tags/wp-testing-formula-misprint)**, [individual answers](https://wordpress.org/tags/wp-testing-individual-answers), [migration](https://wordpress.org/tags/wp-testing-migration), [missing mysqli](https://wordpress.org/tags/wp-testing-missing-mysqli), [more example tests for free](https://wordpress.org/tags/wp-testing-more-example-tests-for-free), [multisite](https://wordpress.org/tags/wp-testing-multisite), [not reproduced](https://wordpress.org/tags/wp-testing-not-reproduced), [reorder scales results answers](https://wordpress.org/tags/wp-testing-reorder-scales-results-answers), **[results page](https://wordpress.org/tags/wp-testing-results-page)**, [scores](https://wordpress.org/tags/wp-testing-scores), [skip question](https://wordpress.org/tags/wp-testing-skip-question), **[styling](https://wordpress.org/tags/wp-testing-styling)**, [theme customizing](https://wordpress.org/tags/wp-testing-theme-customizing), [translation](https://wordpress.org/tags/wp-testing-translation), [upgrade](https://wordpress.org/tags/wp-testing-upgrade). +**Support**: [access](https://wordpress.org/tags/wp-testing-access), [conflict plugin](https://wordpress.org/tags/wp-testing-conflict-plugin), **[conflict theme](https://wordpress.org/tags/wp-testing-conflict-theme)**, [custom template](https://wordpress.org/tags/wp-testing-custom-template), [database config](https://wordpress.org/tags/wp-testing-database-config), [demo](https://wordpress.org/tags/wp-testing-demo), [dispute](https://wordpress.org/tags/wp-testing-dispute), [export import tests](https://wordpress.org/tags/wp-testing-export-import-tests), [fields](https://wordpress.org/tags/wp-testing-fields), **[formula misprint](https://wordpress.org/tags/wp-testing-formula-misprint)**, [formulas](https://wordpress.org/tags/wp-testing-formulas), [individual answers](https://wordpress.org/tags/wp-testing-individual-answers), [migration](https://wordpress.org/tags/wp-testing-migration), [missing mysqli](https://wordpress.org/tags/wp-testing-missing-mysqli), [more example tests for free](https://wordpress.org/tags/wp-testing-more-example-tests-for-free), [multisite](https://wordpress.org/tags/wp-testing-multisite), [non actual](https://wordpress.org/tags/wp-testing-non-actual), [not reproduced](https://wordpress.org/tags/wp-testing-not-reproduced), [reorder scales results answers](https://wordpress.org/tags/wp-testing-reorder-scales-results-answers), **[results page](https://wordpress.org/tags/wp-testing-results-page)**, **[scores](https://wordpress.org/tags/wp-testing-scores)**, [server error 503](https://wordpress.org/tags/wp-testing-server-error-503), **[shortcode](https://wordpress.org/tags/wp-testing-shortcode)**, [skip question](https://wordpress.org/tags/wp-testing-skip-question), **[styling](https://wordpress.org/tags/wp-testing-styling)**, [theme customizing](https://wordpress.org/tags/wp-testing-theme-customizing), [translation](https://wordpress.org/tags/wp-testing-translation), [upgrade](https://wordpress.org/tags/wp-testing-upgrade). **Other**: [addon](https://wordpress.org/tags/wp-testing-addon), [changelog](https://wordpress.org/tags/wp-testing-changelog), [fix me for free](https://wordpress.org/tags/wp-testing-fix-me-for-free), [manual](https://wordpress.org/tags/wp-testing-manual), [reward](https://wordpress.org/tags/wp-testing-reward), **[translation](https://wordpress.org/tags/wp-testing-translation)**, [upgrade](https://wordpress.org/tags/wp-testing-upgrade). diff --git a/composer.json b/composer.json index 3702f386..756355c7 100644 --- a/composer.json +++ b/composer.json @@ -39,6 +39,7 @@ }, "autoload": { "classmap": [ + "db/migrations/wp_testing/", "src/", "vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php" ] @@ -131,10 +132,10 @@ "source": { "url": "https://github.com/garex/flourish-classes", "type": "git", - "reference": "85ef4360f05787f3455ec2d3293194b58f10d132" + "reference": "0a5b2536d9736b6fe12d8ab1b8f9ad341d2397bf" }, "dist": { - "url": "https://github.com/garex/flourish-classes/archive/85ef4360f05787f3455ec2d3293194b58f10d132.zip", + "url": "https://github.com/garex/flourish-classes/archive/0a5b2536d9736b6fe12d8ab1b8f9ad341d2397bf.zip", "type": "zip" } } diff --git a/db/migrations/wp_testing/20140901000000_AddWpTables.php b/db/migrations/wp_testing/20140901000000_WpTesting_Migration_AddWpTables.php similarity index 89% rename from db/migrations/wp_testing/20140901000000_AddWpTables.php rename to db/migrations/wp_testing/20140901000000_WpTesting_Migration_AddWpTables.php index 32ad9774..4476926e 100644 --- a/db/migrations/wp_testing/20140901000000_AddWpTables.php +++ b/db/migrations/wp_testing/20140901000000_WpTesting_Migration_AddWpTables.php @@ -1,16 +1,14 @@ execute(' - CREATE TABLE IF NOT EXISTS ' . WP_DB_PREFIX . 'posts ( + CREATE TABLE IF NOT EXISTS ' . $this->globalPrefix . 'posts ( ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, post_author bigint(20) unsigned NOT NULL DEFAULT "0", post_date datetime NOT NULL DEFAULT "0000-00-00 00:00:00", @@ -42,7 +40,7 @@ public function up() ) DEFAULT CHARSET=utf8 '); $this->execute(' - CREATE TABLE IF NOT EXISTS ' . WP_DB_PREFIX . 'terms ( + CREATE TABLE IF NOT EXISTS ' . $this->globalPrefix . 'terms ( term_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, name varchar(200) NOT NULL DEFAULT "", slug varchar(200) NOT NULL DEFAULT "", @@ -53,7 +51,7 @@ public function up() ) DEFAULT CHARSET=utf8 '); $this->execute(' - CREATE TABLE IF NOT EXISTS ' . WP_DB_PREFIX . 'users ( + CREATE TABLE IF NOT EXISTS ' . $this->globalPrefix . 'users ( ID bigint(20) unsigned NOT NULL AUTO_INCREMENT, user_login varchar(60) NOT NULL DEFAULT "", user_pass varchar(64) NOT NULL DEFAULT "", @@ -71,7 +69,7 @@ public function up() '); $this->execute(' - CREATE TABLE IF NOT EXISTS ' . WP_DB_PREFIX . 'term_taxonomy ( + CREATE TABLE IF NOT EXISTS ' . $this->globalPrefix . 'term_taxonomy ( term_taxonomy_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, term_id bigint(20) unsigned NOT NULL DEFAULT "0", taxonomy varchar(32) NOT NULL DEFAULT "", @@ -84,7 +82,7 @@ public function up() ) DEFAULT CHARSET=utf8 '); $this->execute(' - CREATE TABLE IF NOT EXISTS ' . WP_DB_PREFIX . 'term_relationships ( + CREATE TABLE IF NOT EXISTS ' . $this->globalPrefix . 'term_relationships ( object_id bigint(20) unsigned NOT NULL DEFAULT "0", term_taxonomy_id bigint(20) unsigned NOT NULL DEFAULT "0", term_order int(11) NOT NULL DEFAULT "0", @@ -93,7 +91,7 @@ public function up() ) DEFAULT CHARSET=utf8 '); $this->execute(' - CREATE TABLE IF NOT EXISTS ' . WP_DB_PREFIX . 'postmeta ( + CREATE TABLE IF NOT EXISTS ' . $this->globalPrefix . 'postmeta ( meta_id bigint(20) unsigned NOT NULL AUTO_INCREMENT, post_id bigint(20) unsigned NOT NULL DEFAULT "0", meta_key varchar(255) DEFAULT NULL, diff --git a/db/migrations/wp_testing/20140913082248_AddQuestionsTable.php b/db/migrations/wp_testing/20140913082248_AddQuestionsTable.php deleted file mode 100644 index 9f692448..00000000 --- a/db/migrations/wp_testing/20140913082248_AddQuestionsTable.php +++ /dev/null @@ -1,45 +0,0 @@ -drop_table(WPT_DB_PREFIX . 'questions'); - $table = $this->create_table(WPT_DB_PREFIX . 'questions', array( - 'id' => false, - 'options' => $this->get_table_engine_option(), - )); - $table->column('question_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - 'primary_key' => true, - 'auto_increment' => true, - )); - $table->column('test_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - )); - $table->column('question_title', 'text', array( - 'null' => false, - )); - $table->finish(); - $global_prefix = WP_DB_PREFIX; - $plugin_prefix = WPT_DB_PREFIX; - $this->execute(" - ALTER TABLE {$plugin_prefix}questions - ADD CONSTRAINT {$plugin_prefix}fk_question_test - FOREIGN KEY (test_id) - REFERENCES {$global_prefix}posts (ID) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_question_test (test_id) - "); - } - - public function down() - { - $this->drop_table(WPT_DB_PREFIX . 'questions'); - } -} diff --git a/db/migrations/wp_testing/20140913082248_WpTesting_Migration_AddQuestionsTable.php b/db/migrations/wp_testing/20140913082248_WpTesting_Migration_AddQuestionsTable.php new file mode 100644 index 00000000..8cb39c3b --- /dev/null +++ b/db/migrations/wp_testing/20140913082248_WpTesting_Migration_AddQuestionsTable.php @@ -0,0 +1,13 @@ +addForeignKeyToTest($table); + $table->addColumnText('question_title'); + } +} diff --git a/db/migrations/wp_testing/20140916030608_AddTestScoresTable.php b/db/migrations/wp_testing/20140916030608_AddTestScoresTable.php deleted file mode 100644 index 2b205dcc..00000000 --- a/db/migrations/wp_testing/20140916030608_AddTestScoresTable.php +++ /dev/null @@ -1,59 +0,0 @@ -create_table(WPT_DB_PREFIX . 'scores', array( - 'id' => false, - 'options' => $this->get_table_engine_option(), - )); - $pkOptions = array( - 'unsigned' => true, - 'null' => false, - 'primary_key' => true, - ); - $table->column('answer_id', 'biginteger', $pkOptions); - $table->column('question_id', 'biginteger', $pkOptions); - $table->column('scale_id', 'biginteger', $pkOptions); - $table->column('score_value', 'tinyinteger', array( - 'null' => false, - 'default' => 0, - )); - $table->finish(); - - $global_prefix = WP_DB_PREFIX; - $plugin_prefix = WPT_DB_PREFIX; - $this->execute(" - ALTER TABLE {$plugin_prefix}scores - - ADD CONSTRAINT {$plugin_prefix}fk_score_answer - FOREIGN KEY (answer_id) - REFERENCES {$global_prefix}terms (term_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_score_answer (answer_id), - - ADD CONSTRAINT {$plugin_prefix}fk_score_question - FOREIGN KEY (question_id) - REFERENCES {$plugin_prefix}questions (question_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_score_question (question_id), - - ADD CONSTRAINT {$plugin_prefix}fk_score_scale - FOREIGN KEY (scale_id) - REFERENCES {$global_prefix}terms (term_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_score_scale (scale_id) - "); - } - - public function down() - { - $this->drop_table(WPT_DB_PREFIX . 'scores'); - } -} diff --git a/db/migrations/wp_testing/20140916030608_WpTesting_Migration_AddTestScoresTable.php b/db/migrations/wp_testing/20140916030608_WpTesting_Migration_AddTestScoresTable.php new file mode 100644 index 00000000..5e4157bf --- /dev/null +++ b/db/migrations/wp_testing/20140916030608_WpTesting_Migration_AddTestScoresTable.php @@ -0,0 +1,33 @@ +createTable('scores') + ->addForeignKey('answer_id', array( + 'primary_key' => true, + 'keyName' => 'fk_score_answer', + 'referencedTable' => "{$this->globalPrefix}terms", + 'referencedKey' => 'term_id', + )) + ->addForeignKey('question_id', array( + 'primary_key' => true, + 'keyName' => 'fk_score_question', + 'referencedTable' => "{$this->pluginPrefix}questions", + )) + ->addForeignKey('scale_id', array( + 'primary_key' => true, + 'keyName' => 'fk_score_scale', + 'referencedTable' => "{$this->globalPrefix}terms", + 'referencedKey' => 'term_id', + )) + ->addColumnIntegerTiny('score_value', array('default' => 0)) + ->finish(); + } + + public function down() + { + $this->dropTable('scores'); + } +} diff --git a/db/migrations/wp_testing/20140925023344_AddPassingsTables.php b/db/migrations/wp_testing/20140925023344_AddPassingsTables.php deleted file mode 100644 index 8c4f44cb..00000000 --- a/db/migrations/wp_testing/20140925023344_AddPassingsTables.php +++ /dev/null @@ -1,99 +0,0 @@ -create_table(WPT_DB_PREFIX . 'passings', array( - 'id' => false, - 'options' => $this->get_table_engine_option(), - )); - $table->column('passing_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - 'primary_key' => true, - 'auto_increment' => true, - )); - $table->column('test_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - )); - $table->column('respondent_id', 'biginteger', array( - 'unsigned' => true, - )); - $table->column('created', 'datetime', array( - 'null' => false, - )); - $table->column('modified', 'datetime', array( - 'null' => false, - )); - $table->finish(); - - $global_prefix = WP_DB_PREFIX; - $plugin_prefix = WPT_DB_PREFIX; - $this->execute(" - ALTER TABLE {$plugin_prefix}passings - - ADD CONSTRAINT {$plugin_prefix}fk_passing_test - FOREIGN KEY (test_id) - REFERENCES {$global_prefix}posts (ID) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_passing_test (test_id), - - ADD CONSTRAINT {$plugin_prefix}fk_passing_respondent - FOREIGN KEY (respondent_id) - REFERENCES {$global_prefix}users (ID) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_passing_respondent (respondent_id) - "); - - $table = $this->create_table(WPT_DB_PREFIX . 'passing_answers', array( - 'id' => false, - 'options' => $this->get_table_engine_option(), - )); - $pkOptions = array( - 'unsigned' => true, - 'null' => false, - 'primary_key' => true, - ); - $table->column('answer_id', 'biginteger', $pkOptions); - $table->column('question_id', 'biginteger', $pkOptions); - $table->column('passing_id', 'biginteger', $pkOptions); - $table->finish(); - - $this->execute(" - ALTER TABLE {$plugin_prefix}passing_answers - - ADD CONSTRAINT {$plugin_prefix}fk_passing_answer_answer - FOREIGN KEY (answer_id) - REFERENCES {$global_prefix}terms (term_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_passing_answer_answer (answer_id), - - ADD CONSTRAINT {$plugin_prefix}fk_passing_answer_question - FOREIGN KEY (question_id) - REFERENCES {$plugin_prefix}questions (question_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_passing_answer_question (question_id), - - ADD CONSTRAINT {$plugin_prefix}fk_passing_answer_passing - FOREIGN KEY (passing_id) - REFERENCES {$plugin_prefix}passings (passing_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_passing_answer_passing (passing_id) - "); - } - - public function down() - { - $this->drop_table(WPT_DB_PREFIX . 'passing_answers'); - $this->drop_table(WPT_DB_PREFIX . 'passings'); - } -} diff --git a/db/migrations/wp_testing/20140925023344_WpTesting_Migration_AddPassingsTables.php b/db/migrations/wp_testing/20140925023344_WpTesting_Migration_AddPassingsTables.php new file mode 100644 index 00000000..e22c3866 --- /dev/null +++ b/db/migrations/wp_testing/20140925023344_WpTesting_Migration_AddPassingsTables.php @@ -0,0 +1,48 @@ +createTable('passings') + ->addPrimaryKey('passing_id') + ->addForeignKey('test_id', array( + 'keyName' => 'fk_passing_test', + 'referencedTable' => "{$this->globalPrefix}posts", + 'referencedKey' => 'ID', + )) + ->addNullableForeignKey('respondent_id', array( + 'keyName' => 'fk_passing_respondent', + 'referencedTable' => "{$this->globalPrefix}users", + 'referencedKey' => 'ID', + )) + ->addColumnDateTime('created') + ->addColumnDateTime('modified') + ->finish(); + + $this->createTable('passing_answers') + ->addForeignKey('answer_id', array( + 'primary_key' => true, + 'keyName' => 'fk_passing_answer_answer', + 'referencedTable' => "{$this->globalPrefix}terms", + 'referencedKey' => 'term_id', + )) + ->addForeignKey('question_id', array( + 'primary_key' => true, + 'keyName' => 'fk_passing_answer_question', + 'referencedTable' => "{$this->pluginPrefix}questions", + )) + ->addForeignKey('passing_id', array( + 'primary_key' => true, + 'keyName' => 'fk_passing_answer_passing', + 'referencedTable' => "{$this->pluginPrefix}passings", + )) + ->finish(); + } + + public function down() + { + $this->dropTable('passing_answers'); + $this->dropTable('passings'); + } +} diff --git a/db/migrations/wp_testing/20140928160013_AddExampleTest.php b/db/migrations/wp_testing/20140928160013_WpTesting_Migration_AddExampleTest.php similarity index 94% rename from db/migrations/wp_testing/20140928160013_AddExampleTest.php rename to db/migrations/wp_testing/20140928160013_WpTesting_Migration_AddExampleTest.php index 37e13846..5d6b9128 100644 --- a/db/migrations/wp_testing/20140928160013_AddExampleTest.php +++ b/db/migrations/wp_testing/20140928160013_WpTesting_Migration_AddExampleTest.php @@ -1,19 +1,17 @@ globalPrefix . 'posts'; + $terms = $this->globalPrefix . 'terms'; + $termTaxonomy = $this->globalPrefix . 'term_taxonomy'; + $termRelashionships = $this->globalPrefix . 'term_relationships'; + $questions = $this->pluginPrefix . 'questions'; + $scores = $this->pluginPrefix . 'scores'; $this->execute(" INSERT INTO $posts ( @@ -177,12 +175,12 @@ public function up() public function down() { - $posts = WP_DB_PREFIX . 'posts'; - $terms = WP_DB_PREFIX . 'terms'; - $termTaxonomy = WP_DB_PREFIX . 'term_taxonomy'; - $termRelashionships = WP_DB_PREFIX . 'term_relationships'; - $questions = WPT_DB_PREFIX . 'questions'; - $scores = WPT_DB_PREFIX . 'scores'; + $posts = $this->globalPrefix . 'posts'; + $terms = $this->globalPrefix . 'terms'; + $termTaxonomy = $this->globalPrefix . 'term_taxonomy'; + $termRelashionships = $this->globalPrefix . 'term_relationships'; + $questions = $this->pluginPrefix . 'questions'; + $scores = $this->pluginPrefix . 'scores'; $this->execute(" SET FOREIGN_KEY_CHECKS = 0; diff --git a/db/migrations/wp_testing/20141004124247_AddFormulasTable.php b/db/migrations/wp_testing/20141004124247_AddFormulasTable.php deleted file mode 100644 index e57ec363..00000000 --- a/db/migrations/wp_testing/20141004124247_AddFormulasTable.php +++ /dev/null @@ -1,59 +0,0 @@ -create_table(WPT_DB_PREFIX . 'formulas', array( - 'id' => false, - 'options' => $this->get_table_engine_option(), - )); - $table->column('formula_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - 'primary_key' => true, - 'auto_increment' => true, - )); - $table->column('test_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - )); - $table->column('result_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - )); - $table->column('formula_source', 'text', array( - 'null' => false, - )); - $table->finish(); - - $global_prefix = WP_DB_PREFIX; - $plugin_prefix = WPT_DB_PREFIX; - $this->execute(" - ALTER TABLE {$plugin_prefix}formulas - - ADD CONSTRAINT {$plugin_prefix}fk_formula_test - FOREIGN KEY (test_id) - REFERENCES {$global_prefix}posts (ID) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_formula_test (test_id), - - ADD CONSTRAINT {$plugin_prefix}fk_formula_result - FOREIGN KEY (result_id) - REFERENCES {$global_prefix}terms (term_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_formula_result (result_id), - - ADD UNIQUE INDEX uq_formula_test_result (test_id, result_id) - "); - } - - public function down() - { - $this->drop_table(WPT_DB_PREFIX . 'formulas'); - } -} diff --git a/db/migrations/wp_testing/20141004124247_WpTesting_Migration_AddFormulasTable.php b/db/migrations/wp_testing/20141004124247_WpTesting_Migration_AddFormulasTable.php new file mode 100644 index 00000000..7001b98a --- /dev/null +++ b/db/migrations/wp_testing/20141004124247_WpTesting_Migration_AddFormulasTable.php @@ -0,0 +1,23 @@ +addForeignKeyToTest($table); + $table + ->addForeignKey('result_id', array( + 'keyName' => 'fk_formula_result', + 'referencedTable' => "{$this->globalPrefix}terms", + 'referencedKey' => 'term_id', + )) + ->addColumnText('formula_source') + ->addIndexUnique('uq_formula_test_result', array( + 'test_id', + 'result_id' + )); + } +} diff --git a/db/migrations/wp_testing/20141007035029_AddFormulasToExampleTest.php b/db/migrations/wp_testing/20141007035029_WpTesting_Migration_AddFormulasToExampleTest.php similarity index 89% rename from db/migrations/wp_testing/20141007035029_AddFormulasToExampleTest.php rename to db/migrations/wp_testing/20141007035029_WpTesting_Migration_AddFormulasToExampleTest.php index 651fdde0..42fc6696 100644 --- a/db/migrations/wp_testing/20141007035029_AddFormulasToExampleTest.php +++ b/db/migrations/wp_testing/20141007035029_WpTesting_Migration_AddFormulasToExampleTest.php @@ -1,16 +1,14 @@ globalPrefix . 'posts'; + $terms = $this->globalPrefix . 'terms'; + $formulas = $this->pluginPrefix . 'formulas'; + $termTaxonomy = $this->globalPrefix . 'term_taxonomy'; + $termRelashionships = $this->globalPrefix . 'term_relationships'; $testSlug = 'eysencks-personality-inventory-epi-extroversionintroversion'; $testId = $this->field("SELECT ID FROM $posts WHERE post_type = 'wpt_test' AND post_name = '$testSlug' ORDER BY ID LIMIT 1"); @@ -57,10 +55,10 @@ public function up() public function down() { - $terms = WP_DB_PREFIX . 'terms'; - $formulas = WPT_DB_PREFIX . 'formulas'; - $termTaxonomy = WP_DB_PREFIX . 'term_taxonomy'; - $termRelashionships = WP_DB_PREFIX . 'term_relationships'; + $terms = $this->globalPrefix . 'terms'; + $formulas = $this->pluginPrefix . 'formulas'; + $termTaxonomy = $this->globalPrefix . 'term_taxonomy'; + $termRelashionships = $this->globalPrefix . 'term_relationships'; $this->execute(" SET FOREIGN_KEY_CHECKS = 0; diff --git a/db/migrations/wp_testing/20141102190330_AllowEmptyFormulas.php b/db/migrations/wp_testing/20141102190330_AllowEmptyFormulas.php deleted file mode 100644 index 4dcf602c..00000000 --- a/db/migrations/wp_testing/20141102190330_AllowEmptyFormulas.php +++ /dev/null @@ -1,20 +0,0 @@ -change_column(WPT_DB_PREFIX . 'formulas', 'formula_source', 'text', array( - 'null' => true, - )); - } - - public function down() - { - $this->change_column(WPT_DB_PREFIX . 'formulas', 'formula_source', 'text', array( - 'null' => false, - )); - } -} diff --git a/db/migrations/wp_testing/20141102190330_WpTesting_Migration_AllowEmptyFormulas.php b/db/migrations/wp_testing/20141102190330_WpTesting_Migration_AllowEmptyFormulas.php new file mode 100644 index 00000000..d9cb1732 --- /dev/null +++ b/db/migrations/wp_testing/20141102190330_WpTesting_Migration_AllowEmptyFormulas.php @@ -0,0 +1,9 @@ +add_meta('wpt_publish_on_home', 1); - } - - public function down() - { - $this->remove_meta('wpt_publish_on_home'); - } -} diff --git a/db/migrations/wp_testing/20141108033658_WpTesting_Migration_AddPublishOnHomeMeta.php b/db/migrations/wp_testing/20141108033658_WpTesting_Migration_AddPublishOnHomeMeta.php new file mode 100644 index 00000000..611afbe6 --- /dev/null +++ b/db/migrations/wp_testing/20141108033658_WpTesting_Migration_AddPublishOnHomeMeta.php @@ -0,0 +1,7 @@ + 1); +} diff --git a/db/migrations/wp_testing/20141122130034_DecodeFormulasSource.php b/db/migrations/wp_testing/20141122130034_DecodeFormulasSource.php deleted file mode 100644 index 22cf2370..00000000 --- a/db/migrations/wp_testing/20141122130034_DecodeFormulasSource.php +++ /dev/null @@ -1,21 +0,0 @@ -select_all('SELECT * FROM ' . WPT_DB_PREFIX . 'formulas'); - foreach ($rows as $row) { - $this->query( - 'UPDATE ' . WPT_DB_PREFIX . 'formulas SET formula_source = "' . - $this->quote_string(urldecode($row['formula_source'])) . - '" WHERE formula_id = ' . $row['formula_id'] - ); - } - } - - public function down() - { - // do nothing - } -} diff --git a/db/migrations/wp_testing/20141122130034_WpTesting_Migration_DecodeFormulasSource.php b/db/migrations/wp_testing/20141122130034_WpTesting_Migration_DecodeFormulasSource.php new file mode 100644 index 00000000..33baefe4 --- /dev/null +++ b/db/migrations/wp_testing/20141122130034_WpTesting_Migration_DecodeFormulasSource.php @@ -0,0 +1,22 @@ +selectAll('SELECT * FROM ' . $this->pluginPrefix . 'formulas'); + foreach ($rows as $row) { + $this->execute( + 'UPDATE ' . $this->pluginPrefix . 'formulas SET formula_source = "' . + $this->quoteString(urldecode($row['formula_source'])) . + '" WHERE formula_id = ' . $row['formula_id'] + ); + } + } + + public function down() + { + // do nothing + } +} diff --git a/db/migrations/wp_testing/20141126191658_SwitchToIndividualAnswers.php b/db/migrations/wp_testing/20141126191658_SwitchToIndividualAnswers.php deleted file mode 100644 index c02192c3..00000000 --- a/db/migrations/wp_testing/20141126191658_SwitchToIndividualAnswers.php +++ /dev/null @@ -1,246 +0,0 @@ -create_table(WPT_DB_PREFIX . 'answers', array( - 'id' => false, - 'options' => $this->get_table_engine_option(), - )); - $table->column('answer_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - 'primary_key' => true, - 'auto_increment' => true, - )); - $table->column('question_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - )); - $table->column('global_answer_id', 'biginteger', array( - 'unsigned' => true, - )); - $table->column('answer_title', 'text', array( - 'null' => true, - )); - $table->finish(); - - $global_prefix = WP_DB_PREFIX; - $plugin_prefix = WPT_DB_PREFIX; - $this->execute(" - ALTER TABLE {$plugin_prefix}answers - - ADD CONSTRAINT {$plugin_prefix}fk_answer_question - FOREIGN KEY (question_id) - REFERENCES {$plugin_prefix}questions (question_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_answer_question (question_id), - - ADD CONSTRAINT {$plugin_prefix}fk_answer_global_answer - FOREIGN KEY (global_answer_id) - REFERENCES {$global_prefix}terms (term_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_answer_global_answer (global_answer_id) - "); - - // fill-up wp_t_answers from tests and global answers - $this->execute(" - INSERT INTO {$plugin_prefix}answers - SELECT DISTINCT - NULL AS answer_id, - q.question_id AS question_id, - tt.term_id AS global_answer_id, - '' AS answer_title - FROM {$global_prefix}term_taxonomy AS tt - JOIN {$global_prefix}term_relationships AS tr ON tt.term_taxonomy_id = tr.term_taxonomy_id - AND tt.taxonomy = 'wpt_answer' - JOIN {$global_prefix}posts AS t ON tr.object_id = t.id - JOIN {$plugin_prefix}questions AS q ON q.test_id = t.id - ORDER BY q.question_id, tt.term_id - "); - - // backup wp_t_scores as a future table structure - $this->execute(" - DROP TABLE IF EXISTS {$plugin_prefix}scores_backup; - CREATE TABLE {$plugin_prefix}scores_backup AS - SELECT - a.answer_id AS answer_id, - scale_id AS scale_id, - score_value AS score_value - FROM - {$plugin_prefix}scores AS s, - {$plugin_prefix}answers AS a - WHERE TRUE - AND s.answer_id = a.global_answer_id - AND s.question_id = a.question_id - ; - "); - - // truncate scores - $this->execute("TRUNCATE TABLE {$plugin_prefix}scores"); - - // switch both scores and passing answers to wp_t_answers - $this->execute(" - ALTER TABLE {$plugin_prefix}passing_answers - DROP FOREIGN KEY {$plugin_prefix}fk_passing_answer_question, - DROP FOREIGN KEY {$plugin_prefix}fk_passing_answer_answer - ; - ALTER TABLE {$plugin_prefix}passing_answers - DROP COLUMN question_id, - DROP PRIMARY KEY, - ADD PRIMARY KEY (answer_id, passing_id), - DROP INDEX fk_passing_answer_question, - DROP INDEX fk_passing_answer_answer - ; - ALTER TABLE {$plugin_prefix}passing_answers - ADD CONSTRAINT {$plugin_prefix}fk_passing_answer_answer - FOREIGN KEY (answer_id) - REFERENCES {$plugin_prefix}answers (answer_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_passing_answer_answer (answer_id) - "); - $this->execute(" - ALTER TABLE {$plugin_prefix}scores - DROP FOREIGN KEY {$plugin_prefix}fk_score_question, - DROP FOREIGN KEY {$plugin_prefix}fk_score_answer - ; - ALTER TABLE {$plugin_prefix}scores - DROP COLUMN question_id, - DROP PRIMARY KEY, - ADD PRIMARY KEY (answer_id, scale_id), - DROP INDEX fk_score_question, - DROP INDEX fk_score_answer - ; - ALTER TABLE {$plugin_prefix}scores - ADD CONSTRAINT {$plugin_prefix}fk_score_answer - FOREIGN KEY (answer_id) - REFERENCES {$plugin_prefix}answers (answer_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_score_answer (answer_id) - "); - - // fill-up wp_t_scores from backup - $this->execute(" - INSERT INTO {$plugin_prefix}scores - SELECT * FROM {$plugin_prefix}scores_backup; - DROP TABLE {$plugin_prefix}scores_backup; - "); - } - - public function down() - { - $global_prefix = WP_DB_PREFIX; - $plugin_prefix = WPT_DB_PREFIX; - $questionOptions = array( - 'unsigned' => true, - 'null' => false, - 'after' => 'answer_id' - ); - - // backup wp_t_scores (for global answers) as an old table structure - $this->execute(" - DROP TABLE IF EXISTS {$plugin_prefix}scores_backup; - CREATE TABLE {$plugin_prefix}scores_backup AS - SELECT - a.global_answer_id AS answer_id, - a.question_id, - s.scale_id, - s.score_value - FROM - {$plugin_prefix}scores AS s - JOIN - {$plugin_prefix}answers AS a ON s.answer_id = a.answer_id - AND a.global_answer_id IS NOT NULL - "); - - // backup wp_t_passing_answers (for global answers) as an old table structure - $this->execute(" - DROP TABLE IF EXISTS {$plugin_prefix}passing_answers_backup; - CREATE TABLE {$plugin_prefix}passing_answers_backup AS - SELECT - a.global_answer_id AS answer_id, - a.question_id, - pa.passing_id - FROM - {$plugin_prefix}passing_answers AS pa - JOIN - {$plugin_prefix}answers AS a ON pa.answer_id = a.answer_id - AND a.global_answer_id IS NOT NULL - "); - - // truncate scores and passing_answers - $this->execute("TRUNCATE TABLE {$plugin_prefix}scores"); - $this->execute("TRUNCATE TABLE {$plugin_prefix}passing_answers"); - - // switch both scores and passing answers to global answers - $this->execute("ALTER TABLE {$plugin_prefix}scores DROP FOREIGN KEY {$plugin_prefix}fk_score_answer"); - $this->execute("ALTER TABLE {$plugin_prefix}scores DROP INDEX fk_score_answer"); - $this->add_column("{$plugin_prefix}scores", 'question_id', 'biginteger', $questionOptions); - $this->execute(" - ALTER TABLE {$plugin_prefix}scores - - DROP PRIMARY KEY, - ADD PRIMARY KEY(answer_id, question_id, scale_id), - - ADD CONSTRAINT {$plugin_prefix}fk_score_answer - FOREIGN KEY (answer_id) - REFERENCES {$global_prefix}terms (term_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_score_answer (answer_id), - - ADD CONSTRAINT {$plugin_prefix}fk_score_question - FOREIGN KEY (question_id) - REFERENCES {$plugin_prefix}questions (question_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_score_question (question_id) - "); - - $this->execute("ALTER TABLE {$plugin_prefix}passing_answers DROP FOREIGN KEY {$plugin_prefix}fk_passing_answer_answer"); - $this->execute("ALTER TABLE {$plugin_prefix}passing_answers DROP INDEX fk_passing_answer_answer"); - $this->add_column("{$plugin_prefix}passing_answers", 'question_id', 'biginteger', $questionOptions); - $this->execute(" - ALTER TABLE {$plugin_prefix}passing_answers - - DROP PRIMARY KEY, - ADD PRIMARY KEY(answer_id, question_id, passing_id), - - ADD CONSTRAINT {$plugin_prefix}fk_passing_answer_answer - FOREIGN KEY (answer_id) - REFERENCES {$global_prefix}terms (term_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_passing_answer_answer (answer_id), - - ADD CONSTRAINT {$plugin_prefix}fk_passing_answer_question - FOREIGN KEY (question_id) - REFERENCES {$plugin_prefix}questions (question_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_passing_answer_question (question_id) - "); - - // drop wp_t_answers - $this->execute("DROP TABLE {$plugin_prefix}answers"); - - // fill-up wp_t_scores/wp_t_passing_answers from backups - $this->execute(" - INSERT INTO {$plugin_prefix}scores - SELECT * FROM {$plugin_prefix}scores_backup; - DROP TABLE {$plugin_prefix}scores_backup; - "); - $this->execute(" - INSERT INTO {$plugin_prefix}passing_answers - SELECT * FROM {$plugin_prefix}passing_answers_backup; - DROP TABLE {$plugin_prefix}passing_answers_backup; - "); - } -} diff --git a/db/migrations/wp_testing/20141126191658_WpTesting_Migration_SwitchToIndividualAnswers.php b/db/migrations/wp_testing/20141126191658_WpTesting_Migration_SwitchToIndividualAnswers.php new file mode 100644 index 00000000..80f7ea35 --- /dev/null +++ b/db/migrations/wp_testing/20141126191658_WpTesting_Migration_SwitchToIndividualAnswers.php @@ -0,0 +1,216 @@ +createTable('answers') + ->addPrimaryKey('answer_id') + ->addForeignKey('question_id', array( + 'keyName' => 'fk_answer_question', + 'referencedTable' => "{$this->pluginPrefix}questions", + )) + ->addNullableForeignKey('global_answer_id', array( + 'keyName' => 'fk_answer_global_answer', + 'referencedTable' => "{$this->globalPrefix}terms", + 'referencedKey' => 'term_id', + )) + ->addColumnText('answer_title', array('null' => true)) + ->finish(); + + // fill-up wp_t_answers from tests and global answers + $this->execute(" + INSERT INTO {$this->pluginPrefix}answers + SELECT DISTINCT + NULL AS answer_id, + q.question_id AS question_id, + tt.term_id AS global_answer_id, + '' AS answer_title + FROM {$this->globalPrefix}term_taxonomy AS tt + JOIN {$this->globalPrefix}term_relationships AS tr ON tt.term_taxonomy_id = tr.term_taxonomy_id + AND tt.taxonomy = 'wpt_answer' + JOIN {$this->globalPrefix}posts AS t ON tr.object_id = t.id + JOIN {$this->pluginPrefix}questions AS q ON q.test_id = t.id + ORDER BY q.question_id, tt.term_id + "); + + // backup wp_t_scores as a future table structure + $this->execute(" + DROP TABLE IF EXISTS {$this->pluginPrefix}scores_backup; + CREATE TABLE {$this->pluginPrefix}scores_backup AS + SELECT + a.answer_id AS answer_id, + scale_id AS scale_id, + score_value AS score_value + FROM + {$this->pluginPrefix}scores AS s, + {$this->pluginPrefix}answers AS a + WHERE TRUE + AND s.answer_id = a.global_answer_id + AND s.question_id = a.question_id + ; + "); + + // truncate scores + $this->execute("TRUNCATE TABLE {$this->pluginPrefix}scores"); + + // switch both scores and passing answers to wp_t_answers + $this->execute(" + ALTER TABLE {$this->pluginPrefix}passing_answers + DROP FOREIGN KEY {$this->pluginPrefix}fk_passing_answer_question, + DROP FOREIGN KEY {$this->pluginPrefix}fk_passing_answer_answer + ; + ALTER TABLE {$this->pluginPrefix}passing_answers + DROP COLUMN question_id, + DROP PRIMARY KEY, + ADD PRIMARY KEY (answer_id, passing_id), + DROP INDEX fk_passing_answer_question, + DROP INDEX fk_passing_answer_answer + ; + ALTER TABLE {$this->pluginPrefix}passing_answers + ADD CONSTRAINT {$this->pluginPrefix}fk_passing_answer_answer + FOREIGN KEY (answer_id) + REFERENCES {$this->pluginPrefix}answers (answer_id) + ON DELETE CASCADE + ON UPDATE CASCADE, + ADD INDEX fk_passing_answer_answer (answer_id) + "); + $this->execute(" + ALTER TABLE {$this->pluginPrefix}scores + DROP FOREIGN KEY {$this->pluginPrefix}fk_score_question, + DROP FOREIGN KEY {$this->pluginPrefix}fk_score_answer + ; + ALTER TABLE {$this->pluginPrefix}scores + DROP COLUMN question_id, + DROP PRIMARY KEY, + ADD PRIMARY KEY (answer_id, scale_id), + DROP INDEX fk_score_question, + DROP INDEX fk_score_answer + ; + ALTER TABLE {$this->pluginPrefix}scores + ADD CONSTRAINT {$this->pluginPrefix}fk_score_answer + FOREIGN KEY (answer_id) + REFERENCES {$this->pluginPrefix}answers (answer_id) + ON DELETE CASCADE + ON UPDATE CASCADE, + ADD INDEX fk_score_answer (answer_id) + "); + + // fill-up wp_t_scores from backup + $this->execute(" + INSERT INTO {$this->pluginPrefix}scores + SELECT * FROM {$this->pluginPrefix}scores_backup; + DROP TABLE {$this->pluginPrefix}scores_backup; + "); + } + + public function down() + { + $questionOptions = array( + 'unsigned' => true, + 'null' => false, + 'after' => 'answer_id' + ); + + // backup wp_t_scores (for global answers) as an old table structure + $this->execute(" + DROP TABLE IF EXISTS {$this->pluginPrefix}scores_backup; + CREATE TABLE {$this->pluginPrefix}scores_backup AS + SELECT + a.global_answer_id AS answer_id, + a.question_id, + s.scale_id, + s.score_value + FROM + {$this->pluginPrefix}scores AS s + JOIN + {$this->pluginPrefix}answers AS a ON s.answer_id = a.answer_id + AND a.global_answer_id IS NOT NULL + "); + + // backup wp_t_passing_answers (for global answers) as an old table structure + $this->execute(" + DROP TABLE IF EXISTS {$this->pluginPrefix}passing_answers_backup; + CREATE TABLE {$this->pluginPrefix}passing_answers_backup AS + SELECT + a.global_answer_id AS answer_id, + a.question_id, + pa.passing_id + FROM + {$this->pluginPrefix}passing_answers AS pa + JOIN + {$this->pluginPrefix}answers AS a ON pa.answer_id = a.answer_id + AND a.global_answer_id IS NOT NULL + "); + + // truncate scores and passing_answers + $this->execute("TRUNCATE TABLE {$this->pluginPrefix}scores"); + $this->execute("TRUNCATE TABLE {$this->pluginPrefix}passing_answers"); + + // switch both scores and passing answers to global answers + $this->execute("ALTER TABLE {$this->pluginPrefix}scores DROP FOREIGN KEY {$this->pluginPrefix}fk_score_answer"); + $this->execute("ALTER TABLE {$this->pluginPrefix}scores DROP INDEX fk_score_answer"); + $this->addColumn("{$this->pluginPrefix}scores", 'question_id', 'biginteger', $questionOptions); + $this->execute(" + ALTER TABLE {$this->pluginPrefix}scores + + DROP PRIMARY KEY, + ADD PRIMARY KEY(answer_id, question_id, scale_id), + + ADD CONSTRAINT {$this->pluginPrefix}fk_score_answer + FOREIGN KEY (answer_id) + REFERENCES {$this->globalPrefix}terms (term_id) + ON DELETE CASCADE + ON UPDATE CASCADE, + ADD INDEX fk_score_answer (answer_id), + + ADD CONSTRAINT {$this->pluginPrefix}fk_score_question + FOREIGN KEY (question_id) + REFERENCES {$this->pluginPrefix}questions (question_id) + ON DELETE CASCADE + ON UPDATE CASCADE, + ADD INDEX fk_score_question (question_id) + "); + + $this->execute("ALTER TABLE {$this->pluginPrefix}passing_answers DROP FOREIGN KEY {$this->pluginPrefix}fk_passing_answer_answer"); + $this->execute("ALTER TABLE {$this->pluginPrefix}passing_answers DROP INDEX fk_passing_answer_answer"); + $this->addColumn("{$this->pluginPrefix}passing_answers", 'question_id', 'biginteger', $questionOptions); + $this->execute(" + ALTER TABLE {$this->pluginPrefix}passing_answers + + DROP PRIMARY KEY, + ADD PRIMARY KEY(answer_id, question_id, passing_id), + + ADD CONSTRAINT {$this->pluginPrefix}fk_passing_answer_answer + FOREIGN KEY (answer_id) + REFERENCES {$this->globalPrefix}terms (term_id) + ON DELETE CASCADE + ON UPDATE CASCADE, + ADD INDEX fk_passing_answer_answer (answer_id), + + ADD CONSTRAINT {$this->pluginPrefix}fk_passing_answer_question + FOREIGN KEY (question_id) + REFERENCES {$this->pluginPrefix}questions (question_id) + ON DELETE CASCADE + ON UPDATE CASCADE, + ADD INDEX fk_passing_answer_question (question_id) + "); + + // drop wp_t_answers + $this->execute("DROP TABLE {$this->pluginPrefix}answers"); + + // fill-up wp_t_scores/wp_t_passing_answers from backups + $this->execute(" + INSERT INTO {$this->pluginPrefix}scores + SELECT * FROM {$this->pluginPrefix}scores_backup; + DROP TABLE {$this->pluginPrefix}scores_backup; + "); + $this->execute(" + INSERT INTO {$this->pluginPrefix}passing_answers + SELECT * FROM {$this->pluginPrefix}passing_answers_backup; + DROP TABLE {$this->pluginPrefix}passing_answers_backup; + "); + } +} diff --git a/db/migrations/wp_testing/20150117155757_AddPassingDetails.php b/db/migrations/wp_testing/20150117155757_AddPassingDetails.php deleted file mode 100644 index ad29dc43..00000000 --- a/db/migrations/wp_testing/20150117155757_AddPassingDetails.php +++ /dev/null @@ -1,18 +0,0 @@ -add_column(WPT_DB_PREFIX . 'passings', 'ip', 'string', array('limit' => 45)); - $this->add_column(WPT_DB_PREFIX . 'passings', 'device_uuid', 'uuid'); - } - - public function down() - { - $this->remove_column(WPT_DB_PREFIX . 'passings', 'ip'); - $this->remove_column(WPT_DB_PREFIX . 'passings', 'device_uuid'); - } -} diff --git a/db/migrations/wp_testing/20150117155757_WpTesting_Migration_AddPassingDetails.php b/db/migrations/wp_testing/20150117155757_WpTesting_Migration_AddPassingDetails.php new file mode 100644 index 00000000..2b3a1ade --- /dev/null +++ b/db/migrations/wp_testing/20150117155757_WpTesting_Migration_AddPassingDetails.php @@ -0,0 +1,19 @@ + 'passings', + 'column' => 'ip', + 'type' => 'string', + 'options' => array('limit' => 45), + ), + array( + 'table' => 'passings', + 'column' => 'device_uuid', + 'type' => 'uuid', + ), + ); +} diff --git a/db/migrations/wp_testing/20150120194216_AddResultPageOptions.php b/db/migrations/wp_testing/20150120194216_AddResultPageOptions.php deleted file mode 100644 index 88d70d5d..00000000 --- a/db/migrations/wp_testing/20150120194216_AddResultPageOptions.php +++ /dev/null @@ -1,20 +0,0 @@ -add_meta('wpt_result_page_show_scales', 1); - $this->add_meta('wpt_result_page_show_test_description', 1); - } - - public function down() - { - $this->remove_meta('wpt_result_page_show_scales'); - $this->remove_meta('wpt_result_page_show_test_description'); - } - -} diff --git a/db/migrations/wp_testing/20150120194216_WpTesting_Migration_AddResultPageOptions.php b/db/migrations/wp_testing/20150120194216_WpTesting_Migration_AddResultPageOptions.php new file mode 100644 index 00000000..247f2ffa --- /dev/null +++ b/db/migrations/wp_testing/20150120194216_WpTesting_Migration_AddResultPageOptions.php @@ -0,0 +1,10 @@ + 1, + 'wpt_result_page_show_test_description' => 1, + ); +} diff --git a/db/migrations/wp_testing/20150131233053_AddUserAgentToPassing.php b/db/migrations/wp_testing/20150131233053_AddUserAgentToPassing.php deleted file mode 100644 index a695b062..00000000 --- a/db/migrations/wp_testing/20150131233053_AddUserAgentToPassing.php +++ /dev/null @@ -1,16 +0,0 @@ -add_column(WPT_DB_PREFIX . 'passings', 'user_agent', 'text'); - } - - public function down() - { - $this->remove_column(WPT_DB_PREFIX . 'passings', 'user_agent'); - } -} diff --git a/db/migrations/wp_testing/20150131233053_WpTesting_Migration_AddUserAgentToPassing.php b/db/migrations/wp_testing/20150131233053_WpTesting_Migration_AddUserAgentToPassing.php new file mode 100644 index 00000000..de4bb4b8 --- /dev/null +++ b/db/migrations/wp_testing/20150131233053_WpTesting_Migration_AddUserAgentToPassing.php @@ -0,0 +1,13 @@ + 'passings', + 'column' => 'user_agent', + 'type' => 'text', + ), + ); +} diff --git a/db/migrations/wp_testing/20150201011503_AddTestPageOptions.php b/db/migrations/wp_testing/20150201011503_AddTestPageOptions.php deleted file mode 100644 index 2a535012..00000000 --- a/db/migrations/wp_testing/20150201011503_AddTestPageOptions.php +++ /dev/null @@ -1,20 +0,0 @@ -add_meta('wpt_test_page_submit_button_caption', ''); - $this->add_meta('wpt_test_page_reset_answers_on_back', 0); - } - - public function down() - { - $this->remove_meta('wpt_test_page_submit_button_caption'); - $this->remove_meta('wpt_test_page_reset_answers_on_back'); - } - -} diff --git a/db/migrations/wp_testing/20150201011503_WpTesting_Migration_AddTestPageOptions.php b/db/migrations/wp_testing/20150201011503_WpTesting_Migration_AddTestPageOptions.php new file mode 100644 index 00000000..6dec4891 --- /dev/null +++ b/db/migrations/wp_testing/20150201011503_WpTesting_Migration_AddTestPageOptions.php @@ -0,0 +1,10 @@ + '', + 'wpt_test_page_reset_answers_on_back' => 0, + ); +} diff --git a/db/migrations/wp_testing/20150215143537_AddSortToAnswers.php b/db/migrations/wp_testing/20150215143537_AddSortToAnswers.php deleted file mode 100644 index 261506e1..00000000 --- a/db/migrations/wp_testing/20150215143537_AddSortToAnswers.php +++ /dev/null @@ -1,16 +0,0 @@ -add_column(WPT_DB_PREFIX . 'answers', 'answer_sort', 'integer', array('default' => 100)); - } - - public function down() - { - $this->remove_column(WPT_DB_PREFIX . 'answers', 'answer_sort'); - } -} diff --git a/db/migrations/wp_testing/20150215143537_WpTesting_Migration_AddSortToAnswers.php b/db/migrations/wp_testing/20150215143537_WpTesting_Migration_AddSortToAnswers.php new file mode 100644 index 00000000..97e2bf82 --- /dev/null +++ b/db/migrations/wp_testing/20150215143537_WpTesting_Migration_AddSortToAnswers.php @@ -0,0 +1,14 @@ + 'answers', + 'column' => 'answer_sort', + 'type' => 'integer', + 'options' => array('default' => 100) + ), + ); +} diff --git a/db/migrations/wp_testing/20150215150706_AddScalesSortOption.php b/db/migrations/wp_testing/20150215150706_AddScalesSortOption.php deleted file mode 100644 index 95d4858f..00000000 --- a/db/migrations/wp_testing/20150215150706_AddScalesSortOption.php +++ /dev/null @@ -1,18 +0,0 @@ -add_meta('wpt_result_page_sort_scales_by_score', 0); - } - - public function down() - { - $this->remove_meta('wpt_result_page_sort_scales_by_score'); - } - -} diff --git a/db/migrations/wp_testing/20150215150706_WpTesting_Migration_AddScalesSortOption.php b/db/migrations/wp_testing/20150215150706_WpTesting_Migration_AddScalesSortOption.php new file mode 100644 index 00000000..430c64ff --- /dev/null +++ b/db/migrations/wp_testing/20150215150706_WpTesting_Migration_AddScalesSortOption.php @@ -0,0 +1,7 @@ + 0); +} diff --git a/db/migrations/wp_testing/20150216181127_AddProgressMeterOption.php b/db/migrations/wp_testing/20150216181127_AddProgressMeterOption.php deleted file mode 100644 index fd597def..00000000 --- a/db/migrations/wp_testing/20150216181127_AddProgressMeterOption.php +++ /dev/null @@ -1,18 +0,0 @@ -add_meta('wpt_test_page_show_progress_meter', 0); - } - - public function down() - { - $this->remove_meta('wpt_test_page_show_progress_meter'); - } - -} diff --git a/db/migrations/wp_testing/20150216181127_WpTesting_Migration_AddProgressMeterOption.php b/db/migrations/wp_testing/20150216181127_WpTesting_Migration_AddProgressMeterOption.php new file mode 100644 index 00000000..619a83aa --- /dev/null +++ b/db/migrations/wp_testing/20150216181127_WpTesting_Migration_AddProgressMeterOption.php @@ -0,0 +1,7 @@ + 0); +} diff --git a/db/migrations/wp_testing/20150221150014_AddScalesDiagramOption.php b/db/migrations/wp_testing/20150221150014_AddScalesDiagramOption.php deleted file mode 100644 index c4301265..00000000 --- a/db/migrations/wp_testing/20150221150014_AddScalesDiagramOption.php +++ /dev/null @@ -1,18 +0,0 @@ -add_meta('wpt_result_page_show_scales_diagram', 0); - } - - public function down() - { - $this->remove_meta('wpt_result_page_show_scales_diagram'); - } - -} diff --git a/db/migrations/wp_testing/20150221150014_WpTesting_Migration_AddScalesDiagramOption.php b/db/migrations/wp_testing/20150221150014_WpTesting_Migration_AddScalesDiagramOption.php new file mode 100644 index 00000000..5a4830c5 --- /dev/null +++ b/db/migrations/wp_testing/20150221150014_WpTesting_Migration_AddScalesDiagramOption.php @@ -0,0 +1,7 @@ + 0); +} diff --git a/db/migrations/wp_testing/20150228141341_AddMultipleAnswersOption.php b/db/migrations/wp_testing/20150228141341_AddMultipleAnswersOption.php deleted file mode 100644 index 585ab166..00000000 --- a/db/migrations/wp_testing/20150228141341_AddMultipleAnswersOption.php +++ /dev/null @@ -1,18 +0,0 @@ -add_meta('wpt_test_page_multiple_answers', 0); - } - - public function down() - { - $this->remove_meta('wpt_test_page_multiple_answers'); - } - -} diff --git a/db/migrations/wp_testing/20150228141341_WpTesting_Migration_AddMultipleAnswersOption.php b/db/migrations/wp_testing/20150228141341_WpTesting_Migration_AddMultipleAnswersOption.php new file mode 100644 index 00000000..51268146 --- /dev/null +++ b/db/migrations/wp_testing/20150228141341_WpTesting_Migration_AddMultipleAnswersOption.php @@ -0,0 +1,7 @@ + 0); +} diff --git a/db/migrations/wp_testing/20150308201857_EnableAdvancedOptionsForDefaultTest.php b/db/migrations/wp_testing/20150308201857_EnableAdvancedOptionsForDefaultTest.php deleted file mode 100644 index cc0dc06f..00000000 --- a/db/migrations/wp_testing/20150308201857_EnableAdvancedOptionsForDefaultTest.php +++ /dev/null @@ -1,22 +0,0 @@ -update_meta_in_example('wpt_result_page_show_test_description', 0); - $this->update_meta_in_example('wpt_test_page_show_progress_meter', 1); - $this->update_meta_in_example('wpt_result_page_show_scales_diagram', 0); - } - - public function down() - { - $this->update_meta_in_example('wpt_result_page_show_test_description', 1); - $this->update_meta_in_example('wpt_test_page_show_progress_meter', 0); - $this->update_meta_in_example('wpt_result_page_show_scales_diagram', 0); - } - -} diff --git a/db/migrations/wp_testing/20150308201857_WpTesting_Migration_EnableAdvancedOptionsForDefaultTest.php b/db/migrations/wp_testing/20150308201857_WpTesting_Migration_EnableAdvancedOptionsForDefaultTest.php new file mode 100644 index 00000000..acee964a --- /dev/null +++ b/db/migrations/wp_testing/20150308201857_WpTesting_Migration_EnableAdvancedOptionsForDefaultTest.php @@ -0,0 +1,32 @@ +updateMetaInExample('wpt_result_page_show_test_description', 0); + $this->updateMetaInExample('wpt_test_page_show_progress_meter', 1); + $this->updateMetaInExample('wpt_result_page_show_scales_diagram', 0); + } + + public function down() + { + $this->updateMetaInExample('wpt_result_page_show_test_description', 1); + $this->updateMetaInExample('wpt_test_page_show_progress_meter', 0); + $this->updateMetaInExample('wpt_result_page_show_scales_diagram', 0); + } + + protected function updateMetaInExample($key, $value) + { + $this->execute(" + UPDATE {$this->globalPrefix}posts AS p, {$this->globalPrefix}postmeta AS m + SET m.meta_value = '$value' + WHERE TRUE + AND m.meta_key = '$key' + AND p.post_type = 'wpt_test' + AND p.post_title = 'Eysenck’s Personality Inventory (EPI) (Extroversion/Introversion)' + AND m.post_id = p.ID + "); + } +} diff --git a/db/migrations/wp_testing/20150320053524_CleanUpExperimentalMigrations.php b/db/migrations/wp_testing/20150320053524_WpTesting_Migration_CleanUpExperimentalMigrations.php similarity index 83% rename from db/migrations/wp_testing/20150320053524_CleanUpExperimentalMigrations.php rename to db/migrations/wp_testing/20150320053524_WpTesting_Migration_CleanUpExperimentalMigrations.php index ba012798..31943f5d 100644 --- a/db/migrations/wp_testing/20150320053524_CleanUpExperimentalMigrations.php +++ b/db/migrations/wp_testing/20150320053524_WpTesting_Migration_CleanUpExperimentalMigrations.php @@ -1,6 +1,6 @@ drop_table(WPT_DB_PREFIX . 'sections'); - $table = $this->create_table(WPT_DB_PREFIX . 'sections', array( - 'id' => false, - 'options' => $this->get_table_engine_option(), - )); - $table->column('section_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - 'primary_key' => true, - 'auto_increment' => true, - )); - $table->column('test_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - )); - $table->column('question_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - )); - $table->column('section_title', 'text', array( - 'null' => false, - )); - $table->finish(); - - $global_prefix = WP_DB_PREFIX; - $plugin_prefix = WPT_DB_PREFIX; - $this->execute(" - ALTER TABLE {$plugin_prefix}sections - - ADD CONSTRAINT {$plugin_prefix}fk_section_test - FOREIGN KEY (test_id) - REFERENCES {$global_prefix}posts (ID) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_section_test (test_id), - - ADD CONSTRAINT {$plugin_prefix}fk_section_question - FOREIGN KEY (question_id) - REFERENCES {$plugin_prefix}questions (question_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_section_question (question_id), - - ADD UNIQUE INDEX uq_section_test_question (test_id, question_id) - "); - } - - public function down() - { - $this->drop_table(WPT_DB_PREFIX . 'sections'); - } -} diff --git a/db/migrations/wp_testing/20150324041508_WpTesting_Migration_AddSectionsTable.php b/db/migrations/wp_testing/20150324041508_WpTesting_Migration_AddSectionsTable.php new file mode 100644 index 00000000..5dbac77a --- /dev/null +++ b/db/migrations/wp_testing/20150324041508_WpTesting_Migration_AddSectionsTable.php @@ -0,0 +1,23 @@ +addForeignKeyToTest($table); + $table + ->addForeignKey('question_id', array( + 'keyName' => 'fk_section_question', + 'referencedTable' => "{$this->pluginPrefix}questions", + 'referencedKey' => 'question_id', + )) + ->addColumnText('section_title') + ->addIndexUnique('uq_section_test_question', array( + 'test_id', + 'question_id' + )); + } +} diff --git a/db/migrations/wp_testing/20150426194928_AddFieldsTables.php b/db/migrations/wp_testing/20150426194928_AddFieldsTables.php deleted file mode 100644 index 5b86d27e..00000000 --- a/db/migrations/wp_testing/20150426194928_AddFieldsTables.php +++ /dev/null @@ -1,112 +0,0 @@ -drop_table(WPT_DB_PREFIX . 'field_values'); - $this->drop_table(WPT_DB_PREFIX . 'fields'); - - // Fields - $table = $this->create_table(WPT_DB_PREFIX . 'fields', array( - 'id' => false, - 'options' => $this->get_table_engine_option(), - )); - $table->column('field_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - 'primary_key' => true, - 'auto_increment' => true, - )); - $table->column('test_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - )); - $table->column('field_title', 'text', array( - 'null' => false, - )); - $table->column('field_type', 'string', array( - 'null' => false, - )); - $table->column('field_is_required', 'boolean', array( - 'null' => false, - 'default' => 1, - )); - $table->column('field_sort', 'integer', array( - 'null' => false, - 'default' => 100, - )); - $table->column('field_clarification', 'text'); - $table->column('field_list_values', 'text'); - $table->column('field_default_value', 'text'); - $table->finish(); - - $global_prefix = WP_DB_PREFIX; - $plugin_prefix = WPT_DB_PREFIX; - $this->execute(" - ALTER TABLE {$plugin_prefix}fields - - ADD CONSTRAINT {$plugin_prefix}fk_field_test - FOREIGN KEY (test_id) - REFERENCES {$global_prefix}posts (ID) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_field_test (test_id) - "); - - // Fields values - $table = $this->create_table(WPT_DB_PREFIX . 'field_values', array( - 'id' => false, - 'options' => $this->get_table_engine_option(), - )); - $table->column('field_value_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - 'primary_key' => true, - 'auto_increment' => true, - )); - $table->column('field_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - )); - $table->column('passing_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - )); - $table->column('field_value', 'text'); - $table->finish(); - - $this->execute(" - ALTER TABLE {$plugin_prefix}field_values - - ADD CONSTRAINT {$plugin_prefix}fk_field_value_field - FOREIGN KEY (field_id) - REFERENCES {$plugin_prefix}fields (field_id) - ON DELETE RESTRICT - ON UPDATE CASCADE, - ADD INDEX fk_field_value_field (field_id), - - ADD CONSTRAINT {$plugin_prefix}fk_field_value_passing - FOREIGN KEY (passing_id) - REFERENCES {$plugin_prefix}passings (passing_id) - ON DELETE CASCADE - ON UPDATE CASCADE, - ADD INDEX fk_field_value_passing (passing_id) - "); - } - - public function down() - { - $plugin_prefix = WPT_DB_PREFIX; - $this->execute(" - SET FOREIGN_KEY_CHECKS = 0; - TRUNCATE TABLE {$plugin_prefix}field_values; - TRUNCATE TABLE {$plugin_prefix}fields; - SET FOREIGN_KEY_CHECKS = 1; - "); - $this->drop_table($plugin_prefix . 'field_values'); - $this->drop_table($plugin_prefix . 'fields'); - } -} diff --git a/db/migrations/wp_testing/20150426194928_WpTesting_Migration_AddFieldsTables.php b/db/migrations/wp_testing/20150426194928_WpTesting_Migration_AddFieldsTables.php new file mode 100644 index 00000000..fa7e6a4e --- /dev/null +++ b/db/migrations/wp_testing/20150426194928_WpTesting_Migration_AddFieldsTables.php @@ -0,0 +1,54 @@ + true); + + // Fields + $this->createTable('fields') + ->addPrimaryKey('field_id') + ->addForeignKey('test_id', array( + 'keyName' => 'fk_field_test', + 'referencedTable' => "{$this->globalPrefix}posts", + 'referencedKey' => 'ID', + )) + ->addColumnText('field_title') + ->addColumnString('field_type') + ->addColumnBoolean('field_is_required', array('default' => 1)) + ->addColumnInteger('field_sort', array('default' => 100)) + ->addColumnText('field_clarification', $nullable) + ->addColumnText('field_list_values', $nullable) + ->addColumnText('field_default_value', $nullable) + ->finish(); + + // Fields values + $this->createTable('field_values') + ->addPrimaryKey('field_value_id') + ->addForeignKey('field_id', array( + 'keyName' => 'fk_field_value_field', + 'referencedTable' => "{$this->pluginPrefix}fields", + 'onDelete' => 'RESTRICT' + )) + ->addForeignKey('passing_id', array( + 'keyName' => 'fk_field_value_passing', + 'referencedTable' => "{$this->pluginPrefix}passings" + )) + ->addColumnText('field_value', $nullable) + ->finish(); + } + + public function down() + { + $this->execute(" + SET FOREIGN_KEY_CHECKS = 0; + TRUNCATE TABLE {$this->pluginPrefix}field_values; + TRUNCATE TABLE {$this->pluginPrefix}fields; + SET FOREIGN_KEY_CHECKS = 1; + "); + $this->dropTable('field_values'); + $this->dropTable('fields'); + } +} diff --git a/db/migrations/wp_testing/20150510175539_AddLinkInDemoTest.php b/db/migrations/wp_testing/20150510175539_WpTesting_Migration_AddLinkInDemoTest.php similarity index 86% rename from db/migrations/wp_testing/20150510175539_AddLinkInDemoTest.php rename to db/migrations/wp_testing/20150510175539_WpTesting_Migration_AddLinkInDemoTest.php index d5430432..d281bb15 100644 --- a/db/migrations/wp_testing/20150510175539_AddLinkInDemoTest.php +++ b/db/migrations/wp_testing/20150510175539_WpTesting_Migration_AddLinkInDemoTest.php @@ -1,11 +1,11 @@ globalPrefix . 'posts'; $this->execute(" UPDATE $posts SET post_content = CONCAT(post_content, '\\n\\n

This test is a demonstration of psychological tests plugin.

') @@ -17,7 +17,7 @@ public function up() public function down() { - $posts = WP_DB_PREFIX . 'posts'; + $posts = $this->globalPrefix . 'posts'; $this->execute(" UPDATE $posts SET post_content = TRIM(REPLACE(post_content, '

This test is a demonstration of psychological tests plugin.

', '')) diff --git a/db/migrations/wp_testing/20150530145555_RenamePassingColumnsInWpStyle.php b/db/migrations/wp_testing/20150530145555_RenamePassingColumnsInWpStyle.php deleted file mode 100644 index ca62036b..00000000 --- a/db/migrations/wp_testing/20150530145555_RenamePassingColumnsInWpStyle.php +++ /dev/null @@ -1,29 +0,0 @@ -rename_columns('', 'passing_'); - } - - public function down() - { - $this->rename_columns('passing_', ''); - } - - private function rename_columns($old_prefix, $new_prefix) - { - $columns = array( - 'created', - 'modified', - 'ip', - 'device_uuid', - 'user_agent', - ); - - foreach ($columns as $column) { - $this->rename_column(WPT_DB_PREFIX . 'passings', $old_prefix . $column, $new_prefix . $column); - } - } -} diff --git a/db/migrations/wp_testing/20150530145555_WpTesting_Migration_RenamePassingColumnsInWpStyle.php b/db/migrations/wp_testing/20150530145555_WpTesting_Migration_RenamePassingColumnsInWpStyle.php new file mode 100644 index 00000000..76ec7194 --- /dev/null +++ b/db/migrations/wp_testing/20150530145555_WpTesting_Migration_RenamePassingColumnsInWpStyle.php @@ -0,0 +1,29 @@ +renameColumns('', 'passing_'); + } + + public function down() + { + $this->renameColumns('passing_', ''); + } + + private function renameColumns($oldPrefix, $newPrefix) + { + $columns = array( + 'created', + 'modified', + 'ip', + 'device_uuid', + 'user_agent', + ); + + foreach ($columns as $column) { + $this->renameColumn($this->pluginPrefix . 'passings', $oldPrefix . $column, $newPrefix . $column); + } + } +} diff --git a/db/migrations/wp_testing/20150530160000_AddStatusToPassings.php b/db/migrations/wp_testing/20150530160000_AddStatusToPassings.php deleted file mode 100644 index 6af12874..00000000 --- a/db/migrations/wp_testing/20150530160000_AddStatusToPassings.php +++ /dev/null @@ -1,32 +0,0 @@ - 'respondent_id', - 'values' => array('publish', 'trash'), - 'default' => 'publish', - 'null' => false, - ); - $this->add_column(WPT_DB_PREFIX . 'passings', 'passing_status', 'enum', $options); - - $plugin_prefix = WPT_DB_PREFIX; - $this->execute(" - ALTER TABLE {$plugin_prefix}passings - ADD INDEX i_passing_status_created_id (passing_status, passing_created, passing_id) - "); - } - - public function down() - { - $plugin_prefix = WPT_DB_PREFIX; - $this->execute(" - ALTER TABLE {$plugin_prefix}passings - DROP INDEX i_passing_status_created_id - "); - $this->remove_column(WPT_DB_PREFIX . 'passings', 'passing_status'); - } -} diff --git a/db/migrations/wp_testing/20150530160000_WpTesting_Migration_AddStatusToPassings.php b/db/migrations/wp_testing/20150530160000_WpTesting_Migration_AddStatusToPassings.php new file mode 100644 index 00000000..b84ad439 --- /dev/null +++ b/db/migrations/wp_testing/20150530160000_WpTesting_Migration_AddStatusToPassings.php @@ -0,0 +1,34 @@ + 'passings', + 'column' => 'passing_status', + 'type' => 'enum', + 'options' => array( + 'after' => 'respondent_id', + 'values' => array('publish', 'trash'), + 'default' => 'publish', + 'null' => false, + ) + ), + ); + + private $indexColumns = array('passing_status', 'passing_created', 'passing_id'); + private $indexOptions = array('name' => 'i_passing_status_created_id'); + + public function up() + { + parent::up(); + $this->addIndex('passings', $this->indexColumns, $this->indexOptions); + } + + public function down() + { + $this->removeIndex('passings', $this->indexColumns, $this->indexOptions); + parent::down(); + } +} diff --git a/db/migrations/wp_testing/20150614145310_NullifySectionQuestion.php b/db/migrations/wp_testing/20150614145310_NullifySectionQuestion.php deleted file mode 100644 index 1b3313e8..00000000 --- a/db/migrations/wp_testing/20150614145310_NullifySectionQuestion.php +++ /dev/null @@ -1,20 +0,0 @@ -change_column(WPT_DB_PREFIX . 'sections', 'question_id', 'biginteger', array( - 'unsigned' => true, - 'null' => true, - )); - } - - public function down() - { - $this->change_column(WPT_DB_PREFIX . 'sections', 'question_id', 'biginteger', array( - 'unsigned' => true, - 'null' => false, - )); - } -} diff --git a/db/migrations/wp_testing/20150614145310_WpTesting_Migration_NullifySectionQuestion.php b/db/migrations/wp_testing/20150614145310_WpTesting_Migration_NullifySectionQuestion.php new file mode 100644 index 00000000..bb48490c --- /dev/null +++ b/db/migrations/wp_testing/20150614145310_WpTesting_Migration_NullifySectionQuestion.php @@ -0,0 +1,10 @@ + true); +} diff --git a/db/migrations/wp_testing/20150804182815_AllowSectionQuestionsDuplicates.php b/db/migrations/wp_testing/20150804182815_AllowSectionQuestionsDuplicates.php deleted file mode 100644 index 4c984330..00000000 --- a/db/migrations/wp_testing/20150804182815_AllowSectionQuestionsDuplicates.php +++ /dev/null @@ -1,22 +0,0 @@ -execute(" - ALTER TABLE {$plugin_prefix}sections - DROP INDEX uq_section_test_question - "); - } - - public function down() - { - $plugin_prefix = WPT_DB_PREFIX; - $this->execute(" - ALTER TABLE {$plugin_prefix}sections - ADD UNIQUE INDEX uq_section_test_question (test_id, question_id) - "); - } -} diff --git a/db/migrations/wp_testing/20150804182815_WpTesting_Migration_AllowSectionQuestionsDuplicates.php b/db/migrations/wp_testing/20150804182815_WpTesting_Migration_AllowSectionQuestionsDuplicates.php new file mode 100644 index 00000000..3db161b2 --- /dev/null +++ b/db/migrations/wp_testing/20150804182815_WpTesting_Migration_AllowSectionQuestionsDuplicates.php @@ -0,0 +1,18 @@ + 'uq_section_test_question', 'unique' => true); + + public function up() + { + $this->removeIndex('sections', $this->indexColumns, $this->indexOptions); + } + + public function down() + { + $this->addIndex('sections', $this->indexColumns, $this->indexOptions); + } +} diff --git a/db/migrations/wp_testing/20150806190742_NullifySectionTitle.php b/db/migrations/wp_testing/20150806190742_NullifySectionTitle.php deleted file mode 100644 index a3c03cf6..00000000 --- a/db/migrations/wp_testing/20150806190742_NullifySectionTitle.php +++ /dev/null @@ -1,22 +0,0 @@ -nullify_section_title(true); - } - - public function down() - { - $this->nullify_section_title(false); - } - - private function nullify_section_title($to) - { - $this->change_column(WPT_DB_PREFIX . 'sections', 'section_title', 'text', array( - 'null' => $to - )); - } -} diff --git a/db/migrations/wp_testing/20150806190742_WpTesting_Migration_NullifySectionTitle.php b/db/migrations/wp_testing/20150806190742_WpTesting_Migration_NullifySectionTitle.php new file mode 100644 index 00000000..d623046b --- /dev/null +++ b/db/migrations/wp_testing/20150806190742_WpTesting_Migration_NullifySectionTitle.php @@ -0,0 +1,9 @@ +add_column(WPT_DB_PREFIX . 'sections', 'section_description', 'mediumtext'); - } - - public function down() - { - $this->remove_column(WPT_DB_PREFIX . 'sections', 'section_description'); - } -} diff --git a/db/migrations/wp_testing/20150807044411_WpTesting_Migration_AddSectionDescription.php b/db/migrations/wp_testing/20150807044411_WpTesting_Migration_AddSectionDescription.php new file mode 100644 index 00000000..bed5b9c8 --- /dev/null +++ b/db/migrations/wp_testing/20150807044411_WpTesting_Migration_AddSectionDescription.php @@ -0,0 +1,13 @@ + 'sections', + 'column' => 'section_description', + 'type' => 'mediumtext', + ), + ); +} diff --git a/db/migrations/wp_testing/20150808133733_DecimalizeScores.php b/db/migrations/wp_testing/20150808133733_WpTesting_Migration_DecimalizeScores.php similarity index 52% rename from db/migrations/wp_testing/20150808133733_DecimalizeScores.php rename to db/migrations/wp_testing/20150808133733_WpTesting_Migration_DecimalizeScores.php index c62010a8..1e4a5c39 100644 --- a/db/migrations/wp_testing/20150808133733_DecimalizeScores.php +++ b/db/migrations/wp_testing/20150808133733_WpTesting_Migration_DecimalizeScores.php @@ -1,11 +1,11 @@ change_column(WPT_DB_PREFIX . 'scores', 'score_value', 'decimal', array( + $this->changeColumn($this->pluginPrefix . 'scores', 'score_value', 'decimal', array( 'precision' => 6, 'scale' => 3, 'null' => false, @@ -15,7 +15,7 @@ public function up() public function down() { - $this->change_column(WPT_DB_PREFIX . 'scores', 'score_value', 'tinyinteger', array( + $this->changeColumn($this->pluginPrefix . 'scores', 'score_value', 'tinyinteger', array( 'null' => false, 'default' => 0, )); diff --git a/db/migrations/wp_testing/Base/AddColumn.php b/db/migrations/wp_testing/Base/AddColumn.php new file mode 100644 index 00000000..3e98cec3 --- /dev/null +++ b/db/migrations/wp_testing/Base/AddColumn.php @@ -0,0 +1,26 @@ + .., column => .., type => .., options => ..]] + * @var array + */ + protected $columns = array(); + + public function up() + { + foreach ($this->columns as $column) { + $column += array('options' => array()); + $this->addColumn($this->pluginPrefix . $column['table'], $column['column'], $column['type'], $column['options']); + } + } + + public function down() + { + foreach ($this->columns as $column) { + $this->removeColumn($this->pluginPrefix . $column['table'], $column['column']); + } + } +} diff --git a/db/migrations/wp_testing/Base/AddMeta.php b/db/migrations/wp_testing/Base/AddMeta.php new file mode 100644 index 00000000..7b784f4e --- /dev/null +++ b/db/migrations/wp_testing/Base/AddMeta.php @@ -0,0 +1,42 @@ + default value + * @var array + */ + protected $metas = array(); + + public function up() + { + foreach ($this->metas as $key => $value) { + $this->addMeta($key, $value); + } + } + + public function down() + { + foreach (array_keys($this->metas) as $key) { + $this->removeMeta($key); + } + } + + protected function addMeta($key, $value) + { + $this->execute(" + INSERT INTO {$this->globalPrefix}postmeta(post_id, meta_key, meta_value) + SELECT ID, '$key', '$value' + FROM {$this->globalPrefix}posts WHERE post_type = 'wpt_test' + "); + } + + protected function removeMeta($key) + { + $this->execute(" + DELETE FROM {$this->globalPrefix}postmeta + WHERE meta_key = '$key' + "); + } +} diff --git a/db/migrations/wp_testing/Base/AddSingleTable.php b/db/migrations/wp_testing/Base/AddSingleTable.php new file mode 100644 index 00000000..3874ed41 --- /dev/null +++ b/db/migrations/wp_testing/Base/AddSingleTable.php @@ -0,0 +1,38 @@ +createTable($this->entity . 's')->addPrimaryKey($this->entity . '_id'); + $this->setUpTable($table); + $table->finish(); + } + + public function down() + { + $this->dropTable($this->entity . 's'); + } + + /** + * @param WpTesting_Migration_TableDefinition $table + * @return void + */ + protected function addForeignKeyToTest($table) + { + $table->addForeignKey('test_id', array( + 'keyName' => "fk_{$this->entity}_test", + 'referencedTable' => "{$this->globalPrefix}posts", + 'referencedKey' => 'ID', + )); + } + + /** + * @param WpTesting_Migration_TableDefinition $table + * @return void + */ + abstract protected function setUpTable($table); +} diff --git a/db/migrations/wp_testing/Base/Base.php b/db/migrations/wp_testing/Base/Base.php new file mode 100644 index 00000000..04d3a3a2 --- /dev/null +++ b/db/migrations/wp_testing/Base/Base.php @@ -0,0 +1,47 @@ +adaptee = new Ruckusing_Migration_Base($dbAdapter); + $this->setUp(); + } + + /** + * @return void + */ + protected function setUp() + { + $this->globalPrefix = WP_DB_PREFIX; + $this->pluginPrefix = WPT_DB_PREFIX; + } + + /** + * @return void + */ + abstract public function up(); + + /** + * @return void + */ + abstract public function down(); + + public function execute($query) + { + return $this->adaptee->execute($query); + } +} diff --git a/db/migrations/wp_testing/Base/MigrateColumn.php b/db/migrations/wp_testing/Base/MigrateColumn.php new file mode 100644 index 00000000..a9710916 --- /dev/null +++ b/db/migrations/wp_testing/Base/MigrateColumn.php @@ -0,0 +1,92 @@ +adaptee->rename_column($tableName, $columnName, $newColumnName); + } + + /** + * Add a column + * + * @param string $tableName the name of the table + * @param string $columnName the column name + * @param string $type the column type + * @param array|string $options + * + * @return boolean + */ + protected function addColumn($tableName, $columnName, $type, $options = array()) + { + return $this->adaptee->add_column($tableName, $columnName, $type, $options); + } + + /** + * Remove a column + * + * @param string $tableName the name of the table + * @param string $columnName the column name + * + * @return boolean + */ + protected function removeColumn($tableName, $columnName) + { + return $this->adaptee->remove_column($tableName, $columnName); + } + + /** + * Change a column + * + * @param string $tableName the name of the table + * @param string $columnName the column name + * @param string $type the column type + * @param array|string $options + * + * @return boolean + */ + protected function changeColumn($tableName, $columnName, $type, $options = array()) + { + return $this->adaptee->change_column($tableName, $columnName, $type, $options); + } + + /** + * Add an index + * + * @param string $tableName the name of the table + * @param array|string $columnName the column name(-s) + * @param array|string $options [name, unique] + * + * @return boolean + */ + protected function addIndex($tableName, $columnName, $options = array()) + { + $tableName = $this->pluginPrefix . $tableName; + return $this->adaptee->add_index($tableName, $columnName, $options); + } + + /** + * Remove an index + * + * @param string $tableName the name of the table + * @param array|string $columnName the column name(-s) + * @param array|string $options [name] + * + * @return boolean + */ + protected function removeIndex($tableName, $columnName, $options = array()) + { + $tableName = $this->pluginPrefix . $tableName; + return $this->adaptee->remove_index($tableName, $columnName, $options); + } +} diff --git a/db/migrations/wp_testing/Base/MigrateTable.php b/db/migrations/wp_testing/Base/MigrateTable.php new file mode 100644 index 00000000..3199a452 --- /dev/null +++ b/db/migrations/wp_testing/Base/MigrateTable.php @@ -0,0 +1,74 @@ +adaptee->get_adapter(); + if (!($adapter instanceof Ruckusing_Adapter_MySQL_Base)) { + throw new Ruckusing_Exception('Only MySQL adapter allowed'); + } + $tableName = $this->pluginPrefix . $tableName; + $options += array( + 'id' => false, + 'options' => $this->getTableEngineOption(), + 'pluginPrefix' => $this->pluginPrefix, + ); + + return new WpTesting_Migration_TableDefinition($adapter, $tableName, $options); + } + + /** + * Drop a table + * + * @param string $tableName the name of the table + * + * @return boolean + */ + public function dropTable($tableName) + { + return $this->adaptee->drop_table($this->pluginPrefix . $tableName); + } + + /** + * Get default wordpress tables engine + * @return string + */ + private function getTableEngineOption() + { + try { + return 'ENGINE=' . $this->getWpTableEngine(); + } catch (Exception $e) { + $this->adaptee->get_adapter()->logger->log('Engine option is unknown: ' . $e->getMessage()); + } + return ''; + } + + /** + * Get default wordpress tables engine + * + * @throws Ruckusing_Exception + * @return string + */ + private function getWpTableEngine() + { + $status = $this->adaptee->select_one("SHOW TABLE STATUS LIKE '{$this->globalPrefix}posts'"); + + if (empty($status['Engine'])) { + throw new Ruckusing_Exception( + 'Default WP table is missing or it has unknown engine', + Ruckusing_Exception::INVALID_TABLE_DEFINITION + ); + } + + return $status['Engine']; + } +} diff --git a/db/migrations/wp_testing/Base/NullifyColumn.php b/db/migrations/wp_testing/Base/NullifyColumn.php new file mode 100644 index 00000000..2755a110 --- /dev/null +++ b/db/migrations/wp_testing/Base/NullifyColumn.php @@ -0,0 +1,27 @@ +nullifyColumn(true); + } + + public function down() + { + $this->nullifyColumn(false); + } + + private function nullifyColumn($to) + { + $this->changeColumn($this->pluginPrefix . $this->tableName, $this->columnName, $this->columnType, array( + 'null' => $to + ) + $this->columnOptions); + } +} diff --git a/db/migrations/wp_testing/Base/TableDefinition.php b/db/migrations/wp_testing/Base/TableDefinition.php new file mode 100644 index 00000000..3cb9fdfd --- /dev/null +++ b/db/migrations/wp_testing/Base/TableDefinition.php @@ -0,0 +1,173 @@ +dbAdapter = $adapter; + $this->tableName = $name; + $this->pluginPrefix = $options['pluginPrefix']; + } + + public function addPrimaryKey($columnName, $options = array()) + { + return $this->addKey($columnName, $options + array( + 'primary_key' => true, + 'auto_increment' => true, + )); + } + + public function addForeignKey($columnName, $options = array()) + { + $options += array( + 'referencedKey' => $columnName, + 'onDelete' => 'CASCADE', + 'onUpdate' => 'CASCADE', + ); + return $this + ->addKey($columnName, $options) + ->addConstraintForeignKey( + $options['keyName'], $columnName, + $options['referencedTable'], $options['referencedKey'], + $options['onDelete'], $options['onUpdate']) + ->addIndex($options['keyName'], array($columnName)) + ; + } + + private function addKey($columnName, $options = array()) + { + return $this->addColumnIntegerBig($columnName, $options + array( + 'unsigned' => true, + )); + } + + public function addNullableForeignKey($columnName, $options = array()) + { + return $this->addForeignKey($columnName, $options + array( + 'null' => true, + )); + } + + public function addColumnIntegerTiny($columnName, $options = array()) + { + return $this->column($columnName, 'tinyinteger', $options); + } + + public function addColumnInteger($columnName, $options = array()) + { + return $this->column($columnName, 'integer', $options); + } + + public function addColumnIntegerBig($columnName, $options = array()) + { + return $this->column($columnName, 'biginteger', $options); + } + + public function addColumnBoolean($columnName, $options = array()) + { + return $this->column($columnName, 'boolean', $options); + } + + public function addColumnDateTime($columnName, $options = array()) + { + return $this->column($columnName, 'datetime', $options); + } + + public function addColumnString($columnName, $options = array()) + { + return $this->column($columnName, 'string', $options); + } + + public function addColumnText($columnName, $options = array()) + { + return $this->column($columnName, 'text', $options); + } + + private function addConstraintForeignKey($name, $key, $referencedTable, $referencedKey, $onDelete = 'CASCADE', $onUpdate = 'CASCADE') + { + $name = $this->pluginPrefix . $name; + $this->alterTableDefinitions[] = " + ADD CONSTRAINT $name + FOREIGN KEY ($key) + REFERENCES $referencedTable($referencedKey) + ON DELETE $onDelete + ON UPDATE $onUpdate + "; + + return $this; + } + + /** + * @param string $name + * @param array $columns + * @param string $options + * @return self + */ + public function addIndex($name, $columns, $options = '') + { + $columns = implode(', ', $columns); + $this->alterTableDefinitions[] = " + ADD $options INDEX $name($columns) + "; + + return $this; + } + + /** + * @param string $name + * @param array $columns + * @return self + */ + public function addIndexUnique($name, $columns) + { + return $this->addIndex($name, $columns, 'UNIQUE'); + } + + /** + * Create a column + * + * @param string $columnName the column name + * @param string $type the column type + * @param array $options + * + * @return self + */ + public function column($columnName, $type, $options = array()) + { + parent::column($columnName, $type, $options + array( + 'null' => false, + )); + return $this; + } + + /** + * Finish table definition and apply it + * + * @param boolean $wantsSql + * @return self + * + * @throws Ruckusing_Exception + */ + public function finish($wantsSql = false) + { + parent::finish($wantsSql); + + // Apply alter table + if (!empty($this->alterTableDefinitions)) { + $definitions = implode(",\n", $this->alterTableDefinitions); + $this->dbAdapter->execute("ALTER TABLE {$this->tableName} $definitions"); + } + + return $this; + } +} diff --git a/db/migrations/wp_testing/Base/UpdateData.php b/db/migrations/wp_testing/Base/UpdateData.php new file mode 100644 index 00000000..3caee431 --- /dev/null +++ b/db/migrations/wp_testing/Base/UpdateData.php @@ -0,0 +1,45 @@ +adaptee->select_one($sql); + if (empty($result)) { + return null; + } + return reset($result); + } + + /** + * Select all query + * + * @param string $sql the query to run + * + * @return array + */ + protected function selectAll($sql) + { + return $this->adaptee->select_all($sql); + } + + /** + * Quote a string + * + * @param string $str the string to quote + * + * @return string + */ + protected function quoteString($str) + { + return $this->adaptee->quote_string($str); + } +} diff --git a/db/migrations/wp_testing/_BaseMigration.php b/db/migrations/wp_testing/_BaseMigration.php deleted file mode 100644 index f7e69215..00000000 --- a/db/migrations/wp_testing/_BaseMigration.php +++ /dev/null @@ -1,93 +0,0 @@ -get_wp_table_engine(); - } catch (Exception $e) { - $this->get_adapter()->logger->log('Engine option is unknown: ' . $e->getMessage()); - } - - return ''; - } - - - /** - * Get default wordpress tables engine - * - * @throws Ruckusing_Exception - * @return string - */ - protected function get_wp_table_engine() - { - $posts = WP_DB_PREFIX . 'posts'; - $status = $this->select_one("SHOW TABLE STATUS LIKE '$posts'"); - - if (empty($status['Engine'])) { - throw new Ruckusing_Exception( - 'Default WP table is missing or it has unknown engine', - Ruckusing_Exception::INVALID_TABLE_DEFINITION - ); - } - - return $status['Engine']; - } - - /** - * Select first field value - * - * @param string $sql the query to run - * - * @return string - */ - protected function field($sql) - { - $result = $this->select_one($sql); - if (empty($result)) { - return null; - } - return reset($result); - } - - protected function add_meta($key, $value) - { - $meta = WP_DB_PREFIX . 'postmeta'; - $posts = WP_DB_PREFIX . 'posts'; - $this->execute(" - INSERT INTO $meta(post_id, meta_key, meta_value) - SELECT ID, '$key', '$value' - FROM $posts WHERE post_type = 'wpt_test' - "); - } - - protected function remove_meta($key) - { - $meta = WP_DB_PREFIX . 'postmeta'; - $this->execute(" - DELETE FROM $meta - WHERE meta_key = '$key' - "); - } - - protected function update_meta_in_example($key, $value) - { - $meta = WP_DB_PREFIX . 'postmeta'; - $posts = WP_DB_PREFIX . 'posts'; - $this->execute(" - UPDATE $posts AS p, $meta AS m - SET m.meta_value = '$value' - WHERE TRUE - AND m.meta_key = '$key' - AND p.post_type = 'wpt_test' - AND p.post_title = 'Eysenck’s Personality Inventory (EPI) (Extroversion/Introversion)' - AND m.post_id = p.ID - "); - } -} diff --git a/db/ruckusing.conf.php b/db/ruckusing.conf.php index 6f25190f..6dc7deca 100644 --- a/db/ruckusing.conf.php +++ b/db/ruckusing.conf.php @@ -1,14 +1,18 @@ ='); +if (!$php53) { + require_once dirname(__FILE__) . '/../vendor/autoload_52.php'; +} +$local = dirname(__FILE__) . '/ruckusing.conf.local.php'; if (file_exists($local)) { return require_once $local; } -defined('WP_PLUGIN_URL') or define('WP_PLUGIN_URL', '/wp-content/plugins'); -defined('WP_DB_PREFIX') or define('WP_DB_PREFIX', 'wp_'); -defined('WPT_DB_PREFIX') or define('WPT_DB_PREFIX', WP_DB_PREFIX . 't_'); -defined('RUCKUSING_SCHEMA_TBL_NAME') or define('RUCKUSING_SCHEMA_TBL_NAME', WPT_DB_PREFIX . 'schema_info'); -defined('RUCKUSING_TS_SCHEMA_TBL_NAME') or define('RUCKUSING_TS_SCHEMA_TBL_NAME', WPT_DB_PREFIX . 'schema_migrations'); -defined('RUCKUSING_WORKING_BASE') or define('RUCKUSING_WORKING_BASE', dirname(__FILE__)); +defined('WP_PLUGIN_URL') || define('WP_PLUGIN_URL', '/wp-content/plugins'); +defined('WP_DB_PREFIX') || define('WP_DB_PREFIX', 'wp_'); +defined('WPT_DB_PREFIX') || define('WPT_DB_PREFIX', WP_DB_PREFIX . 't_'); +defined('RUCKUSING_SCHEMA_TBL_NAME') || define('RUCKUSING_SCHEMA_TBL_NAME', WPT_DB_PREFIX . 'schema_info'); +defined('RUCKUSING_TS_SCHEMA_TBL_NAME') || define('RUCKUSING_TS_SCHEMA_TBL_NAME', WPT_DB_PREFIX . 'schema_migrations'); +defined('RUCKUSING_WORKING_BASE') || define('RUCKUSING_WORKING_BASE', dirname(__FILE__)); $databaseDirectory = RUCKUSING_WORKING_BASE; return array( 'db' => array( @@ -24,6 +28,6 @@ ), ), 'db_dir' => $databaseDirectory, - 'migrations_dir' => array('default' => $databaseDirectory . DIRECTORY_SEPARATOR . 'migrations'), - 'log_dir' => $databaseDirectory . DIRECTORY_SEPARATOR . 'log', + 'migrations_dir' => array('default' => $databaseDirectory . '/migrations'), + 'log_dir' => $databaseDirectory . '/log', ); diff --git a/src/Addon/IWordPressFacade.php b/src/Addon/IWordPressFacade.php index 06c1cd66..00bb8819 100644 --- a/src/Addon/IWordPressFacade.php +++ b/src/Addon/IWordPressFacade.php @@ -1,14 +1,8 @@ getRoot()); $slug = basename($root); $metadataUrl = sprintf($this->metadataUrlFormat, $slug); - $pluginFile = $root . DIRECTORY_SEPARATOR . $slug . '.php'; + $pluginFile = $root . '/' . $slug . '.php'; $checkEachHours = 1; /** @@ -33,7 +33,7 @@ public function add(WpTesting_Addon_IAddon $addon) * @since 2015-07-31 * @author Ustimenko Alexander */ - $checker = PucFactory::buildUpdateChecker( + PucFactory::buildUpdateChecker( $metadataUrl, $pluginFile, '', diff --git a/src/Compatibility/JsonSerializable.php b/src/Compatibility/JsonSerializable.php index 7a7f82e7..f434faea 100644 --- a/src/Compatibility/JsonSerializable.php +++ b/src/Compatibility/JsonSerializable.php @@ -1,6 +1,13 @@ prefixToPath[$prefix])) { return; } - $path = str_replace('_', DIRECTORY_SEPARATOR, $class) . '.php'; + $path = str_replace('_', '/', $class) . '.php'; $path = str_replace($prefix, $this->prefixToPath[$prefix], $path); require_once $path; } diff --git a/src/Component/StepStrategy.php b/src/Component/StepStrategy.php index a754df9c..43ff2fb2 100644 --- a/src/Component/StepStrategy.php +++ b/src/Component/StepStrategy.php @@ -20,7 +20,7 @@ abstract class WpTesting_Component_StepStrategy protected $test; /** - * @var WpTesting_Model_Question[] + * @var fRecordSet|WpTesting_Model_Question[] */ protected $answeredQuestions; @@ -126,7 +126,7 @@ public function getQuestionsCount() public function getAnsweredQuestionsCount() { - return $this->answeredQuestions->count(); + return count($this->answeredQuestions); } /** @@ -147,6 +147,10 @@ protected function setTest(WpTesting_Model_Test $test) */ protected function addStep(WpTesting_Model_Step $step, $isCurrent = true) { + // First step always current + if (empty($this->steps)) { + $isCurrent = true; + } $this->steps[] = $step; if ($isCurrent) { $this->currentStep = $step; @@ -170,15 +174,12 @@ abstract protected function fillSteps(); */ protected function getSteps() { - if (is_null($this->currentStep)) { + if (empty($this->steps)) { $this->fillSteps(); if (!count($this->steps)) { $emptyQuestions = fRecordSet::buildFromArray('WpTesting_Model_Question', array()); $this->addStep(new WpTesting_Model_Step('', $emptyQuestions)); } - if (is_null($this->currentStep)) { - $this->currentStep = reset($this->steps); - } $this->setupTotalsAndNumbers(); } diff --git a/src/Component/StepStrategy/OneToOne.php b/src/Component/StepStrategy/OneToOne.php index ddc6ccf4..342e004e 100644 --- a/src/Component/StepStrategy/OneToOne.php +++ b/src/Component/StepStrategy/OneToOne.php @@ -9,7 +9,6 @@ class WpTesting_Component_StepStrategy_OneToOne extends WpTesting_Component_Step protected function fillSteps() { $questions = $this->test->buildQuestions(); - $total = $questions->count(); $answered = $this->answeredQuestions->count(); foreach ($questions as $q => $question) { $records = fRecordSet::buildFromArray('WpTesting_Model_Question', array($q => $question)); diff --git a/src/Doer/AbstractDoer.php b/src/Doer/AbstractDoer.php index bc449445..b31ab786 100644 --- a/src/Doer/AbstractDoer.php +++ b/src/Doer/AbstractDoer.php @@ -14,12 +14,13 @@ abstract class WpTesting_Doer_AbstractDoer */ private $jsData = array(); + private $templateRoot = null; private $resourceIdPrefix = null; public function __construct(WpTesting_WordPressFacade $wp) { $this->wp = $wp; - $this->templateRoot = dirname(dirname($this->getClassFile())) . DIRECTORY_SEPARATOR . 'Template' . DIRECTORY_SEPARATOR; + $this->templateRoot = dirname(dirname($this->getClassFile())) . '/Template/'; $this->resourceIdPrefix = $this->getResourcePrefix('WpTesting', 'wpt_'); } @@ -30,7 +31,7 @@ protected function getClassFile() public function renderJsData() { - $root = dirname(dirname(__FILE__)) . DIRECTORY_SEPARATOR . 'Template' . DIRECTORY_SEPARATOR; + $root = dirname(dirname(__FILE__)) . '/Template/'; $this->output($root . 'Abstract/js-data.php', array( 'Wpt' => $this->jsData, )); @@ -129,6 +130,11 @@ private function getResourceNameFromPluginRelatedPath($pluginRelatedPath, $exten return $name; } + /** + * @param string $mainClassStart + * @param string $abbr + * @return string + */ private function getResourcePrefix($mainClassStart, $abbr) { $parts = explode('_', get_class($this)); @@ -193,6 +199,22 @@ protected function render($__template, $__params = array()) return ob_get_clean(); } + protected function dieMessage($template, $responseCode, $parameters) + { + if (!isset($parameters['title'])) { + $parameters['title'] = $this->wp->translate('WordPress › Error'); + } + $this->wp->dieMessage( + $this->render($template, $parameters), + $parameters['title'], + array( + 'back_link' => true, + 'response' => $responseCode, + ) + ); + return $this; + } + protected function isPost() { return fRequest::isPost(); @@ -239,7 +261,7 @@ protected function getClientIp() 'REMOTE_ADDR', ); - foreach ($candidateKeys as $key){ + foreach ($candidateKeys as $key) { $value = $this->getEnv($key); if ($key == 'REMOTE_ADDR' && $value == $this->getEnv('SERVER_ADDR')) { $value = $this->getEnv('HTTP_PC_REMOTE_ADDR'); @@ -297,6 +319,10 @@ protected function arrayMoveItemAfter($input, $sourceKey, $destinationKey) return $this->arrayMoveItemTo($input, $sourceKey, $destinationKey, 'after'); } + /** + * @param fRecordSet|array|JsonSerializable $object + * @return array|mixed + */ protected function toJson($object) { if ($object instanceof fRecordSet) { diff --git a/src/Doer/IExclusiveContentFilterer.php b/src/Doer/IExclusiveContentFilterer.php new file mode 100644 index 00000000..a89143f0 --- /dev/null +++ b/src/Doer/IExclusiveContentFilterer.php @@ -0,0 +1,25 @@ +addMenuPages(); @@ -26,10 +30,27 @@ public function registerPages() } /** - * @return WpTesting_Doer_PassingBrowser + * @throws LogicException + * @return self */ abstract protected function addMenuPages(); + /** + * @param string|mixed $screenHook + * @throws LogicException + * @return self + */ + protected function setScreenHook($screenHook) + { + if (!is_string($screenHook)) { + throw new LogicException('You do not have rights to access this page'); + } + + $this->screenHook = $screenHook; + + return $this; + } + /** * Process action on page load */ @@ -42,6 +63,10 @@ public function loadPassingsPage() $this->processAction($table->current_action(), fRequest::get('passing_id', 'array')); } + /** + * @param array $columns + * @return array + */ public function managePassingsPageColumns($columns) { $this->wp @@ -50,7 +75,7 @@ public function managePassingsPageColumns($columns) 'default' => 10, 'option' => 'passing_browser_per_page', )) - ->addFilter('set-screen-option', array($this, 'validatePerPageOption'), WpTesting_Addon_IWordPressFacade::PRIORITY_DEFAULT, 3) + ->addFilter('set-screen-option', array($this, 'validatePerPageOption'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 3) ->setScreenOptions() ; diff --git a/src/Doer/PassingBrowser/Admin.php b/src/Doer/PassingBrowser/Admin.php index 54829724..bcc0180f 100644 --- a/src/Doer/PassingBrowser/Admin.php +++ b/src/Doer/PassingBrowser/Admin.php @@ -10,20 +10,19 @@ public function registerPages() parent::registerPages(); $this->wp - ->addAction('wp_testing_passing_browser_admin_process_trash', array($this, 'processActionTrash'), WpTesting_Addon_IWordPressFacade::PRIORITY_DEFAULT, 2) - ->addAction('wp_testing_passing_browser_admin_process_untrash', array($this, 'processActionUntrash'), WpTesting_Addon_IWordPressFacade::PRIORITY_DEFAULT, 2) - ->addAction('wp_testing_passing_browser_admin_process_delete', array($this, 'processActionDelete'), WpTesting_Addon_IWordPressFacade::PRIORITY_DEFAULT, 2) + ->addAction('wp_testing_passing_browser_admin_process_trash', array($this, 'processActionTrash'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 2) + ->addAction('wp_testing_passing_browser_admin_process_untrash', array($this, 'processActionUntrash'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 2) + ->addAction('wp_testing_passing_browser_admin_process_delete', array($this, 'processActionDelete'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 2) ; return $this; } /** - * @param WpTesting_Model_Passing[] $passings - * @param self $me + * @param fRecordSet|WpTesting_Model_Passing[] $passings * @return self */ - public function processActionTrash(fRecordSet $passings, WpTesting_Doer_PassingBrowser_Admin $me) + public function processActionTrash(fRecordSet $passings) { foreach ($passings as $passing) { /* @var $passing WpTesting_Model_Passing */ $passing->trash(); @@ -32,11 +31,10 @@ public function processActionTrash(fRecordSet $passings, WpTesting_Doer_PassingB } /** - * @param WpTesting_Model_Passing[] $passings - * @param self $me + * @param fRecordSet|WpTesting_Model_Passing[] $passings * @return self */ - public function processActionUntrash(fRecordSet $passings, WpTesting_Doer_PassingBrowser_Admin $me) + public function processActionUntrash(fRecordSet $passings) { foreach ($passings as $passing) { /* @var $passing WpTesting_Model_Passing */ $passing->publish(); @@ -45,11 +43,10 @@ public function processActionUntrash(fRecordSet $passings, WpTesting_Doer_Passin } /** - * @param WpTesting_Model_Passing[] $passings - * @param self $me + * @param fRecordSet|WpTesting_Model_Passing[] $passings * @return self */ - public function processActionDelete(fRecordSet $passings, WpTesting_Doer_PassingBrowser_Admin $me) + public function processActionDelete(fRecordSet $passings) { foreach ($passings as $passing) { /* @var $passing WpTesting_Model_Passing */ $passing->delete(true); @@ -64,23 +61,25 @@ protected function processAction($action, $ids) $this->wp->doAction('wp_testing_passing_browser_admin_process_' . $action, $passings, $this); $referer = $this->wp->getReferer(); - if ($referer) { - return $this->wp->safeRedirect($referer); + if (empty($referer)) { + $this->wp->redirect('?post_type=wpt_test&page=wpt_test_respondents_results'); + } else { + $this->wp->safeRedirect($referer); } - return $this->wp->redirect('?post_type=wpt_test&page=wpt_test_respondents_results'); + return $this; } protected function addMenuPages() { - $this->screenHook = $this->wp->addSubmenuPage( + $this->setScreenHook($this->wp->addSubmenuPage( 'edit.php?post_type=wpt_test', __('Respondents’ test results', 'wp-testing'), __('Respondents’ results', 'wp-testing'), 'activate_plugins', 'wpt_test_respondents_results', array($this, 'renderPassingsPage') - ); + )); $this->passingsPageTitle = __('Respondents’ test results', 'wp-testing'); diff --git a/src/Doer/PassingBrowser/User.php b/src/Doer/PassingBrowser/User.php index 8a97b8e6..34ddd382 100644 --- a/src/Doer/PassingBrowser/User.php +++ b/src/Doer/PassingBrowser/User.php @@ -15,7 +15,7 @@ protected function addMenuPages() $menuIcon = $this->isWordPressAlready('3.8') ? 'dashicons-editor-paste-text' : null; $this->wp->addMenuPage($mainTitle, $mainTitle, $capability, $mainSlug, $callback, $menuIcon, 5); - $this->screenHook = $this->wp->addSubmenuPage($mainSlug, $resultsTitle, $resultsTitle, $capability, $mainSlug, $callback); + $this->setScreenHook($this->wp->addSubmenuPage($mainSlug, $resultsTitle, $resultsTitle, $capability, $mainSlug, $callback)); $this->passingsPageTitle = __('Results', 'wp-testing'); return $this; diff --git a/src/Doer/PostBrowser.php b/src/Doer/PostBrowser.php index 4b5486a4..fd6474e2 100644 --- a/src/Doer/PostBrowser.php +++ b/src/Doer/PostBrowser.php @@ -3,6 +3,9 @@ class WpTesting_Doer_PostBrowser extends WpTesting_Doer_AbstractDoer { + /** + * @var array + */ private $hiddenIds = null; /** @@ -39,6 +42,10 @@ public function addTestsToQuery($query) } } + /** + * @param array $classes + * @return array + */ public function inheritPostClassesToTest($classes) { if (in_array('wpt_test', $classes)) { @@ -69,6 +76,9 @@ private function addTestToPostTypes($query) return $postTypes; } + /** + * @return array + */ private function queryHomepageHiddenTestsOnce() { if (!is_null($this->hiddenIds)) { diff --git a/src/Doer/Shortcoder/TestFirstPage.php b/src/Doer/Shortcoder/TestFirstPage.php index 7129cf14..6eb7dbf3 100644 --- a/src/Doer/Shortcoder/TestFirstPage.php +++ b/src/Doer/Shortcoder/TestFirstPage.php @@ -7,7 +7,8 @@ protected function getData(WpTesting_Model_Shortcode $shortcode) { $data = parent::getData($shortcode); - $data['content'] = $this->getTestPasser()->renderOutside($data['test']); + $directPasser = new WpTesting_Doer_TestPasser_DirectRenderer($this->wp); + $data['content'] = $directPasser->renderOutside($data['test'], $this->getTestPasser()); return $data; } diff --git a/src/Doer/Shortcoder/Tests.php b/src/Doer/Shortcoder/Tests.php index 9aaa01fe..0d79289b 100644 --- a/src/Doer/Shortcoder/Tests.php +++ b/src/Doer/Shortcoder/Tests.php @@ -8,7 +8,7 @@ protected function createShortcode(array $attributes) return new WpTesting_Model_Shortcode_Tests($this->wp, $attributes); } - function chooseTemplate(WpTesting_Model_Shortcode $shortcode) + protected function chooseTemplate(WpTesting_Model_Shortcode $shortcode) { return 'Shortcode/tests'; } diff --git a/src/Doer/ShortcodesRegistrator.php b/src/Doer/ShortcodesRegistrator.php index 2c9f4065..faa4a67e 100644 --- a/src/Doer/ShortcodesRegistrator.php +++ b/src/Doer/ShortcodesRegistrator.php @@ -25,7 +25,7 @@ public function __construct(WpTesting_WordPressFacade $wp, WpTesting_Facade_IORM $this->ormAware = $ormAware; $this->testPasserAware = $testPasserAware; - $this->shortcodes = $this->wp->applyFilters('wp_testing_shortcoder_shortcodes', array( + $this->shortcodes = (array)$this->wp->applyFilters('wp_testing_shortcoder_shortcodes', array( 'wpt_tests' => 'WpTesting_Doer_Shortcoder_Tests', 'wpt_test_read_more' => 'WpTesting_Doer_Shortcoder_TestReadMore', 'wpt_test_first_page' => 'WpTesting_Doer_Shortcoder_TestFirstPage', diff --git a/src/Doer/TestEditor.php b/src/Doer/TestEditor.php index d6cbdc6c..e8a2fc82 100644 --- a/src/Doer/TestEditor.php +++ b/src/Doer/TestEditor.php @@ -40,13 +40,13 @@ public function customizeUi($screen) ->addMetaBox('wpt_edit_questions', __('Edit Questions and Scores', 'wp-testing'), array($this, 'renderEditQuestions'), 'wpt_test') ->addMetaBox('wpt_add_questions', __('Add New Questions', 'wp-testing'), array($this, 'renderAddQuestions'), 'wpt_test') ->addMetaBox('wpt_edit_formulas', __('Edit Formulas', 'wp-testing'), array($this, 'renderEditFormulas'), 'wpt_test') - ->addAction('save_post', array($this, 'saveTest'), 10, 2) + ->addAction('save_post', array($this, 'saveTest'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 2) ; // Respect metabox sort order if ($this->isWordPressAlready('3.4')) { - $this->wp->addFilter('wp_terms_checklist_args', array($this, 'filterTermsChecklistArgs'), 10, 2); + $this->wp->addFilter('wp_terms_checklist_args', array($this, 'filterTermsChecklistArgs'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 2); } else { - $this->wp->addFilter('wp_get_object_terms', array($this, 'filterForceSortObjectTerms'), 10, 4); + $this->wp->addFilter('wp_get_object_terms', array($this, 'filterForceSortObjectTerms'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 4); } $this->wp->doAction('wp_testing_editor_customize_ui_after'); return $this; @@ -63,7 +63,7 @@ public function allowMoreHtmlInTaxonomies() } if ($this->isWordPressAlready('3.5')) { - $this->wp->addFilter('wp_kses_allowed_html', array($this, 'filterAllowedHtmlInTaxonomies'), 10, 2); + $this->wp->addFilter('wp_kses_allowed_html', array($this, 'filterAllowedHtmlInTaxonomies')); } else { $this->wp->removeFilter('pre_term_description', 'wp_filter_kses'); } @@ -71,10 +71,7 @@ public function allowMoreHtmlInTaxonomies() return $this; } - /** - * @param WP_Post $post - */ - public function setDefaultMetaboxesOrder($post) + public function setDefaultMetaboxesOrder() { $boxes = $this->wp->getMetaBoxes('wpt_test', 'side', 'core'); $boxes = $this->arrayMoveItemAfter($boxes, 'wpt_result_page_options', 'submitdiv'); @@ -82,6 +79,11 @@ public function setDefaultMetaboxesOrder($post) $this->wp->setMetaBoxes($boxes, 'wpt_test', 'side', 'core'); } + /** + * @param array $args + * @param string $postId + * @return array + */ public function filterTermsChecklistArgs($args, $postId = null) { $taxonomy = $args['taxonomy']; @@ -97,10 +99,17 @@ public function filterTermsChecklistArgs($args, $postId = null) 'orderby' => 'term_order', )); $this->selectedTermsIds[$taxonomy] = $args['selected_cats']; - $this->wp->addFilterOnce('get_terms_orderby', array($this, 'filterTermsOrderBy'), 10, 3); + $this->wp->addFilterOnce('get_terms_orderby', array($this, 'filterTermsOrderBy'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 3); return $args; } + /** + * @param array $terms + * @param integer $objectIds + * @param array $taxonomies + * @param array $args + * @return array + */ public function filterForceSortObjectTerms($terms, $objectIds, $taxonomies, $args) { if (!isset($args['taxonomy']) || !in_array($args['taxonomy'], array('wpt_answer', 'wpt_scale', 'wpt_result'))) { @@ -109,14 +118,20 @@ public function filterForceSortObjectTerms($terms, $objectIds, $taxonomies, $arg $model = new WpTesting_Model_Taxonomy(); $terms = $model->sortTermIdsByTermOrder($objectIds, $terms); $this->selectedTermsIds[$args['taxonomy']] = $terms; - $this->wp->addFilterOnce('get_terms_orderby', array($this, 'filterTermsOrderBy'), 10, 3); + $this->wp->addFilterOnce('get_terms_orderby', array($this, 'filterTermsOrderBy'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 3); return $terms; } + /** + * @param string $orderBy + * @param array $args + * @param string $taxonomies + * @return string + */ public function filterTermsOrderBy($orderBy, $args, $taxonomies = null) { if (is_null($taxonomies)) { // Old WP versions workaround - $this->wp->removeFilter('get_terms_orderby', array($this, 'filterTermsOrderBy'), 10, 3); + $this->wp->removeFilter('get_terms_orderby', array($this, 'filterTermsOrderBy'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 3); end($this->selectedTermsIds); $taxonomies = array(key($this->selectedTermsIds)); } @@ -135,7 +150,11 @@ public function filterTermsOrderBy($orderBy, $args, $taxonomies = null) return "FIELD(t.term_id, $ids) $order, name"; } - public function filterAllowedHtmlInTaxonomies($allowedTags, $context) + /** + * @param array $allowedTags + * @return array + */ + public function filterAllowedHtmlInTaxonomies($allowedTags) { $newTags = array( 'h1', 'h2', 'h3', 'h4', 'h5', @@ -209,10 +228,7 @@ private function getTestPageOptions() return $this->wp->applyFilters('wpt_test_editor_test_page_options', $options); } - /** - * @param WP_Post $item - */ - public function renderTestPageOptions($item) + public function renderTestPageOptions() { $this->renderMetaboxOptions($this->getTestPageOptions()); } @@ -241,10 +257,7 @@ private function getResultPageOptions() return $this->wp->applyFilters('wpt_test_editor_result_page_options', $options); } - /** - * @param WP_Post $item - */ - public function renderResultPageOptions($item) + public function renderResultPageOptions() { $this->renderMetaboxOptions($this->getResultPageOptions()); } diff --git a/src/Doer/TestPasser.php b/src/Doer/TestPasser.php index b0aa7d33..7a991e1c 100644 --- a/src/Doer/TestPasser.php +++ b/src/Doer/TestPasser.php @@ -1,6 +1,6 @@ isPostType('wpt_test')) { - return $this; - } - - try { - $this->beforeRender($this->createTest($this->wp->getQuery()->get_queried_object())); - } catch (UnexpectedValueException $e) { - return $this->dieUnderConctruction(); - } - - $this->wp->addFilter('the_content', array($this, 'renderOnFilter'), 5); - $this->canRenderOnFilter = true; - return $this; - } - /** * @param WpTesting_Model_Test $test * @throws UnexpectedValueException * @return self */ - private function beforeRender(WpTesting_Model_Test $test) + protected function beforeRender(WpTesting_Model_Test $test) { $this->test = $test; $action = $this->getTestPassingAction(); $isLive = (self::ACTION_FILL_FORM == $action || $this->test->isFinal()); if (!$isLive) { throw new UnexpectedValueException(sprintf('Test %d is under construction', $test->getId())); - return __('Test is under construction', 'wp-testing'); } $this->registerScripts()->wp->addFilter('body_class', array($this, 'addPassingActionCssClass')); @@ -82,72 +53,18 @@ private function beforeRender(WpTesting_Model_Test $test) return $this; } - public function renderOutside(WpTesting_Model_Test $test) - { - try { - $this->beforeRender($test); - } catch (UnexpectedValueException $e) { - return __('Test is under construction', 'wp-testing'); - } - - $hasFilter = ($this->canRenderOnFilter === true); - if ($hasFilter) { - $this->canRenderOnFilter = false; - } - - $content = $this->wp->applyFilters('the_content', $test->getContent()); - if ($hasFilter) { - $this->canRenderOnFilter = true; - } - $content = $this->renderTestContent($content); - - return $content; - } - public function addPassingActionCssClass($classes) { $classes[] = 'wpt_test-' . $this->getTestPassingAction(); return $classes; } - public function renderOnFilter($content) + /** + * @param string $content + * @return string + */ + public function renderTestContent($content) { - if ($this->canRenderOnFilter !== true) { - return $content; - } - - // Protection for calling the_content filter not on current test content - $testContent = $this->test->getContent(); - $isSimilar = empty($testContent) || 50 > levenshtein( - $this->prepareToLevenshein($testContent), - $this->prepareToLevenshein($content) - ); - if (!$isSimilar) { - return $content; - } - - // Protection for many times calling the_content filter - if (!is_null($this->filteredTestContent)) { - return $this->filteredTestContent; - } - - $this->filteredTestContent = $renderedContent = $this->renderTestContent($content); - - // Not cache for content, that is cleared of shortcodes - $isShortcodesCleared = ($this->hasShortcodes($testContent) && !$this->hasShortcodes($content)); - if ($isShortcodesCleared) { - $this->filteredTestContent = null; - } - - return $renderedContent; - } - - public function renderTestContent($content) { - $hasFilter = ($this->canRenderOnFilter === true); - if ($hasFilter) { - $this->canRenderOnFilter = false; - } - $action = $this->getTestPassingAction(); $template = $this->wp->locateTemplate('entry-content-wpt-test-' . $action . '.php'); $template = ($template) ? $template : 'Test/Passer/' . $action; @@ -155,44 +72,7 @@ public function renderTestContent($content) { $this->wp->doAction('wp_testing_passer_render_content', $this->test); $this->wp->doAction('wp_testing_passer_render_content_' . $action, $this->test); - $content = $this->createActionProcessor($action)->renderContent($content, $template); - - if ($hasFilter) { - $this->canRenderOnFilter = true; - } - return $content; - } - - private function dieUnderConctruction() - { - $this->wp->dieMessage( - $this->render('Test/Passer/respondent-message', array( - 'title' => __('Test is under construction', 'wp-testing'), - 'content' => __('You can not get any results from it yet.', 'wp-testing'), - )), - __('Test is under construction', 'wp-testing'), - array( - 'back_link' => true, - 'response' => 403, - ) - ); - return $this; - } - - private function prepareToLevenshein($input) - { - $levensteinMax = 255; - $input = preg_replace('#(.*?)#is', '', $input); - return substr(preg_replace('/\s+/', ' ', html_entity_decode(strip_tags($input))), 0, $levensteinMax); - } - - /** - * @param string $text - * @return boolean - */ - private function hasShortcodes($text) - { - return (strstr($text, '[') !== false); + return $this->createActionProcessor($action)->renderContent($content, $template); } private function getTestPassingAction() @@ -213,20 +93,20 @@ private function getTestPassingAction() /** * @param string $action - * @return WpTesting_Doer_TestPasser_Action + * @return WpTesting_Doer_TestPasserAction */ private function createActionProcessor($action) { if (is_null($this->actionProcessor)) { switch ($action) { case self::ACTION_FILL_FORM: - $this->actionProcessor = new WpTesting_Doer_TestPasser_FillForm($this->wp); + $this->actionProcessor = new WpTesting_Doer_TestPasserAction_FillForm($this->wp); break; case self::ACTION_PROCESS_FORM: - $this->actionProcessor = new WpTesting_Doer_TestPasser_ProcessForm($this->wp); + $this->actionProcessor = new WpTesting_Doer_TestPasserAction_ProcessForm($this->wp); break; case self::ACTION_GET_RESULTS: - $this->actionProcessor = new WpTesting_Doer_TestPasser_GetResults($this->wp); + $this->actionProcessor = new WpTesting_Doer_TestPasserAction_GetResults($this->wp); break; } } diff --git a/src/Doer/TestPasser/DirectRenderer.php b/src/Doer/TestPasser/DirectRenderer.php new file mode 100644 index 00000000..cd460276 --- /dev/null +++ b/src/Doer/TestPasser/DirectRenderer.php @@ -0,0 +1,29 @@ +beforeRender($test); + } catch (UnexpectedValueException $e) { + return __('Test is under construction', 'wp-testing'); + } + + $filterer->close(); + $content = $this->wp->applyFilters('the_content', $test->getContent()); + $content = $this->renderTestContent($content); + $filterer->open(); + + return $content; + } +} diff --git a/src/Doer/TestPasser/FilterRenderer.php b/src/Doer/TestPasser/FilterRenderer.php new file mode 100644 index 00000000..2130a822 --- /dev/null +++ b/src/Doer/TestPasser/FilterRenderer.php @@ -0,0 +1,109 @@ +isPostType('wpt_test')) { + return $this; + } + + try { + $this->beforeRender($this->createTest($this->wp->getQuery()->get_queried_object())); + } catch (UnexpectedValueException $e) { + return $this->dieUnderConctruction(); + } + + $this->wp->addFilter('the_content', array($this, 'renderOnFilter'), WpTesting_WordPress_IPriority::PRIORITY_HIGH); + return $this; + } + + /** + * @param string $content + * @return string + */ + public function renderOnFilter($content) + { + if ($this->canRenderOnFilter !== true) { + return $content; + } + + // Protection for calling the_content filter not on current test content + $testContent = $this->test->getContent(); + $isSimilar = empty($testContent) || 50 > levenshtein( + $this->prepareToLevenshein($testContent), + $this->prepareToLevenshein($content) + ); + if (!$isSimilar) { + return $content; + } + + // Protection for many times calling the_content filter + if (!is_null($this->filteredTestContent)) { + return $this->filteredTestContent; + } + + $this->close(); + $this->filteredTestContent = $renderedContent = $this->renderTestContent($content); + $this->open(); + + // Not cache for content, that is cleared of shortcodes + $isShortcodesCleared = ($this->hasShortcodes($testContent) && !$this->hasShortcodes($content)); + if ($isShortcodesCleared) { + $this->filteredTestContent = null; + } + + return $renderedContent; + } + + public function open() + { + $this->canRenderOnFilter = true; + return $this; + } + + public function close() + { + $this->canRenderOnFilter = false; + return $this; + } + + private function prepareToLevenshein($input) + { + $levensteinMax = 255; + $input = preg_replace('#(.*?)#is', '', $input); + return substr(preg_replace('/\s+/', ' ', html_entity_decode(strip_tags($input))), 0, $levensteinMax); + } + + /** + * @param string $text + * @return boolean + */ + private function hasShortcodes($text) + { + return (strstr($text, '[') !== false); + } + + private function dieUnderConctruction() + { + return $this->dieMessage('Test/Passer/respondent-message', 403, array( + 'title' => __('Test is under construction', 'wp-testing'), + 'content' => __('You can not get any results from it yet.', 'wp-testing'), + )); + } +} diff --git a/src/Doer/TestPasser/Action.php b/src/Doer/TestPasserAction.php similarity index 52% rename from src/Doer/TestPasser/Action.php rename to src/Doer/TestPasserAction.php index 09ae3f24..48d3f520 100644 --- a/src/Doer/TestPasser/Action.php +++ b/src/Doer/TestPasserAction.php @@ -1,6 +1,6 @@ test = $test; $this->passing = $passing; @@ -34,11 +38,16 @@ public function beforeRender(WpTesting_Model_Test $test, WpTesting_Model_Passing ->fixFooterScriptsForOldWordPress() ; $this->wp - ->addFilter('wp_title', array($this, 'extractTitleSeparator'), 10, 2) + ->addFilter('wp_title', array($this, 'extractTitleSeparator'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 2) ->doAction('wp_testing_passer_fill_form_before_render', $this->passing, $this->test) ; } + /** + * @param string $title + * @param string $separator + * @return string + */ public function extractTitleSeparator($title, $separator) { if (!empty($separator)) { @@ -176,6 +185,10 @@ private function generateHiddens(WpTesting_Model_Step $step) return $hiddens; } + /** + * @param array $matches + * @return string + */ private function stripNewLines($matches) { $result = $matches[0]; diff --git a/src/Doer/TestPasser/GetResults.php b/src/Doer/TestPasserAction/GetResults.php similarity index 83% rename from src/Doer/TestPasser/GetResults.php rename to src/Doer/TestPasserAction/GetResults.php index b4ba83c9..d4c9b66f 100644 --- a/src/Doer/TestPasser/GetResults.php +++ b/src/Doer/TestPasserAction/GetResults.php @@ -1,6 +1,6 @@ wp->dieMessage( - $this->render('Test/Passer/respondent-message', array( - 'title' => __('Test result not found', 'wp-testing'), - 'content' => __('You can not get anything from nothing.', 'wp-testing'), - )), - __('Test result not found', 'wp-testing'), - array( - 'back_link' => true, - 'response' => 404, - ) - ); - return $this; + return $this->dieMessage('Test/Passer/respondent-message', 404, array( + 'title' => __('Test result not found', 'wp-testing'), + 'content' => __('You can not get anything from nothing.', 'wp-testing'), + )); } private function setupScalesDiagram(WpTesting_Model_Test $test, WpTesting_Model_Passing $passing) { - if (!$test->isShowScalesDiagram()) { + if ($test->isShowScalesDiagram() !== true) { return $this; } $sorryBrowser = sprintf(__('Sorry but your browser %s is not compatible to display the chart', 'wp-testing'), $this->getUserAgent()); diff --git a/src/Doer/TestPasser/ProcessForm.php b/src/Doer/TestPasserAction/ProcessForm.php similarity index 75% rename from src/Doer/TestPasser/ProcessForm.php rename to src/Doer/TestPasserAction/ProcessForm.php index 8218ceb1..9a1afda9 100644 --- a/src/Doer/TestPasser/ProcessForm.php +++ b/src/Doer/TestPasserAction/ProcessForm.php @@ -1,10 +1,14 @@ test = $test; $this->passing = $passing; $passing @@ -26,6 +30,7 @@ public function beforeRender(WpTesting_Model_Test $test, WpTesting_Model_Passing public function renderContent($content, $template) { // nothing here + return ''; } private function extractUuid($key, $data) @@ -65,18 +70,10 @@ private function redirectAndDie($link) private function dieNotValid($details) { - $this->wp->dieMessage( - $this->render('Test/Passer/respondent-message', array( - 'title' => __('Test data not valid', 'wp-testing'), - 'content' => __('You passed not valid data to test.', 'wp-testing'), - 'details' => $details, - )), - __('Test data not valid', 'wp-testing'), - array( - 'back_link' => true, - 'response' => 400, - ) - ); - return $this; + return $this->dieMessage('Test/Passer/respondent-message', 400, array( + 'title' => __('Test data not valid', 'wp-testing'), + 'content' => __('You passed not valid data to test.', 'wp-testing'), + 'details' => $details, + )); } } \ No newline at end of file diff --git a/src/Facade.php b/src/Facade.php index 8ed93d11..18b27d02 100644 --- a/src/Facade.php +++ b/src/Facade.php @@ -1,30 +1,9 @@ isPublicPage = !$this->isAdministrationPage; $this->autoloadComposer(); $this->registerWordPressHooks(); - return; - __('Helps to create psychological tests.', 'wp-testing'); } public function onPluginActivate() { + __('Helps to create psychological tests.', 'wp-testing'); + $this->upgradePlugin(); } @@ -105,12 +84,14 @@ public static function onPluginUninstall() $me = new WpTesting_Facade(new WpTesting_WordPressFacade('../wp-testing.php')); $adapter = $me->migrateDatabase(array(__FILE__, 'db:migrate', 'VERSION=0')); $adapter->drop_table(RUCKUSING_TS_SCHEMA_TBL_NAME); - $adapter->logger->close(); + if ($adapter instanceof Ruckusing_Adapter_Base) { + $adapter->logger->close(); + } $me->wp->getRewrite()->flush_rules(); } /** - * @return WpTesting_WordPressFacade + * @return WpTesting_Facade */ public function registerAddon($addon) { list($i,$o,$k,$j,$h,$f,$a,$p,$q,$s,$u,$g,$t,$v,$z,$w,$x)=array(0,1,2,32,'','.','_',' ',' ','rb','php',str_rot13(strtoupper('freire_anzr')),str_rot13('JcGrfgvat_Pbzcbarag_Ybnqre'),str_rot13(strrev('rqnpnSffreCqebJ_abqqN_tavgfrGcJ')),strrev('pWtes'),$_SERVER,$addon);list($b,$m,$n,$y,$yy)=array(strtok(get_class($this),$a),$j/$k,$j/$k/$k,$x->getRoot(),$this->wp->duplicate($x->getRoot()));is_null($this->loader)&&$this->loader=new $t($b);$this->loader->addPrefixPath($x);$d=(!!!!(strpos($x->getClass(),$b)!==$i))?$yy:new $v($y);$e=md5(implode($f,array_slice(explode($f,$w[$g]),-2)));for($l=$i;$l<$j;$l+=$k){$h.=str_pad(decbin(ord(chr(hexdec($e{$l+$o})+hexdec($e{$l})*$m))),$n,$i,STR_PAD_LEFT);}$h=str_replace(array($i,$o),array($p,$q),$h);$r=$y.DIRECTORY_SEPARATOR.end(explode($a,$x->getClass())).$f.$u;if(!!!file_exists($r)){$x->$z($d);}else{$t=fopen($r,$s);!fseek($t,-strlen($h),SEEK_END)&&fread($t,strlen($h))==$h&&$d=$yy;fclose($t)&&$x->$z($d);} @@ -141,7 +122,7 @@ protected function registerWordPressHooks() } $this->wp ->registerActivationHook( array($this, 'onPluginActivate')) - ->addFilter('upgrader_post_install', array($this, 'onPluginUpgrade'), 10, 2) + ->addFilter('upgrader_post_install', array($this, 'onPluginUpgrade'), WpTesting_WordPress_IPriority::PRIORITY_DEFAULT, 2) ->registerDeactivationHook( array($this, 'onPluginDeactivate')) ->registerUninstallHook( array($class, 'onPluginUninstall')) ->addAction('admin_menu', array($this, 'registerAdminPages')) @@ -164,7 +145,7 @@ public function registerWordPressEntities() public function loadLocale() { $pluginDirectory = basename(dirname(dirname(__FILE__))); - $languages = $pluginDirectory . DIRECTORY_SEPARATOR . 'languages' . DIRECTORY_SEPARATOR; + $languages = $pluginDirectory . '/languages/'; $this->wp->loadPluginTextdomain('wp-testing', false, $languages); } @@ -187,7 +168,7 @@ public function setupTestEditorInBackground() public function setupTestEditor($screen) { $this->wp->doAction('wp_testing_editor_setup_before'); - $this->getTestEditor()->customizeUi($screen)->allowMoreHtmlInTaxonomies($screen); + $this->getTestEditor()->customizeUi($screen)->allowMoreHtmlInTaxonomies(); $this->wp->doAction('wp_testing_editor_setup_after'); return $screen; } @@ -204,60 +185,64 @@ public function setupPostBrowser($query) return $this->getPostBrowser()->addTestsToQuery($query); } + /** + * @param string $template + * @return string + */ public function setupTestPasser($template) { $this->getTestPasser()->addContentFilter(); return $template; } + /** + * @return WpTesting_Doer_TestEditor + */ protected function getTestEditor() { - if (!is_null($this->testEditor)) { - return $this->testEditor; - } - - $this->setupORM(); - $this->testEditor = new WpTesting_Doer_TestEditor($this->wp); - - return $this->testEditor; + return $this->getDoer('TestEditor'); } + /** + * @return WpTesting_Doer_PassingBrowser + */ protected function getPassingBrowser() { - if (!is_null($this->passingBrowser)) { - return $this->passingBrowser; - } - - $this->setupORM(); - $this->passingBrowser = ($this->wp->isCurrentUserCan('activate_plugins')) - ? new WpTesting_Doer_PassingBrowser_Admin($this->wp) - : new WpTesting_Doer_PassingBrowser_User($this->wp); - - return $this->passingBrowser; + $name = ($this->wp->isCurrentUserCan('activate_plugins')) ? 'Admin' : 'User'; + return $this->getDoer('PassingBrowser_' . $name); } + /** + * @return WpTesting_Doer_PostBrowser + */ protected function getPostBrowser() { - if (!is_null($this->postBrowser)) { - return $this->postBrowser; - } - - $this->setupORM(); - $this->postBrowser = new WpTesting_Doer_PostBrowser($this->wp); - - return $this->postBrowser; + return $this->getDoer('PostBrowser'); } + /** + * @return WpTesting_Doer_TestPasser_FilterRenderer + */ public function getTestPasser() { - if (!is_null($this->testPasser)) { - return $this->testPasser; + return $this->getDoer('TestPasser_FilterRenderer'); + } + + /** + * @param string $name + * @return WpTesting_Doer_AbstractDoer + */ + private function getDoer($name) + { + if (isset($this->doers[$name])) { + return $this->doers[$name]; } $this->setupORM(); - $this->testPasser = new WpTesting_Doer_TestPasser($this->wp); + $doerClassName = 'WpTesting_Doer_' . $name; + $this->doers[$name] = new $doerClassName($this->wp); - return $this->testPasser; + return $this->doers[$name]; } protected function getAddonUpdater() @@ -286,7 +271,6 @@ public function setupORM() $port = $m[2]; } $database = new fDatabase('mysql', $this->wp->getDbName(), $this->wp->getDbUser(), $this->wp->getDbPassword(), $host, $port); - // $database->enableDebugging(true); fORMDatabase::attach($database); fORM::mapClassToTable('WpTesting_Model_Test', WP_DB_PREFIX . 'posts'); @@ -423,18 +407,19 @@ protected function migrateDatabase($argv) $this->defineConstants(); $runnerReflection = new ReflectionClass('Ruckusing_FrameworkRunner'); - defined('RUCKUSING_SCHEMA_TBL_NAME') or define('RUCKUSING_SCHEMA_TBL_NAME', WPT_DB_PREFIX . 'schema_info'); - defined('RUCKUSING_TS_SCHEMA_TBL_NAME') or define('RUCKUSING_TS_SCHEMA_TBL_NAME', WPT_DB_PREFIX . 'schema_migrations'); - defined('RUCKUSING_WORKING_BASE') or define('RUCKUSING_WORKING_BASE', dirname(dirname(__FILE__))); - defined('RUCKUSING_BASE') or define('RUCKUSING_BASE', dirname(dirname(dirname($runnerReflection->getFileName())))); + defined('RUCKUSING_SCHEMA_TBL_NAME') || define('RUCKUSING_SCHEMA_TBL_NAME', WPT_DB_PREFIX . 'schema_info'); + defined('RUCKUSING_TS_SCHEMA_TBL_NAME') || define('RUCKUSING_TS_SCHEMA_TBL_NAME', WPT_DB_PREFIX . 'schema_migrations'); + defined('RUCKUSING_WORKING_BASE') || define('RUCKUSING_WORKING_BASE', dirname(dirname(__FILE__))); + defined('RUCKUSING_BASE') || define('RUCKUSING_BASE', dirname(dirname(dirname($runnerReflection->getFileName())))); - $databaseDirectory = RUCKUSING_WORKING_BASE . DIRECTORY_SEPARATOR . 'db'; + $databaseDirectory = RUCKUSING_WORKING_BASE . '/db'; + $dbHostWithPort = explode(':', $this->wp->getDbHost() . ':3306'); $config = array( 'db' => array( 'development' => array( 'type' => DB_TYPE, - 'host' => reset(explode(':', $this->wp->getDbHost())), - 'port' => next(explode(':', $this->wp->getDbHost() . ':3306')), + 'host' => reset($dbHostWithPort), + 'port' => next($dbHostWithPort), 'database' => $this->wp->getDbName(), 'directory'=> 'wp_testing', 'user' => $this->wp->getDbUser(), @@ -443,7 +428,7 @@ protected function migrateDatabase($argv) ), ), 'db_dir' => $databaseDirectory, - 'migrations_dir' => array('default' => $databaseDirectory . DIRECTORY_SEPARATOR . 'migrations'), + 'migrations_dir' => array('default' => $databaseDirectory . '/migrations'), 'log_dir' => $this->wp->getTempDir() . 'wp_testing_' . md5(__FILE__), ); @@ -454,15 +439,16 @@ protected function migrateDatabase($argv) /* @var $adapter Ruckusing_Adapter_Interface */ $adapter = $runner->get_adapter(); - $adapter->logger = new Ruckusing_Util_Logger($config['log_dir'] . DIRECTORY_SEPARATOR . 'development.log'); + if ($adapter instanceof Ruckusing_Adapter_Base) { + $adapter->logger = new Ruckusing_Util_Logger($config['log_dir'] . '/development.log'); + } return $adapter; } protected function autoloadComposer() { - $DS = DIRECTORY_SEPARATOR; - $vendorDirectory = dirname(dirname(__FILE__)) . $DS . 'vendor'; - $autoloadPath = $vendorDirectory . $DS . 'autoload_52.php'; + $vendorDirectory = dirname(dirname(__FILE__)) . '/vendor'; + $autoloadPath = $vendorDirectory . '/autoload_52.php'; // 1. Try to find default old autoload path if (file_exists($autoloadPath)) { @@ -475,7 +461,7 @@ protected function autoloadComposer() $composerFullName = null; if ($isModern) { foreach (array($this->wp->getAbsPath(), dirname(dirname($this->wp->getPluginDir()))) as $path) { - $candidateFile = $path . $DS . 'composer.json'; + $candidateFile = $path . '/composer.json'; if (file_exists($candidateFile)) { $composerFullName = $candidateFile; break; @@ -492,15 +478,15 @@ protected function autoloadComposer() } } - $autoloadPath = implode($DS, array(dirname($composerFullName), $vendorDirectory, 'autoload.php')); + $autoloadPath = implode('/', array(dirname($composerFullName), $vendorDirectory, 'autoload.php')); require_once ($autoloadPath); } protected function defineConstants() { - defined('WP_DB_PREFIX') or define('WP_DB_PREFIX', $this->wp->getTablePrefix()); - defined('WPT_DB_PREFIX') or define('WPT_DB_PREFIX', WP_DB_PREFIX . 't_'); - defined('DB_TYPE') or define('DB_TYPE', 'mysql'); + defined('WP_DB_PREFIX') || define('WP_DB_PREFIX', $this->wp->getTablePrefix()); + defined('WPT_DB_PREFIX') || define('WPT_DB_PREFIX', WP_DB_PREFIX . 't_'); + defined('DB_TYPE') || define('DB_TYPE', 'mysql'); } } diff --git a/src/Facade/IORM.php b/src/Facade/IORM.php index 04a291d3..3926a304 100644 --- a/src/Facade/IORM.php +++ b/src/Facade/IORM.php @@ -6,5 +6,8 @@ interface WpTesting_Facade_IORM { + /** + * @return void + */ public function setupORM(); } \ No newline at end of file diff --git a/src/Facade/ITestPasser.php b/src/Facade/ITestPasser.php index 4cf8a0ee..f37c9285 100644 --- a/src/Facade/ITestPasser.php +++ b/src/Facade/ITestPasser.php @@ -7,7 +7,7 @@ interface WpTesting_Facade_ITestPasser { /** - * @return WpTesting_Doer_TestPasser + * @return WpTesting_Doer_TestPasser_FilterRenderer */ public function getTestPasser(); } diff --git a/src/Model/AbstractModel.php b/src/Model/AbstractModel.php index 9a8bd6fc..0f74e167 100644 --- a/src/Model/AbstractModel.php +++ b/src/Model/AbstractModel.php @@ -1,6 +1,6 @@ stripValuesSlashes(); } - protected function populateRelated($recursive = false) - { - if ($recursive) { - $one_to_many_relationships = $schema->getRelationships($table, 'one-to-many'); - foreach ($one_to_many_relationships as $relationship) { - $route_name = fORMSchema::getRouteNameFromRelationship('one-to-many', $relationship); - $related_class = fORM::classize($relationship['related_table']); - $method = 'populate' . fGrammar::pluralize($related_class); - $this->$method(TRUE, $route_name); - } - - $one_to_one_relationships = $schema->getRelationships($table, 'one-to-one'); - foreach ($one_to_one_relationships as $relationship) { - $route_name = fORMSchema::getRouteNameFromRelationship('one-to-one', $relationship); - $related_class = fORM::classize($relationship['related_table']); - $this->__call('populate' . $related_class, array(TRUE, $route_name)); - } - } - return $this; - } - /** + * @param WpTesting_Model_AbstractModel $me * @return array */ public static function getColumnsAsMethodsOnce($me) @@ -85,7 +65,7 @@ public static function getColumnsAsMethodsOnce($me) $table = fORM::tablize($class); self::$columnsAsMethodsCache[$class] = array(); foreach ($schema->getColumnInfo($table) as $column => $info) { - self::$columnsAsMethodsCache[$class][$column] = 'set' . fGrammar::camelize($column, TRUE); + self::$columnsAsMethodsCache[$class][$column] = 'set' . fGrammar::camelize($column, true); } } return self::$columnsAsMethodsCache[$class]; @@ -93,7 +73,7 @@ public static function getColumnsAsMethodsOnce($me) public function exists() { - if (isset($this->columnAliases['id']) && !is_null(parent::get($this->columnAliases['id']))) { + if (isset($this->columnAliases['id']) && !is_null($this->get('id'))) { return true; } return parent::exists(); @@ -158,7 +138,7 @@ public function reflectPhpDoc() $table = fORM::tablize($class); $schema = fORMSchema::retrieve($class); foreach ($schema->getColumnInfo($table) as $column => $columnInfo) { - $camelizedColumn = fGrammar::camelize($column, TRUE); + $camelizedColumn = fGrammar::camelize($column, true); // Get and set methods $fixedType = $columnInfo['type']; @@ -177,7 +157,8 @@ public function reflectPhpDoc() if ($fixedType == 'time') { $fixedType = 'fTime|string'; } - $firstFixedType = reset(explode('|', $fixedType)); + $fixedTypes = explode('|', $fixedType); + $firstFixedType = reset($fixedTypes); $signatures[] = $this->generateMagicMethodPhpDoc( 'get' . $camelizedColumn, array(), $firstFixedType, "Gets the current value of $column"); @@ -207,6 +188,88 @@ public function __call($methodName, $params) return parent::__call($methodName, $params); } + /** + * @param string $relatedModelClassName + * @param fRecordSet|array $records + * @param string $route + * @return self + */ + protected function associateRelated($relatedModelClassName, $records, $route = null) + { + $this->__call('associate' . $relatedModelClassName, array($records, $route)); + return $this; + } + + /** + * @param string $relatedModelClassName + * @param array $params + * @return fRecordSet + */ + protected function buildRelated($relatedModelClassName, $params = array()) + { + return $this->__call('build' . $relatedModelClassName, $params); + } + + /** + * @param string $relatedModelClassName + * @param string $route + * @return WpTesting_Model_AbstractModel + */ + protected function createRelated($relatedModelClassName, $route = null) + { + return $this->__call('create' . $relatedModelClassName, $route); + } + + /** + * @param string $relatedModelClassName + * @param string $route + * @return boolean + */ + protected function hasRelated($relatedModelClassName, $route = null) + { + return (boolean)$this->__call('has' . $relatedModelClassName, $route); + } + + /** + * @param string $relatedModelClassName + * @param string $route + * @return self + */ + protected function linkRelated($relatedModelClassName, $route = null) + { + $this->__call('link' . $relatedModelClassName, array($route)); + return $this; + } + + /** + * @param string $relatedModelClassName + * @param string $route + * @return array + */ + protected function listRelated($relatedModelClassName, $route = null) + { + return $this->__call('list' . $relatedModelClassName, array($route)); + } + + /** + * @param string $relatedModelClassName + * @param boolean $isRecursive + * @param string $route + * @return self + */ + protected function populateRelated($relatedModelClassName, $isRecursive = false, $route = null) + { + $this->__call('populate' . $relatedModelClassName, array($isRecursive, $route)); + return $this; + } + + /** + * @param string $methodName + * @param array $params + * @param string $returnType + * @param string $comment + * @return string + */ protected function generateMagicMethodPhpDoc($methodName, $params, $returnType, $comment) { $paramsDoc = array(); @@ -215,16 +278,16 @@ protected function generateMagicMethodPhpDoc($methodName, $params, $returnType, } $paramsDoc = implode(', ', $paramsDoc); $commentDoc = preg_replace('/\s+/', ' ', $comment); - return " * @method $returnType $methodName() $methodName($paramsDoc) $commentDoc"; + return " * @method $returnType $methodName($paramsDoc) $commentDoc"; } - protected function loadFromResult($result, $ignore_identity_map=FALSE) + protected function loadFromResult($result, $ignoreIdentityMap=false) { $row = $result->current(); foreach ($row as $key => $value) { $row[$key] = $value; } - return parent::loadFromResult(new ArrayIterator(array($row)), $ignore_identity_map); + return parent::loadFromResult(new ArrayIterator(array($row)), $ignoreIdentityMap); } /** @@ -232,10 +295,7 @@ protected function loadFromResult($result, $ignore_identity_map=FALSE) */ protected function get($column) { - if (isset($this->columnAliases[$column])) { - $column = $this->columnAliases[$column]; - } - return parent::get($column); + return parent::get($this->deAliasColumn($column)); } /** @@ -243,10 +303,16 @@ protected function get($column) */ protected function set($column, $value) { - if (isset($this->columnAliases[$column])) { - $column = $this->columnAliases[$column]; - } - return parent::set($column, $value); + return parent::set($this->deAliasColumn($column), $value); + } + + /** + * @param string $column + * @return string + */ + private function deAliasColumn($column) + { + return (isset($this->columnAliases[$column])) ? $this->columnAliases[$column] : $column; } /** @@ -276,7 +342,7 @@ protected function getWp() return $this->wp; } - public function hasRelated($records, $class) + public function hasRelatedIn($records, $class) { foreach ($records as $record) { if (isset($record->related_records[fORM::tablize($class)])) { diff --git a/src/Model/AbstractParent.php b/src/Model/AbstractParent.php index 2da5dcb3..6b088aa4 100644 --- a/src/Model/AbstractParent.php +++ b/src/Model/AbstractParent.php @@ -4,7 +4,7 @@ * Allows to use parent class object without knowing it's data. * Used in addons when adding behaviours. * - * @method integer getId() getId() Gets the current value of id + * @method integer getId() Gets the current value of id */ abstract class WpTesting_Model_AbstractParent extends WpTesting_Model_AbstractModel { diff --git a/src/Model/AbstractTerm.php b/src/Model/AbstractTerm.php index 1ffdfcfb..1ca36e99 100644 --- a/src/Model/AbstractTerm.php +++ b/src/Model/AbstractTerm.php @@ -1,11 +1,11 @@ buildWpTesting_Model_Taxonomy()->getRecord(0); + return $this->buildRelated('WpTesting_Model_Taxonomy')->getRecord(0); } /** @@ -33,19 +33,26 @@ public function getAbbr() return mb_substr($this->getTitleOnce(), 0, 1, 'UTF-8'); } + /** + * @return string + */ public function getDescription() { - /* @var $result fRecordset */ - $result = $this->buildWpTesting_Model_Taxonomy(); + $result = $this->buildRelated('WpTesting_Model_Taxonomy'); if (!$result->count()) { return null; } return $result->getRecord(0)->getDescription(); } + /** + * @param integer $index + * @return string + */ public function getCssClass($index = null) { - $name = strtolower(end(explode('_', get_class($this)))); + $classParts = explode('_', get_class($this)); + $name = strtolower(end($classParts)); $id = $this->getId(); $slug = $this->getSlug(); $css = "$name $name-id-$id $name-slug-$slug"; diff --git a/src/Model/Answer.php b/src/Model/Answer.php index f9e00e8e..c030d876 100644 --- a/src/Model/Answer.php +++ b/src/Model/Answer.php @@ -1,12 +1,14 @@ populateSelf()->populateRelated($recursive); - } - - protected function populateRelated($recursive = false) - { + $this->populateSelf(); if ($recursive) { - $this->populateWpTesting_Model_Score(true, 'answer_id'); + $this->populateRelated('WpTesting_Model_Score', true, 'answer_id'); } return $this; } @@ -85,25 +83,20 @@ public function getGlobalTitle() } /** - * @return WpTesting_Model_Score[] + * @return fRecordSet|WpTesting_Model_Score[] */ public function buildScores() { return $this->buildScoresOnce(); } - public function associateScores($scores) - { - $this->associateWpTesting_Model_Score($scores); - } - /** - * @return fRecordSet of WpTesting_Model_Score + * @return fRecordSet|WpTesting_Model_Score[] */ protected function buildScoresOnce() { if (is_null($this->scores)) { - $this->scores = $this->buildWpTesting_Model_Scores(); + $this->scores = $this->buildRelated('WpTesting_Model_Scores'); $this->scoresByScaleId = array(); foreach ($this->scores as $score) { $this->scoresByScaleId[$score->get('scale_id')] = $score; @@ -117,7 +110,7 @@ protected function buildScoresOnce() */ public function createGlobalAnswer() { - return $this->createWpTesting_Model_GlobalAnswer(); + return $this->createRelated('WpTesting_Model_GlobalAnswer'); } /** @@ -125,7 +118,7 @@ public function createGlobalAnswer() */ public function createQuestion() { - return $this->createWpTesting_Model_Question(); + return $this->createRelated('WpTesting_Model_Question'); } /** @@ -150,7 +143,7 @@ public function getScoreByScale(WpTesting_Model_Scale $scale) if (!isset($this->scoresByScaleId[$scale->getId()])) { $this->scoresByScaleId[$scale->getId()] = new WpTesting_Model_Score(); $this->scoresByScaleId[$scale->getId()]->setScaleId($scale->getId()); - $this->associateWpTesting_Model_Scores($scores->merge($this->scoresByScaleId[$scale->getId()])); + $this->associateRelated('WpTesting_Model_Scores', $scores->merge($this->scoresByScaleId[$scale->getId()])); } return $this->scoresByScaleId[$scale->getId()]; } diff --git a/src/Model/Formula.php b/src/Model/Formula.php index 7b7a8b64..318047fc 100644 --- a/src/Model/Formula.php +++ b/src/Model/Formula.php @@ -5,13 +5,13 @@ * * Values with percents are replaced for their percentage analogs (when source contains %). * - * @method integer getId() getId() Gets the current value of id - * @method integer getTestId() getTestId() Gets the current value of test id - * @method WpTesting_Model_Formula setTestId() setTestId(integer $id) Sets the value for test id - * @method integer getResultId() getResultId() Gets the current value of result id - * @method WpTesting_Model_Formula setResultId() setResultId(integer $id) Sets the value for result id - * @method string getSource() getSource() Gets the current value of source - * @method WpTesting_Model_Formula setSource() setSource(string $source) Sets the value for source + * @method integer getId() Gets the current value of id + * @method integer getTestId() Gets the current value of test id + * @method WpTesting_Model_Formula setTestId(integer $id) Sets the value for test id + * @method integer getResultId() Gets the current value of result id + * @method WpTesting_Model_Formula setResultId(integer $id) Sets the value for result id + * @method string getSource() Gets the current value of source + * @method WpTesting_Model_Formula setSource(string $source) Sets the value for source */ class WpTesting_Model_Formula extends WpTesting_Model_AbstractModel { @@ -40,7 +40,7 @@ public function resetValues() * Adds value to values list without rewriting. Converts value type to integer if it's not double. * * @param string $name - * @param numeric $value + * @param integer|float $value * @param float $percentageValue Required only when we have "%" in source * @throws InvalidArgumentException * @return WpTesting_Model_Formula @@ -229,7 +229,7 @@ public function addValues(array $values) */ public function createResult() { - return $this->createWpTesting_Model_Result(); + return $this->createRelated('WpTesting_Model_Result'); } public function validateSource(WpTesting_Model_Formula $me, &$values, &$oldValues, &$relatedRecords, &$cache, &$validationMessages) @@ -250,7 +250,7 @@ public function validateSource(WpTesting_Model_Formula $me, &$values, &$oldValue // Check for formula correctness /* @var $test WpTesting_Model_Test */ - $test = $me->createWpTesting_Model_Test()->setWp($this->getWp()); + $test = $me->createRelated('WpTesting_Model_Test')->setWp($this->getWp()); $varNames = array(); foreach ($test->buildFormulaVariables() as $var) { $varNames[] = $var->getSource(); @@ -271,7 +271,7 @@ protected function configure() * * @param string $name1 * @param string $name2 - * @return number + * @return integer */ protected function compareValueNames($name1, $name2) { @@ -293,7 +293,7 @@ protected function compareValueNames($name1, $name2) * * @param string $name1 * @param string $name2 - * @return number + * @return integer */ protected function compareValueNamesInverted($name1, $name2) { diff --git a/src/Model/Passing.php b/src/Model/Passing.php index 9ee0ab51..62a4b9b2 100644 --- a/src/Model/Passing.php +++ b/src/Model/Passing.php @@ -1,24 +1,24 @@ setCreated(time())->setModified(time())->setTestId($test->getId()); - parent::populate(true); - $this->linkWpTesting_Model_Answers(); - return $this; + $now = time(); + return $this + ->setCreated($now) + ->setModified($now) + ->setTestId($test->getId()) + ->populate(true) + ->linkRelated('WpTesting_Model_Answers') + ; } /** @@ -103,7 +107,7 @@ public function populateAll() $this->wp->doAction('wp_testing_passing_populate_all_before', $this); $_POST = $this->wp->applyFilters('wp_testing_passing_adapt_for_populate', $_POST, $this); - parent::populate(true); + $this->populate(true); $this->wp->doAction('wp_testing_passing_populate_all_after', $this); return $this; @@ -162,7 +166,7 @@ public function setRespondentId($respondentId) if (empty($respondentId)) { $respondentId = null; } - return parent::set('respondent_id', $respondentId); + return $this->set('respondent_id', $respondentId); } public function setStepStrategy(WpTesting_Component_StepStrategy $stepStrategy) @@ -204,15 +208,15 @@ public function getAnsweredQuestionsCount() } /** - * @return WpTesting_Model_Answer[] + * @return fRecordSet|WpTesting_Model_Answer[] */ public function buildAnswers() { - return $this->buildWpTesting_Model_Answers(); + return $this->buildRelated('WpTesting_Model_Answers'); } /** - * @return WpTesting_Model_Score[] + * @return fRecordSet|WpTesting_Model_Score[] */ public function buildAnswersScores() { @@ -228,7 +232,7 @@ public function buildAnswersScores() /** * Build scales and setup their ranges from test's questions * - * @return WpTesting_Model_Scale[] + * @return fRecordSet|WpTesting_Model_Scale[] */ public function buildScalesWithRange() { @@ -258,7 +262,7 @@ public function buildScalesWithRange() * Build scales and setup their ranges from test's questions. * Cached version. * - * @return WpTesting_Model_Scale[] + * @return fRecordSet|WpTesting_Model_Scale[] */ public function buildScalesWithRangeOnce() { @@ -271,7 +275,7 @@ public function buildScalesWithRangeOnce() /** * Prepare results through test, that has true formulas, using current test variables * - * @return WpTesting_Model_Result[] + * @return fRecordSet|WpTesting_Model_Result[] */ public function buildResults() { @@ -296,7 +300,7 @@ public function buildResults() */ public function createTest() { - return $this->createWpTesting_Model_Test()->setWp($this->getWp()); + return $this->createRelated('WpTesting_Model_Test')->setWp($this->getWp()); } public function trash() diff --git a/src/Model/Question.php b/src/Model/Question.php index 0ec2f3b3..d6a7e4bf 100644 --- a/src/Model/Question.php +++ b/src/Model/Question.php @@ -1,9 +1,9 @@ populateSelf()->populateRelated($recursive); - } - - protected function populateRelated($recursive = false) - { + $this->populateSelf(); if ($recursive) { - $this->populateWpTesting_Model_Answer(true, 'question_id'); + $this->populateRelated('WpTesting_Model_Answer', true, 'question_id'); } return $this; } /** - * @return WpTesting_Model_Answer[] + * @return fRecordSet|WpTesting_Model_Answer[] */ public function buildAnswers() { - return $this->buildWpTesting_Model_Answer(); + return $this->buildRelated('WpTesting_Model_Answer'); } public function associateAnswers($answers) { - $this->associateWpTesting_Model_Answer($answers); + $this->associateRelated('WpTesting_Model_Answer', $answers); } /** @@ -49,10 +45,11 @@ public function associateAnswers($answers) */ public function createTest() { - return $this->createWpTesting_Model_Test()->setWp($this->getWp()); + return $this->createRelated('WpTesting_Model_Test')->setWp($this->getWp()); } - public function jsonSerialize() { + public function jsonSerialize() + { return array( 'id' => $this->getId(), 'title' => $this->getTitle(), diff --git a/src/Model/Respondent.php b/src/Model/Respondent.php index 3162c17b..cfefedaf 100644 --- a/src/Model/Respondent.php +++ b/src/Model/Respondent.php @@ -1,10 +1,10 @@ maximum - min(array($this->minimum, 0)); - } + } /** * @return number diff --git a/src/Model/Score.php b/src/Model/Score.php index 4075d9c0..043492c7 100644 --- a/src/Model/Score.php +++ b/src/Model/Score.php @@ -1,8 +1,8 @@ createWpTesting_Model_Scale('scale_id'); + return $this->createRelated('WpTesting_Model_Scale', 'scale_id'); } } diff --git a/src/Model/Shortcode.php b/src/Model/Shortcode.php index bc76e465..5548f43a 100644 --- a/src/Model/Shortcode.php +++ b/src/Model/Shortcode.php @@ -37,13 +37,17 @@ public function getUniqueName() /** * Should be overrided by shortcodes, which could be identified by ids/names/other params - * @return mixed + * @return string */ protected function getUniqueIdentifier() { return null; } + /** + * @param WpTesting_Facade_IORM $ormAware + * @return array + */ public function getDataForTemplate(WpTesting_Facade_IORM $ormAware) { return array(); diff --git a/src/Model/Shortcode/Attribute.php b/src/Model/Shortcode/Attribute.php index fce6d521..610239d4 100644 --- a/src/Model/Shortcode/Attribute.php +++ b/src/Model/Shortcode/Attribute.php @@ -3,14 +3,30 @@ class WpTesting_Model_Shortcode_Attribute { + /** + * @var string + */ private $externalName; + + /** + * @var string + */ private $propertyName; + + /** + * @var mixed + */ private $defaultValue; private $allowMask; private $allowList; private $errorGuide; + /** + * @param string $externalName + * @param string $propertyName + * @param mixed $defaultValue + */ public function __construct($externalName, $propertyName = null, $defaultValue = null) { $this->externalName = $externalName; @@ -81,12 +97,15 @@ public function cleanValue($dirtyValue) return $dirtyValue; } + /** + * @return string + */ public function getPropertyName() { return $this->propertyName; } - private function formExceptionMessage($template) + private function formExceptionMessage() { $argsPhp52Workaround = func_get_args(); $message = call_user_func_array('sprintf', $argsPhp52Workaround); diff --git a/src/Model/Shortcode/Test.php b/src/Model/Shortcode/Test.php index 72ce3a58..9445c4b6 100644 --- a/src/Model/Shortcode/Test.php +++ b/src/Model/Shortcode/Test.php @@ -30,10 +30,13 @@ public function getDataForTemplate(WpTesting_Facade_IORM $ormAware) ); } + /** + * @return string + */ protected function getUniqueIdentifier() { $ids = array_filter(array($this->testId, $this->testName)); - return reset($ids); + return (string)reset($ids); } /** diff --git a/src/Model/Shortcode/TestFirstPage.php b/src/Model/Shortcode/TestFirstPage.php index 15ff9816..45ef23f8 100644 --- a/src/Model/Shortcode/TestFirstPage.php +++ b/src/Model/Shortcode/TestFirstPage.php @@ -4,11 +4,4 @@ class WpTesting_Model_Shortcode_TestFirstPage extends WpTesting_Model_Shortcode_ { const NAME = 'wpt_test_first_page'; - - public function getDataForTemplate(WpTesting_Facade_IORM $ormAware) - { - return array_merge(parent::getDataForTemplate($ormAware), array( - 'content' => null, - )); - } } diff --git a/src/Model/Step.php b/src/Model/Step.php index 8bf8e37d..1215dd0e 100644 --- a/src/Model/Step.php +++ b/src/Model/Step.php @@ -3,17 +3,28 @@ class WpTesting_Model_Step { private $title = ''; + + /** + * @var fRecordSet|WpTesting_Model_Question[] + */ private $questions = array(); + private $description = null; private $total = 1; private $number = 1; - public function __construct($title, fRecordSet $questions, $description = null) + /** + * @param string $title + * @param fRecordSet|WpTesting_Model_Question[] $questions + * @param string $description + * @throws InvalidArgumentException + */ + public function __construct($title, $questions, $description = null) { - $this->title = $title; - $this->questions = $questions; - $this->description = $description; + $this->title = $title; + $this->setQuestions($questions); + $this->description = $description; } public function setTotalAndNumber($total, $number) @@ -81,4 +92,29 @@ public function isLast() { return ($this->number == $this->total); } + + /** + * @param fRecordSet|WpTesting_Model_Question[] $questions + * @throws InvalidArgumentException + * @return self + */ + private function setQuestions($questions) + { + if (empty($questions) || count($questions) == 0) { + $this->questions = array(); + return $this; + } + + if (!is_a($questions, 'fRecordSet')) { + $questions = fRecordSet::buildFromArray('WpTesting_Model_Question', (array)$questions); + } + + if ($questions->getClass() != 'WpTesting_Model_Question') { + throw new InvalidArgumentException('Step require questions, but provided ' . $questions->getClass()); + } + + $this->questions = $questions; + + return $this; + } } diff --git a/src/Model/Taxonomy.php b/src/Model/Taxonomy.php index c7dd94b1..2e7c13b2 100644 --- a/src/Model/Taxonomy.php +++ b/src/Model/Taxonomy.php @@ -3,7 +3,7 @@ /** * WordPress needed model for category-like entities * - * @method string getDescription() getDescription() Gets the current value of description + * @method string getDescription() Gets the current value of description */ class WpTesting_Model_Taxonomy extends WpTesting_Model_AbstractModel { diff --git a/src/Model/Test.php b/src/Model/Test.php index 6a61848e..446f2eb9 100644 --- a/src/Model/Test.php +++ b/src/Model/Test.php @@ -1,30 +1,30 @@ me()->buildWpTesting_Model_Questions(); + return $this->me()->buildRelated('WpTesting_Model_Questions'); } /** - * @return WpTesting_Model_Question[] + * @return fRecordSet|WpTesting_Model_Question[] */ public function buildQuestionsWithAnswersAndScores() { @@ -85,16 +85,16 @@ public function buildQuestionsWithAnswersAndScores() if (!count($questions)) { return $questions; } - if ($this->me()->hasRelated($questions, 'WpTesting_Model_Answer')) { + if ($this->me()->hasRelatedIn($questions, 'WpTesting_Model_Answer')) { return $questions; } $answersById = $this->associateManyRelated($questions, 'WpTesting_Model_Answer', 'question_id'); - $scoresById = $this->associateManyRelated($answersById, 'WpTesting_Model_Score', 'answer_id'); + $this->associateManyRelated($answersById, 'WpTesting_Model_Score', 'answer_id'); return $questions; } /** - * @return WpTesting_Model_Question[] + * @return fRecordSet|WpTesting_Model_Question[] */ public function buildQuestionsWithAnswers() { @@ -102,30 +102,25 @@ public function buildQuestionsWithAnswers() if (!count($questions)) { return $questions; } - if ($this->me()->hasRelated($questions, 'WpTesting_Model_Answer')) { + if ($this->me()->hasRelatedIn($questions, 'WpTesting_Model_Answer')) { return $questions; } - $answersById = $this->associateManyRelated($questions, 'WpTesting_Model_Answer', 'question_id'); + $this->associateManyRelated($questions, 'WpTesting_Model_Answer', 'question_id'); return $questions; } /** - * @return WpTesting_Model_Scale[] + * @return fRecordSet|WpTesting_Model_Scale[] */ public function buildScales() { - $ids = $this->getTermIdFromFilteredTaxonomies('wpt_scale'); - return fRecordSet::build('WpTesting_Model_Scale', array( - 'term_id=' => $ids, - ), array( - 'FIELD(term_id, ' . implode(', ', $ids) . ')' => 'asc', - )); + return $this->buildRelatedTaxonomies('wpt_scale', 'WpTesting_Model_Scale'); } /** * Build scales and setup their ranges from test's questions * - * @return WpTesting_Model_Scale[] + * @return fRecordSet|WpTesting_Model_Scale[] */ public function buildScalesWithRange() { @@ -133,7 +128,7 @@ public function buildScalesWithRange() if (!$scales->count()) { return $scales; } - $questionIds = array_filter($this->listWpTesting_Model_Questions()); + $questionIds = array_filter($this->listRelated('WpTesting_Model_Questions')); if (empty($questionIds)) { return $scales; } @@ -178,7 +173,7 @@ public function buildScalesWithRange() } /** - * @return WpTesting_Model_Result[] + * @return fRecordSet|WpTesting_Model_Result[] */ public function buildResults() { @@ -224,20 +219,25 @@ public function buildFormulaVariables(WpTesting_Model_Passing $passing = null) } /** - * @return WpTesting_Model_Formula[] + * @return fRecordSet|WpTesting_Model_Formula[] */ public function buildFormulas() { - return $this->buildWpTesting_Model_Formulas(); + return $this->buildRelated('WpTesting_Model_Formulas'); } /** - * @return WpTesting_Model_GlobalAnswer[] + * @return fRecordSet|WpTesting_Model_GlobalAnswer[] */ public function buildGlobalAnswers() { - $ids = $this->getTermIdFromFilteredTaxonomies('wpt_answer'); - return fRecordSet::build('WpTesting_Model_GlobalAnswer', array( + return $this->buildRelatedTaxonomies('wpt_answer', 'WpTesting_Model_GlobalAnswer'); + } + + protected function buildRelatedTaxonomies($taxomony, $model) + { + $ids = $this->getTermIdFromFilteredTaxonomies($taxomony); + return fRecordSet::build($model, array( 'term_id=' => $ids, ), array( 'FIELD(term_id, ' . implode(', ', $ids) . ')' => 'asc', @@ -245,15 +245,15 @@ public function buildGlobalAnswers() } /** - * @return WpTesting_Model_Taxonomy[] + * @return fRecordSet|WpTesting_Model_Taxonomy[] */ protected function buildTaxonomies() { - return $this->buildWpTesting_Model_Taxonomy(); + return $this->buildRelated('WpTesting_Model_Taxonomy'); } /** - * @return fRecordSet of WpTesting_Model_Taxonomy + * @return fRecordSet|WpTesting_Model_Taxonomy[] */ protected function buildTaxonomiesOnce() { @@ -303,13 +303,13 @@ protected function getFormulasPrefix() /** * Adds new question associated to this test * @param string $title - * @return WpTesting_Model_Test + * @return self */ public function addQuestion($title) { $question = new WpTesting_Model_Question(); $question->setTitle($title); - $this->associateWpTesting_Model_Questions($this->buildQuestions()->merge($question)); + $this->associateRelated('WpTesting_Model_Questions', $this->buildQuestions()->merge($question)); return $this; } @@ -325,8 +325,8 @@ public function associateGlobalAnswer(WpTesting_Model_GlobalAnswer $globalAnswer private function associateAbstractTerm(WpTesting_Model_AbstractTerm $term) { - $this->associateWpTesting_Model_Taxonomies( - $this->buildWpTesting_Model_Taxonomies() + $this->associateRelated('WpTesting_Model_Taxonomies', + $this->buildRelated('WpTesting_Model_Taxonomies') ->merge($term->createTaxonomy()) ); return $this; @@ -457,7 +457,7 @@ public function canEditScores() { return true && $this->hasScales() - && $this->hasWpTesting_Model_Questions() + && $this->hasRelated('WpTesting_Model_Questions') && $this->hasAnswers() ; } @@ -630,7 +630,7 @@ public function adaptForPopulate($request, $testId) */ public function populateQuestions($isRecursive = false) { - $this->populateWpTesting_Model_Questions($isRecursive); + $this->populateRelated('WpTesting_Model_Questions', $isRecursive); $table = fORM::tablize('WpTesting_Model_Question'); $records =& $this->related_records[$table]['test_id']['record_set']; $records = $records->filter(array('getTitle!=' => '')); @@ -643,7 +643,7 @@ public function populateQuestions($isRecursive = false) */ public function populateFormulas($isRecursive = false) { - return $this->populateWpTesting_Model_Formulas($isRecursive); + return $this->populateRelated('WpTesting_Model_Formulas', $isRecursive); } /** @@ -700,7 +700,7 @@ public function getPublishedUrl() /** * Export as WP native content entity object * - * @return WP_Post + * @return WP_Post|stdClass */ public function toWpPost() { diff --git a/src/Query/AbstractQuery.php b/src/Query/AbstractQuery.php index 2df0ca33..c495c66f 100644 --- a/src/Query/AbstractQuery.php +++ b/src/Query/AbstractQuery.php @@ -21,11 +21,31 @@ public static function create($className = __CLASS__) } /** - * @return WpTesting_Model_AbstractModel[] + * @return fRecordSet|WpTesting_Model_AbstractModel[] */ public function findAll() { return fRecordSet::build($this->modelName); } -} \ No newline at end of file + /** + * Translates one SQL statement using fSQLTranslation and executes it + * + * @param string $sql + * @return fResult + * @throws BadMethodCallException + */ + protected function singleTranslatedQuery($sql) + { + $arguments = func_get_args(); + $arguments[0] = $sql; + $result = call_user_func_array(array($this->db, 'translatedQuery'), $arguments); + if ($result instanceof fResult) { + return $result; + } + if (is_array($result) && isset($result[0]) && $result[0] instanceof fResult) { + return $result[0]; + } + throw new BadMethodCallException('Result of translatedQuery is not fRecordSet: ' . var_export($result, true)); + } +} diff --git a/src/Query/AbstractTerm.php b/src/Query/AbstractTerm.php index 121534c5..74b02046 100644 --- a/src/Query/AbstractTerm.php +++ b/src/Query/AbstractTerm.php @@ -35,4 +35,4 @@ protected function findByParams(array $where = array()) throw new fNotFoundException($this->modelName . ' not found by conditions: ' . var_export($where, true)); } } -} \ No newline at end of file +} diff --git a/src/Query/GlobalAnswer.php b/src/Query/GlobalAnswer.php index 59f42afd..3576022f 100644 --- a/src/Query/GlobalAnswer.php +++ b/src/Query/GlobalAnswer.php @@ -23,4 +23,4 @@ public function findByName($name) { return parent::findByName($name); } -} \ No newline at end of file +} diff --git a/src/Query/Passing.php b/src/Query/Passing.php index cacd58f2..66b84e23 100644 --- a/src/Query/Passing.php +++ b/src/Query/Passing.php @@ -14,6 +14,9 @@ public function findAllPagedSorted($page, $recordsPerPage = 10, $orderBy = array return $this->findAllPagedSortedByParams(array(), $page, $recordsPerPage, $orderBy); } + /** + * @return fRecordSet|WpTesting_Model_Passing[] + */ public function findAllPagedSortedByParams($params, $page, $recordsPerPage = 10, $orderBy = array()) { $conditions = array(); @@ -61,7 +64,7 @@ public function findAllPagedSortedByParams($params, $page, $recordsPerPage = 10, /** * @param array $ids * @param array $orderBy - * @return fRecordSet + * @return fRecordSet|WpTesting_Model_Passing[] */ public function findAllByIds($ids, $orderBy = array()) { @@ -73,7 +76,7 @@ public function findAllByIds($ids, $orderBy = array()) /** * Passings sorted by the order of provided $ids * @param array $ids - * @return fRecordSet + * @return fRecordSet|WpTesting_Model_Passing[] */ public function findAllByIdsSorted($ids) { @@ -95,7 +98,7 @@ public function queryAllMonths() */ public function queryAllMonthsByRespondent($respondentId) { - return $this->db->translatedQuery(' + return $this->singleTranslatedQuery(' SELECT DISTINCT YEAR(passing_created) AS created_year, MONTH(passing_created) AS created_month FROM %r WHERE (respondent_id = %i OR %i = 0) @@ -108,10 +111,10 @@ public function queryAllMonthsByRespondent($respondentId) */ public function countAllStatuses() { - return $this->db->translatedQuery(' + return $this->singleTranslatedQuery(' SELECT passing_status, COUNT(*) AS passing_count FROM %r GROUP BY passing_status ', $this->tableName); } -} \ No newline at end of file +} diff --git a/src/Query/Scale.php b/src/Query/Scale.php index 91f4f82a..53f35b7e 100644 --- a/src/Query/Scale.php +++ b/src/Query/Scale.php @@ -23,4 +23,4 @@ public function findByName($name) { return parent::findByName($name); } -} \ No newline at end of file +} diff --git a/src/Query/Test.php b/src/Query/Test.php index bf025a7e..50802994 100644 --- a/src/Query/Test.php +++ b/src/Query/Test.php @@ -24,7 +24,7 @@ public function findByIdOrName($id, $name) /** * @param array $orderBy - * @return WpTesting_Model_Test[] + * @return fRecordSet|WpTesting_Model_Test[] */ public function findAll(array $orderBy = array()) { @@ -33,7 +33,7 @@ public function findAll(array $orderBy = array()) /** * @param array $orderBy - * @return WpTesting_Model_Test[] + * @return fRecordSet|WpTesting_Model_Test[] */ public function findAllPublished(array $orderBy = array(), $limit = null) { @@ -58,7 +58,7 @@ public function findAllByIds(array $ids = array()) /** * @param integer $respondentId * @param array $orderBy - * @return WpTesting_Model_Test[] + * @return fRecordSet|WpTesting_Model_Test[] */ public function findAllByPassingRespondent($respondentId, array $orderBy = array('Test.ID')) { @@ -82,7 +82,7 @@ public function findAllByPassingRespondent($respondentId, array $orderBy = array /** * @param array $where * @param array $orderBy - * @return WpTesting_Model_Test[] + * @return fRecordSet|WpTesting_Model_Test[] */ protected function findAllByParams(array $where = array(), array $orderBy = array(), $limit = null) { @@ -94,8 +94,8 @@ protected function findAllByParams(array $where = array(), array $orderBy = arra /** * @param array $where * @param array $orderBy - * @return WpTesting_Model_Test[] - * @throws fNoRemainingException When test is not found + * @return WpTesting_Model_Test + * @throws fNoRemainingException When test is not found */ protected function findFirstByParams(array $where = array(), array $orderBy = array()) { diff --git a/src/Template/Test/Editor/metabox-options.php b/src/Template/Test/Editor/metabox-options.php index 30d10b91..154980b6 100644 --- a/src/Template/Test/Editor/metabox-options.php +++ b/src/Template/Test/Editor/metabox-options.php @@ -1,4 +1,5 @@ - + + $option): ?> diff --git a/src/Widget/ListTable.php b/src/Widget/ListTable.php index f8471141..22e2bb2b 100644 --- a/src/Widget/ListTable.php +++ b/src/Widget/ListTable.php @@ -121,14 +121,17 @@ public function prepare_items() 'total_pages' => ceil($total / $this->records_per_page) )); - $this->row_number = ($this->get_pagenum()-1) * $this->records_per_page; + $this->row_number = intval(($this->get_pagenum()-1) * $this->records_per_page); if ($this->is_order_desc()) { - $this->row_number = ($total + 1) - $this->row_number; + $this->row_number = intval(($total + 1) - $this->row_number); } return $this; } + /** + * @return boolean + */ public function has_items() { if ($this->items instanceof fRecordSet) { @@ -211,7 +214,7 @@ public function column_default($item, $column_name) /** * @param WpTesting_Model_AbstractModel $item * @param string $column_name - * @return string + * @return string|integer */ protected function render_static_column(WpTesting_Model_AbstractModel $item, $column_name) { diff --git a/src/Widget/ListTableColumn.php b/src/Widget/ListTableColumn.php index a2d632ec..940d8d7f 100644 --- a/src/Widget/ListTableColumn.php +++ b/src/Widget/ListTableColumn.php @@ -3,17 +3,27 @@ abstract class WpTesting_Widget_ListTableColumn { + /** + * @return string + */ abstract public function key(); + /** + * @return string + */ public function placeAfter() { return null; } + /** + * @return string + */ abstract public function title(); /** * @param WpTesting_Model_AbstractModel $item + * @return string */ abstract public function value($item); } diff --git a/src/Widget/PassingTable.php b/src/Widget/PassingTable.php index 16e0dd19..60070e91 100644 --- a/src/Widget/PassingTable.php +++ b/src/Widget/PassingTable.php @@ -40,20 +40,42 @@ protected function render_filter_controls() /** * @param WpTesting_Model_Passing $item * @param string $column_name - * @return string + * @return string|integer */ protected function render_static_column(WpTesting_Model_Passing $item, $column_name) { switch($column_name) { case 'passing_created': - return $item->getCreated(); + return $item->getCreated()->__toString(); + case 'test_title': + $test = $item->createTest(); + return $this->render_link( + $this->get_test_title_link($test), + $test->getTitle() + ); } return ''; } + protected function get_test_title_link(WpTesting_Model_Test $test) + { + return $this->wp->getPostPermalink($test->getId()); + } + + protected function find_items() + { + return WpTesting_Query_Passing::create() + ->findAllPagedSortedByParams($this->get_find_items_params(), $this->get_pagenum(), $this->records_per_page, $this->get_order_by()); + } + + /** + * @return array + */ + abstract protected function get_find_items_params(); + /** - * @return WpTesting_Model_Test[] + * @return fRecordSet|WpTesting_Model_Test[] */ abstract protected function find_tests(); diff --git a/src/Widget/PassingTable/Admin.php b/src/Widget/PassingTable/Admin.php index f2782f6e..531d74ae 100644 --- a/src/Widget/PassingTable/Admin.php +++ b/src/Widget/PassingTable/Admin.php @@ -106,13 +106,11 @@ public function prepare_items() return parent::prepare_items(); } - protected function find_items() + protected function get_find_items_params() { $params = $this->get_filter_params($this->find_items_filter_params); $params['passing_status'] = fRequest::get('passing_status', 'array', array('publish')); - - return WpTesting_Query_Passing::create() - ->findAllPagedSortedByParams($params, $this->get_pagenum(), $this->records_per_page, $this->get_order_by()); + return $params; } protected function find_tests() @@ -125,7 +123,8 @@ protected function find_years_months() return WpTesting_Query_Passing::create()->queryAllMonths(); } - public function column_cb(WpTesting_Model_Passing $item) { + public function column_cb(WpTesting_Model_Passing $item) + { $label = $this->render_tag('label', array( 'class' => 'screen-reader-text', 'for' => 'cb-select-' . $item->getId(), @@ -146,7 +145,7 @@ public function column_cb(WpTesting_Model_Passing $item) { /** * @param WpTesting_Model_Passing $item * @param string $column_name - * @return string + * @return string|integer */ protected function render_static_column(WpTesting_Model_Passing $item, $column_name) { @@ -163,13 +162,6 @@ protected function render_static_column(WpTesting_Model_Passing $item, $column_n case 'passing_user_agent': return $item->getUserAgent(); - case 'test_title': - $test = $item->createTest(); - return $this->render_link( - $this->wp->getEditPostLink($test->getId()), - $test->getTitle() - ); - case 'results': $links = array(); @@ -224,7 +216,13 @@ protected function render_static_column(WpTesting_Model_Passing $item, $column_n return parent::render_static_column($item, $column_name); } - public function get_views() { + protected function get_test_title_link(WpTesting_Model_Test $test) + { + return $this->wp->getEditPostLink($test->getId()); + } + + public function get_views() + { $results = WpTesting_Query_Passing::create()->countAllStatuses(); $views = array( 'all' => '', diff --git a/src/Widget/PassingTable/User.php b/src/Widget/PassingTable/User.php index a9e13b28..39e7cdcd 100644 --- a/src/Widget/PassingTable/User.php +++ b/src/Widget/PassingTable/User.php @@ -30,14 +30,13 @@ protected function get_static_columns() ); } - protected function find_items() + protected function get_find_items_params() { $params = $this->get_filter_params(array( 'test_id', )); $params['respondent_id'] = $this->wp->getCurrentUserId(); - return WpTesting_Query_Passing::create() - ->findAllPagedSortedByParams($params, $this->get_pagenum(), $this->records_per_page, $this->get_order_by()); + return $params; } protected function find_tests() @@ -55,7 +54,7 @@ protected function find_years_months() /** * @param WpTesting_Model_Passing $item * @param string $column_name - * @return string + * @return string|integer */ protected function render_static_column(WpTesting_Model_Passing $item, $column_name) { @@ -63,13 +62,6 @@ protected function render_static_column(WpTesting_Model_Passing $item, $column_n case 'row_number': return $this->get_row_number(); - case 'test_title': - $test = $item->createTest(); - return $this->render_link( - $this->wp->getPostPermalink($test->getId()), - $test->getTitle() - ); - case 'results': $links = array(); diff --git a/src/Widget/PlaceholderTemplate/Collection.php b/src/Widget/PlaceholderTemplate/Collection.php index bbcf0128..753d0e17 100644 --- a/src/Widget/PlaceholderTemplate/Collection.php +++ b/src/Widget/PlaceholderTemplate/Collection.php @@ -3,9 +3,9 @@ class WpTesting_Widget_PlaceholderTemplate_Collection { /** - * @var WpTesting_Widget_PlaceholderTemplate[] + * @var array|WpTesting_Widget_PlaceholderTemplate[] */ - private $templates; + private $templates = array(); /** * Set template by key diff --git a/src/WordPress/IPriority.php b/src/WordPress/IPriority.php new file mode 100644 index 00000000..2b7fd273 --- /dev/null +++ b/src/WordPress/IPriority.php @@ -0,0 +1,25 @@ +` tag for the user's avatar. */ - function getAvatar($idOrEmail, $size = 96, $default = '', $alt = false) + public function getAvatar($idOrEmail, $size = 96, $default = '', $alt = false) { return get_avatar($idOrEmail, $size, $default, $alt); } @@ -345,7 +362,7 @@ function getAvatar($idOrEmail, $size = 96, $default = '', $alt = false) * * @since 3.5.0 * - * @param int $userId Optional. User ID. Defaults to the current user. + * @param integer|null $userId Optional. User ID. Defaults to the current user. * @return string URL to edit user page or empty string. */ public function getEditUserLink($userId = null) @@ -355,7 +372,7 @@ public function getEditUserLink($userId = null) } $currentUserId = $this->getCurrentUserId(); - if (!$userId) { + if (is_null($userId)) { $userId = $currentUserId; } @@ -444,6 +461,10 @@ protected function setPluginFile($pluginFile) return $this; } + /** + * @param string $pluginFile + * @return string + */ private function guessPluginFilePath($pluginFile) { if (!defined('WP_PLUGIN_DIR')) { @@ -528,7 +549,7 @@ public function registerPluginScript($name, $pluginRelatedPath, array $dependenc * @param string $path * @param array $dependencies * @param string $version - * @param string $isInFooter + * @param boolean $isInFooter * @return WpTesting_WordPressFacade */ public function registerScript($name, $path, array $dependencies = array(), $version = false, $isInFooter = false) @@ -641,7 +662,7 @@ public function locateTemplate($templateNames, $isLoad = false, $isRequireOnce = * * @since 1.0.0 * - * @param number|WP_Post $id + * @param integer|WP_Post|stdClass $id * @param string $isLeaveName * @return string|bool */ @@ -801,7 +822,7 @@ public function getSalt($scheme = 'auth') * @param int $functionArgsCount optional. The number of arguments the function accept (default 1). * @return WpTesting_WordPressFacade */ - public function addAction($tag, $function, $priority = 10, $functionArgsCount = 1) + public function addAction($tag, $function, $priority = self::PRIORITY_DEFAULT, $functionArgsCount = 1) { add_action($tag, $function, $priority, $functionArgsCount); return $this; @@ -857,8 +878,9 @@ public function didAction($tag) * @param int $priority Optional. The priority of the function. Default 10. * @return WpTesting_WordPressFacade */ - public function removeAction($tag, $function, $priority = 10) { - remove_action($tag, $function); + public function removeAction($tag, $function, $priority = 10) + { + remove_action($tag, $function, $priority); return $this; } @@ -873,7 +895,7 @@ public function removeAction($tag, $function, $priority = 10) { * @param int $functionArgsCount optional. The number of arguments the function accept (default 1). * @return WpTesting_WordPressFacade */ - public function addFilter($tag, $function, $priority = 10, $functionArgsCount = 1) + public function addFilter($tag, $function, $priority = self::PRIORITY_DEFAULT, $functionArgsCount = 1) { add_filter($tag, $function, $priority, $functionArgsCount); return $this; @@ -885,15 +907,15 @@ public function addFilter($tag, $function, $priority = 10, $functionArgsCount = * @since 2.5.0 * * @param string $tag The name of the filter hook. - * @param callback|bool $function Optional. The callback to check for. Default false. - * @return false|int If $function is omitted, returns boolean for whether the hook has + * @param callback|boolean $function Optional. The callback to check for. Default false. + * @return boolean|integer If $function is omitted, returns boolean for whether the hook has * anything registered. When checking a specific function, the priority of that * hook is returned, or false if the function is not attached. When using the * $function_to_check argument, this function may return a non-boolean value * that evaluates to false (e.g.) 0, so use the === operator for testing the * return value. */ - public function hasFilter($tag, $function) + public function hasFilter($tag, $function = false) { return has_filter($tag, $function); } @@ -904,9 +926,9 @@ public function hasFilter($tag, $function) * @see WpTesting_WordPressFacade::addFilter * @return WpTesting_WordPressFacade */ - public function addFilterOnce($tag, $function, $priority = 10, $functionArgsCount = 1) + public function addFilterOnce($tag, $function, $priority = self::PRIORITY_DEFAULT, $functionArgsCount = 1) { - if ($this->hasFilter($tag, $function)) { + if ($this->hasFilter($tag, $function) !== false) { return $this; } return $this->addFilter($tag, $function, $priority, $functionArgsCount); @@ -951,7 +973,6 @@ public function removeFilter($tag, $functionToRemove, $priority = 10, $acceptedA * * @param string $tag The name of the filter hook. * @param mixed $value The value on which the filters hooked to `$tag` are applied on. - * @param mixed $var Additional variables passed to the functions hooked to `$tag`. * @return mixed The filtered value after all hooked functions are applied to it. */ public function applyFilters($tag, $value) @@ -1025,7 +1046,7 @@ public function removeShortcode($tag) * @param string $shortcode Optional. The name of the shortcode, provided for context to enable filtering * @return array Combined and filtered attribute list. */ - function sanitazeShortcodeAttributes($defaults, $attributes, $shortcode = '') + public function sanitazeShortcodeAttributes($defaults, $attributes, $shortcode = '') { return shortcode_atts($defaults, $attributes, $shortcode); } @@ -1086,9 +1107,13 @@ public function getMetaBoxes($screen = null, $context = 'advanced', $priority = */ public function setMetaBoxes($values, $screen = null, $context = 'advanced', $priority = 'default') { - return $this->processMetaBoxes($screen, $context, $priority, __FUNCTION__, $values); + $this->processMetaBoxes($screen, $context, $priority, __FUNCTION__, $values); + return $this; } + /** + * @return array + */ protected function processMetaBoxes($screen, $context, $priority, $action, $values) { global $wp_meta_boxes; @@ -1107,10 +1132,9 @@ protected function processMetaBoxes($screen, $context, $priority, $action, $valu if ('getMetaBoxes' == $action) { return $wp_meta_boxes[$page][$context][$priority]; - } - if ('setMetaBoxes' == $action) { + } elseif ('setMetaBoxes' == $action) { $wp_meta_boxes[$page][$context][$priority] = $values; - return $this; + return array(); } } @@ -1227,7 +1251,7 @@ public function addMenuPage($pageTitle, $menuTitle, $capability, $menuSlug, $fun * @param string $capability The capability required for this menu to be displayed to the user. * @param string $menuSlug The slug name to refer to this menu by (should be unique for this menu) * @param callback $function The function to be called to output the content for this page. - * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability required. + * @return string|boolean The resulting page's hook_suffix, or false if the user does not have the capability required. */ public function addSubmenuPage($parentSlug, $pageTitle, $menuTitle, $capability, $menuSlug, $function = '') { diff --git a/src/bootstrap.php b/src/bootstrap.php new file mode 100644 index 00000000..5baa0cdb --- /dev/null +++ b/src/bootstrap.php @@ -0,0 +1,10 @@ + + + + + mlt_producer + 00:00:11:03 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 178049 + bd6e3c02773e484b272693995512e9a8 + 1 + + + mlt_producer + 00:00:23:18 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/02.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 1728030 + 37bd02aa2b7e99312ec7a9b164404163 + 1 + + + producer + 00:00:11:04 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/img/01-title.png + 25 + 1 + 1 + 1 + 1 + 1616 + 1024 + pixbuf + 289548 + 563e9403b590b549efcb267964aaaede + + + mlt_producer + 00:00:01:29 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/02-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + let-s-activate + 1 + 31822 + 1939c5615953ed27815175e57feafe46 + 1 + + + mlt_producer + 00:00:03:28 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/02-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + we-see-menu + 1 + 63166 + dd36d980819cd5dc027826ae361f187b + 1 + + + mlt_producer + 00:00:04:09 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 68962 + 7eee8c0249883ca260368f712a4ac1c2 + 1 + + + mlt_producer + 00:00:23:14 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/03.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 1117157 + 70f3a60e2d555e45dc3560b1bffe1732 + 57 + 123 + 1 + + + mlt_producer + 00:03:40:26 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/04.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 39351947 + a9fc7d435e2203aa5d6f52e535e5a4b8 + 1 + + + mlt_producer + 00:00:03:08 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + 1 + 52707 + 38ea7d77bec24830d9104de839b124c4 + 1 + + + mlt_producer + 00:00:02:01 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + 1 + 33063 + 4062144bcced45436fa7a007c6d84a04 + 1 + + + mlt_producer + 00:00:01:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + 1 + 27630 + 593f765c4c68c67c4e8240c59369506a + 1 + + + mlt_producer + 00:00:03:02 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 1 + 1 + 49364 + 02f0c8ac186266eb8e748338325e6598 + 1 + + + mlt_producer + 00:00:05:18 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-05.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 5 + 2 + 1 + 89906 + 76d499c3e1c61f5b0dbf0e2e62b242f4 + 1 + + + mlt_producer + 00:00:06:16 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-06.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 6 + 3 + 1 + 104952 + 042b06d23062bf430ab1fc67a2d7e916 + 1 + + + mlt_producer + 00:00:02:25 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-07.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 7 + 4 + 1 + 45602 + e0a9826c88e2fe3653bc2d44004a99ff + 1 + + + mlt_producer + 00:00:08:03 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-08.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 8 + 5 + 1 + 130030 + e69fb428f3f018d0943c99ebb0ec1ca4 + 1 + + + mlt_producer + 00:00:05:10 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-09.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 9 + 6 + 1 + 85726 + 7718caef35699b71f7b6dd7a57874cf9 + 1 + + + mlt_producer + 00:00:02:06 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-10.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 10 + 7 + 1 + 35572 + e053ca72af68f505c896fb13ed6c12b3 + 1 + + + mlt_producer + 00:00:07:16 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-11.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 11 + 1 + 1 + 120836 + 1c1bb1fd0bed7f9768e4403b7f4bcf74 + 1 + + + mlt_producer + 00:00:02:27 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-12.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 12 + 2 + 1 + 46857 + d2e7f09855715be1d9a5c204e59fd4e5 + 1 + + + mlt_producer + 00:00:04:02 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-13.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 13 + 3 + 1 + 65665 + 9c0ac2f2a153d4a496fe214478bd49ae + 1 + + + mlt_producer + 00:00:05:00 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-14.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 14 + 4 + 1 + 80294 + 2ca83b3da3bb31e191854cb45834f81b + 1 + + + mlt_producer + 00:00:16:13 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/05.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 1408394 + 1f7e285b7dd04b83b8b24032c75bb0d8 + 1 + + + mlt_producer + 00:00:03:23 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/05-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 5-e-1 + 1 + 60653 + 1576e9d09b4c7a81146dbf6e110436a3 + 1 + + + mlt_producer + 00:00:24:12 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/06.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 1429384 + cdbc83b7cd9614f8ba1974182f5d7442 + 1 + + + mlt_producer + 00:00:11:12 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/06.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 186826 + 1861092116fbd860f9eb2fa2937f2983 + 1 + + + mlt_producer + 00:00:51:06 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/07.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 5194049 + 30a756a8aed7c8ad6d262109790638f7 + 1 + + + mlt_producer + 00:00:05:14 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/07-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + 1 + 87816 + 94a939df862690031800fb37ce903572 + 1 + + + mlt_producer + 00:00:01:15 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/07-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + 1 + 24286 + 69233d392d036399bc98993b0d74afb9 + 1 + + + mlt_producer + 00:00:04:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/07-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + 1 + 75695 + ebc24e3c69be454f51da5ab6365f0f0d + 1 + + + mlt_producer + 00:00:04:01 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/07-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 4 + 1 + 64828 + 6f55a2dfb6808bc4c75fb20f19344b3d + 1 + + + mlt_producer + 00:00:04:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/08-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + 1 + 75695 + e35ae7f9bfab6d831f75c18125404d64 + 1 + + + mlt_producer + 00:00:04:01 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/08-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + 1 + 65246 + aad67fa750d513237f7a24527af9010d + 1 + + + mlt_producer + 00:00:02:08 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/08-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + 1 + 36825 + 8be00f15b0f9d148af048581e39e5702 + 1 + + + mlt_producer + 00:00:05:07 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/08-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 4 + 1 + 84054 + 48f90ba9ddab636bd37cbcbd9ebd6be9 + 1 + + + mlt_producer + 00:00:03:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/08-05.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 5 + 5 + 1 + 59813 + 47ae5213086aa726b96aae7483474aa0 + 1 + + + mlt_producer + 00:00:43:18 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/08.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 6742673 + 827af32503d75ce645645309c7a47acd + 1 + + + mlt_producer + 00:01:08:28 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/09.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 5801961 + 444733a3c51b73634ece83f297ca6f04 + 1 + + + mlt_producer + 00:00:02:08 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + 1 + 36825 + 295de7e3b8434b1a7e081840e599b7a6 + 1 + + + mlt_producer + 00:00:03:04 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + 1 + 50618 + 4d96fb711542d0d1f113a7afa94ae753 + 1 + + + mlt_producer + 00:00:03:28 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + 1 + 63156 + 728372178e545091ed424a43a1fabe54 + 1 + + + mlt_producer + 00:00:02:19 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 4 + 1 + 42676 + c86f8c1e808accf08687552ed00ed4f3 + 1 + + + mlt_producer + 00:00:02:11 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-05.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 5 + 5 + 1 + 38079 + 8486e2d03c503c93d7a2ee0082ccb490 + 1 + + + mlt_producer + 00:00:04:28 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-06.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 6 + 6 + 1 + 79457 + 29c600d011e3082a82332f3d511453e6 + 1 + + + mlt_producer + 00:00:02:03 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-07.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 7 + 7 + 1 + 34317 + 7016d16646d4a8b8288400b23f3dab80 + 1 + + + mlt_producer + 00:00:04:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/10-a-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + 1 + 75695 + b21a0d3b58c7092c3fe386216d21e206 + 1 + + + mlt_producer + 00:00:04:01 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/10-a-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + 1 + 65246 + 0012cf28789db74606c87a7136900529 + 1 + + + mlt_producer + 00:00:06:03 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/10-a-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + 1 + 97847 + 62b8d1048855817321d0adc0c6be0ee7 + 1 + + + mlt_producer + 00:00:03:06 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/10-a-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 4 + 1 + 51872 + c3d99eba5076166fc9edc420518e42a4 + 1 + + + mlt_producer + 00:00:48:24 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/10.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 3363182 + 9b692dbd68bb5567c3894d4fb6c2fef0 + 1 + + + mlt_producer + 00:00:47:20 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/11.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 3313095 + 81250357bbecd701f7ab6d1cca8abbb6 + 1 + + + mlt_producer + 00:00:15:26 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/11-a-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + 1 + 254582 + 6cd94488272f4f76b933ec5690e9ecc1 + 1 + + + mlt_producer + 00:00:04:23 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/11-a-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + 1 + 76949 + 8259501805d7652112de4d2c11de3703 + 1 + + + mlt_producer + 00:00:07:16 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/11-a-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + 1 + 121253 + cecf06099b4d584e9d3132483195a288 + 1 + + + mlt_producer + 00:00:02:22 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/11-a-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 4 + 1 + 44348 + b64bd49a4e6e1273f017030fdad37da5 + 1 + + + mlt_producer + 00:00:05:04 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/12-c.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 82754 + c070abab23f054213a3a2f738e9d7edd + 1 + + + mlt_producer + 00:00:06:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/12-a-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + 1 + 107460 + 31b73205d955dc90eafe588a0ab97ccb + 1 + + + mlt_producer + 00:00:16:11 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/12-a-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + 1 + 262105 + 74f8da2a5259b72c9987e68dff385531 + 1 + + + mlt_producer + 00:00:03:16 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/12-a-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 4 + 1 + 56887 + 5cfc7d7cc32df80026d26ce16abe8405 + 1 + + + mlt_producer + 00:00:01:02 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/12-a-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 5 + 1 + 17599 + b44a8669f68c34d0955aacbbbab993e5 + 1 + + + mlt_producer + 00:00:56:28 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/12.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 3824166 + 9714b71dd4ed177ececb2e4da358cbec + 1 + + + producer + 00:00:26:26 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/13.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + 1886105 + fac558b231c32d715f5dfe175e9fdbd8 + + + mlt_producer + 00:00:12:19 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/13-a.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 202709 + c331b70e4745075db5da79091629debb + 1 + + + mlt_producer + 00:00:07:15 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/13-c.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + 1 + 120417 + f2080ed96da4ecdef95d2a36c4f2ed07 + 1 + + + mlt_producer + 00:00:03:18 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/13-f.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 58095 + b81845c49e856dc62ef5f3d8b526125d + 1 + + + mlt_producer + 00:00:38:08 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/14.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 612727 + 45bc5eb20e0128ec2b8dc7e65c6e570c + 1 + + + mlt_producer + 00:06:40:22 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/05_Roland TR 707 Beat 115 bpm.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 192000 + LAME3.99r + 1 + 1 + 1 + 9618539 + b90b648c7057c29ef96ac4f4e6734e9a + 1 + + + mlt_producer + 00:04:13:22 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/background/Drop-2-funky-lounge-pop-song.wav + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16 + 44100 + 2 + pcm_s16le + PCM signed 16-bit little-endian + 1411200 + 1 + 44765392 + 2cb89268180f2606da0998e5ab37eb8e + 1 + + + mlt_producer + 00:06:40:01 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/Jazzistic-music-loop-120-bpm.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 192000 + LAME3.99r + 1 + 1 + 1 + 9601612 + a9053f224a4bcb215eb1e38b190172c2 + 1 + + + <customeffects/> + + 1446664988374 + 0 + 0 + 0 + 15.08.0 + 11661 + atsc_720p_30 + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video + ts + 2000 + 1000 + -f mpegts -acodec libmp3lame -ac 2 -ab 128k -vcodec mpeg2video -g 5 -s 640x480 -qscale 7 + 0.91 + 1 + 1700 + 2006 + 6 + + <groups/> + + + 192 + 25 + MP4 + + -1 + 0 + 0 + 0 + H.264/AAC High Profile + 1 + 0 + 180 + 320 + 0 + -1 + 0 + 0 + 0 + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/Wp-testing-Intro.mp4 + 0 + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + producer + 23730 + pause + black + 0 + colour + + + + + + producer + 00:00:11:03 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 178049 + bd6e3c02773e484b272693995512e9a8 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + + + producer + 00:00:01:29 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/02-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 31822 + 1939c5615953ed27815175e57feafe46 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + let-s-activate + + + producer + 00:00:03:28 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/02-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 63166 + dd36d980819cd5dc027826ae361f187b + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + we-see-menu + + + producer + 00:00:04:09 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 68962 + 7eee8c0249883ca260368f712a4ac1c2 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + + + producer + 00:00:03:08 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 52707 + 38ea7d77bec24830d9104de839b124c4 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + + + producer + 00:00:02:01 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 33063 + 4062144bcced45436fa7a007c6d84a04 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + + + producer + 00:00:01:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 27630 + 593f765c4c68c67c4e8240c59369506a + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + + + producer + 00:00:03:02 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 49364 + 02f0c8ac186266eb8e748338325e6598 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 1 + + + producer + 00:00:05:18 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-05.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 89906 + 76d499c3e1c61f5b0dbf0e2e62b242f4 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 5 + 2 + + + producer + 00:00:06:16 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-06.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 104952 + 042b06d23062bf430ab1fc67a2d7e916 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 6 + 3 + + + producer + 00:00:02:25 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-07.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 45602 + e0a9826c88e2fe3653bc2d44004a99ff + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 7 + 4 + + + producer + 00:00:08:03 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-08.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 130030 + e69fb428f3f018d0943c99ebb0ec1ca4 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 8 + 5 + + + producer + 00:00:05:10 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-09.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 85726 + 7718caef35699b71f7b6dd7a57874cf9 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 9 + 6 + + + producer + 00:00:02:06 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-10.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 35572 + e053ca72af68f505c896fb13ed6c12b3 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 10 + 7 + + + producer + 00:00:07:16 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-11.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 120836 + 1c1bb1fd0bed7f9768e4403b7f4bcf74 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 11 + 1 + + + producer + 00:00:02:27 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-12.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 46857 + d2e7f09855715be1d9a5c204e59fd4e5 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 12 + 2 + + + producer + 00:00:04:02 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-13.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 65665 + 9c0ac2f2a153d4a496fe214478bd49ae + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 13 + 3 + + + producer + 00:00:05:00 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/04-14.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 80294 + 2ca83b3da3bb31e191854cb45834f81b + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 14 + 4 + + + producer + 00:00:03:23 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/05-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 60653 + 1576e9d09b4c7a81146dbf6e110436a3 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 5-e-1 + + + producer + 00:00:11:12 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/06.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 186826 + 1861092116fbd860f9eb2fa2937f2983 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + + + producer + 00:00:05:14 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/07-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 87816 + 94a939df862690031800fb37ce903572 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + + + producer + 00:00:01:15 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/07-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 24286 + 69233d392d036399bc98993b0d74afb9 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + + + producer + 00:00:04:01 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/07-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 64828 + 6f55a2dfb6808bc4c75fb20f19344b3d + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 4 + + + producer + 00:00:04:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/07-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 75695 + ebc24e3c69be454f51da5ab6365f0f0d + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + + + producer + 00:00:04:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/08-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 75695 + e35ae7f9bfab6d831f75c18125404d64 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + + + producer + 00:00:04:01 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/08-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 65246 + aad67fa750d513237f7a24527af9010d + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + + + producer + 00:00:02:08 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/08-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 36825 + 8be00f15b0f9d148af048581e39e5702 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + + + producer + 00:00:05:07 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/08-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 84054 + 48f90ba9ddab636bd37cbcbd9ebd6be9 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 4 + + + producer + 00:00:03:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/08-05.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 59813 + 47ae5213086aa726b96aae7483474aa0 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 5 + 5 + + + producer + 00:00:02:08 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 36825 + 295de7e3b8434b1a7e081840e599b7a6 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + + + producer + 00:00:03:04 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 50618 + 4d96fb711542d0d1f113a7afa94ae753 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + + + producer + 00:00:03:28 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 63156 + 728372178e545091ed424a43a1fabe54 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + + + producer + 00:00:02:19 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 42676 + c86f8c1e808accf08687552ed00ed4f3 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 4 + + + producer + 00:00:02:11 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-05.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 38079 + 8486e2d03c503c93d7a2ee0082ccb490 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 5 + 5 + + + producer + 00:00:04:28 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-06.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 79457 + 29c600d011e3082a82332f3d511453e6 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 6 + 6 + + + producer + 00:00:02:03 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/09-g-07.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 34317 + 7016d16646d4a8b8288400b23f3dab80 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 7 + 7 + + + producer + 00:00:04:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/10-a-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 75695 + b21a0d3b58c7092c3fe386216d21e206 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + + + producer + 00:00:04:01 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/10-a-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 65246 + 0012cf28789db74606c87a7136900529 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + + + producer + 00:00:06:03 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/10-a-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 97847 + 62b8d1048855817321d0adc0c6be0ee7 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + + + producer + 00:00:03:06 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/10-a-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 51872 + c3d99eba5076166fc9edc420518e42a4 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 4 + + + producer + 00:00:15:26 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/11-a-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 254582 + 6cd94488272f4f76b933ec5690e9ecc1 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + + + producer + 00:00:04:23 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/11-a-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 76949 + 8259501805d7652112de4d2c11de3703 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + + + producer + 00:00:07:16 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/11-a-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 121253 + cecf06099b4d584e9d3132483195a288 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 3 + + + producer + 00:00:02:22 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/11-a-04.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 44348 + b64bd49a4e6e1273f017030fdad37da5 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 4 + 4 + + + producer + 00:00:06:21 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/12-a-01.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 107460 + 31b73205d955dc90eafe588a0ab97ccb + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + + + producer + 00:00:16:11 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/12-a-02.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 262105 + 74f8da2a5259b72c9987e68dff385531 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 2 + 2 + + + producer + 00:00:05:04 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/12-c.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 82754 + c070abab23f054213a3a2f738e9d7edd + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + + + producer + 00:00:03:16 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/12-a-03.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 56887 + 5cfc7d7cc32df80026d26ce16abe8405 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 3 + 4 + + + producer + 00:00:12:19 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/13-a.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 202709 + c331b70e4745075db5da79091629debb + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + + + producer + 00:00:07:15 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/13-c.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 120417 + f2080ed96da4ecdef95d2a36c4f2ed07 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + 1 + 1 + + + producer + 00:00:03:18 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/13-f.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 58095 + b81845c49e856dc62ef5f3d8b526125d + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + + + producer + 00:00:38:08 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/14.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 612727 + 45bc5eb20e0128ec2b8dc7e65c6e570c + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 128000 + LAME3.99r + + + Audio + 1 + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + producer + 2650 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/04.mkv?2,5 + 1 + framebuffer + 1 + + + producer + 3897 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/04.mkv?1,7 + 1 + framebuffer + 1 + + + producer + 1656 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/04.mkv?4 + 1 + framebuffer + 1 + + + producer + 1104 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/04.mkv?6 + 1 + framebuffer + 1 + + + producer + 6626 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/04.mkv?1 + 1 + framebuffer + + + producer + 5096 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/04.mkv?1,3 + 1 + framebuffer + 1 + + + producer + 5521 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/04.mkv?1,2 + 1 + framebuffer + 1 + + + producer + 2194 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/07.mkv?0,7 + 1 + framebuffer + 1 + + + producer + 768 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/07.mkv?2 + 1 + framebuffer + 1 + + + producer + 1024 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/07.mkv?1,5 + 1 + framebuffer + 1 + + + producer + 654 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/08.mkv?2 + 1 + framebuffer + 1 + + + producer + 1034 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/09.mkv?2 + 1 + framebuffer + 1 + + + producer + 2068 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/09.mkv?1 + 1 + framebuffer + + + producer + 00:00:48:24 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/10.mkv + -1 + 0 + 1 + avformat-novalidate + 1 + 1 + 3363182 + 59f0254235256f9391e6f7fae975b3d3 + 1 + was here + 1 + video + 15 + 1 + 1616 + 1024 + 15 + yuv420p + 1 + 709 + theora + Theora + 0 + 0.3.8.1 + Lavf56.36.100 + 1 + 1 + 15 + 1 + 709 + 2 + 1616 + 1024 + 0 + 1 + + + producer + 1171 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/10.mkv?1,25 + 1 + framebuffer + 1 + + + producer + 1464 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/10.mkv?1 + 1 + framebuffer + + + producer + 2042 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/11.mkv?0,7 + 1 + framebuffer + 1 + + + producer + 953 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/11.mkv?1,5 + 1 + framebuffer + 1 + + + producer + 476 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/11.mkv?3 + 1 + framebuffer + 1 + + + producer + 1423 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/12.mkv?1,2 + 1 + framebuffer + 1 + + + producer + 1708 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/12.mkv?1 + 1 + framebuffer + + + producer + 3416 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/12.mkv?0,5 + 1 + framebuffer + 1 + + + producer + 1343 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/13.mkv?0,6 + 1 + framebuffer + 1 + + + producer + 2015 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/13.mkv?0,4 + 1 + framebuffer + 1 + + + producer + 806 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mkv/13.mkv?1 + 1 + framebuffer + + + Video + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 + 1 + filter + brightness + fade_to_black + brightness + 1 + 0 + + + + + + producer + 23731 + pause + projects/UstimenkoAlexander/wp-testing/wp-testing/tools/intro-video/mp3/Jazzistic-music-loop-120-bpm.mp3 + 0 + -1 + 1 + avformat-novalidate + 1 + 9601612 + a9053f224a4bcb215eb1e38b190172c2 + 1 + was here + 1 + audio + s16p + 44100 + 2 + mp3 + MP3 (MPEG audio layer 3) + 192000 + LAME3.99r + 1 + 1 + + + Back + + + 0 + 75 + 20dB + filter + volume + volume + volume + 1 + + + 0,04 + + + 0 + 75 + 20dB + filter + volume + fadeout + volume + 2 + 1 + 0 + + + + + 0 + 75 + 20dB + filter + volume + fadein + volume + 3 + 0 + 1 + + + + + + + + + + + 1 + 2 + transition + mix + 1 + 1 + 237 + + + 1 + 2 + transition + mix + 1 + 237 + 1 + + + 1 + 2 + transition + mix + 1 + 237 + 1 + + + 1 + 2 + transition + mix + 1 + 237 + 1 + + + 1 + 2 + transition + mix + 1 + 237 + 1 + + + 1 + 2 + transition + mix + 1 + 237 + 1 + + + 1 + 2 + transition + mix + 1 + 237 + 1 + + + 1 + 3 + transition + mix + 1 + 237 + 1 + + + 1 + 3 + transition + mix + 1 + 237 + 1 + + + 1 + 2 + transition + mix + 1 + 1 + 237 + + + 1 + 3 + transition + mix + 1 + 1 + 237 + + + 0 + 1 + transition + mix + 1 + 1 + 237 + + + 0 + 2 + transition + mix + 1 + 1 + 237 + + + 0 + 3 + transition + mix + 1 + 1 + 237 + + + diff --git a/tools/intro-video/convert.sh b/tools/intro-video/convert.sh new file mode 100755 index 00000000..5849c68e --- /dev/null +++ b/tools/intro-video/convert.sh @@ -0,0 +1,2 @@ +mkdir -p mkv +ls -1 ogv/* | xargs -n 1 basename -s .ogv | xargs -I {} ffmpeg -y -i ogv/{}.ogv -c copy mkv/{}.mkv diff --git a/tools/intro-video/img/01-title.png b/tools/intro-video/img/01-title.png new file mode 100644 index 00000000..df0a7dec Binary files /dev/null and b/tools/intro-video/img/01-title.png differ diff --git a/tools/intro-video/img/01-title.xcf b/tools/intro-video/img/01-title.xcf new file mode 100644 index 00000000..f182b261 Binary files /dev/null and b/tools/intro-video/img/01-title.xcf differ diff --git a/tools/intro-video/package.json b/tools/intro-video/package.json new file mode 100644 index 00000000..7c71e301 --- /dev/null +++ b/tools/intro-video/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "casperjs": "^1.1.0-beta3" + } +} diff --git a/tools/intro-video/setup-site.js b/tools/intro-video/setup-site.js new file mode 100644 index 00000000..a02f9b99 --- /dev/null +++ b/tools/intro-video/setup-site.js @@ -0,0 +1,76 @@ +var casper = require('casper').create({ + verbose: true, + logLevel: "debug" +}); + +casper.options.viewportSize = {width: 1280, height: 850} + +casper +.start('http://wpti.dev:8000/') + +.thenOpen('http://wpti.dev:8000/wp-login.php', { + method: 'post', + data : { + log: 'wpti', + pwd: 'wpti' + } +}) + +.thenOpen('http://wpti.dev:8000/wp-admin/profile.php', function() { + this.clickLabel('Blue', 'label') + this.fill('form#your-profile', { + nickname : 'Tests Author', + display_name : 'Tests Author', + email : 'ustimenko.alexander@gmail.com' + }, true) +}).waitForUrl(/updated/) + +.thenOpen('http://wpti.dev:8000/wp-admin/options-general.php', function() { + this.fill('form', { + blogname : 'Psychological tests and quizzes', + blogdescription : 'WordPress testing plugin' + }, true) +}).waitForUrl(/updated/) + +.thenOpen('http://wpti.dev:8000/wp-admin/options-permalink.php', function() { + this.click('#permalink_structure') + this.sendKeys('#permalink_structure', '/%postname%/') + this.click('#submit') +}).waitForUrl(/options/) + +.thenOpen('http://wpti.dev:8000/wp-admin/customize.php?theme=twentyfifteen', function() { + this.evaluate(function() { + function changeColor(name, value) { + jQuery('#customize-control-' + name + ' .wp-color-picker') + .val(value) + .change(); + }; + + changeColor('background_color', '#e0e046'); + changeColor('sidebar_textcolor', '#1B380F'); + changeColor('header_background_color', '#b8f741'); + + }) + + this.click('#save') +}).waitForText('Saved') + +.thenOpen('http://wpti.dev:8000/wp-admin/plugins.php', function () { + this.click('#cb input') + this.evaluate(function() { + jQuery('.wrap form select:first').val('activate-selected') + }) + this.click('#doaction') +}).waitForUrl(/activate/, null, null, 60000) + +.then(function() { + this.click('#cb input') + this.evaluate(function() { + jQuery('.wrap form select:first').val('deactivate-selected') + }) + this.click('#doaction') +}).waitForUrl(/deactivate/) + +casper.run(function() { + this.exit() +}) diff --git a/tools/intro-video/setup-site.sh b/tools/intro-video/setup-site.sh new file mode 100755 index 00000000..ff03dc32 --- /dev/null +++ b/tools/intro-video/setup-site.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash + +set -e + +HERE=$(readlink -f $(dirname "$0")) + +cd $HERE/../.. + +tests/integration-environment/create.sh + +cd $HERE +PHANTOMJS_EXECUTABLE=node_modules/casperjs/node_modules/.bin/phantomjs node_modules/.bin/casperjs setup-site.js diff --git a/tools/refactoring/compare-schemas.sh b/tools/refactoring/compare-schemas.sh new file mode 100755 index 00000000..fca708d5 --- /dev/null +++ b/tools/refactoring/compare-schemas.sh @@ -0,0 +1,16 @@ + +set -e + +HERE=`pwd` +cd ../../db + +mysql -e 'drop database if exists wp_testing_4_3_1' +mysql -e 'create database wp_testing_4_3_1 DEFAULT CHARACTER SET utf8' +../vendor/bin/ruckus.php db:migrate + +cd $HERE +mysqldump wp_testing_4_3_1 |\ +sed 's/[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\} *[0-9]\{1,2\}:[0-9]\{2\}:[0-9]\{2\}/xxxx-xx-xx xx:xx:xx/g' |\ +sed 's/[a-f0-9][a-f0-9-]\{34\}[a-f0-9]/xxxxxxxxxxxxxxxx/' > current.sql + +diff master.sql current.sql diff --git a/tools/refactoring/methods2diagram.sh b/tools/refactoring/methods2diagram.sh new file mode 100755 index 00000000..fd4b2436 --- /dev/null +++ b/tools/refactoring/methods2diagram.sh @@ -0,0 +1,31 @@ + +HERE=`pwd` +cd ../../db/migrations/wp_testing + +( +cat << EOF + +digraph Calls { + layout=fdp + overlap=false + splines=polyline + edge [ + color="#6F715C" + arrowhead=open + ] + node [ + style="rounded,filled" + color="#F2CA52" + shape=box + fontname="Ubuntu" + fontsize=10 + ] +EOF + +ack -o '[^$]+>[a-zA-Z_]+\(' | sed -e 's/:/ /g' | awk '{ print $1 " " $3 }' | sort | uniq |\ +# egrep -v '(e->getMessage|get_adapter|this->execute|Base/Base|Base/AddMeta|updateMetaInExample|Base/UpdateData)' |\ +# egrep -v '(DecodeFormulasSource|this->field|Base/MigrateColumn|Column|Base/MigrateTable|Base/TableDefinition)' |\ +sed -e 's/[0-9]*_WpTesting_Migration_//' -e 's/[()]//g' -e 's/.php//' -e 's/this->//' |\ +awk '{ print " \"" $1 "\" [color=\"#C6DCE1\"] \n" " \"" $1 "\" -> \"" $2 "\"" }' +echo "}" +) | dot -Tsvg > $HERE/calls.svg \ No newline at end of file diff --git a/tools/refactoring/methods2diagram2.sh b/tools/refactoring/methods2diagram2.sh new file mode 100755 index 00000000..a5fcc09e --- /dev/null +++ b/tools/refactoring/methods2diagram2.sh @@ -0,0 +1,29 @@ + +HERE=`pwd` +cd ../../src + +( +cat << EOF + +digraph Calls { + layout=fdp + overlap=false + splines=polyline + edge [ + color="#6F715C" + arrowhead=open + ] + node [ + style="rounded,filled" + color="#F2CA52" + shape=box + fontname="Ubuntu" + fontsize=10 + ] +EOF + +ack -o 'wp->[a-zA-Z_]+\(' | sed -e 's/:/ /g' | awk '{ print $1 " " $3 }' | sort | uniq |\ +sed -e 's/[()]//g' -e 's/.php//' |\ +awk '{ print " \"" $1 "\" [color=\"#C6DCE1\"] \n" " \"" $1 "\" -> \"" $2 "\"" }' +echo "}" +) | dot -Tsvg > $HERE/calls.svg \ No newline at end of file diff --git a/wp-testing.php b/wp-testing.php index 64827ce0..90bce39f 100644 --- a/wp-testing.php +++ b/wp-testing.php @@ -3,7 +3,7 @@ * Plugin Name: Wp-testing * Plugin URI: http://wordpress.org/extend/plugins/wp-testing/ * Description: Helps to create psychological tests. - * Version: 0.17.1 + * Version: 0.17.2 * Author: Alexander Ustimenko * Author URI: http://ustimen.co * License: GPL3 @@ -11,7 +11,6 @@ * Domain Path: /languages */ -require_once dirname(__FILE__) . '/src/WordPressFacade.php'; -require_once dirname(__FILE__) . '/src/Facade.php'; +require_once dirname(__FILE__) . '/src/bootstrap.php'; $WpTesting_Facade = new WpTesting_Facade(new WpTesting_WordPressFacade(__FILE__));