diff --git a/README.md b/README.md index c20133ef9..c0e46502d 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ In order to get started you will want to do the following: 1. Set up your own [github.com account](https://github.com/join) if you don't already have one. 2. Set up a local development environment like [Kalabox](https://github.com/kalamuna/kalaboxv1) or [Kalastack](https://github.com/kalamuna/kalastack). 3. [Create a fork of this](https://github.com/kalamuna/playbox/fork) project. -4. [Import](https://github.com/kalamuna/kalastack/wiki/How-to-import-a-preexisting-Drupal-site-into-kalastack.) this fork into your local dev environment and set up its [files](http://files.kalamuna.com/playbox_dev_2015-03-29T01-44-54_UTC_files.tar.gz) and [database](http://files.kalamuna.com/playbox_dev_2015-03-29T01-44-54_UTC_database.sql.gz). +4. [Import](https://github.com/kalamuna/kalastack/wiki/Usage-Importing-a-preexisting-Drupal-Site) this fork into your local dev environment and set up its [files](http://files.kalamuna.com/playbox_dev_2015-03-29T01-44-54_UTC_files.tar.gz) and [database](http://files.kalamuna.com/playbox_dev_2015-03-29T01-44-54_UTC_database.sql.gz). 5. Set up your git repo for github flow. See [below](#Contributing). 6. Create a branch for the issue you are working on. 7. Commit code and push it up! diff --git a/sites/all/modules/playbox_core/playbox_core.module b/sites/all/modules/playbox_core/playbox_core.module index 33473c603..b93a9b8be 100644 --- a/sites/all/modules/playbox_core/playbox_core.module +++ b/sites/all/modules/playbox_core/playbox_core.module @@ -49,3 +49,11 @@ function playbox_core_field_formatter_view($entity_type, $entity, $field, $insta } return $element; } + +/** + * Enables the Trump It! module. + */ +function playbox_core_update_7200() { + // Enable the Trump It! module. + module_enable(array('playbox_trumpit')); +} // playbox_core_update_7200 \ No newline at end of file diff --git a/sites/all/modules/playbox_trumpit/ListPhrases.txt b/sites/all/modules/playbox_trumpit/ListPhrases.txt new file mode 100644 index 000000000..ac3cb9b7a --- /dev/null +++ b/sites/all/modules/playbox_trumpit/ListPhrases.txt @@ -0,0 +1,25 @@ +- http://www.usmagazine.com/celebrity-news/news/donald-trumps-craziest-quotes-the-2016-presidential-hopeful-speaks-201568 + +“I’m the worst thing that’s ever happened to ISIS.” +“Donald J. Trump is calling for a total and complete shutdown of Muslims entering the United States.” +“Did you read about Starbucks? No more 'Merry Christmas' at Starbucks. No more. Maybe we should boycott Starbucks." +“Sorry, there is no STAR on the stage tonight!” +“Look at that face! Would anyone vote for that? Can you imagine that, the face of our next president?" +“We have to have a wall. We have to have a border. And in that wall we’re going to have a big fat door where people can come into the country, but they have to come in legally.” +“I’m owned by the people! I mean, I’m telling you, I’m no angel, but I’m gonna do right by them!” +“I think apologizing’s a great thing, but you have to be wrong. I will absolutely apologize, sometime in the hopefully distant future, if I’m ever wrong.” +“When these people walk in the room, they don’t say, ‘Oh, hello! How’s the weather? It’s so beautiful outside. Isn’t it lovely? How are the Yankees doing? Oh they’re doing wonderful. Great.’ [Asians] say, ‘We want deal!’” +“You haven’t been called, go back to Univision.” +“Heidi Klum. Sadly, she's no longer a 10." +“You could see there was blood coming out of her eyes. Blood coming out of her… wherever.” +“He’s not a war hero. He’s a war hero because he was captured. I like people who weren’t captured.” +“No more massive injections. Tiny children are not horses—one vaccine at a time, over time.” +“When Mexico sends its people, they’re not sending the best. They’re sending people that have lots of problems and they’re bringing those problems. They’re bringing drugs, they’re bringing crime. They’re rapists and some, I assume, are good people, but I speak to border guards and they’re telling us what we’re getting.” +“NBC News just called it ‘The Great Freeze’ — coldest weather in years. Is our country still spending money on the GLOBAL WARMING HOAX?” +“I have a great relationship with the blacks. I’ve always had a great relationship with the blacks.” +“Do you know that Hillary Clinton was a birther? She wanted those records and fought like hell. People forgot. Did you know John McCain was a birther? Wanted those records? They couldn’t get the records. Hillary failed. John McCain failed. Trump was able to get him to give something — I don’t know what the hell it was — but it doesn’t matter.” +“Rosie O’Donnell’s disgusting both inside and out. You take a look at her, she’s a slob. She talks like a truck driver, she doesn’t have her facts, she’ll say anything that comes to her mind. Her show failed when it was a talk show, the ratings went very, very, very low and very bad, and she got essentially thrown off television. I mean she’s basically a disaster.” +“It’s like in golf. A lot of people — I don’t want this to sound trivial — but a lot of people are switching to these really long putters, very unattractive. It’s weird. You see these great players with these really long putters, because they can’t sink three-footers anymore. And, I hate it. I am a traditionalist. I have so many fabulous friends who happen to be gay, but I am a traditionalist.” +“I’ve said if Ivanka weren’t my daughter, perhaps I’d be dating her.” +“All of the women on The Apprentice flirted with me — consciously or unconsciously. That’s to be expected.” +“The line of ‘Make America great again,’ the phrase, that was mine, I came up with it about a year ago, and I kept using it, and everybody’s using it, they are all loving it. I don’t know I guess I should copyright it, maybe I have copyrighted it.” diff --git a/sites/all/modules/playbox_trumpit/playbox_trumpit.admin.inc b/sites/all/modules/playbox_trumpit/playbox_trumpit.admin.inc new file mode 100644 index 000000000..c7b1d9f40 --- /dev/null +++ b/sites/all/modules/playbox_trumpit/playbox_trumpit.admin.inc @@ -0,0 +1,17 @@ + 'textarea', + '#title' => t('A list of wonderful quotes from D.T.'), + '#description' => t('This is the list of quotes of wonder and beauty from D.T. that will be used as a signature for each - randomly - decided battle.
Originally copied from "http://www.usmagazine.com/celebrity-news/news/donald-trumps-craziest-quotes-the-2016-presidential-hopeful-speaks-201568".'), + '#default_value' => variable_get('playbox_trumpit_phrases', ''), + '#required' => TRUE, + '#rows' => 30, + ); + + return system_settings_form($form); +} \ No newline at end of file diff --git a/sites/all/modules/playbox_trumpit/playbox_trumpit.features.field_base.inc b/sites/all/modules/playbox_trumpit/playbox_trumpit.features.field_base.inc new file mode 100644 index 000000000..d1f1b8856 --- /dev/null +++ b/sites/all/modules/playbox_trumpit/playbox_trumpit.features.field_base.inc @@ -0,0 +1,41 @@ + 1, + 'cardinality' => 1, + 'deleted' => 0, + 'entity_types' => array(), + 'field_name' => 'field_playbox_trumped', + 'foreign keys' => array( + 'format' => array( + 'columns' => array( + 'format' => 'format', + ), + 'table' => 'filter_format', + ), + ), + 'indexes' => array( + 'format' => array( + 0 => 'format', + ), + ), + 'locked' => 0, + 'module' => 'text', + 'settings' => array(), + 'translatable' => 0, + 'type' => 'text_long', + ); + + return $field_bases; +} diff --git a/sites/all/modules/playbox_trumpit/playbox_trumpit.features.field_instance.inc b/sites/all/modules/playbox_trumpit/playbox_trumpit.features.field_instance.inc new file mode 100644 index 000000000..6a9735da3 --- /dev/null +++ b/sites/all/modules/playbox_trumpit/playbox_trumpit.features.field_instance.inc @@ -0,0 +1,70 @@ + 'playbox_battle', + 'default_value' => NULL, + 'deleted' => 0, + 'description' => 'This is the quote that explains why the winner won and the loser lost.', + 'display' => array( + 'default' => array( + 'label' => 'above', + 'module' => 'text', + 'settings' => array(), + 'type' => 'text_default', + 'weight' => 9, + ), + 'featured' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + 'teaser' => array( + 'label' => 'above', + 'settings' => array(), + 'type' => 'hidden', + 'weight' => 0, + ), + ), + 'entity_type' => 'node', + 'field_name' => 'field_playbox_trumped', + 'label' => 'Trumped', + 'required' => 0, + 'settings' => array( + 'linkit' => array( + 'button_text' => 'Search', + 'enable' => 0, + 'profile' => '', + ), + 'text_processing' => 0, + 'user_register_form' => FALSE, + ), + 'widget' => array( + 'active' => 1, + 'module' => 'text', + 'settings' => array( + 'rows' => 5, + ), + 'type' => 'text_textarea', + 'weight' => 11, + ), + ); + + // Translatables + // Included for use with string extractors like potx. + t('This is the quote that explains why the winner won and the loser lost.'); + t('Trumped'); + + return $field_instances; +} diff --git a/sites/all/modules/playbox_trumpit/playbox_trumpit.features.inc b/sites/all/modules/playbox_trumpit/playbox_trumpit.features.inc new file mode 100644 index 000000000..8b3a7c624 --- /dev/null +++ b/sites/all/modules/playbox_trumpit/playbox_trumpit.features.inc @@ -0,0 +1,14 @@ + "1"); + } +} diff --git a/sites/all/modules/playbox_trumpit/playbox_trumpit.info b/sites/all/modules/playbox_trumpit/playbox_trumpit.info new file mode 100644 index 000000000..ee1e7d9ae --- /dev/null +++ b/sites/all/modules/playbox_trumpit/playbox_trumpit.info @@ -0,0 +1,18 @@ +name = Playbox TrumpIt +description = Provides a "Trump It!" button on Battle node forms. +core = 7.x +package = Playbox +version = 7.x-1.0 +project = playbox_trumpit +dependencies[] = ctools +dependencies[] = features +dependencies[] = strongarm +dependencies[] = text +configure = admin/config/playbox/trump-it +datestamp = 1340830936 +features[ctools][] = strongarm:strongarm:1 +features[features_api][] = api:2 +features[field_base][] = field_playbox_trumped +features[field_instance][] = node-playbox_battle-field_playbox_trumped +features[variable][] = playbox_trumpit_phrases +mtime = 1462354569 diff --git a/sites/all/modules/playbox_trumpit/playbox_trumpit.module b/sites/all/modules/playbox_trumpit/playbox_trumpit.module new file mode 100644 index 000000000..b61832c9b --- /dev/null +++ b/sites/all/modules/playbox_trumpit/playbox_trumpit.module @@ -0,0 +1,186 @@ +' . t('Trump It! adds a "Trump It!" button to the node add and edit forms.') . '

'; + case 'admin/help#playbox_trumpit': + return '

' . t('Trump It! adds a "Trump It!" button to the node add and edit forms.') . '

'; + default: + return ''; + } +} +/** + * Implements hook_permission(). + */ +function playbox_trumpit_permission() { + return array( + 'use trump it' => array( + 'title' => t('Use Trump It! Button'), + 'description' => t('Display the Trump It! Button on the specified entity forms.'), + ), + 'administer trump it' => array( + 'title' => t('Administer Trump It!'), + 'description' => t('Change the Trump It! configuration.'), + ), + ); +} +/** + * Implements hook_menu(). + */ +function playbox_trumpit_menu() { + $items = array(); + $items['admin/config/playbox/trump-it'] = array( + 'title' => 'Trump It! Settings', + 'description' => 'Administer settings related to the Trump It! module.', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('playbox_trumpit_admin_settings'), + 'access arguments' => array('administer trump it'), + 'type' => MENU_NORMAL_ITEM, + 'file' => 'playbox_trumpit.admin.inc' + ); + return $items; +} + +/** + * Implements hook_form_alter(). + */ +function playbox_trumpit_form_node_form_alter(&$form, $form_state, $form_id) { + + + $form['field_playbox_trumped'][LANGUAGE_NONE][0]['#disabled'] = TRUE; + + // if the type is not set, it's not a node and we are not interested + if (!isset($form['type']['#value']) || $form['type']['#value'] !== 'playbox_battle' ) { + return; + } + + if( $form['field_playbox_battle_completed'][LANGUAGE_NONE]['#default_value'] > 0 ) { + return; + } + + + if (user_access('use trump it')) { + + //add trump it btn + $form['actions']['trump_it'] = array( + '#type' => 'submit', + '#access' => user_access('use trump it'), + '#value' => t('Trump It!'), + '#submit' => array('redirect_trump_it_submit'), + ); + } +} +/** + * Custom Submit Handler for Redirecting Save & Edit's to the node form after saving + * + * @param $form + * @param $form_state + */ +function redirect_trump_it_submit($form, &$form_state) { + + // First: decide randomly on the winner/loser, between the robot and president contestants + // Public-Opinion-Considerations: If more than 90% of the total votes are in favor of one candidate, pick the other! + $sum = $form_state['values']['field_playbox_president_votes'][LANGUAGE_NONE][0]['value'] + $form_state['values']['field_playbox_robot_votes'][LANGUAGE_NONE][0]['value']; + if( $sum > 0 ) { + if( ( $form_state['values']['field_playbox_president_votes'][LANGUAGE_NONE][0]['value'] / $sum ) > 0.9 ) { + $winner = $form_state['values']['field_playbox_robot']; + $loser = $form_state['values']['field_playbox_president']; + } + else if( $form_state['values']['field_playbox_president_votes'][LANGUAGE_NONE][0]['value'] / $sum < 0.1 ) { + $winner = $form_state['values']['field_playbox_president']; + $loser = $form_state['values']['field_playbox_robot']; + } + } + if( !isset($winner) ){ + if( rand(0,1) ){ + $winner = $form_state['values']['field_playbox_president']; + $loser = $form_state['values']['field_playbox_robot']; + } + else { + $winner = $form_state['values']['field_playbox_robot']; + $loser = $form_state['values']['field_playbox_president']; + } + } + // Set the values on the form + $form_state['values']['field_playbox_loser'] = $loser; + $form_state['values']['field_playbox_winner'] = $winner; + + // Second: pick a quote randomly from our arsenal, to trumpishly explain the decision + if ($phrases = variable_get('playbox_trumpit_phrases', 0)) { + $phrases = explode(PHP_EOL,$phrases); + $form_state['values']['field_playbox_trumped'][LANGUAGE_NONE][0]['value'] = $phrases[array_rand($phrases)]; + $form_state['values']['field_playbox_battle_completed'][LANGUAGE_NONE][0]['value'] = true; + } + + // call default node save/submit function + node_form_submit($form, $form_state); + +} + +function raks() { + + if (variable_get('save_edit_unpublish_new_only', 0) && !$form_state['values']['nid']) { + $form_state['values']['status'] = 0; + } + // DO IT EVERY TIME Save & Edit is used. (Seems like a rare case) + elseif (variable_get('save_edit_unpublish', 0) && !variable_get('save_edit_unpublish_new_only', 0)) { + $form_state['values']['status'] = 0; + } + // WAIT... if someone clicked the Publish button, maybe we should retick that option now + if ($form_state['clicked_button']['#id'] == 'edit-save-edit-publish') { + $form_state['values']['status'] = 1; + } + // call default node save/submit function + node_form_submit($form, $form_state); + // only redirect if using the Save & Edit button + if ($form_state['clicked_button']['#id'] == 'edit-save-edit' || $form_state['clicked_button']['#id'] == 'edit-actions-save-edit') { + // change redirect location + if (isset($_REQUEST['destination'])) { + $form_state['redirect'] = url('node/' . $form_state['nid'] . '/edit', + array( + 'query' => array( + 'destination' => $_REQUEST['destination'], + ), + 'absolute' => TRUE, + ) + ); + $_GET['destination'] = $form_state['redirect']; + unset($_REQUEST['destination']); + } + else { + // just go back to the form edit page, and dont worry about the redirect + $form_state['redirect'] = 'node/' . $form_state['nid'] . '/edit'; + } + } +} \ No newline at end of file diff --git a/sites/all/modules/playbox_trumpit/playbox_trumpit.strongarm.inc b/sites/all/modules/playbox_trumpit/playbox_trumpit.strongarm.inc new file mode 100644 index 000000000..4210d10d5 --- /dev/null +++ b/sites/all/modules/playbox_trumpit/playbox_trumpit.strongarm.inc @@ -0,0 +1,44 @@ +disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */ + $strongarm->api_version = 1; + $strongarm->name = 'playbox_trumpit_phrases'; + $strongarm->value = '“I’m the worst thing that’s ever happened to ISIS.” +“Donald J. Trump is calling for a total and complete shutdown of Muslims entering the United States.” +“Did you read about Starbucks? No more \'Merry Christmas\' at Starbucks. No more. Maybe we should boycott Starbucks." +“Sorry, there is no STAR on the stage tonight!” +“Look at that face! Would anyone vote for that? Can you imagine that, the face of our next president?" +“We have to have a wall. We have to have a border. And in that wall we’re going to have a big fat door where people can come into the country, but they have to come in legally.” +“I’m owned by the people! I mean, I’m telling you, I’m no angel, but I’m gonna do right by them!” +“I think apologizing’s a great thing, but you have to be wrong. I will absolutely apologize, sometime in the hopefully distant future, if I’m ever wrong.” +“When these people walk in the room, they don’t say, ‘Oh, hello! How’s the weather? It’s so beautiful outside. Isn’t it lovely? How are the Yankees doing? Oh they’re doing wonderful. Great.’ [Asians] say, ‘We want deal!’” +“You haven’t been called, go back to Univision.” +“Heidi Klum. Sadly, she\'s no longer a 10." +“You could see there was blood coming out of her eyes. Blood coming out of her… wherever.” +“He’s not a war hero. He’s a war hero because he was captured. I like people who weren’t captured.” +“No more massive injections. Tiny children are not horses—one vaccine at a time, over time.” +“When Mexico sends its people, they’re not sending the best. They’re sending people that have lots of problems and they’re bringing those problems. They’re bringing drugs, they’re bringing crime. They’re rapists and some, I assume, are good people, but I speak to border guards and they’re telling us what we’re getting.” +“NBC News just called it ‘The Great Freeze’ — coldest weather in years. Is our country still spending money on the GLOBAL WARMING HOAX?” +“I have a great relationship with the blacks. I’ve always had a great relationship with the blacks.” +“Do you know that Hillary Clinton was a birther? She wanted those records and fought like hell. People forgot. Did you know John McCain was a birther? Wanted those records? They couldn’t get the records. Hillary failed. John McCain failed. Trump was able to get him to give something — I don’t know what the hell it was — but it doesn’t matter.” +“Rosie O’Donnell’s disgusting both inside and out. You take a look at her, she’s a slob. She talks like a truck driver, she doesn’t have her facts, she’ll say anything that comes to her mind. Her show failed when it was a talk show, the ratings went very, very, very low and very bad, and she got essentially thrown off television. I mean she’s basically a disaster.” +“It’s like in golf. A lot of people — I don’t want this to sound trivial — but a lot of people are switching to these really long putters, very unattractive. It’s weird. You see these great players with these really long putters, because they can’t sink three-footers anymore. And, I hate it. I am a traditionalist. I have so many fabulous friends who happen to be gay, but I am a traditionalist.” +“I’ve said if Ivanka weren’t my daughter, perhaps I’d be dating her.” +“All of the women on The Apprentice flirted with me — consciously or unconsciously. That’s to be expected.” +“The line of ‘Make America great again,’ the phrase, that was mine, I came up with it about a year ago, and I kept using it, and everybody’s using it, they are all loving it. I don’t know I guess I should copyright it, maybe I have copyrighted it.” +'; + $export['playbox_trumpit_phrases'] = $strongarm; + + return $export; +}