updated core to 7.58 (right after the site was hacked)
This commit is contained in:
@ -0,0 +1,12 @@
|
||||
name = Vertical tabs example
|
||||
description = Show how to use vertical tabs for enhancing user experience.
|
||||
package = Example modules
|
||||
core = 7.x
|
||||
files[] = vertical_tabs_example.test
|
||||
|
||||
; Information added by Drupal.org packaging script on 2017-01-10
|
||||
version = "7.x-1.x-dev"
|
||||
core = "7.x"
|
||||
project = "examples"
|
||||
datestamp = "1484076787"
|
||||
|
@ -0,0 +1,23 @@
|
||||
(function ($) {
|
||||
|
||||
/**
|
||||
* Update the summary for the module's vertical tab.
|
||||
*/
|
||||
Drupal.behaviors.vertical_tabs_exampleFieldsetSummaries = {
|
||||
attach: function (context) {
|
||||
// Use the fieldset class to identify the vertical tab element
|
||||
$('fieldset#edit-vertical-tabs-example', context).drupalSetSummary(function (context) {
|
||||
// Depending on the checkbox status, the settings will be customized, so
|
||||
// update the summary with the custom setting textfield string or a use a
|
||||
// default string.
|
||||
if ($('#edit-vertical-tabs-example-enabled', context).attr('checked')) {
|
||||
return Drupal.checkPlain($('#edit-vertical-tabs-example-custom-setting', context).val());
|
||||
}
|
||||
else {
|
||||
return Drupal.t('Using default');
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Module file for vertical_tabs_example module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @defgroup vertical_tabs_example Example: Vertical Tabs
|
||||
* @ingroup examples
|
||||
* @{
|
||||
* Demonstrates the vertical tabs functionality provided by Drupal 7.
|
||||
*
|
||||
* This example does not cover how to save or load a custom setting, and only
|
||||
* deals with the elements visibility and summary in the tab.
|
||||
*
|
||||
* @see vertical_tabs_example.js
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*
|
||||
* Gives us a simple explanation page.
|
||||
*/
|
||||
function vertical_tabs_example_menu() {
|
||||
$items['examples/vertical_tabs'] = array(
|
||||
'title' => 'Vertical tabs example',
|
||||
'description' => 'Shows how vertical tabs can best be supported by a custom module',
|
||||
'page callback' => '_vertical_tabs_example_explanation',
|
||||
'access callback' => TRUE,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_alter().
|
||||
*
|
||||
* Adds custom fieldset to the node form, and attach ajax behaviour for vertical
|
||||
* panels to update the settings description.
|
||||
*
|
||||
* @see vertical_tabs_example.js
|
||||
*/
|
||||
function vertical_tabs_example_form_alter(&$form, $form_state, $form_id) {
|
||||
// Only include on node add/edit forms.
|
||||
if (!empty($form['#node_edit_form'])) {
|
||||
|
||||
// Create a fieldset that will be included in the vertical tab.
|
||||
$form['vertical_tabs_example'] = array(
|
||||
'#type' => 'fieldset',
|
||||
'#title' => t('Example vertical tab'),
|
||||
'#collapsible' => TRUE,
|
||||
'#collapsed' => FALSE,
|
||||
'#tree' => TRUE,
|
||||
// Send this tab to the top of the list.
|
||||
'#weight' => -99,
|
||||
// The #group value must match the name of the vertical tabs element.
|
||||
// In most cases, this is 'additional_settings'.
|
||||
'#group' => 'additional_settings',
|
||||
// Vertical tabs provide its most usable appearance when they are used to
|
||||
// include a summary of the information contained in the fieldset. To do
|
||||
// this, we attach additional JavaScript to handle changing the summary
|
||||
// when form settings are changed.
|
||||
'#attached' => array(
|
||||
'js' => array(
|
||||
'vertical-tabs' => drupal_get_path('module', 'vertical_tabs_example') . '/vertical_tabs_example.js',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// The form elements below provide a demonstration of how a fieldset
|
||||
// summary can be displayed in a collapsed tab.
|
||||
//
|
||||
// This checkbox is used to show or hide the custom settings form using
|
||||
// javascript (altering states of a container defined later).
|
||||
$form['vertical_tabs_example']['enabled'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Change this setting'),
|
||||
'#default_value' => FALSE,
|
||||
);
|
||||
|
||||
// This container will be used to store the whole form for our custom
|
||||
// settings. This way, showing/hiding the form using javascript is easier,
|
||||
// as only one element should be set visible.
|
||||
$form['vertical_tabs_example']['vertical_tabs_examplecontainer'] = array(
|
||||
'#type' => 'container',
|
||||
'#parents' => array('vertical_tabs_example'),
|
||||
'#states' => array(
|
||||
'invisible' => array(
|
||||
// If the checkbox is not enabled, show the container.
|
||||
'input[name="vertical_tabs_example[enabled]"]' => array('checked' => FALSE),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
// The string of this textfield will be shown as summary in the vertical
|
||||
// tab.
|
||||
$form['vertical_tabs_example']['vertical_tabs_examplecontainer']['custom_setting'] = array(
|
||||
'#type' => 'textfield',
|
||||
'#title' => t('Use this setting instead'),
|
||||
'#default_value' => 'I am a setting with a summary',
|
||||
'#description' => t('As you type into this field, the summary will be updated in the tab.'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple explanation page.
|
||||
*/
|
||||
function _vertical_tabs_example_explanation() {
|
||||
return t("<p>The Vertical Tabs Example shows how a custom module can add a vertical tab to a node edit form, and support its summary field with JavaScript.</p><p>To see the effects of this module, <a href='!node_add'>add a piece of content</a> and look at the set of tabs at the bottom. We've added one called 'Example vertical tab.'</p>", array('!node_add' => url('node/add')));
|
||||
}
|
||||
/**
|
||||
* @} End of "defgroup vertical_tabs_example".
|
||||
*/
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Test file for vertical_tabs_example module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default test case for the vertical_tabs_example module.
|
||||
*
|
||||
* @ingroup vertical_tabs_example
|
||||
*/
|
||||
class VerticalTabsExampleTestCase extends DrupalWebTestCase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Vertical Tabs Example',
|
||||
'description' => 'Functional tests for the Vertical Tabs Example module.' ,
|
||||
'group' => 'Examples',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setUp() {
|
||||
parent::setUp('vertical_tabs_example');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the menu paths defined in vertical_tabs_example module.
|
||||
*/
|
||||
public function testVerticalTabsExampleMenus() {
|
||||
$paths = array(
|
||||
'examples/vertical_tabs',
|
||||
);
|
||||
foreach ($paths as $path) {
|
||||
$this->drupalGet($path);
|
||||
$this->assertResponse(200, '200 response for path: ' . $path);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user