Skip to content

Commit

Permalink
Playbox Trump It! module
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefanos Petrakis committed May 4, 2016
1 parent 33f1964 commit 9dd82fe
Show file tree
Hide file tree
Showing 9 changed files with 368 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ DirectoryIndex index.php index.html index.htm
#
# If your site is running in a VirtualDocumentRoot at http://example.com/,
# uncomment the following line:
# RewriteBase /
RewriteBase /drupals/playbox/

# Pass all requests not referring directly to files in the filesystem to
# index.php. Clean URLs are handled in drupal_environment_initialize().
Expand Down
25 changes: 25 additions & 0 deletions sites/all/modules/playbox_trumpit/ListPhrases.txt
Original file line number Diff line number Diff line change
@@ -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.�
17 changes: 17 additions & 0 deletions sites/all/modules/playbox_trumpit/playbox_trumpit.admin.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* @file
* Admin Settings form for Trump It!
*/
function playbox_trumpit_admin_settings() {
$form['playbox_trumpit_phrases'] = array(
'#type' => '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.<br />Originally copied from "<strong><a target="_blank" href="http://www.usmagazine.com/celebrity-news/news/donald-trumps-craziest-quotes-the-2016-presidential-hopeful-speaks-201568">http://www.usmagazine.com/celebrity-news/news/donald-trumps-craziest-quotes-the-2016-presidential-hopeful-speaks-201568</a></strong>".'),
'#default_value' => variable_get('playbox_trumpit_phrases', ''),
'#required' => TRUE,
'#rows' => 30,
);

return system_settings_form($form);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
/**
* @file
* playbox_trumpit.features.field_base.inc
*/

/**
* Implements hook_field_default_field_bases().
*/
function playbox_trumpit_field_default_field_bases() {
$field_bases = array();

// Exported field_base: 'field_playbox_trumped'
$field_bases['field_playbox_trumped'] = array(
'active' => 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;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php
/**
* @file
* playbox_trumpit.features.field_instance.inc
*/

/**
* Implements hook_field_default_field_instances().
*/
function playbox_trumpit_field_default_field_instances() {
$field_instances = array();

// Exported field_instance: 'node-playbox_battle-field_playbox_trumped'
$field_instances['node-playbox_battle-field_playbox_trumped'] = array(
'bundle' => 'playbox_battle',
'default_value' => NULL,
'deleted' => 0,
'description' => '',
'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('Trumped');

return $field_instances;
}
14 changes: 14 additions & 0 deletions sites/all/modules/playbox_trumpit/playbox_trumpit.features.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
/**
* @file
* playbox_trumpit.features.inc
*/

/**
* Implements hook_ctools_plugin_api().
*/
function playbox_trumpit_ctools_plugin_api($module = NULL, $api = NULL) {
if ($module == "strongarm" && $api == "strongarm") {
return array("version" => "1");
}
}
18 changes: 18 additions & 0 deletions sites/all/modules/playbox_trumpit/playbox_trumpit.info
Original file line number Diff line number Diff line change
@@ -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 = 1462351748
139 changes: 139 additions & 0 deletions sites/all/modules/playbox_trumpit/playbox_trumpit.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
<?php
/**
* @file
* Code for the Playbox TrumpIt feature.
*/

include_once 'playbox_trumpit.features.inc';

/**
* @file
* Code for the Playbox TrumpIt! feature.
*
* Provides a button that gives users the option to
* Save a form they are working on, AND return to the
* editing form in one step.
*
* I find this quite usefull when entering a very long
* blog post, and my thumb hovering dangerously close to
* the mouse button that will take me "back" and lose all
* my entered changes/data.
*
* No Kittens were harmed during the creation of this module.
*/

/**
* Provide online user help.
*
* @param $path
* @param $arg
* @return
* Help text
*/
function playbox_trumpit_help($path, $arg) {
switch ($path) {
case 'admin/settings/playbox_trumpit':
return '<p>' . t('Trump It! adds a "Trump It!" button to the node add and edit forms.') . '</p>';
case 'admin/help#playbox_trumpit':
return '<p>' . t('Trump It! adds a "Trump It!" button to the node add and edit forms.') . '</p>';
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) {

// 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 (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) {
// we will first check to see if they want to auto-unpublish, and make modifications if so
// before submitting the node
// ONLY do something on new nodes
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';
}
}
}
44 changes: 44 additions & 0 deletions sites/all/modules/playbox_trumpit/playbox_trumpit.strongarm.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
/**
* @file
* playbox_trumpit.strongarm.inc
*/

/**
* Implements hook_strongarm().
*/
function playbox_trumpit_strongarm() {
$export = array();

$strongarm = new stdClass();
$strongarm->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;
}

0 comments on commit 9dd82fe

Please sign in to comment.